From 5a679187b1dbdfd030b4c99bb89fb7d9d6f82cde Mon Sep 17 00:00:00 2001 From: 仲国强 <519541279@qq.com> Date: 星期五, 03 九月 2021 15:13:13 +0800 Subject: [PATCH] 首检、工序检增加生产任务单子id。 --- WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 344 ++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 228 insertions(+), 116 deletions(-) diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs index c247d35..e7b2e6b 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> /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳 @@ -39,6 +39,8 @@ //鍙嶅簭鍒楀寲 msg1 = "[" + msg1.ToString() + "]"; List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1); + long HMainInterID = 0; + HMainInterID = list[0].HMainInterID; string eventType = list[0].eventType; string BillType = "3791"; string HBillSubType = "3791"; @@ -261,16 +263,16 @@ ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" + ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" + ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" + - ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID" + + ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID" + ") " + " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL + "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + - ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",'" + HStationOutTime + "'," + HSourceID + "," + HPayProcID + + ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID + "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 + "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" + "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + - "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + + "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + ") "); } else if ("Modify".Equals(eventType)) @@ -390,15 +392,15 @@ ///鍙傛暟锛歴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 { if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList " + sWhere, "h_v_MES_StationOutBillList"); + ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList " + sWhere + " order by 鍑虹珯鏃堕棿 desc", "h_v_MES_StationOutBillList"); } else { @@ -473,137 +475,247 @@ } - // + #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 + { + 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 ='" + 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)) + { + //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱 + //鍐欏叆鏁版嵁琛� + 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 = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" }; + } + } + 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 = "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 { - 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) + + 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 + + + //鎵归噺鍑虹珯 + #region 鎵归噺鍑虹珯妯″潡杩斿洖鏄庣粏淇℃伅鍒楄〃 + [Route("Cj_StationOutBill/get_BarCodeDetail")] + [HttpGet] + public object get_BarCodeDetail(string HMainInterID) + { + try + { + ds = oCN.RunProcReturn( + "select a.HBillNo,a.HInterID,a.HQty,a.HProcExchBillNo,a.HICMOBillNo" + + ",b.HNumber HMaterNumber,b.HName HMaterName,b.HModel HMaterModel,c.HName HSourceName,d.HName HGroupName" + + ",e.HName HEmpName,a.HMaker,a.HMakeDate " + + " from Sc_StationOutBillMain a " + + " left join Gy_Material b on a.HMaterID = b.HItemID " + + " left join Gy_Source c on a.HSourceID = c.HItemID " + + " left join Gy_Group d on a.HGroupID = d.HItemID " + + " left join Gy_Employee e on a.HEmpID = e.HItemID " + + " where HMainInterID = " + HMainInterID + " order by a.HMakeDate desc", "Sc_StationOutBillMain"); + if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鏂囦欢涓嶈兘涓虹┖锛�"; + 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; - } + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = e.Message; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } - } + #endregion + } } \ No newline at end of file -- Gitblit v1.9.1