From 695f61f39ad983df2b381402829cbfec2319bf63 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期一, 28 十一月 2022 17:29:57 +0800
Subject: [PATCH] SOP接口开发
---
VueWebApi/Controllers/SystemSettingController.cs | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 162 insertions(+), 0 deletions(-)
diff --git a/VueWebApi/Controllers/SystemSettingController.cs b/VueWebApi/Controllers/SystemSettingController.cs
index 4c266d6..d303ade 100644
--- a/VueWebApi/Controllers/SystemSettingController.cs
+++ b/VueWebApi/Controllers/SystemSettingController.cs
@@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using System.Data;
+using System.Globalization;
+using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -20,6 +22,7 @@
//瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
ToMessage mes = new ToMessage();
RedisHelper redis = new RedisHelper();
+ string FileIP = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
#region[缂栫爜瑙勫垯鏌ヨ]
/// <summary>
@@ -142,5 +145,164 @@
return TJson.toJson(mes);
}
#endregion
+
+
+ #region[SOP鍒楄〃鏌ヨ]
+ /// <summary>
+ /// SOP鍒楄〃鏌ヨ
+ /// </summary>
+ /// <param name="search">鎼滅储鍏抽敭瀛�</param>
+ /// <param name="check">鏄惁閫変腑鏈�楂樼増鏈�</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "SystemSopSearch")]
+ [HttpGet]
+ public HttpResponseMessage SystemSopSearch(string search = null, string check = null,int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = SystemSettingBLL.SystemSopSearch(search, check, startNum, endNum, prop, order);
+ return TJson.toJson(mes);
+ }
+ #endregion
+
+ #region[SOP鏂囦欢涓婁紶鏌ユ壘璁惧绫诲瀷鏁版嵁]
+ /// <summary>
+ /// SOP鏂囦欢涓婁紶鏌ユ壘璁惧绫诲瀷鏁版嵁
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "SystemSopDeviceSearch")]
+ [HttpGet]
+ public HttpResponseMessage SystemSopDeviceSearch()
+ {
+ mes = SystemSettingBLL.SystemSopDeviceSearch();
+ return TJson.toJson(mes);
+ }
+ #endregion
+
+ #region[SOP鏂囦欢浣滀笟鏂囦欢涓婁紶鑾峰彇鏈�澶х増鏈彿]
+ /// <summary>
+ /// SOP鏂囦欢浣滀笟鏂囦欢涓婁紶鑾峰彇鏈�澶х増鏈彿
+ /// </summary>
+ /// <param name="devicetypecode">璁惧绫诲瀷缂栧彿</param>
+ /// <param name="filetypecode">鏂囦欢绫诲瀷缂栧彿</param>
+ /// <param name="partcode">鐗╂枡缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "SystemSopMaxVersion")]
+ [HttpGet]
+ public HttpResponseMessage SystemSopMaxVersion(string devicetypecode,string filetypecode,string partcode)
+ {
+ mes = SystemSettingBLL.SystemSopMaxVersion(devicetypecode, filetypecode, partcode);
+ return TJson.toJson(mes);
+ }
+ #endregion
+
+ #region[SOP鏂囦欢涓婁紶鎻愪氦]
+ /// <summary>
+ /// SOP鏂囦欢涓婁紶鎻愪氦
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "SystemSopSava")]
+ [HttpPost]
+ public HttpResponseMessage SystemSopSava()
+ {
+ string savePath = "";
+ HttpPostedFile files = HttpContext.Current.Request.Files[0];//鑾峰彇涓婁紶鐨勬枃浠�
+ string devicetypecode = HttpContext.Current.Request["devicetypecode"].ToString();//璁惧绫诲瀷缂栫爜
+ string partcode = HttpContext.Current.Request["partcode"].ToString();//鐗╂枡缂栫爜
+ string filetypecode = HttpContext.Current.Request["filetypecode"].ToString();//鏂囦欢绫诲瀷缂栫爜
+ string fileversion = HttpContext.Current.Request["fileversion"].ToString();//鏂囦欢鐗堟湰鍙�
+ string defilename = HttpContext.Current.Request["defilename"].ToString();//鏂囦欢鍚嶇О
+ var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //鎿嶄綔浜哄憳
+ if (files == null || files.ContentLength <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "鏂囦欢涓嶈兘涓虹┖锛�";
+ }
+ else
+ {
+
+ string file_name = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + Path.GetFileName(files.FileName); //鏃堕棿鎴冲姞鏂囦欢鍚�
+ int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
+ string fileEx = System.IO.Path.GetExtension(file_name);//鑾峰彇涓婁紶鏂囦欢鐨勬墿灞曞悕
+ int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M
+ string FileType = ".pdf";//瀹氫箟涓婁紶鏂囦欢鐨勭被鍨嬪瓧绗︿覆
+ string FileType1 = ".mp4";//瀹氫箟涓婁紶鏂囦欢鐨勭被鍨嬪瓧绗︿覆
+
+ if (!FileType.Contains(fileEx) && !FileType1.Contains(fileEx))
+ {
+ mes.code = "300";
+ mes.Message = "鏂囦欢绫诲瀷涓嶅锛屽彧鑳藉鍏df鏍煎紡鐨勬枃浠跺拰mp4鏍煎紡鏂囦欢锛�";
+ }
+ else
+ {
+ if (filesize >= Maxsize)
+ {
+ mes.code = "300";
+ mes.Message = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼�!";
+ }
+ else
+ {
+ string path = System.Web.HttpContext.Current.Server.MapPath("/File/DeviceFile/");
+
+ if (Directory.Exists(path) == false)//濡傛灉涓嶅瓨鍦ㄥ氨鍒涘缓file鏂囦欢澶�
+ {
+ Directory.CreateDirectory(path); //娣诲姞鏂囦欢澶�
+ }
+ savePath = Path.Combine(path, file_name);
+ if (Directory.Exists(savePath) == true) //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�
+ {
+ mes.code = "300";
+ mes.Message = "宸插瓨鍦ㄥ悓鍚嶆枃浠�!";
+ }
+ else
+ {
+ files.SaveAs(savePath); //灏嗛�夋嫨鐨勬枃浠朵繚瀛樺埌鎸囧畾鏂囦欢澶逛笅
+ string FilesName = System.Web.HttpContext.Current.Server.MapPath("/File/DeviceFile/" + file_name);
+ string StrPath = "/File/DeviceFile/" + file_name;
+ mes = SystemSettingBLL.SystemSopSava(devicetypecode, filetypecode, partcode,fileversion,file_name,defilename,username, StrPath);
+ }
+ }
+ }
+ }
+ return TJson.toJson(mes);
+ }
+ #endregion
+
+ #region[SOP鏂囦欢鍒犻櫎]
+ /// <summary>
+ /// SOP鏂囦欢鍒犻櫎
+ /// </summary>
+ /// <param name="id">鏂囦欢id</param>
+ /// <param name="filepath">鏂囦欢鍦板潃</param>
+ /// <returns></returns>
+ [Route(template: "SystemSopDelete")]
+ [HttpPost]
+ public HttpResponseMessage SystemSopDelete(string id,string filepath)
+ {
+ mes = SystemSettingBLL.SystemSopDelete(id,filepath);
+ return TJson.toJson(mes);
+ }
+ #endregion
+
+ #region[SOP鏂囦欢棰勮]
+ /// <summary>
+ /// SOP鏂囦欢棰勮
+ /// </summary>
+ /// <param name="id">鏂囦欢id</param>
+ /// <param name="filepath">鏂囦欢鍦板潃</param>
+ /// <returns></returns>
+ [Route(template: "SystemSopView")]
+ [HttpPost]
+ public HttpResponseMessage SystemSopView(string id, string filepath)
+ {
+ mes.code = "200";
+ mes.data = Url.Content(FileIP + filepath);
+ return TJson.toJson(mes);
+ }
+ #endregion
}
}
--
Gitblit v1.9.3