From 719e8f81782c6b04a99ac29b5a8e20991f3b0b28 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 20 十二月 2023 17:26:11 +0800
Subject: [PATCH] 1.修改设备点检、保养标准导入时判断提示 2.修改模具点检、保养标准导入时判断提示
---
VueWebCoreApi/Controllers/ImportExcelController.cs | 136 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/VueWebCoreApi/Controllers/ImportExcelController.cs b/VueWebCoreApi/Controllers/ImportExcelController.cs
index 2838ec1..e2ef326 100644
--- a/VueWebCoreApi/Controllers/ImportExcelController.cs
+++ b/VueWebCoreApi/Controllers/ImportExcelController.cs
@@ -1,9 +1,13 @@
锘縰sing Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
+using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Models.SystemSetting;
using VueWebCoreApi.Tools;
namespace VueWebCoreApi.Controllers
@@ -14,8 +18,6 @@
//[ChannelActionFilter]
public class ImportExcelController : Controller
{
- //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
- ToMessage mes = new ToMessage();
#region[Excel瀵煎叆妯℃澘鍒楄〃]
/// <summary>
@@ -26,6 +28,7 @@
[HttpGet]
public JsonResult ExcelModelData()
{
+ ToMessage mes = new ToMessage();
List<ScoreReport> list = ExcelList.ExcelData();
mes.code = "200";
mes.data = list;
@@ -43,6 +46,7 @@
[HttpGet]
public JsonResult DownLoadExcel(string FileCode = null)
{
+ ToMessage mes = new ToMessage();
List<ScoreReport> list = ExcelList.ExcelData();
list = list.Where(s => s.FileCode == FileCode).ToList();
var filename = list[0].FileName + ".xls";
@@ -53,5 +57,133 @@
return Json(mes);
}
#endregion
+
+ #region [Excel瀵煎叆鏁版嵁鎻愪氦銆佹ā鏉块獙璇併�佹暟鎹鍏
+ /// <summary>
+ /// Excel瀵煎叆鏁版嵁鎻愪氦銆佹ā鏉块獙璇併�佹暟鎹鍏�
+ /// </summary>
+ /// <param name="myModel">鎻愪氦鏁版嵁</param>
+ /// <returns></returns>
+ [Route(template: "ExcelModelCheck")]
+ [HttpPost]
+ public JsonResult ExcelModelCheck([FromBody] ExceImport myModel)
+ {
+ string FileCode = myModel.FileCode;
+ List<DataTable> dataTable = myModel.TableData;
+
+ ExcelModelCheck list = new ExcelModelCheck();
+ list.json1 = ExcelCheck(dataTable, FileCode); //妯℃澘楠岃瘉
+ if (list.json1.code == "301")
+ {
+ list.json1 = list.json1;
+ return Json(list);
+ }
+ list.json2 = ExcelCheckData(myModel); //鏁版嵁楠岃瘉
+ if (list.json2.code == "301")
+ {
+ list.json2 = list.json2;
+ return Json(list);
+ }
+ list.json3 = ExcelImportSubmit(dataTable, FileCode); //鏁版嵁瀵煎叆
+ if (list.json3.code == "300")
+ {
+ list.json3 = list.json3;
+ return Json(list);
+ }
+ return Json(list);
+ }
+ #endregion
+
+ #region [Excel瀵煎叆妯℃澘楠岃瘉]
+ /// <summary>
+ /// Excel瀵煎叆妯℃澘楠岃瘉
+ /// </summary>
+ /// <param name="dataTable">鎻愪氦鏁版嵁</param>
+ /// <param name="FileCode">鏂囦欢缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "ExcelCheckUpload")]
+ [HttpGet]
+ [ApiExplorerSettings(IgnoreApi = true)]
+ public ToMessage ExcelCheck(List<DataTable> dataTable, string FileCode = null)
+ {
+ ToMessage mes = new ToMessage();
+ try
+ {
+ mes = ExcelCheckBLL.ExcelCheck(FileCode, dataTable);
+ if (mes.code == "301") //涓婁紶妯℃澘涓嶆槸鎸囧畾妯℃澘
+ {
+ return mes;
+ }
+ return mes;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.message = e.Message;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [Excel瀵煎叆鏁版嵁楠岃瘉]
+ /// <summary>
+ /// Excel瀵煎叆鏁版嵁楠岃瘉
+ /// </summary>
+ /// <param name="myModel">鎻愪氦鏁版嵁</param>
+ /// <returns></returns>
+ [Route(template: "ExcelCheckData")]
+ [HttpPost]
+ [ApiExplorerSettings(IgnoreApi = true)]
+ public ToMessage ExcelCheckData([FromBody] ExceImport myModel)
+ {
+ ToMessage mes = new ToMessage();
+ string message = "";
+ string StuCode = "";
+ int count = 0;
+ List<ExcelErro> list = new List<ExcelErro>();
+ string FileCode = myModel.FileCode;
+ List<DataTable> dataTable = myModel.TableData;
+ list = ExcelCheckBLL.ExcelCheckData(FileCode, dataTable, out StuCode, out message, out count);
+ mes.code = StuCode;
+ mes.message = message;
+ mes.count = count;
+ mes.data = list;
+ return mes;
+ }
+ #endregion
+
+ #region[Excel瀵煎叆鏁版嵁]
+ /// <summary>
+ /// Excel瀵煎叆鏁版嵁
+ /// </summary>
+ /// <param name="dataTable">鎻愪氦鏁版嵁</param>
+ /// <param name="FileCode">鏂囦欢缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "ExcelImportSubmit")]
+ [HttpPost]
+ [ApiExplorerSettings(IgnoreApi = true)]
+ public ToMessage ExcelImportSubmit(List<DataTable> dataTable, string FileCode = null)
+ {
+ ToMessage mes = new ToMessage();
+ try
+ {
+ //var token = HttpContext.Request.Headers["Token"].ToString();
+ var token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyY29kZSI6Ijk5OSIsInVzZXJuYW1lIjoi5rWL6K-V6LSm5Y-3Iiwic3RvcmdfY29kZSI6IlNDQjAxXzEiLCJzdG9yZ19uYW1lIjoi55Sf5Lqn5LiA6YOoIiwiaXNfc3lzdGVtX2FkbWluIjoiTiIsInJvbGVfY29kZSI6IlIyMzA4MjMwMiw5OTk5Iiwicm9sZV9kYXRhcGVybWlzc2lvbnMiOiIiLCJ1c2VydHlwZSI6IlBDIiwicmVkaXNrZXkiOiJOZXdNRVNMb2dpblVzZXJJRFBDOTk5IiwidGltZW91dCI6IjIwMjMtMTItMTVUMTc6MTg6MjEuMTQyMjc1MiswODowMCJ9.IPaJpspiHjk4Qh9keXNy8lJl1Scj87EnnksKd8Hnj8o";
+ User us = JwtTools.Denocode(token.ToString());
+ mes = ExcelCheckBLL.ExcelImportSubmit(FileCode, dataTable, us);
+ if (mes.code == "300")
+ {
+ return mes;
+ }
+ return mes;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.message = e.Message;
+ }
+ return mes;
+ }
+ #endregion
}
}
--
Gitblit v1.9.3