From 6b317b0899f680d658180bb1b0619c36f7341fef Mon Sep 17 00:00:00 2001 From: 王 垚 <1402714037@qq.com> Date: 星期五, 18 六月 2021 10:10:35 +0800 Subject: [PATCH] 生产开工单 --- WebAPI/Controllers/SCGL/Sc_MESBeginWorkBillController.cs | 259 +++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 225 insertions(+), 34 deletions(-) diff --git a/WebAPI/Controllers/SCGL/Sc_MESBeginWorkBillController.cs b/WebAPI/Controllers/SCGL/Sc_MESBeginWorkBillController.cs index a048efc..de78d43 100644 --- a/WebAPI/Controllers/SCGL/Sc_MESBeginWorkBillController.cs +++ b/WebAPI/Controllers/SCGL/Sc_MESBeginWorkBillController.cs @@ -1,60 +1,172 @@ 锘縰sing Newtonsoft.Json.Linq; -using Pub_Class; using System; -using System.Collections; using System.Collections.Generic; using System.Data; -using System.Data.SqlClient; +using System.Linq; +using System.Net; +using System.Net.Http; using System.Web.Http; using WebAPI.Models; -namespace WebAPI.Controllers +namespace WebAPI.Controllers.SCGL { - //鐢熶骇寮�宸ュ崟Controller public class Sc_MESBeginWorkBillController : ApiController { - public DBUtility.ClsPub.Enum_BillStatus BillStatus; - private json objJsonResult = new json(); - SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - DataSet ds; + public DataSet ds = new DataSet(); + public WebServer webserver = new WebServer(); + #region 寮�宸ュ崟 - /// <summary> - /// 杩斿洖鐢熶骇寮�宸ュ崟鍒楄〃 - ///鍙傛暟锛歴tring sql銆� - ///杩斿洖鍊硷細object銆� - /// </summary> - [Route("Sc_MESBeginWorkBill/list")] + #region 寮�宸ュ崟鍒楄〃 + + [Route("Sc_MESBeginWorkBill/GetMESBeginWorkBill")] [HttpGet] - public object list(string sWhere) + public object GetMESBeginWorkBill(string sWhere) { try { - if (sWhere == null || sWhere.Equals("")) + + ds = Sc_GetMESBeginWorkBill(sWhere); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + public static DataSet Sc_GetMESBeginWorkBill(string sWhere) + { + if (sWhere == null || sWhere.Equals("")) + { + return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MESBeginWorkBillList_NEW ", "h_v_Sc_MESBeginWorkBillList_NEW"); + } + else + { + string sql1 = "select * from h_v_Sc_MESBeginWorkBillList_NEW where 1 = 1 "; + string sql = sql1 + sWhere; + return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MESBeginWorkBillList_NEW"); + } + + } + + #endregion + + #region[寮�宸ュ崟缂栬緫鏃惰幏鍙栬〃澶存暟鎹甝 + [Route("Sc_MESBeginWorkBill/Sc_MESBeginWorkBillListCheckDetai")] + [HttpGet] + public ApiResult<DataSet> Sc_MESBeginWorkBillListCheckDetai(string HID) + { + 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_Sc_MESBeginWorkBillList_NEW where hmainid= " + HID + " ", "h_v_Sc_MESBeginWorkBillList_NEW"); + 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 }; + } + #endregion + + #region 寮�宸ュ崟淇濆瓨/缂栬緫 + /// <summary> + /// 寮�宸ュ崟 + /// </summary> + /// <param name="msg"></param> + /// <returns></returns> + [Route("Sc_MESBeginWorkBill/SaveGetMESBeginWorkBillList")] + [HttpPost] + public object SaveGetMESBeginWorkBillList([FromBody] JObject msg) + { + var _value = msg["msg"].ToString(); + string msg1 = _value.ToString(); + string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string msg2 = sArray[0].ToString(); + + + + string UserName = ""; + ListModels oListModels = new ListModels(); + try + { + DLL.ClsSc_MESBeginWorkBill oBill = new DLL.ClsSc_MESBeginWorkBill(); + List<Model.ClsSc_MESBeginWorkBillMain> lsmain = new List<Model.ClsSc_MESBeginWorkBillMain>(); + msg2 = msg2.Replace("\\", ""); + msg2 = msg2.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_Gy_MESBeginWorkBillMain(msg2); + foreach (Model.ClsSc_MESBeginWorkBillMain oItem in lsmain) { - ds = oCN.RunProcReturn("select * from h_v_Sc_MESBeginWorkBillList " + sWhere, "h_v_Sc_MESBeginWorkBillList"); + //oItem.HMaker = ""; + UserName = oItem.HMaker; //鍒跺崟浜� + oItem.HBillType = "3787"; + oItem.HBillSubType = "3787"; + //oItem.HBillNo = ""; //鍗曟嵁鍙� + //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --鏃ユ湡 + //oItem.HInnerBillNo = ""; // --鍐呴儴鍗曟嵁鍙� + oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); + oItem.HBarCodeMakeDate = Convert.ToDateTime(DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"))); //鎵弿鏃ユ湡锛堝勾-鏈�-鏃�-鏃�-鍒�-绉掞級 + //oItem.HEquipID = 0; //璁惧ID(Gy_EquipMent) + //oItem.HPeriod = 0; + //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --缁翠慨鏃ユ湡 + //oItem.HCheckResult = ""; //楠屾敹缁撹--(姝e父锛屽紓甯�) + //oItem.HEmpID = 0; //楠屾敹浜�(Gy_Employee) + //oItem.HManagerID = 0; //璐熻矗浜�(Gy_Employee) + //oItem.HDeptID = 0; //楠屾敹閮ㄩ棬(Gy_Department) + //oItem.HExplanation = ""; //鎽樿(鏁呴殰鎻忚堪) + //oItem.HRemark = ""; //澶囨敞 + + //oItem.HMainSourceInterID = oItem.HInterID; + + //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); + if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + oBill.omodel = oItem; + } + + //淇濆瓨 + //淇濆瓨瀹屾瘯鍚庡鐞� + bool bResult; + if (oBill.omodel.HInterID == 0) + { + // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); + bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { - string sql1 = "select * from h_v_Sc_MESBeginWorkBillList where 1 = 1 "; - string sql = sql1 + sWhere; - ds = oCN.RunProcReturn(sql, "h_v_Sc_MESBeginWorkBillList"); + bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } - if (ds == null || ds.Tables[0].Rows.Count == 0) + if (bResult) { objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"; - objJsonResult.data = null; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�"); + objJsonResult.data = 1; return objJsonResult; } else { - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "Sucess锛�"; - objJsonResult.data = ds.Tables[0]; + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; return objJsonResult; } } @@ -62,14 +174,93 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region [寮�宸ュ崟鍒犻櫎鍔熻兘] + /// <summary> + /// 寮�宸ュ崟鍒犻櫎鍔熻兘 + /// </summary> + /// <returns></returns> + [Route("Sc_MESBeginWorkBill/DeltetMESBeginWorkBill")] + [HttpGet] + public object DeltetMESBeginWorkBill(string HInterID) + { + //缂栬緫鏉冮檺 + //if (!DBUtility.ClsPub.Security_Log("Sc_MESBeginWorkBill_Delete", 1, true, DBUtility.ClsPub.CurUserName)) + //{ + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); + if (lngBillKey == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + DLL.ClsSc_MESBeginWorkBill oBill = new DLL.ClsSc_MESBeginWorkBill(); + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) + { + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HChecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + if (IsDete) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + else + { + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈壘鍒�"; objJsonResult.data = null; return objJsonResult; } } + #endregion - - - // + #endregion } -} \ No newline at end of file +} -- Gitblit v1.9.1