From 797e02f68d79c931233f25af1d39bc136ce6185d Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期一, 21 四月 2025 15:47:05 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs | 701 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 667 insertions(+), 34 deletions(-) diff --git a/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs b/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs index 1cb308f..76db3cf 100644 --- a/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs +++ b/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs @@ -1,10 +1,14 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections.Generic; using System.Data; +using System.IO; +using System.Web; using System.Web.Http; using WebAPI.Models; + namespace WebAPI.Controllers { public class Sb_EquipDotCheckBillController : ApiController @@ -14,7 +18,9 @@ public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛� SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); public DAL.ClsSb_EquipDotCheckBill BillNew = new DAL.ClsSb_EquipDotCheckBill(); //瀵瑰簲鍗曟嵁绫� - public DAL.ClsSb_EquipDotCheckBill BillOld = new DAL.ClsSb_EquipDotCheckBill(); //瀵瑰簲鍗曟嵁绫� + public DAL.ClsSb_EquipDotCheckBill BillOld = new DAL.ClsSb_EquipDotCheckBill(); //瀵瑰簲鍗曟嵁绫� + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); //鑾峰彇绯荤粺鍙傛暟 + string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; #region 璁惧鐐规璁板綍琛� @@ -28,6 +34,7 @@ { try { + List<object> columnNameList = new List<object>(); if (!DBUtility.ClsPub.Security_Log("Sb_EquipDotCheckBillList", 1, false, user)) { objJsonResult.code = "0"; @@ -36,38 +43,59 @@ objJsonResult.data = null; return objJsonResult; } - if (sWhere == null || sWhere.Equals("")) + + string sReturn = ""; + string HViewName = "h_v_Sb_EquipDotCheckBillList";//瑙嗗浘鍛藉悕 + if (oSystemParameter.ShowBill(ref sReturn) == true) { - ds = oCN.RunProcReturn("select * from h_v_Sb_EquipDotCheckBillList " + sWhere + " order by hmainid desc", "h_v_Sb_EquipDotCheckBillList"); + if (oSystemParameter.omodel.WMS_CampanyName == "涔濊彵") + { + HViewName = "h_v_Sb_EquipDotCheckBillMainList"; + } } else - { - string sql1 = "select * from h_v_Sb_EquipDotCheckBillList where 1 = 1"; - string sql = sql1 + sWhere + " order by hmainid desc"; - ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBillList"); - } - if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "娌℃湁浣犺鎵剧殑璁板綍锛�"; + objJsonResult.Message = "鍗曟嵁璇诲彇澶辫触锛�"; objJsonResult.data = null; return objJsonResult; } + + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("select * from " + HViewName + " " + sWhere + " order by hmainid desc", HViewName); + } else { - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�"; - objJsonResult.data = ds.Tables[0]; - return objJsonResult; + string sql1 = "select * from " + HViewName + " " + " where 1 = 1"; + string sql = sql1 + sWhere + " order by hmainid desc"; + ds = oCN.RunProcReturn(sql, HViewName); } - //ds = Sb_EquipDotCheckBillList_s(sWhere); - //objJsonResult.code = "1"; - //objJsonResult.count = 1; - //objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�"; - //objJsonResult.data = ds.Tables[0]; + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + //if (ds.Tables[0].Rows.Count != 0 || ds != null) + //{ + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + //} + //else + //{ + //objJsonResult.code = "0"; + //objJsonResult.count = 0; + //objJsonResult.Message = "鏃犳暟鎹�"; + //objJsonResult.data = null; //return objJsonResult; + //} } catch (Exception ex) { @@ -78,6 +106,59 @@ return objJsonResult; } } + + #region 璁惧鐐规璁板綍鍒嗛〉鏌ヨ + [Route("Sb_EquipDotCheckBill/GetEquipDotCheckBillListPage")] + [HttpGet] + public object GetEquipDotCheckBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipDotCheckBillList", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + sWhere = sWhere.Replace("'", "''"); + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("exec h_p_Sb_EquipDotCheckBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipDotCheckBillListPage"); + } + else + { + ds = oCN.RunProcReturn("exec h_p_Sb_EquipDotCheckBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipDotCheckBillListPage"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + 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; + } + } + #endregion #region sql璇彞 @@ -135,6 +216,7 @@ //oItem.HBillNo = ""; oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --鏃ユ湡 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); //oItem.HMakeDate = ""; //oItem.HYear = ""; //oItem.HPeriod = ""; @@ -207,7 +289,6 @@ objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; - //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); objJsonResult.data = 1; return objJsonResult; } @@ -281,7 +362,29 @@ return objJsonResult; } - bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + //鍒犻櫎鍓嶆帶鍒� + DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_Sb_EquipDotCheckBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + user + "'", "h_p_Sb_EquipDotCheckBill_BeforeDelCtrl"); + if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + } + + bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Sb_EquipDotCheckBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; @@ -318,7 +421,7 @@ if (string.IsNullOrEmpty(HID)) return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sb_EquipDotCheckBillList where hmainid= " + HID + " ", "h_v_Sb_EquipDotCheckBillList"); + var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sb_EquipDotCheckBill_Edit2 where hmainid= " + HID + " ", "h_v_Sb_EquipDotCheckBill_Edit2"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄧ偣妫�璁板綍琛�" }; return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet }; @@ -336,7 +439,7 @@ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { - ds = oCN.RunProcReturn("select 鐐规椤圭洰ID HDotCheckItemID,鐐规椤圭洰浠g爜 as HDotCheckCode ,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜虹紪鐮� HManagerCode,璐熻矗浜� HManagerName from h_v_Sb_EquipDotCheckBillList", "h_v_Sb_EquipDotCheckBillList"); + ds = oCN.RunProcReturn("select * from h_v_Sb_EquipDotCheckBill_Edit", "h_v_Sb_EquipDotCheckBill_Edit"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�"; @@ -344,9 +447,9 @@ } else { - string sql1 = "select 鐐规椤圭洰ID HDotCheckItemID,鐐规椤圭洰浠g爜 as HDotCheckCode ,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜虹紪鐮� HManagerCode,璐熻矗浜� HManagerName from h_v_Sb_EquipDotCheckBillList where 1 = 1 "; + string sql1 = "select * from h_v_Sb_EquipDotCheckBill_Edit where 1 = 1 "; string sql = sql1 + sqlWhere; - ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBillList"); + ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBill_Edit"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�"; @@ -365,13 +468,8 @@ #endregion - - - #endregion - - #region 璁惧鐐规璁板綍鍗昉DA #region 鏍规嵁璁惧鏉$爜鏌ユ壘璁惧妗f淇℃伅PDA [Route("Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown")] @@ -390,6 +488,49 @@ } //寰楀埌淇℃伅 ds = oCN.RunProcReturn("select top 1 * from Gy_EquipFileBillMain where HEquipFileNumber= '" + HBarCode + "'", "Gy_EquipFileBillMain"); + //鍐欏叆淇℃伅 + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏈煡璇㈠埌璁惧淇℃伅锛�"; + objJsonResult.data = null; + return objJsonResult; + } + 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; + } + } + #endregion + + #region 鏍规嵁璁惧鏉$爜鏌ユ壘璁惧妗f淇℃伅PDA 鏌ヨ鏉$爜妗f鍒楄〃 + [Route("Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown_List")] + [HttpGet] + public object txtHBarCode_KeyDown_List(string HBarCode) + { + try + { + if (HBarCode == null || HBarCode.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏉″舰鐮佷笉鑳戒负绌猴紒"; + objJsonResult.data = null; + return objJsonResult; + } + //寰楀埌淇℃伅 + ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_EquipFileMainList where 鏉″舰鐮�= '" + HBarCode + "'", "h_v_Gy_EquipFileMainList"); //鍐欏叆淇℃伅 if (ds == null || ds.Tables[0].Rows.Count == 0) { @@ -502,8 +643,8 @@ oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItemSub.HCloseType = false; //鍏抽棴绫诲瀷 //oItemSub.HRemark = ""; //澶囨敞 - oItemSub.HSourceInterID = 0; // 婧愬崟涓诲唴鐮� - oItemSub.HSourceEntryID = 0; //婧愬崟瀛愬唴鐮� + //oItemSub.HSourceInterID = 0; // 婧愬崟涓诲唴鐮� + //oItemSub.HSourceEntryID = 0; //婧愬崟瀛愬唴鐮� //oItemSub.HSourceBillNo = ""; //婧愬崟鍗曞彿 //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷 //oItemSub.HRelationQty = 0; //鍏宠仈鏁伴噺 @@ -555,7 +696,499 @@ } #endregion + #region 璁惧鐐规璁板綍鍗曞鏍�/鍙嶅鏍稿姛鑳� + [Route("Sb_EquipDotCheckBill/CheckSb_EquipDotCheckBill")] + [HttpGet] + public object CheckSb_EquipDotCheckBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Sb_EquipDotCheckBill_Check", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬鏍�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 瀹℃牳 2 鍙嶅鏍� + if (Type == 1) + { + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Sb_EquipDotCheckBill_BeforeCheckCtrl " + HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipDotCheckBill_BeforeCheckCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + + if (!BillOld.CheckBill(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Sb_EquipDotCheckBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_Sb_EquipDotCheckBill_BeforeUnCheckCtrl " + HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipDotCheckBill_BeforeUnCheckCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //=========================================================== + + if (!BillOld.AbandonCheck(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Sb_EquipDotCheckBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + + oCN.Commit();//鎻愪氦浜嬪姟 + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎵ц鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } #endregion + #region 璁惧鐐规璁板綍鍗曞叧闂�/鍙嶅叧闂姛鑳� + [Route("Sb_EquipDotCheckBill/CloseSb_EquipDotCheckBill")] + [HttpGet] + public object CloseSb_EquipDotCheckBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Sb_EquipDotCheckBill_Close", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 鍏抽棴 2 鍙嶅叧闂� + if (Type == 1) + { + string sql = ""; + //鍏抽棴鍓嶆帶鍒�===============================================Begin=================================================================== + sql = "exec h_p_Sb_EquipDotCheckBill_BeforeCloseCtrl " + HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Sb_EquipDotCheckBill_BeforeCloseCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍏抽棴鍓嶆帶鍒�===============================================End=================================================================== + + //鍏抽棴鎻愪氦 + if (BillOld.CloseBill(Convert.ToInt32(HInterID), BillOld.omodel.HBillNo, "h_p_Sb_EquipDotCheckBill_AfterCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + string sql = ""; + //鍙嶅叧闂墠鎺у埗===============================================Begin=================================================================== + sql = "exec h_p_Sb_EquipDotCheckBill_BeforeUnCloseCtrl " + HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Sb_EquipDotCheckBill_BeforeUnCloseCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅叧闂墠鎺у埗===============================================End=================================================================== + + //鍙嶅叧闂彁浜� + if (BillOld.CancelClose(Convert.ToInt32(HInterID), BillOld.omodel.HBillNo, "h_p_Sb_EquipDotCheckBill_AfterUnCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂垚鍔�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + + oCN.Commit();//鎻愪氦浜嬪姟 + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎵ц鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 璁惧鐐规閫炬湡棰勮鎶ヨ〃 + + [Route("Sb_EquipDotCheckWarning/Report")] + [HttpGet] + public object Report(string HYear,string HMonth,string HEquipTypeID, string user) + { + try + { + List<object> columnNameList = new List<object>(); + //if (!DBUtility.ClsPub.Security_Log("Gy_EquipFileList", 1, false, user)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺"; + // objJsonResult.data = null; + // return objJsonResult; + //} + if (HYear == null || HYear.Equals("") || HMonth == null || HMonth.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "璇烽�夋嫨鏈夋晥骞翠唤锛屾湀浠�"; + objJsonResult.data = ""; + objJsonResult.list = columnNameList; + return objJsonResult; + } + else + { + string sql = "exec h_p_Sb_EquipDotCheckWarningReport " + HYear + "," + HMonth + "," + HEquipTypeID; + ds = oCN.RunProcReturn(sql, "h_p_Sb_EquipDotCheckWarningReport"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 璁惧鐐规璁板綍鎷嶇収涓婁紶 + [Route("Sb_EquipDotCheckBill/UploadFile")] + [HttpPost] + public object UploadFile() + { + + 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/EquipFolder/" + 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/EquipFolder/" + 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/EquipFolder/" + 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> + /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛� + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("Sb_EquipDotCheckBill/Filelist")] + [HttpGet] + public object Filelist(string HBillNo) + { + var url = fileip + "/files/EquipFolder/" + 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("Sb_EquipDotCheckBill/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/EquipFolder/" + 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