From 57551133ed6f32ca0056af914344952800d83db8 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期四, 30 五月 2024 10:42:31 +0800
Subject: [PATCH] 调拨单增加审核/反审核.更新即及时库存表信息
---
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 252 insertions(+), 10 deletions(-)
diff --git a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
index aa06451..a4843a3 100644
--- a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -7,6 +7,8 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
+using System.IO;
+using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
@@ -23,7 +25,7 @@
private json objJsonResult = new json();
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
DataSet ds;
-
+ string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
////妫�娴� 褰撳墠閫変腑琛岀殑 椤圭洰鐘舵��
@@ -936,7 +938,18 @@
objJsonResult.data = null;
return objJsonResult;
}
-
+
+ //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+ string s = "";
+ int sYear = 0;
+ int sPeriod = 0;
+ DateTime HDate = DateTime.Now;
+ if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+ {
+ objJsonResult.Message = s;
+ return objJsonResult;
+ }
+
Ds = oCN.RunProcReturn("Select * from h_v_IF_BarCodeBillList Where HItemID in (" + HInterID + ")", "h_v_IF_BarCodeBillList");
if (Ds.Tables[0].Rows.Count != 0)
{
@@ -1018,7 +1031,7 @@
return objJsonResult;
}
//淇濆瓨涓昏〃
- objJsonResult = AddBillMain(msg2);
+ objJsonResult = AddBillMain(msg1);
if (objJsonResult.code == "0")
{
oCN.RollBack();
@@ -1035,8 +1048,13 @@
return objJsonResult;
}
- public json AddBillMain(string msg2)
+ public json AddBillMain(string msg1)
{
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();
+ string msg3 = sArray[1].ToString();//妯″潡鏉冮檺
+ string msg4 = sArray[2].ToString();//褰撳墠浜�
+ string msg5 = sArray[3].ToString();//瀛愯〃鏁版嵁
try
{
msg2 = "[" + msg2.ToString() + "]";
@@ -1091,7 +1109,8 @@
int HNowSupTypeID = mainList[0].HNowSupTypeID;
int HMadeSupID = mainList[0].HMadeSupID;
string HMouldClass = mainList[0].HMouldClass;
-
+ int HNowWHID = mainList[0].HNowWHID;
+ int HNowSPID = mainList[0].HNowSPID;
//涓昏〃
oCN.RunProc("Insert Into Gy_MouldFileMain " +
@@ -1104,7 +1123,7 @@
",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" +
",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" +
",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" +
- ",HMouldClass) " +
+ ",HMouldClass,HNowWHID,HNowSPID) " +
" values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
"," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" +
",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" +
@@ -1114,8 +1133,7 @@
"," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty +
"," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" +
",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID +
- ",'"+ HMouldClass + "') ");
-
+ ",'"+ HMouldClass + "'," + HNowWHID + "," + HNowSPID + ") ");
//瀛愯〃
oCN.RunProc("Insert into Gy_MouldFileSub " +
@@ -1125,6 +1143,8 @@
" values('" + HInterID + "',0,''" +
",0,0,'','',0,0 " +
") ");
+
+ objJsonResult = AddBillSub(msg5,HInterID, HBillNo);
if (objJsonResult.code == "0")
{
@@ -1167,6 +1187,7 @@
string msg2 = sArray[0].ToString();
string msg3 = sArray[1].ToString();//妯″潡鏉冮檺
string msg4 = sArray[2].ToString();//褰撳墠浜�
+ string msg5 = sArray[3].ToString();//瀛愯〃鏁版嵁
try
{
if (!DBUtility.ClsPub.Security_Log(msg3, 1, false, msg4))
@@ -1233,6 +1254,8 @@
int HNowSupTypeID = mainList[0].HNowSupTypeID;
int HMadeSupID = mainList[0].HMadeSupID;
string HMouldClass = mainList[0].HMouldClass;
+ int HNowWHID = mainList[0].HNowWHID;
+ int HNowSPID = mainList[0].HNowSPID;
//鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
oCN.BeginTran();
@@ -1287,13 +1310,19 @@
",HProdWeight=" + HProdWeight.ToString() +
",HBarCode='" + HBarCode.ToString() + "'" +
",HMadeSupID=" + HMadeSupID +
+ ",HNowWHID=" + HNowWHID +
+ ",HNowSPID=" + HNowSPID +
" where HInterID=" + HInterID.ToString());
//淇敼瀛愰」鐩唬鐮�
//oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
//灏嗕笂绾� 涓洪潪鏈骇
// oCN.RunProc("Update Gy_Department set HEndflag=0 where HItemID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
- //
+
+ oCN.RunProc("delete from Gy_MouldFileSub_SubMater where HInterID='" + HInterID + "'");
+
+ objJsonResult = AddBillSub(msg5, HInterID, HBillNo);
+
oCN.Commit();
objJsonResult.code = "1";
objJsonResult.count = 1;
@@ -1312,6 +1341,39 @@
}
}
+ public json AddBillSub(string msg5, long HInterID, string HBillNo)
+ {
+ List<Gy_MouldFileSub_SubMater> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_MouldFileSub_SubMater>>(msg5);
+ int i = 0; //浣滀负瀛愯〃鍐呯爜
+ foreach (Gy_MouldFileSub_SubMater oSub in DetailColl)
+ {
+ i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
+
+ int HEntryID = i;
+ string HRemark = oSub.HRemark;
+ int HMouldFileID = oSub.HMouldFileID;
+ DateTime HUnionDate = oSub.HUnionDate;
+
+ string sql = "insert into Gy_MouldFileSub_SubMater" +
+ "(HInterID,HBillNo_bak,HEntryID,HRemark,HMouldFileID,HUnionDate) " +
+ "values(" +
+ "" + HInterID +
+ ",'" + HBillNo +
+ "'," + HEntryID +
+ ",'" + HRemark +
+ "','" + HMouldFileID +
+ "','" + HUnionDate +
+ "')";
+
+ oCN.RunProc(sql);
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = null;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
/// <summary>
/// 纾ㄥ叿妗f淇敼鎸夐挳鏂规硶-璁$畻涓嬫淇濆吇/鏍℃鏃ユ湡-鑾峰彇妗f鏈�杩戜竴娆$殑淇濆吇璁板綍
@@ -1359,7 +1421,7 @@
{
try
{
- ds = oCN.RunProcReturn("select * from h_v_Gy_MouldFileList where hmainid=" + HInterID, "h_v_Gy_MouldFileList");
+ ds = oCN.RunProcReturn("select * from h_v_Gy_MouldFile_Edit where hmainid=" + HInterID, "h_v_Gy_MouldFile_Edit");
objJsonResult.code = "1";
objJsonResult.count = 1;
@@ -1942,5 +2004,185 @@
public string msg { get; set; } //鏈骇鏍囧織
}
+ #region 鐗╂枡鏂囦欢涓婁紶澶勭悊
+ [Route("Gy_Mater/UploadFile")]
+ [HttpPost]
+ public object UploadFile()
+ {
+
+ string HNumber = HttpContext.Current.Request.Params["HNumber"]; //鐗╂枡浠g爜
+ 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/Material/" + HNumber);
+ //string path = @"D:\\Files\Material\\"+ HBillNo;
+ dynamic dyResult = UpLoadFile(files, path, HNumber, 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 HNumber, 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
+ {
+ if (files == null || files.ContentLength <= 0)
+ {
+ Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" };
+ return Result_Ob;
+ }
+ if (filesize >= Maxsize)
+ {
+ 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 ='" + HNumber + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
+ if (Directory.Exists(path))
+ {
+ File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢
+ files.SaveAs(fileurl);
+ string StrPath = "/files/Material/" + HNumber + "/" + 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 + "','" + HNumber +
+ "') ");
+ }
+ else
+ {
+ Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+ }
+ }
+ else
+ {
+ Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+ files.SaveAs(fileurl);
+ string StrPath = "/files/Material/" + HNumber + "/" + 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 + "','" + HNumber +
+ "') ");
+ }
+ else
+ {
+ Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ Result_Ob = new { result = 0, returnval = e.Message };
+ }
+ return Result_Ob;
+ }
+
+ /// <summary>
+ /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+ /// </summary>
+ /// <param name="sWhere"></param>
+ /// <returns></returns>
+ [Route("Gy_Mater/Filelist")]
+ [HttpGet]
+ public object Filelist(string HNumber)
+ {
+ var url = fileip + "/files/Material/" + HNumber + "/";
+ //@"C:\\files\\"
+ try
+ {
+ ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HNumber + "'", "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 = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢
+ /// </summary>
+ /// <param name="sWhere"></param>
+ /// <returns></returns>
+ [Route("Gy_Mater/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/Material/" + 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