From 83d48bd7e1c1eccb9905cceae02e7b5b61c94156 Mon Sep 17 00:00:00 2001
From: jingh <jingh@LAPTOP-I53VDLOO>
Date: 星期一, 16 八月 2021 19:26:33 +0800
Subject: [PATCH] 流转卡拆分增加字段;工艺路线导入增加进度条
---
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 285 ++++++++++++++++++++++++++++++++++----------------------
1 files changed, 174 insertions(+), 111 deletions(-)
diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index c247d35..727a50f 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -21,7 +21,7 @@
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
DataSet ds;
DataSet ds1;
-
+ string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
/// <summary>
/// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
@@ -390,9 +390,9 @@
///鍙傛暟锛歴tring sql銆�
///杩斿洖鍊硷細object銆�
/// </summary>
- [Route("Cj_StationOutBill/list")]
+ [Route("Cj_StationOutBill/get_Display")]
[HttpGet]
- public object list(string sWhere)
+ public object get_Display(string sWhere)
{
try
{
@@ -473,137 +473,200 @@
}
- //
+ #region 宸ュ簭鍑虹珯姹囨姤鍗曟枃浠朵笂浼犲鐞�
-
- [Route("Cj_StationOutBill/UploadFile")]
+ [Route("Cj_StationOutBill/UploadFile1")]
[HttpPost]
- public object UploadFile()
+ public object UploadFile1()
{
+
+ string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //鍗曟嵁鍙�
+ string HRemark = HttpContext.Current.Request.Params["HRemark"]; //澶囨敞
+ string HUserName = HttpContext.Current.Request.Params["HUserName"]; //鍒涘缓浜�
+ HttpPostedFile files = HttpContext.Current.Request.Files["file"];
+ string path = HttpContext.Current.Server.MapPath("~/../Files/" + HBillNo);
+ //string path = @"D:\\Files\\"+ HBillNo;
+ dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName);
+ if (dyResult != null && dyResult.result == 1)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "涓婁紶鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = dyResult.returnval;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ }
+
+ public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName)
+ {
+ dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" };
+ string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞
+ string fileExtension = Path.GetExtension(files.FileName);// 鏂囦欢鎵╁睍鍚�
+ string filename = files.FileName;//鏂囦欢鍚�
+ string fileSavePath = path;// 涓婁紶淇濆瓨璺緞
+ int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
+ int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M
try
{
- int num = 0;
- string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //鍗曟嵁鍙�
- string HRemark = HttpContext.Current.Request.Params["HRemark"]; //澶囨敞
- string HUserName = HttpContext.Current.Request.Params["HUserName"]; //鍗曟嵁鍙�
- string uploadPath = HttpContext.Current.Server.MapPath("~/App_Data/");
- HttpRequest request = System.Web.HttpContext.Current.Request;
- HttpFileCollection files = request.Files;
-
- string savePath = "";
- if (files == null || files.Count <= 0)
+ if (files == null || files.ContentLength <= 0)
{
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "鏂囦欢涓嶈兘涓虹┖锛�";
- objJsonResult.data = null;
- return objJsonResult;
+ Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" };
+ return Result_Ob;
}
- else
+ if (filesize >= Maxsize)
{
- for (int i = 0; i < files.Count; i++)
+ Result_Ob = new { result = 0, returnval = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒" };
+ return Result_Ob;
+ }
+
+ string fileurl = Path.Combine(fileSavePath, filename);
+ if (Directory.Exists(fileurl) == true) //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�
+ {
+ Result_Ob = new { result = 0, returnval = "瀛樺湪鍚屽悕鏂囦欢锛�" };
+ return Result_Ob;
+ }
+ //鍒犻櫎鏁版嵁琛ㄦ暟鎹�
+ ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='"+ filename + "'", "MES_AccessoriesList");
+ if (Directory.Exists(path))
+ {
+ File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢
+ files.SaveAs(fileurl);
+ string StrPath = "/files/"+ HBillNo+"/"+ filename;
+ if (File.Exists(fileurl))
{
-
- // 鑾峰彇鏂囦欢
- HttpPostedFile httpPostedFile = files[i];
-
- string filePath = Path.GetFullPath(httpPostedFile.FileName);//鏂囦欢涓婁紶璺緞
- string fileExtension = Path.GetExtension(httpPostedFile.FileName);// 鏂囦欢鎵╁睍鍚�
- string filename = httpPostedFile.FileName;
- string fileSavePath = uploadPath;// 涓婁紶淇濆瓨璺緞
- int filesize = files[i].ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
- int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M
- if (filesize >= Maxsize)
- {
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒";
- objJsonResult.data = null;
- return objJsonResult;
- }
- if (Directory.Exists(fileSavePath) == false)//濡傛灉涓嶅瓨鍦ㄥ氨鍒涘缓file鏂囦欢澶�
- {
- Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
- }
- savePath = Path.Combine(fileSavePath, filename);
- //鏌ヨ鏂囦欢鍏宠仈琛�,鏄惁宸插瓨鍦ㄤ笂浼犳暟鎹�
- ds = oCN.RunProcReturn("select * from MES_AccessoriesList where HSourceBillNo = " + HBillNo, "MES_AccessoriesList");
- if (ds == null || ds.Tables[0].Rows.Count == 0)
- {
- //鍐欏叆鏈嶅姟鍣ㄦ枃浠�
- httpPostedFile.SaveAs(savePath);
- //鍐欏叆鏁版嵁琛�
- oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
- ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
- ",HFileClsID,HSourceBillNo" +
- ") values('"
- + filename.ToString() + "','" + savePath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString()+ "'" +
- ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
- "','" + 0 + "','" + HBillNo +
- "') ");
- }
- else
- {
- //鍒犻櫎鏈嶅姟鍣ㄦ枃浠�
- FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(savePath));
- file.Delete();
- //鍒犻櫎鏁版嵁琛ㄦ暟鎹�
- ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo = " + HBillNo, "MES_AccessoriesList");
-
- //鍐欏叆鏈嶅姟鍣ㄦ枃浠�
- httpPostedFile.SaveAs(savePath);
- //鍐欏叆鏁版嵁琛�
- //鍐欏叆鏁版嵁琛�
- oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
- ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
- ",HFileClsID,HSourceBillNo" +
- ") values('"
- + filename.ToString() + "','" + savePath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
- ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
- "','" + 0 + "','" + HBillNo +
- "') ");
- }
- //if (Directory.Exists(savePath) == true) //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�
- //{
- // objJsonResult.code = "0";
- // objJsonResult.count = 0;
- // objJsonResult.Message = "瀛樺湪鍚屽悕鏂囦欢锛�";
- // objJsonResult.data = null;
- // return objJsonResult;
- //}
- httpPostedFile.SaveAs(savePath);
- string StrPath = "/File/" + filename;
+ //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
//鍐欏叆鏁版嵁琛�
-
- num = num + 1;
- }
- if (num == files.Count)
- {
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "涓婁紶鎴愬姛锛�";
- objJsonResult.data = null;
- return objJsonResult;
+ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+ ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+ ",HFileClsID,HSourceBillNo" +
+ ") values('"
+ + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+ ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+ "','" + 0 + "','" + HBillNo +
+ "') ");
}
else
{
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "涓婁紶澶辫触锛�";
- objJsonResult.data = null;
- return objJsonResult;
+ Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
}
}
+ else
+ {
+ Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+ files.SaveAs(fileurl);
+ string StrPath = "/files/" + HBillNo + "/" + filename;
+ if (File.Exists(fileurl))
+ {
+ //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+ //鍐欏叆鏁版嵁琛�
+ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+ ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+ ",HFileClsID,HSourceBillNo" +
+ ") values('"
+ + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+ ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+ "','" + 0 + "','" + HBillNo +
+ "') ");
+ }
+ else
+ {
+ Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+ }
+ }
+
+ }
+ catch(Exception e)
+ {
+ Result_Ob = new { result = 0, returnval = e.Message };
+ }
+ return Result_Ob;
+ }
+
+ /// <summary>
+ /// 杈撳嚭json缁撴灉 杩斿洖2涓�� result (杈撳嚭succes鐨勫��) returnval (杈撳嚭str鐨勫��)
+ /// </summary>
+ /// <param name="context"></param>
+ /// <param name="success">鏄惁鎿嶄綔鎴愬姛,0琛ㄧず澶辫触;1琛ㄧず鎴愬姛</param>
+ /// <param name="str">杈撳嚭瀛楃涓�</param>
+ protected void JsonResult(HttpContext context, int success, string str)
+ {
+ context.Response.Write("{\"result\" :\"" + success.ToString() + "\",\"returnval\" :\"" + str + "\"}");
+ context.Response.End();
+ }
+
+
+ /// <summary>
+ /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+ /// </summary>
+ /// <param name="sWhere"></param>
+ /// <returns></returns>
+ [Route("Cj_StationOutBill/Filelist")]
+ [HttpGet]
+ public object Filelist(string HBillNo)
+ {
+ var url = fileip + "/files/" + HBillNo+"/";
+ //@"C:\\files\\"
+ try
+ {
+ ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo+"'", "MES_AccessoriesList");
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
- objJsonResult.Message = e.Message;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
-
}
+
+ /// <summary>
+ /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢
+ /// </summary>
+ /// <param name="sWhere"></param>
+ /// <returns></returns>
+ [Route("Cj_StationOutBill/DeleteFilelist")]
+ [HttpGet]
+ public object DeleteFilelist(string HItemID, string HSourceBillNo,string HFileName)
+ {
+ try
+ {
+
+ oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
+ string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/" + HSourceBillNo), HFileName);
+ File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1