From e438bae1bc3ded46d1939dd8918e9dbc0f10a8b4 Mon Sep 17 00:00:00 2001
From: zgq <519541279@qq.com>
Date: 星期二, 15 六月 2021 16:56:23 +0800
Subject: [PATCH] nothing
---
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 139 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 136 insertions(+), 3 deletions(-)
diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index 024517d..c247d35 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -5,6 +5,8 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
+using System.IO;
+using System.Web;
using System.Web.Http;
using WebAPI.Models;
@@ -312,7 +314,7 @@
return objJsonResult;
}
//涓昏〃
-
+
ds = oCN.RunProcReturn("exec h_p_MES_StationOutBill_QtyCtrl " + HInterID + "", "h_p_MES_StationOutBill_QtyCtrl");
if (ds == null)
{
@@ -350,10 +352,10 @@
" Where a.HInterID=" + HProcExchInterID + " and b.HEntryID=" + HProcExchEntryID + " ", "Sc_ProcessExchangeBillMain");
if (ds1 == null || ds1.Tables[0].Rows.Count == 0 || HLastSubProc == false)
{
-
+
}
else if (ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HLastProc"]) == "鏄�")
- {
+ {
}
oCN.Commit();
@@ -472,5 +474,136 @@
//
+
+
+ [Route("Cj_StationOutBill/UploadFile")]
+ [HttpPost]
+ public object UploadFile()
+ {
+ 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)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏂囦欢涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ for (int i = 0; i < files.Count; i++)
+ {
+
+ // 鑾峰彇鏂囦欢
+ 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;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "涓婁紶澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = e.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.1