ImportController.cs 1.45 KB
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;
        private readonly IHostingEnvironment hostingEnvironment;

        public ImportController(IAuth authUtil,ImportService  import, IHostingEnvironment hosting) : base(authUtil)
        {
            this.importService = import;
            importService.sysWebUser = authUtil.GetCurrentUser().User;
            hostingEnvironment = hosting;
        }

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


        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="excelfile">表单提交的文件信息</param>
        /// <returns></returns>
        [HttpPost]
        public string Import(IFormFileCollection excelfile)
        {
            var response = importService.ImportIn(excelfile, hostingEnvironment);
            return Serialize(response);
        }

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