From a1c3a3d1b0b0b8c28a19e99177e4cee5a64949b7 Mon Sep 17 00:00:00 2001 From: zrg <z18737863051@163.com> Date: 星期二, 25 二月 2025 11:20:17 +0800 Subject: [PATCH] 增加斯莫尔 性能检测散点图报表 --- WebAPI/Controllers/Sc_ProcessMangementController.cs | 6259 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 6,120 insertions(+), 139 deletions(-) diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs index 26b7cc7..b8babff 100644 --- a/WebAPI/Controllers/Sc_ProcessMangementController.cs +++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs @@ -1,13 +1,17 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; +using System.IO; using System.Web.Http; +using WebAPI.DLL; using WebAPI.Models; using WebAPI.Service; +using Kingdee.BOS.WebApi.Client; namespace WebAPI.Controllers { @@ -16,8 +20,8 @@ public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); - - + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); + public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; @@ -30,22 +34,31 @@ { try { - if (ds == null || ds.Tables[0].Rows.Count <= 0) + List<object> a = new List<object>(); + foreach (DataColumn col in ds.Tables[0].Columns)//閬嶅巻ds涓涓�涓〃锛圱ables[0]锛夌殑鎵�鏈夊垪锛圕olumns锛夋瘡娆″惊鐜腑锛宑ol鍙橀噺浼氭寔鏈夊綋鍓嶅垪鐨勫紩鐢� { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"; - objJsonResult.data = null; - return objJsonResult; + Type dataType = col.DataType; //鑾峰彇褰撳墠鏁版嵁绫诲瀷浼犲叆 鑷畾涔夊彉閲廳atadataType + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //瀛楃涓叉嫾鎺� // 灏嗗垪鍚嶅拰鏁版嵁绫诲瀷淇℃伅鎷兼帴鎴愪竴涓狫SON鏍煎紡鐨勫瓧绗︿覆 + a.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 } - else - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�"; - objJsonResult.data = ds.Tables[0]; - return objJsonResult; - } + //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 = a; + + return objJsonResult; + //} + //else + //{ + //objJsonResult.code = "0"; + //objJsonResult.count = 0; + //objJsonResult.Message = "鏃犳暟鎹�"; + //objJsonResult.data = null; + //return objJsonResult; + //} } catch (Exception e) { @@ -96,6 +109,1827 @@ return objJsonResult; } + #region 鏈亾宸ュ簭姹囨姤鍏ュ簱 + /// <summary> + /// 鏈亾宸ュ簭姹囨姤鍏ュ簱鍒楄〃 + /// </summary> + /// <param name="sWhere"></param> + /// <param name="user"></param> + /// <returns></returns> + [Route("Sc_ProcessMangement/Sc_ProcessReportList_Last")] + [HttpGet] + public object Sc_ProcessReportList_Last(string sWhere, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡璇㈡潈闄�!"; + objJsonResult.data = null; + return objJsonResult; + } + + string sql1 = "select * from h_v_Sc_ProcessReportList_Last where 1 = 1 and HLastProc='鏄�'"; + string sql = sql1 + sWhere + " order by hmainid desc"; + ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessReportList_Last"); + + 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 宸ュ簭姹囨姤鍏ュ簱 + /// <summary> + /// 鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曞垪琛� + /// </summary> + /// <param name="sWhere"></param> + /// <param name="user"></param> + /// <returns></returns> + [Route("Sc_ProcessMangement/Get_ProcessReportOverList")] + [HttpGet] + public object Get_ProcessReportOverList(string sWhere, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡璇㈡潈闄�!"; + objJsonResult.data = null; + return objJsonResult; + } + + + string sql1 = "select * from h_v_Sc_ProcessReportList_Last where 1 = 1 and HFstProc='鏄�' "; + string sql = sql1 + sWhere + " order by hmainid desc"; + ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessReportList_Last"); + + 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 鏂帿灏� 鏈亾宸ュ簭姹囨姤鍒楄〃 姹囨姤 鍏ュ簱 + /// <summary> + /// 鐢熸垚 鐢熶骇姹囨姤鍗� + /// 鍚屾閲戣澏浜� 宸ュ簭姹囨姤鍏ュ簱鍗� 鍏ュ簱 + /// </summary> + /// <param name="InterID"></param> + /// <param name="user"></param> + /// <param name="BillNo"></param> + /// <param name="OrganizationID"></param> + /// <returns></returns> + //[Route("Sc_ProcessMangement/SRM_SaveICMOReportBill")] + //[HttpGet] + //public object SRM_SaveICMOReportBill(string InterID, string user, string BillNo, string OrganizationID) + //{ + // try + // { + // //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + // Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo); + // string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true); + // //鑾峰彇缁勭粐浠g爜 + // string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString(); + // //鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁 + // DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc"); + // DataRow dr = ds.Tables[0].Rows[0]; + + // //淇濆瓨 + // oCN.BeginTran(); + // DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain where HBillNo='{HBillNo}'", "Sc_ICMOReportBillMain"); + // if (DsTable.Tables[0].Rows.Count > 0) + // { + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "宸插叆搴�,璇蜂笉瑕侀噸澶嶅叆搴�"; + // objJsonResult.data = null; + // return objJsonResult; + // } + // //鐢熶骇姹囨姤鍗曚富琛� + // oCN.RunProc("Insert Into Sc_ICMOReportBillMain " + + // "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + // ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + + // ",HGroupID,HDeptID,HDeptNumber" + + // ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + + // ") " + + // " values('3711','3711'," + HInterID.ToString() + ",'" + BillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + // ",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + + // "','" + dr["HGroupID"].ToString() + "',0,''" + + // ",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + + // ") "); + // //鐢熶骇姹囨姤鍗曞瓙琛� + // oCN.RunProc("Insert into Sc_ICMOReportBillSub " + + // " (HInterID,HEntryID,HMaterID,HMaterNumber" + + // ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" + + // ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," + + // "HCloseMan,HCloseType,HRemark," + + // "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + + // ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + + // ",HICMOInterID,HICMOBillNo,HBarCode" + + // ") values(" + // + HInterID.ToString() + ",1," + dr["HMaterID"].ToString() + ",'" + dr["浜у搧浠g爜"].ToString() + "'" + + // "," + dr["鍚堟牸鏁伴噺"].ToString() + ",0,'',0,0" + + // "," + dr["鎺ユ敹鏁伴噺"].ToString() + "," + dr["HEmpID"].ToString() + ",'" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + "'," + dr["涓嶈壇鏁伴噺"].ToString() + "," + dr["鎶ュ簾鏁伴噺"].ToString() + + // ",'',0,''" + + // "," + InterID.ToString() + ",0,'" + BillNo.ToString() + "','3791',0,0" + + // ",0,0,''" + + // "," + dr["HICMOInterID"].ToString() + ",'" + dr["浠诲姟鍗�"].ToString() + "',''" + + // ") "); + // //鍚屾閲戣澏 + // //璁块棶閲戣澏 + // var loginRet = InvokeHelper.Login(); + // var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + // if (isSuccess == 0) + // { + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + // objJsonResult.data = null; + // return objJsonResult; + // } + // //鏍规嵁浠诲姟鍗曟煡鎵惧埌閲戣澏鐨勭敓浜ц鍗� + // DataSet ds1 = oCN.RunProcReturn("select * from h_v_TOERP_StationOutBillList_LastProc where HICMOEntryID=" + dr["HICMOEntryID"].ToString(), "h_v_TOERP_StationOutBillList_LastProc"); + // DataRow dr1 = ds1.Tables[0].Rows[0]; + + // JObject model = new JObject(); + // model.Add("FBillType", new JObject() { ["Fnumber"] = "SCHBD01_SYS" }); //鍗曟嵁绫诲瀷鐢熶骇姹囨姤鈥淪CHBD02_SYS鈥� 鍏ュ簱姹囨姤SCHBD01_SYS + // model.Add("FPrdOrgId", new JObject() { ["Fnumber"] = dr1["FPrdOrgNUMBER"].ToString() }); //鐢熶骇缁勭粐1 + // model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡1 + // model.Add("FBillNo", BillNo); + + // JArray Fentity = new JArray(); + + // foreach (DataRow item in ds.Tables[0].Rows) + // { + // JObject FentityModel = new JObject(); + // FentityModel.Add("FIsNew", false);// 婧愬崟绫诲瀷 + // FentityModel.Add("FReportType", new JObject() { ["Fnumber"] = dr1["FREPORTTYPENUMBER"].ToString() });//鐢熶骇姹囨姤绫诲瀷 + // FentityModel.Add("FSrcBillType", "PRD_MO");// 婧愬崟绫诲瀷 + // FentityModel.Add("FProductType", "1");// 浜у搧绫诲瀷 + // FentityModel.Add("FSrcBillNo", item["浠诲姟鍗�"].ToString());// 婧愬崟缂栧彿 + // FentityModel.Add("FSrcInterId", dr1["FMOID"].ToString());// 婧愬崟鍐呯爜 + // FentityModel.Add("FSrcEntryId", dr1["FMOENTRYID"].ToString());// 婧愬崟鍒嗗綍鍐呯爜銆� + // FentityModel.Add("FSRCENTRYSEQ", dr1["FMOENTRYSEQ"].ToString());// 婧愬崟鍒嗗綍琛屽彿 + // FentityModel.Add("FUNITID", new JObject() { ["Fnumber"] = dr1["FUNITNUMBER"].ToString() });//鍗曚綅 + // FentityModel.Add("FTimeUnitId", "1");//鏃堕棿鍗曚綅 + // FentityModel.Add("FWorkshipId", new JObject() { ["Fnumber"] = dr1["FWorkShopNUM"].ToString() }); // 鐢熶骇杞﹂棿 + // FentityModel.Add("FStandHourUnitId", "3600"); // 鍗曚綅鏍囧噯宸ユ椂鍗曚綅 + // FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = dr1["FMaterialNUM"].ToString() }); // 鐗╂枡缂栫爜 + // FentityModel.Add("FMoEntrySeq", dr1["FMOENTRYSEQ"].ToString());//鐢熶骇璁㈠崟琛屽彿 + // FentityModel.Add("FMoId", dr1["HICMOInterID"].ToString());//鐢熶骇璁㈠崟鍐呯爜 + // FentityModel.Add("FFinishQty", item["鎺ユ敹鏁伴噺"].ToString());//瀹屾垚鏁伴噺1 + // FentityModel.Add("FQuaQty", item["鍚堟牸鏁伴噺"].ToString());//鍚堟牸鏁伴噺1FFailQty + // FentityModel.Add("FFailQty", item["涓嶈壇鏁伴噺"].ToString());//涓嶅悎鏍兼暟閲� + // FentityModel.Add("FStockInOrgId ", new JObject() { ["Fnumber"] = OrganizationNUM });// 鍏ュ簱缁勭粐 + // FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 浠撳簱 + // FentityModel.Add("FMOBILLNO", dr1["FMOBILLNO"].ToString());// + // FentityModel.Add("FMOENTRYID", dr1["FMOENTRYID"].ToString());// + // FentityModel.Add("FOwnerTypeId", dr1["FOWNERTYPEID"].ToString()); //璐т富绫诲瀷锛欶OwnerTypeId(蹇呭~椤�) + // FentityModel.Add("FOwnerId", new JObject() { ["Fnumber"] = dr1["FOwnerNumber"].ToString() }); //璐т富锛欶OwnerId(蹇呭~椤�) + // FentityModel.Add("FBomId", new JObject() { ["F number"] = dr1["FBOMNUM"].ToString() }); //BOM鐗堟湰锛欶BomId(蹇呭~椤�) + // FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 鎴愭湰鏉冮噸 + // FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 鍊掑啿棰嗘枡 + // FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());// + // FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //鎵瑰彿 + // JArray Fentity2 = new JArray(); + // JObject FentityModel2 = new JObject(); + // FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72"); + // FentityModel2.Add("FEntity_Link_FFlowLineId", "PRD_MO2MORPT"); + // FentityModel2.Add("FEntity_Link_FRuleId", "3"); + // FentityModel2.Add("FEntity_Link_FSTableId", "0"); + // FentityModel2.Add("FEntity_Link_FSTableName", "T_PRD_MOENTRY"); + // FentityModel2.Add("FEntity_Link_FSBillId", dr1["FMOID"].ToString()); + // FentityModel2.Add("FEntity_Link_FSId", dr1["FMOENTRYID"].ToString()); + // FentityModel2.Add("FEntity_Link_FBaseQuaQtyOld", item["鍚堟牸鏁伴噺"].ToString()); + // FentityModel2.Add("FEntity_Link_FBaseQuaQty", item["鍚堟牸鏁伴噺"].ToString()); + // Fentity2.Add(FentityModel2); + // } + // model.Add("FEntity", Fentity); //鏄庣粏淇℃伅 + // JObject jsonRoot = new JObject() + // { + // ["Creator"] = "", + // ["NeedUpDateFields"] = new JArray(), + // ["NeedReturnFields"] = new JArray(), + // ["IsDeleteEntry"] = "false", + // ["SubSystemId"] = "", + // ["IsVerifyBaseDataField"] = "false", + // //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + // ["Model"] = model + // }; + + // string result = InvokeHelper.Save("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨 + // //鍒ゆ柇淇濆瓨鏄惁鎴愬姛 + // if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + // { + // LogService.Write("宸ュ簭姹囨姤鍗曞叆搴撻敊璇痡sonRoot:" + jsonRoot); + // oCN.RollBack(); + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = $"鐢熶骇姹囨姤鍏ュ簱鍗曞悓姝ラ噾铦朵簯澶辫触锛佸崟鍙�:{dr["鍗曟嵁鍙�"].ToString()}" + result; + // objJsonResult.data = null; + // return objJsonResult; + // } + // //鎻愪氦瀹℃牳 + // string result1 = string.Empty; + // string result2 = string.Empty; + // var fID = JObject.Parse(result)["Result"]["Id"].ToString(); + // var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); + // var json = new + // { + // Ids = fID, + // }; + // result1 = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(json));//鎻愪氦 + // result2 = InvokeHelper.Audit("PRD_MORPT", JsonConvert.SerializeObject(json));//鎻愪氦 + // if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + // { + // oCN.RollBack(); + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = $"鐢熶骇姹囨姤鍗曞崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result; + // objJsonResult.data = null; + // return objJsonResult; + // } + + // oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where HBillNo='" + BillNo + "'"); + + // oCN.Commit(); + // objJsonResult.code = "0"; + // objJsonResult.count = 1; + // objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + // objJsonResult.data = 1; + // return objJsonResult; + // } + // catch (Exception e) + // { + // oCN.RollBack(); + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "Exception锛�" + e.ToString(); + // objJsonResult.data = null; + // return objJsonResult; + // } + //} + #endregion + + + + /// <summary> + /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/SaveICMOReportBill_Batch")] + [HttpPost] + public object SaveICMOReportBill_Batch([FromBody] JObject msg) + { + var _value = msg["msg"].ToString(); + string msg1 = _value.ToString(); + string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string InterID = sArray[0].ToString(); + string user = sArray[1].ToString(); + string BillNo = sArray[2].ToString(); + string OrganizationID = sArray[3].ToString(); + ArrayList InterIDArray = new ArrayList(InterID.Split(',')); + ArrayList BillNoArray = new ArrayList(BillNo.Split(',')); + try + { + string bResult; + string HMessage = ""; + string HSuccessBillNo = ""; + string HFailBillNo = ""; + WebAPI.Controllers.Sc_ProcessMangementController oBill = new WebAPI.Controllers.Sc_ProcessMangementController(); + if (InterIDArray.Count != BillNoArray.Count) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏁版嵁涓嶅畬鏁达紝鍐呯爜鏁伴噺涓嶇瓑浜庡崟鎹彿鏁伴噺"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + for (int i = 0; i < InterIDArray.Count;i++) + { + bResult = JsonConvert.SerializeObject(oBill.SaveICMOReportBill(InterIDArray[i].ToString(), user, BillNoArray[i].ToString(), OrganizationID)); + + //鍙嶅簭鍒楀寲 + bResult = "[" + bResult.ToString() + "]"; + + List<JsonResult> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JsonResult>>(bResult); + + if (list[0].count == 1) + { + HSuccessBillNo = HSuccessBillNo + BillNoArray[i].ToString()+"," + "\r\n" ; + } + else + { + HFailBillNo = HFailBillNo + BillNoArray[i].ToString() + ":" + list[0].Message + "," + "\r\n"; + } + HMessage = "姹囨姤鎴愬姛鍗曞彿锛�" + HSuccessBillNo + "\r\n" + " 姹囨姤澶辫触鍗曞彿锛�" + HFailBillNo; + } + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = HMessage; + objJsonResult.data = null; + return objJsonResult; + + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + + /// <summary> + /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/SaveICMOReportBill")] + [HttpGet] + public object SaveICMOReportBill(string InterID, string user, string BillNo, string OrganizationID) + { + try + { + LogService.Write("鐢熶骇姹囨姤鍗曡繘鍏ュ悓姝ユ柟娉曪紝姹囨姤鍗曞彿锛�" + BillNo); + + string sErr = ""; + oSystemParameter.ShowBill(ref sErr); + + + //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true); + //鑾峰彇缁勭粐浠g爜 + string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString(); + //鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁 + DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc"); + if (ds.Tables[0].Rows.Count <= 0) + { + LogService.Write("鐢熶骇姹囨姤鍗曞洖婊氾紝姹囨姤鍗曞彿锛�" + BillNo + " 鍘熷洜锛氱敓鎴愮敓浜ф眹鎶ュ崟杩囩▼涓病鏈夋煡璇㈠埌鍑虹珯鍗�"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鐢熸垚鐢熶骇姹囨姤鍗曡繃绋嬩腑娌℃湁鏌ヨ鍒板嚭绔欏崟"; + objJsonResult.data = null; + return objJsonResult; + } + DataRow dr = ds.Tables[0].Rows[0]; + + //淇濆瓨 + oCN.BeginTran(); + DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain with(nolock) where HBillNo='{HBillNo}'", "Sc_ICMOReportBillMain"); + if (DsTable.Tables[0].Rows.Count > 0) + { + LogService.Write("鐢熶骇姹囨姤鍗曞洖婊氾紝姹囨姤鍗曞彿锛�" + BillNo + " 鍘熷洜锛氬凡鍏ュ簱,璇蜂笉瑕侀噸澶嶅叆搴�"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "宸插叆搴�,璇蜂笉瑕侀噸澶嶅叆搴�"; + objJsonResult.data = null; + return objJsonResult; + } + //鐢熶骇姹囨姤鍗曚富琛� + oCN.RunProc("Insert Into Sc_ICMOReportBillMain " + + "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + + ",HGroupID,HDeptID,HDeptNumber" + + ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + + ") " + + " values('3711','3711'," + HInterID.ToString() + ",'" + BillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + ",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + + "','" + dr["HGroupID"].ToString() + "',0,''" + + ",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + + ") "); + //鐢熶骇姹囨姤鍗曞瓙琛� + oCN.RunProc("Insert into Sc_ICMOReportBillSub " + + " (HInterID,HEntryID,HMaterID,HMaterNumber" + + ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" + + ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," + + "HCloseMan,HCloseType,HRemark," + + "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + + ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + + ",HICMOInterID,HICMOBillNo,HBarCode" + + ") values(" + + HInterID.ToString() + ",1," + dr["HMaterID"].ToString() + ",'" + dr["浜у搧浠g爜"].ToString() + "'" + + "," + dr["鍚堟牸鏁伴噺"].ToString() + ",0,'',0,0" + + "," + dr["鎺ユ敹鏁伴噺"].ToString() + "," + dr["HEmpID"].ToString() + ",'" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + "'," + dr["涓嶈壇鏁伴噺"].ToString() + "," + dr["鎶ュ簾鏁伴噺"].ToString() + + ",'',0,''" + + "," + InterID.ToString() + ",0,'" + BillNo.ToString() + "','3791',0,0" + + ",0,0,''" + + "," + dr["HICMOInterID"].ToString() + ",'" + dr["浠诲姟鍗�"].ToString() + "',''" + + ") "); + //鍚屾閲戣澏 + //璁块棶閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + if (isSuccess == 0) + { + LogService.Write("鐢熶骇姹囨姤鍗曞洖婊氾紝姹囨姤鍗曞彿锛�" + BillNo + " 鍘熷洜锛氭搷浣滃け璐�,閲戣澏璐﹀彿鐧诲綍寮傚父"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + objJsonResult.data = null; + return objJsonResult; + } + //鏍规嵁浠诲姟鍗曟煡鎵惧埌閲戣澏鐨勭敓浜ц鍗� + DataSet ds1 = oCN.RunProcReturn("select * from h_v_TOERP_StationOutBillList_LastProc where HICMOEntryID=" + dr["HICMOEntryID"].ToString(), "h_v_TOERP_StationOutBillList_LastProc"); + DataRow dr1 = ds1.Tables[0].Rows[0]; + + JObject model = new JObject(); + model.Add("FBillType", new JObject() { ["Fnumber"] = "SCHBD01_SYS" }); //鍗曟嵁绫诲瀷鐢熶骇姹囨姤鈥淪CHBD02_SYS鈥� 鍏ュ簱姹囨姤SCHBD01_SYS + model.Add("FPrdOrgId", new JObject() { ["Fnumber"] = dr1["FPrdOrgNUMBER"].ToString() }); //鐢熶骇缁勭粐1 + model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡1 + model.Add("FHZYMESFLAG", "鏄�");// 鏄惁涓篗ES鍚屾 + model.Add("FBillNo", BillNo); + + JArray Fentity = new JArray(); + + foreach (DataRow item in ds.Tables[0].Rows) + { + JObject FentityModel = new JObject(); + FentityModel.Add("FIsNew", false);// 婧愬崟绫诲瀷 + FentityModel.Add("FReportType", new JObject() { ["Fnumber"] = dr1["FREPORTTYPENUMBER"].ToString() });//鐢熶骇姹囨姤绫诲瀷 + FentityModel.Add("FSrcBillType", "PRD_MO");// 婧愬崟绫诲瀷 + FentityModel.Add("FProductType", "1");// 浜у搧绫诲瀷 + FentityModel.Add("FSrcBillNo", item["浠诲姟鍗�"].ToString());// 婧愬崟缂栧彿 + FentityModel.Add("FSrcInterId", dr1["FMOID"].ToString());// 婧愬崟鍐呯爜 + FentityModel.Add("FSrcEntryId", dr1["FMOENTRYID"].ToString());// 婧愬崟鍒嗗綍鍐呯爜銆� + FentityModel.Add("FSRCENTRYSEQ", dr1["FMOENTRYSEQ"].ToString());// 婧愬崟鍒嗗綍琛屽彿 + FentityModel.Add("FUNITID", new JObject() { ["Fnumber"] = dr1["FUNITNUMBER"].ToString() });//鍗曚綅 + FentityModel.Add("FTimeUnitId", "1");//鏃堕棿鍗曚綅 + FentityModel.Add("FWorkshipId", new JObject() { ["Fnumber"] = dr1["FWorkShopNUM"].ToString() }); // 鐢熶骇杞﹂棿 + FentityModel.Add("FStandHourUnitId", "3600"); // 鍗曚綅鏍囧噯宸ユ椂鍗曚綅 + FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = dr1["FMaterialNUM"].ToString() }); // 鐗╂枡缂栫爜 + FentityModel.Add("FMoEntrySeq", dr1["FMOENTRYSEQ"].ToString());//鐢熶骇璁㈠崟琛屽彿 + FentityModel.Add("FMoId", dr1["HICMOInterID"].ToString());//鐢熶骇璁㈠崟鍐呯爜 + FentityModel.Add("FFinishQty", item["鎺ユ敹鏁伴噺"].ToString());//瀹屾垚鏁伴噺1 + FentityModel.Add("FQuaQty", item["鍚堟牸鏁伴噺"].ToString());//鍚堟牸鏁伴噺1FFailQty + FentityModel.Add("FFailQty", item["涓嶈壇鏁伴噺"].ToString());//涓嶅悎鏍兼暟閲� + FentityModel.Add("FScrapQty", item["鎶ュ簾鏁伴噺"].ToString());//鎶ュ簾鏁伴噺 + FentityModel.Add("FStockInOrgId ", new JObject() { ["Fnumber"] = OrganizationNUM });// 鍏ュ簱缁勭粐 + FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 浠撳簱 + FentityModel.Add("FMOID", dr1["FMOID"].ToString());// + FentityModel.Add("FMOBILLNO", dr1["FMOBILLNO"].ToString());// + FentityModel.Add("FMOENTRYID", dr1["FMOENTRYID"].ToString());// + FentityModel.Add("FMOENTRYSEQ", dr1["FMOENTRYSEQ"].ToString());// + FentityModel.Add("FOwnerTypeId", dr1["FOWNERTYPEID"].ToString()); //璐т富绫诲瀷锛欶OwnerTypeId(蹇呭~椤�) + FentityModel.Add("FOwnerId", new JObject() { ["Fnumber"] = dr1["FOwnerNumber"].ToString() }); //璐т富锛欶OwnerId(蹇呭~椤�) + FentityModel.Add("FBomId", new JObject() { ["Fnumber"] = dr1["FBOMNUM"].ToString() }); //BOM鐗堟湰锛欶BomId(蹇呭~椤�) + FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 鎴愭湰鏉冮噸 + FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 鍊掑啿棰嗘枡 + FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());// + if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�") + { + FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() });//鍖呰鏍囪瘑 + } + FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //鎵瑰彿 + FentityModel.Add("F_bsv_Text", dr1["宸ュ簭娴佽浆鍗″彿"].ToString()); //娴佽浆鍗″彿 + JArray Fentity2 = new JArray(); + JObject FentityModel2 = new JObject(); + FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72"); + FentityModel2.Add("FEntity_Link_FFlowLineId", "PRD_MO2MORPT"); + FentityModel2.Add("FEntity_Link_FRuleId", "3"); + FentityModel2.Add("FEntity_Link_FSTableId", "0"); + FentityModel2.Add("FEntity_Link_FSTableName", "T_PRD_MOENTRY"); + FentityModel2.Add("FEntity_Link_FSBillId", dr1["FMOID"].ToString()); + FentityModel2.Add("FEntity_Link_FSId", dr1["FMOENTRYID"].ToString()); + FentityModel2.Add("FEntity_Link_FBaseQuaQtyOld", item["鍚堟牸鏁伴噺"].ToString()); + FentityModel2.Add("FEntity_Link_FBaseQuaQty", item["鍚堟牸鏁伴噺"].ToString()); + Fentity2.Add(FentityModel2); + FentityModel.Add("FEntity_Link", Fentity2); + FentityModel.Add("FBFLowId", new JObject() { ["FID"] = "f6e6eec3-5267-4f02-8593-b633da508a72" }); // + Fentity.Add(FentityModel); + } + model.Add("FEntity", Fentity); //鏄庣粏淇℃伅 + JObject jsonRoot = new JObject() + { + ["Creator"] = "", + ["NeedUpDateFields"] = new JArray(), + ["NeedReturnFields"] = new JArray(), + ["IsDeleteEntry"] = "false", + ["SubSystemId"] = "", + ["IsVerifyBaseDataField"] = "false", + //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + ["Model"] = model + }; + + string result = InvokeHelper.Save("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨 + //鍒ゆ柇淇濆瓨鏄惁鎴愬姛 + if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("宸ュ簭姹囨姤鍗曞叆搴撻敊璇痡sonRoot:" + jsonRoot); + LogService.Write("鐢熶骇姹囨姤鍗曚繚瀛樺け璐ワ紝姹囨姤鍗曞彿锛�" + BillNo + " 鍘熷洜锛�" + result); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"宸ュ簭姹囨姤鍏ュ簱鍗曞悓姝ラ噾铦朵簯澶辫触锛佸崟鍙�:{dr["鍗曟嵁鍙�"].ToString()}" + result; + objJsonResult.data = null; + return objJsonResult; + } + //鎻愪氦瀹℃牳 + string result1 = string.Empty; + string result2 = string.Empty; + var fID = JObject.Parse(result)["Result"]["Id"].ToString(); + var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); + var json = new + { + Ids = fID, + }; + result1 = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(json));//鎻愪氦 + result2 = InvokeHelper.Audit("PRD_MORPT", JsonConvert.SerializeObject(json));//鎻愪氦 + if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("鐢熶骇姹囨姤鍗曟彁浜ゅけ璐ワ紝姹囨姤鍗曞彿锛�" + BillNo + " 鍘熷洜锛�" + result1); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鐢熶骇姹囨姤鍗曞崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result1; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where HBillNo='" + BillNo + "'"); + + oCN.Commit(); + + LogService.Write("鐢熶骇姹囨姤鍗曚繚瀛樻垚鍔燂紝姹囨姤鍗曞彿锛�" + BillNo ); + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write("鐢熶骇姹囨姤鍗曞悓姝ュ彂鐢熷紓甯革紝姹囨姤鍗曞彿锛�" + BillNo + " " + e.ToString()); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + /// <summary> + /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/SaveProcdutInBill_Batch")] + [HttpPost] + public object SaveProcdutInBill_Batch([FromBody] JObject msg) + { + var _value = msg["msg"].ToString(); + string msg1 = _value.ToString(); + string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string BillNo = sArray[0].ToString(); + BillNo = BillNo.Replace("\r\n", "").Replace("[ ", "").Replace("]", ""); + BillNo = BillNo.Replace("\\", "").Replace("\n", "").Replace("\"", ""); + BillNo = BillNo.Trim(); + ArrayList BillNoArray = new ArrayList(BillNo.Split(',')); + + try + { + string bResult; + string HMessage = ""; + string HSuccessBillNo = ""; + string HFailBillNo = ""; + WebAPI.Controllers.Sc_ProcessMangementController oBill = new WebAPI.Controllers.Sc_ProcessMangementController(); + + for (int i = 0; i < BillNoArray.Count; i++) + { + bResult = JsonConvert.SerializeObject(oBill.SaveProcdutInBill(BillNoArray[i].ToString().Trim())); + + //鍙嶅簭鍒楀寲 + bResult = "[" + bResult.ToString() + "]"; + + List<JsonResult> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JsonResult>>(bResult); + + if (list[0].count == 1) + { + HSuccessBillNo = HSuccessBillNo + BillNoArray[i].ToString() + "," + "\r\n"; + } + else + { + HFailBillNo = HFailBillNo + BillNoArray[i].ToString() + ":" + list[0].Message + "," + "\r\n"; + } + HMessage = "鍏ュ簱鎴愬姛鍗曞彿锛�" + HSuccessBillNo + "\r\n" + " 鍏ュ簱澶辫触鍗曞彿锛�" + HFailBillNo; + } + + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = HMessage; + objJsonResult.data = null; + return objJsonResult; + + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + + /// <summary> + /// 鍏ュ簱鈥斺�斾骇鍝佸叆搴撳崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/SaveProcdutInBill")] + [HttpGet] + public object SaveProcdutInBill(string BillNo) + { + try + { + LogService.Write("鐢熶骇鍏ュ簱鍗曡繘鍏ュ悓姝ユ柟娉�:" + " 鍏ュ簱鍗曞彿锛�" + BillNo); + //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + Int64 HInterID = DBUtility.ClsPub.CreateBillID("1202", ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode("1202", ref DBUtility.ClsPub.sExeReturnInfo, true); + ////鑾峰彇缁勭粐浠g爜 + //string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString(); + ////鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁 + //DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc"); + //DataRow dr = ds.Tables[0].Rows[0]; + + //鍒ゆ柇鍏ュ簱鐨勫悎鏍兼暟閲忔槸鍚︿负0 + var DTable = oCN.RunProcReturn("select * from Sc_StationOutBillMain with(nolock) where HBillNo='" + BillNo + "' ", "Sc_StationOutBillMain").Tables[0]; + + if (double.Parse(DTable.Rows[0]["HQty"].ToString()) == 0) + { + LogService.Write("鍚屾閲戣澏鐢熶骇鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氬悎鏍兼暟閲忎负0,涓嶉渶瑕佸叆搴擄紒"); + objJsonResult.code = "1"; + objJsonResult.count = 2; + objJsonResult.Message = "鍚堟牸鏁伴噺涓�0,涓嶉渶瑕佸叆搴擄紒"; + objJsonResult.data = null; + return objJsonResult; + } + + //淇濆瓨 + oCN.BeginTran(); + //鐢熶骇姹囨姤鍗曚富琛� + //oCN.RunProc("Insert Into Sc_ICMOReportBillMain " + + //"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + //",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + + //",HGroupID,HDeptID,HDeptNumber" + + //",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + + //") " + + //" values('3711','3711'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + //",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + + //"','" + dr["HGroupID"].ToString() + "',0,''" + + //",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + + //") "); + ////鐢熶骇姹囨姤鍗曞瓙琛� + //oCN.RunProc("Insert into Sc_ICMOReportBillSub " + + // " (HInterID,HEntryID,HMaterID,HMaterNumber" + + // ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" + + // ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," + + // "HCloseMan,HCloseType,HRemark," + + // "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + + // ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + + // ",HICMOInterID,HICMOBillNo,HBarCode" + + // ") values(" + // + HInterID.ToString() + ",1," + dr["HMaterID"].ToString() + ",'" + dr["浜у搧浠g爜"].ToString() + "'" + + // "," + dr["鍚堟牸鏁伴噺"].ToString() + ",0,'',0,0" + + // "," + dr["鎺ユ敹鏁伴噺"].ToString() + "," + dr["HEmpID"].ToString() + ",'" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + "'," + dr["涓嶈壇鏁伴噺"].ToString() + "," + dr["鎶ュ簾鏁伴噺"].ToString() + + // ",'',0,''" + + // "," + InterID.ToString() + ",0,'" + BillNo.ToString() + "','3791',0,0" + + // ",0,0,''" + + // "," + dr["HICMOInterID"].ToString() + ",'" + dr["浠诲姟鍗�"].ToString() + "',''" + + // ") "); + //鍚屾閲戣澏 + //璁块棶閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + if (isSuccess == 0) + { + LogService.Write("鍚屾閲戣澏鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氭搷浣滃け璐�,閲戣澏璐﹀彿鐧诲綍寮傚父"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + objJsonResult.data = null; + return objJsonResult; + } + // + //DataSet ds1 = oCN.RunProcReturn("select * from h_v_TOERPProcduct_LastProc where HLastProc = '鏄�' and hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc"); + DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc '" + BillNo + "'", "h_p_TOERPProcduct_LastProc"); + + if (ds1 == null || ds1.Tables[0].Rows.Count == 0) + { + LogService.Write("鍚屾閲戣澏鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氭湭鎵惧埌瀵瑰簲鐨勬湰鍦版垨閲戣澏浜戠敓浜ф眹鎶ュ崟璁板綍;1.鏈煡璇㈠埌瀵瑰簲鐨勭敓浜ф眹鎶ュ崟锛�2.璇风‘淇濆綋鍓嶅伐搴忔槸鏈亾宸ュ簭3.姹囨姤鍗曞搴旂殑鍏ュ簱鏁伴噺宸叉弧 璇峰湪閲戣澏浜戞煡鐪嬪叆搴撹褰曪紒"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏈壘鍒板搴旂殑鏈湴鎴栭噾铦朵簯鐢熶骇姹囨姤鍗曡褰�;1.鏈煡璇㈠埌瀵瑰簲鐨勭敓浜ф眹鎶ュ崟锛�2.璇风‘淇濆綋鍓嶅伐搴忔槸鏈亾宸ュ簭3.姹囨姤鍗曞搴旂殑鍏ュ簱鏁伴噺宸叉弧 璇峰湪閲戣澏浜戞煡鐪嬪叆搴撹褰曪紒"; + objJsonResult.data = null; + return objJsonResult; + } + + DataRow dr1 = ds1.Tables[0].Rows[0]; + if (double.Parse(dr1[0].ToString()) <= 0) + { + LogService.Write("鍚屾閲戣澏鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氭湭鎵惧埌瀵瑰簲鐨勭敓浜ф眹鎶ュ崟璁板綍;1.鏈煡璇㈠埌瀵瑰簲鐨勭敓浜ф眹鎶ュ崟锛�2.璇风‘淇濆綋鍓嶅伐搴忔槸鏈亾宸ュ簭3.姹囨姤鍗曞搴旂殑鍏ュ簱鏁伴噺宸叉弧 璇峰湪閲戣澏浜戞煡鐪嬪叆搴撹褰曪紒"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏈壘鍒板搴旂殑鐢熶骇姹囨姤鍗曡褰�;1.鏈煡璇㈠埌瀵瑰簲鐨勭敓浜ф眹鎶ュ崟锛�2.璇风‘淇濆綋鍓嶅伐搴忔槸鏈亾宸ュ簭3.姹囨姤鍗曞搴旂殑鍏ュ簱鏁伴噺宸叉弧 璇峰湪閲戣澏浜戞煡鐪嬪叆搴撹褰曪紒"; + objJsonResult.data = null; + return objJsonResult; + } + + + string sErr = ""; + if (oSystemParameter.ShowBill(ref sErr)) + { + if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�") + { + + //鍒ゆ柇閲戣澏浜戞槸鍚﹀凡缁忔湁鍏ュ簱鐨勬暟鎹� + ds = oCN.RunProcReturn($@"select * from AIS20220308151944..T_PRD_INSTOCK where FBILLNO='{BillNo}'", "T_PRD_INSTOCK"); + + if (ds.Tables[0].Rows.Count > 0) + { + LogService.Write("鍚屾閲戣澏鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氬綋鍓嶅嚭绔欏崟鍙峰凡鍏ュ簱,璇蜂笉瑕侀噸鏂板叆搴�!"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍑虹珯鍗曞彿宸插叆搴�,璇蜂笉瑕侀噸鏂板叆搴�!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍒ゆ柇閲戣澏浜戠敓浜ф眹鎶ュ崟 鏁伴噺 鏄惁 澶т簬 鏈亾鍑虹珯鏁伴噺 + ds = oCN.RunProcReturn($@"select sum(FFinishQty)-sum(FSTOCKINQUASELQTY)-(select HQty from Sc_StationOutBillMain with(nolock) where HBillNo='{BillNo}') + from AIS20220308151944..T_PRD_MORPT rpt3 + left join AIS20220308151944..T_PRD_MORPTENTRY rpt2 on rpt3.FID = rpt2.FID + left join AIS20220308151944..T_PRD_MORPTENTRY_A rpt1 on rpt2.FID = rpt1.FID + where F_bsv_Text=(select HProcExchBillNo from Sc_StationOutBillMain where HBillNo='{BillNo}')", "SumCount"); + + if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0) + { + LogService.Write("鍚屾閲戣澏鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氶噾铦朵簯姹囨姤鏁伴噺灏忎簬鏈湴鍑虹珯鏁伴噺!"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "閲戣澏浜戞眹鎶ユ暟閲忓皬浜庢湰鍦板嚭绔欐暟閲�!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍒ゆ柇鍞竴ID鏄惁涓虹┖ + foreach (DataRow item in ds1.Tables[0].Rows) + { + if (item["HWYID"].ToString() == null || item["HWYID"].ToString() == "" || item["HWYID"].ToString() == "undefined") + { + LogService.Write("鍚屾閲戣澏鐢熶骇鍏ュ簱鍗曞洖婊�--鍑虹珯鍗曞彿锛�" + BillNo + " 鍥炴粴鍘熷洜锛氬敮涓�ID涓虹┖锛岃閲嶆柊鎵嬪姩鍏ュ簱鎴栬仈绯荤鐞嗗憳锛�"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍞竴ID涓虹┖锛岃閲嶆柊鎵嬪姩鍏ュ簱鎴栬仈绯荤鐞嗗憳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + } + + + + + + + JObject model = new JObject(); + model.Add("FBillType", new JObject() { ["FNumber"] = "SCRKD01_SYS" }); //鍗曟嵁绫诲瀷 + model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡 + model.Add("FStockOrgId", new JObject() { ["FNumber"] = dr1["HPrdOrgNumber"].ToString() }); //搴撳瓨缁勭粐浠g爜 + model.Add("FPrdOrgId", new JObject() { ["FNumber"] = dr1["HPrdOrgNumber"].ToString() }); //鐢熶骇缁勭粐浠g爜 + model.Add("FOwnerTypeId0", "BD_OwnerOrg"); + model.Add("FOwnerId0", new JObject() { ["FNumber"] = dr1["HPrdOrgNumber"].ToString() }); // + model.Add("FIsEntrust", "false");// + model.Add("FCurrId", new JObject() { ["FNumber"] = "PRE001" }); // + model.Add("FBillNo", BillNo); + + JArray Fentity = new JArray(); + + foreach (DataRow item in ds1.Tables[0].Rows) + { + JObject FentityModel = new JObject(); + FentityModel.Add("FSrcEntryId", item["HSourceEntryID"].ToString());// 婧愬崟鍒嗗綍鍐呯爜銆� + FentityModel.Add("FIsNew", "false");// 婧愬崟绫诲瀷 + FentityModel.Add("FMaterialId", new JObject() { ["FNumber"] = item["HMaterNumber"].ToString() }); // 鐗╂枡缂栫爜 + FentityModel.Add("FCheckProduct", "false");// + FentityModel.Add("FInStockType", "1");// + FentityModel.Add("FProductType", "1");// + FentityModel.Add("FUNITID", new JObject() { ["FNumber"] = item["HUnitNumber"].ToString() });//鍗曚綅 + FentityModel.Add("FMustQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FCostRate", "100");// + FentityModel.Add("FBaseUnitId", new JObject() { ["FNumber"] = item["HUnitNumber"].ToString() });//鍗曚綅 + FentityModel.Add("FBaseMustQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FBaseRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");// + FentityModel.Add("FOwnerId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });// + + if (oSystemParameter.ShowBill(ref sErr)) + { + if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�") + { + if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ヨ壓璺嚎") + { + FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumbers"].ToString() }); // 浠撳簱 + } + else if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ュ簭") + { + FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumber"].ToString() }); // 浠撳簱 + } + } + } + FentityModel.Add("FLot", new JObject() { ["FNumber"] = item["HBatchNo"].ToString() }); //鎵瑰彿 + FentityModel.Add("FISBACKFLUSH", "true");// + FentityModel.Add("FWorkShopId1", new JObject() { ["FNumber"] = item["HWorkShopNumber"].ToString() }); // 鐢熶骇杞﹂棿 + FentityModel.Add("FMOBILLNO", item["HMOBillNo"].ToString());// + FentityModel.Add("FMoId", item["HICMOInterID"].ToString());//鐢熶骇璁㈠崟鍐呯爜 + FentityModel.Add("FMoEntryId", item["HMOEntryID"].ToString());// + FentityModel.Add("FMoEntrySeq", item["HMOEntrySEQ"].ToString());//鐢熶骇璁㈠崟琛屽彿 + FentityModel.Add("FStockUnitId", new JObject() { ["FNumber"] = item["HUnitNumber"].ToString() });//搴撳瓨鍗曚綅 + FentityModel.Add("FStockRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FSrcBillType", "PRD_MORPT");// + FentityModel.Add("FSrcBillNo", item["HSourceBillNo"].ToString());// + FentityModel.Add("FSrcInterId", item["HSourceInterID"].ToString());// + FentityModel.Add("FBasePrdRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FIsFinished", "false");// + FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT01_SYS" }); // + FentityModel.Add("FSrcEntrySeq", item["HSourceSeQ"].ToString());// 婧愬崟鍒嗗綍琛屽彿 + FentityModel.Add("FMOMAINENTRYID", item["HMOEntryID"].ToString());// + FentityModel.Add("FKeeperTypeId", "BD_KeeperOrg"); + FentityModel.Add("FKeeperId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });// + FentityModel.Add("FIsOverLegalOrg", "false");// + FentityModel.Add("F_bsv_Base1", new JObject() { ["FNumber"] = item["HBZBS"].ToString() });// + FentityModel.Add("F_BSV_TEXT", item["HLZKH"].ToString());// + FentityModel.Add("F_BSV_TEXT1", item["HWYID"].ToString());// + //鎵瑰彿 + //FFLOWID FFLOWLINEID FRULEID FSTABLENAME + //f6e6eec3 - 5267 - 4f02 - 8593 - b633da508a72 3 PRD_MO2MORPT T_PRD_MOENTRY + //涓氬姟娴佺▼鍥撅細FEntity_Link_FFlowId + //鎺ㄨ繘璺嚎锛欶Entity_Link_FFlowLineId + //杞崲瑙勫垯锛欶Entity_Link_FRuleId + //婧愬崟琛ㄥ唴鐮侊細FEntity_Link_FSTableId + //婧愬崟琛細FEntity_Link_FSTableName + //婧愬崟鍐呯爜锛欶Entity_Link_FSBillId + //婧愬崟鍒嗗綍鍐呯爜锛欶Entity_Link_FSId + //鍘熷鎼哄甫閲忥細FEntity_Link_FBaseQuaQtyOld + //淇敼鎼哄甫閲忥細FEntity_Link_FBaseQuaQty + + + + JArray Fentity2 = new JArray(); + JObject FentityModel2 = new JObject(); + FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72"); + FentityModel2.Add("FEntity_Link_FFlowLineId", "5"); + FentityModel2.Add("FEntity_Link_FRuleId", "PRD_MORPT2INSTOCK"); + FentityModel2.Add("FEntity_Link_FSTableName", "T_PRD_MORPTENTRY"); + FentityModel2.Add("FEntity_Link_FSTableId", "0"); + FentityModel2.Add("FEntity_Link_FSBillId", item["HSourceInterID"].ToString()); + FentityModel2.Add("FEntity_Link_FSId", item["HSourceEntryID"].ToString()); + FentityModel2.Add("FEntity_Link_FBasePrdRealQtyOld", item["鍏宠仈鏁伴噺"].ToString()); + FentityModel2.Add("FEntity_Link_FBasePrdRealQty", item["鏁伴噺"].ToString()); + Fentity2.Add(FentityModel2); + FentityModel.Add("FEntity_Link", Fentity2); + FentityModel.Add("FBFLowId", new JObject() { ["FID"] = "f6e6eec3-5267-4f02-8593-b633da508a72" }); // + Fentity.Add(FentityModel); + + + //Fentity.Add(FentityModel); + } + model.Add("FEntity", Fentity); //鏄庣粏淇℃伅 + JObject jsonRoot = new JObject() + { + ["Creator"] = "", + ["NeedUpDateFields"] = new JArray(), + ["NeedReturnFields"] = new JArray(), + //["IsDeleteEntry"] = "true", + //["SubSystemId"] = "", + //["IsVerifyBaseDataField"] = "false", + + + ["IsDeleteEntry"] = "true", + ["SubSystemId"] = "", + ["IsVerifyBaseDataField"] = "true", + ["IsEntryBatchFill"] = "false", + ["ValidateFlag"] = "true", + ["NumberSearch"] = "true", + ["IsAutoAdjustField"] = "false", + ["InterationFlags"] = "", + ["IgnoreInterationFlag"] = "", + + + + + //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + ["Model"] = model + }; + + string result = InvokeHelper.Save("PRD_INSTOCK", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨 + //鍒ゆ柇淇濆瓨鏄惁鎴愬姛 + if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("鐢熶骇鍏ュ簱淇濆瓨閿欒jsonRoot:" + jsonRoot + " 鍏ュ簱鍗曞彿锛�" + BillNo); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鐢熶骇鍏ュ簱鍗曞悓姝ラ噾铦朵簯澶辫触锛佸崟鍙�:{HBillNo.ToString()}" + result + jsonRoot; + objJsonResult.data = null; + return objJsonResult; + } + //鎻愪氦瀹℃牳 + string result1 = string.Empty; + string result2 = string.Empty; + var fID = JObject.Parse(result)["Result"]["Id"].ToString(); + var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); + var json = new + { + Ids = fID, + }; + result1 = InvokeHelper.Submit("PRD_INSTOCK", JsonConvert.SerializeObject(json));//鎻愪氦 + //result2 = InvokeHelper.Audit("PRD_INSTOCK", JsonConvert.SerializeObject(json));//鎻愪氦 + if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("鐢熶骇鍏ュ簱鎻愪氦閿欒jsonRoot:" + jsonRoot + " 鍏ュ簱鍗曞彿锛�" + BillNo); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鐢熶骇鍏ュ簱鍗曞崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where HBillNo='" + BillNo + "'"); + LogService.Write("鐢熶骇鍏ュ簱鍚屾鎴愬姛:" + " 鍏ュ簱鍗曞彿锛�" + BillNo); + oCN.Commit(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write("鐢熶骇鍏ュ簱鍚屾鍙戠敓寮傚父:" + " 鍏ュ簱鍗曞彿锛�" + BillNo + " " + e.ToString()); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + + /// <summary> + /// 鍏ュ簱鈥斺�斾骇鍝佸叆搴撳崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/SaveBFBill")] + [HttpGet] + public object SaveBFBill(string BillNo) + { + try + { + //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + Int64 HInterID = DBUtility.ClsPub.CreateBillID("1202", ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode("1202", ref DBUtility.ClsPub.sExeReturnInfo, true); + ////鑾峰彇缁勭粐浠g爜 + //string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString(); + ////鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁 + //DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc"); + //DataRow dr = ds.Tables[0].Rows[0]; + + //鍒ゆ柇鏈鎶ュ簾鎬绘暟閲忔槸鍚︿负0 + var DTable = oCN.RunProcReturn("select isnull(sum(HWasterQty),0) HWasterQty from Sc_StationOutBillMain where HProcExchBillNo='" + BillNo + "' and HBFFlag=0 ", "Sc_StationOutBillMain").Tables[0]; + + if (double.Parse(DTable.Rows[0]["HWasterQty"].ToString()) == 0) + { + objJsonResult.code = "1"; + objJsonResult.count = 2; + objJsonResult.Message = "鎶ュ簾鏁伴噺涓�0,涓嶉渶瑕佸叆搴擄紒"; + objJsonResult.data = null; + return objJsonResult; + } + + + //淇濆瓨 + oCN.BeginTran(); + //鐢熶骇姹囨姤鍗曚富琛� + //oCN.RunProc("Insert Into Sc_ICMOReportBillMain " + + //"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + //",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + + //",HGroupID,HDeptID,HDeptNumber" + + //",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + + //") " + + //" values('3711','3711'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + //",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + + //"','" + dr["HGroupID"].ToString() + "',0,''" + + //",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + + //") "); + ////鐢熶骇姹囨姤鍗曞瓙琛� + //oCN.RunProc("Insert into Sc_ICMOReportBillSub " + + // " (HInterID,HEntryID,HMaterID,HMaterNumber" + + // ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" + + // ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," + + // "HCloseMan,HCloseType,HRemark," + + // "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + + // ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + + // ",HICMOInterID,HICMOBillNo,HBarCode" + + // ") values(" + // + HInterID.ToString() + ",1," + dr["HMaterID"].ToString() + ",'" + dr["浜у搧浠g爜"].ToString() + "'" + + // "," + dr["鍚堟牸鏁伴噺"].ToString() + ",0,'',0,0" + + // "," + dr["鎺ユ敹鏁伴噺"].ToString() + "," + dr["HEmpID"].ToString() + ",'" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + "'," + dr["涓嶈壇鏁伴噺"].ToString() + "," + dr["鎶ュ簾鏁伴噺"].ToString() + + // ",'',0,''" + + // "," + InterID.ToString() + ",0,'" + BillNo.ToString() + "','3791',0,0" + + // ",0,0,''" + + // "," + dr["HICMOInterID"].ToString() + ",'" + dr["浠诲姟鍗�"].ToString() + "',''" + + // ") "); + //鍚屾閲戣澏 + //璁块棶閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + if (isSuccess == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + objJsonResult.data = null; + return objJsonResult; + } + // + //DataSet ds1 = oCN.RunProcReturn("select * from h_v_TOERPProcduct_LastProc where HLastProc = '鏄�' and hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc"); + DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc_BF '" + BillNo + "'", "h_p_TOERPProcduct_LastProc_BF"); + if (ds1.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,鏌ヤ笉鍒板搴旂殑鍑虹珯鍗曟嵁!"; + objJsonResult.data = null; + return objJsonResult; + } + DataRow dr1 = ds1.Tables[0].Rows[0]; + + JObject model = new JObject(); + model.Add("FBillType", new JObject() { ["FNumber"] = "SCRKD01_SYS" }); //鍗曟嵁绫诲瀷 + model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡 + model.Add("FStockOrgId", new JObject() { ["FNumber"] = dr1["HPrdOrgNumber"].ToString() }); //搴撳瓨缁勭粐浠g爜 + model.Add("FPrdOrgId", new JObject() { ["FNumber"] = dr1["HPrdOrgNumber"].ToString() }); //鐢熶骇缁勭粐浠g爜 + model.Add("FOwnerTypeId0", "BD_OwnerOrg"); + model.Add("FOwnerId0", new JObject() { ["FNumber"] = dr1["HPrdOrgNumber"].ToString() }); // + model.Add("FIsEntrust", "false");// + model.Add("FCurrId", new JObject() { ["FNumber"] = "PRE001" }); // + model.Add("FBillNo", HBillNo); + + JArray Fentity = new JArray(); + + foreach (DataRow item in ds1.Tables[0].Rows) + { + JObject FentityModel = new JObject(); + FentityModel.Add("FSrcEntryId", item["HSourceEntryID"].ToString());// 婧愬崟鍒嗗綍鍐呯爜銆� + FentityModel.Add("FIsNew", "false");// 婧愬崟绫诲瀷 + FentityModel.Add("FMaterialId", new JObject() { ["FNumber"] = item["HMaterNumber"].ToString() }); // 鐗╂枡缂栫爜 + FentityModel.Add("FCheckProduct", "false");// + FentityModel.Add("FInStockType", "1");// + FentityModel.Add("FProductType", "1");// + FentityModel.Add("FUNITID", new JObject() { ["FNumber"] = item["HUnitNumber"].ToString() });//鍗曚綅 + FentityModel.Add("FMustQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FCostRate", "100");// + FentityModel.Add("FBaseUnitId", new JObject() { ["FNumber"] = item["HUnitNumber"].ToString() });//鍗曚綅 + FentityModel.Add("FBaseMustQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FBaseRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");// + FentityModel.Add("FOwnerId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });// + string sErr = ""; + if (oSystemParameter.ShowBill(ref sErr)) + { + if (oSystemParameter.omodel.WMS_CampanyName == "鐟炰笌绁�") + { + if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ヨ壓璺嚎") + { + FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumbers"].ToString() }); // 浠撳簱 + } + else if (oSystemParameter.omodel.MES_StationOutBill_InStockType == "宸ュ簭") + { + FentityModel.Add("FStockId", new JObject() { ["FNumber"] = item["HStockNumber"].ToString() }); // 浠撳簱 + } + } + } + FentityModel.Add("FLot", new JObject() { ["FNumber"] = item["HBatchNo"].ToString() }); //鎵瑰彿 + FentityModel.Add("FISBACKFLUSH", "true");// + FentityModel.Add("FWorkShopId1", new JObject() { ["FNumber"] = item["HWorkShopNumber"].ToString() }); // 鐢熶骇杞﹂棿 + FentityModel.Add("FMOBILLNO", item["HMOBillNo"].ToString());// + FentityModel.Add("FMoId", item["HICMOInterID"].ToString());//鐢熶骇璁㈠崟鍐呯爜 + FentityModel.Add("FMoEntryId", item["HMOEntryID"].ToString());// + FentityModel.Add("FMoEntrySeq", item["HMOEntrySEQ"].ToString());//鐢熶骇璁㈠崟琛屽彿 + FentityModel.Add("FStockUnitId", new JObject() { ["FNumber"] = item["HUnitNumber"].ToString() });//搴撳瓨鍗曚綅 + FentityModel.Add("FStockRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FSrcBillType", "PRD_MORPT");// + FentityModel.Add("FSrcBillNo", item["HSourceBillNo"].ToString());// + FentityModel.Add("FSrcInterId", item["HSourceInterID"].ToString());// + FentityModel.Add("FBasePrdRealQty", item["鏁伴噺"].ToString());// + FentityModel.Add("FIsFinished", "false");// + FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT001" }); // + FentityModel.Add("FSrcEntrySeq", item["HSourceSeQ"].ToString());// 婧愬崟鍒嗗綍琛屽彿 + FentityModel.Add("FMOMAINENTRYID", item["HMOEntryID"].ToString());// + FentityModel.Add("FKeeperTypeId", "BD_KeeperOrg"); + FentityModel.Add("FKeeperId", new JObject() { ["FNumber"] = item["HPrdOrgNumber"].ToString() });// + FentityModel.Add("FIsOverLegalOrg", "false");// + FentityModel.Add("F_bsv_Base1", new JObject() { ["FNumber"] = item["HBZBS"].ToString() });// + FentityModel.Add("F_BSV_TEXT", item["HLZKH"].ToString());// + FentityModel.Add("F_BSV_TEXT1", item["HWYID"].ToString());// + //鎵瑰彿 + //FFLOWID FFLOWLINEID FRULEID FSTABLENAME + //f6e6eec3 - 5267 - 4f02 - 8593 - b633da508a72 3 PRD_MO2MORPT T_PRD_MOENTRY + //涓氬姟娴佺▼鍥撅細FEntity_Link_FFlowId + //鎺ㄨ繘璺嚎锛欶Entity_Link_FFlowLineId + //杞崲瑙勫垯锛欶Entity_Link_FRuleId + //婧愬崟琛ㄥ唴鐮侊細FEntity_Link_FSTableId + //婧愬崟琛細FEntity_Link_FSTableName + //婧愬崟鍐呯爜锛欶Entity_Link_FSBillId + //婧愬崟鍒嗗綍鍐呯爜锛欶Entity_Link_FSId + //鍘熷鎼哄甫閲忥細FEntity_Link_FBaseQuaQtyOld + //淇敼鎼哄甫閲忥細FEntity_Link_FBaseQuaQty + + + + JArray Fentity2 = new JArray(); + JObject FentityModel2 = new JObject(); + FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72"); + FentityModel2.Add("FEntity_Link_FFlowLineId", "5"); + FentityModel2.Add("FEntity_Link_FRuleId", "PRD_MORPT2INSTOCK"); + FentityModel2.Add("FEntity_Link_FSTableName", "T_PRD_MORPTENTRY"); + FentityModel2.Add("FEntity_Link_FSTableId", "0"); + FentityModel2.Add("FEntity_Link_FSBillId", item["HSourceInterID"].ToString()); + FentityModel2.Add("FEntity_Link_FSId", item["HSourceEntryID"].ToString()); + FentityModel2.Add("FEntity_Link_FBasePrdRealQtyOld", item["鍏宠仈鏁伴噺"].ToString()); + FentityModel2.Add("FEntity_Link_FBasePrdRealQty", item["鏁伴噺"].ToString()); + Fentity2.Add(FentityModel2); + FentityModel.Add("FEntity_Link", Fentity2); + FentityModel.Add("FBFLowId", new JObject() { ["FID"] = "f6e6eec3-5267-4f02-8593-b633da508a72" }); // + Fentity.Add(FentityModel); + + + //Fentity.Add(FentityModel); + } + model.Add("FEntity", Fentity); //鏄庣粏淇℃伅 + JObject jsonRoot = new JObject() + { + ["Creator"] = "", + ["NeedUpDateFields"] = new JArray(), + ["NeedReturnFields"] = new JArray(), + //["IsDeleteEntry"] = "true", + //["SubSystemId"] = "", + //["IsVerifyBaseDataField"] = "false", + + + ["IsDeleteEntry"] = "true", + ["SubSystemId"] = "", + ["IsVerifyBaseDataField"] = "true", + ["IsEntryBatchFill"] = "false", + ["ValidateFlag"] = "true", + ["NumberSearch"] = "true", + ["IsAutoAdjustField"] = "false", + ["InterationFlags"] = "", + ["IgnoreInterationFlag"] = "", + + + + + //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + ["Model"] = model + }; + + string result = InvokeHelper.Save("PRD_INSTOCK", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨 + //鍒ゆ柇淇濆瓨鏄惁鎴愬姛 + if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("鐢熶骇鍏ュ簱閿欒jsonRoot:" + jsonRoot); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鐢熶骇鍏ュ簱鍗曞悓姝ラ噾铦朵簯澶辫触锛佸崟鍙�:{HBillNo.ToString()}" + result + jsonRoot; + objJsonResult.data = null; + return objJsonResult; + } + //鎻愪氦瀹℃牳 + string result1 = string.Empty; + string result2 = string.Empty; + var fID = JObject.Parse(result)["Result"]["Id"].ToString(); + var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); + var json = new + { + Ids = fID, + }; + result1 = InvokeHelper.Submit("PRD_INSTOCK", JsonConvert.SerializeObject(json));//鎻愪氦 + //result2 = InvokeHelper.Audit("PRD_INSTOCK", JsonConvert.SerializeObject(json));//鎻愪氦 + if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鐢熶骇鍏ュ簱鍗曞崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result; + objJsonResult.data = null; + return objJsonResult; + } + + //oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where HBillNo='" + BillNo + "'"); + + oCN.Commit(); + oCN.RunProc("update sc_stationoutbillmain set HBFFlag =1 where HProcExchBillNo = '" + BillNo + "'"); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + + /// <summary> + /// 鐢熸垚閲戣澏浜戞潵鏂欐楠屽崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("QCStockInCheckBill/set_SaveQCStockInCheckBill_Json")] + [HttpGet] + public object set_SaveQCStockInCheckBill_Json(string HZJOrgNumber, string HMaterNumber, string HUnitNumber, + double HCheckQty, double HRightQty, double HBadQty, + string HCheckResult, string HSupNumber, + string HUseResult, Int64 HSeQ, Int64 HSourceInterID, + Int64 HSourceEntryID, string HSourceBillNo, string user, + Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID, + Int64 HMaterID, string HSourceBillType, Int64 HSLInterID, + Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID, string HBatchNo) + { + try + { + //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + //Int64 HInterID = DBUtility.ClsPub.CreateBillID("7503", ref DBUtility.ClsPub.sExeReturnInfo); + //string HBillNo = DBUtility.ClsPub.CreateBillCode("7503", ref DBUtility.ClsPub.sExeReturnInfo, true); + + DataSet ds1 = oCN.RunProcReturn("select * from MES_AccessoriesList where HSourceBillNo = '" + HBillNo + "'", "MES_AccessoriesList"); + string HFileName = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFileName"]); + string HFilePath = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFilePath"]); + + string path = HFilePath; + FileInfo fi = new FileInfo(path); + long len = fi.Length; + byte[] buffer = new byte[len]; + FileStream fs = new FileStream(path, FileMode.Open); + fs.Read(buffer, 0, (int)len); + //鏂囦欢IO娴� + string a = Convert.ToBase64String(buffer); + + + //淇濆瓨 + oCN.BeginTran(); + //鐢熶骇姹囨姤鍗曚富琛� + oCN.RunProc("Insert Into QC_POStockInCheckBillMain " + + "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + ",HYear,HPeriod,HRemark,HSupID,HMaterID" + + ",HInstockQty,HCheckQty,HRightQty,HBadQty,HFirstCheckEmp" + + ",HCheckerResult,HSteelStoveNo,HSteelCompReport,HAspect,HSize" + + ") " + + " values('7503','7503'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + ",DATENAME(YEAR,GETDATE()),0,''," + HSupID.ToString() + "," + HMaterID.ToString() + + ",'" + HCheckQty.ToString() + "','" + HCheckQty.ToString() + "','" + HRightQty.ToString() + "','" + HBadQty.ToString() + "','" + HKeeperID.ToString() + "'" + + ",'" + HCheckResult.ToString() + "','', '','',''" + + ") "); + //鐢熶骇姹囨姤鍗曞瓙琛� + oCN.RunProc("Insert into QC_POStockInCheckBillSub " + + " (HInterID,HEntryID,HCloseMan,HCloseType" + + ",HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" + + ",HRelationQty,HRelationMoney,HQCCheckClassID,HQCCheckItemID,HQCStd," + + "HResult,HQCRelValue,HProcCheckEmp,HProcCheckTime" + + ") values(" + + HInterID.ToString() + ",1,'',''" + + ",''," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','" + HSourceBillType.ToString() + "'" + + ",0,0,0,0,''" + + ",'" + HCheckResult.ToString() + "','" + HCheckResult.ToString() + "','" + HKeeperID.ToString() + "',getdate()" + + ") "); + //鍚屾閲戣澏 + //璁块棶閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + if (isSuccess == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + objJsonResult.data = null; + return objJsonResult; + } + + + JObject model = new JObject(); + model.Add("FBillTypeID", new JObject() { ["Fnumber"] = "JYD001_SYS" }); //鍗曟嵁绫诲瀷 鏉ユ枡妫�楠屽崟JYD001_SYS + model.Add("FBusinessType", "1"); //涓氬姟绫诲瀷 + model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡 + model.Add("FInspectOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //璐ㄦ缁勭粐 + model.Add("FSourceOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //鏉ユ簮缁勭粐 + model.Add("FISSYNCED", "false");// 鏄惁宸插悓姝� + model.Add("F_PGKJ_Date", DateTime.Now.ToString("yyyy-MM-dd"));// 鎶ユ鏃ユ湡 + model.Add("FBillNo", HBillNo); + + JArray Fentity = new JArray(); + JObject FentityModel = new JObject(); + FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });// 鐗╂枡鍐呯爜 + FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//璁¢噺鍗曚綅鍐呯爜 + FentityModel.Add("FInspectQty", HCheckQty.ToString());// 妫�楠屾暟閲� + FentityModel.Add("FQualifiedQty", HRightQty.ToString());// 鍚堟牸鏁伴噺 + FentityModel.Add("FUnqualifiedQty", HBadQty.ToString());// 涓嶅悎鏍兼暟閲� + FentityModel.Add("FInspectResult", HCheckResult.ToString());// 妫�楠岀粨鏋� + FentityModel.Add("FQCStatus", "1");// 璐ㄦ鐘舵�� + FentityModel.Add("FIsRelated", false);// 涓嶈壇鍝佸叧鑱旀爣蹇� + FentityModel.Add("FSrcBillType0", "PUR_ReceiveBill");// 婧愬崟绫诲瀷 + FentityModel.Add("FBaseUnitId", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//鍩烘湰鍗曚綅 + FentityModel.Add("FBaseInspectQty", HCheckQty.ToString());//鍩烘湰鍗曚綅妫�楠屾暟閲� + FentityModel.Add("FSupplierId", new JObject() { ["Fnumber"] = HSupNumber.ToString() }); // 渚涘簲鍟� + //FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = HWHNumber.ToString() }); // 浠撳簱 + FentityModel.Add("FInspectTimes", "1"); // 妫�楠屾鏁� + FentityModel.Add("FTimeUnit", "24");//鏃堕棿鍗曚綅 + FentityModel.Add("FSAMPLEDAMAGEBEARER", "2");//鏍锋湰鐮村潖鎵挎媴鏂� + FentityModel.Add("FISFIRSTINSPECT", false);//棣栨 + FentityModel.Add("FBaseQualifiedQty", HRightQty.ToString());//鍩烘湰鍗曚綅鍚堟牸鏁� + FentityModel.Add("FBaseAcceptQty", HRightQty.ToString());//鍩烘湰鍗曚綅鎺ユ敹鏁� + FentityModel.Add("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//甯佸埆 + FentityModel.Add("FIsSplitRow ", false);// 鏄惁鎷嗗垎琛� + FentityModel.Add("FLot", new JObject() { ["Fnumber"] = HBatchNo.ToString() });//鎵瑰彿 + + JArray Fentity2 = new JArray(); + JObject FentityModel2 = new JObject(); + FentityModel2.Add("FPolicyMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });// 鐗╂枡鍐呯爜 + FentityModel2.Add("FPolicyStatus", "1"); //鐘舵�� + FentityModel2.Add("FPolicyQty", HRightQty.ToString()); //鏁伴噺 + FentityModel2.Add("FBasePolicyQty", HRightQty.ToString()); //鍩烘湰鍗曚綅鏁伴噺 + FentityModel2.Add("FUsePolicy", HUseResult.ToString()); //浣跨敤鍐崇瓥 + FentityModel2.Add("FIsCheck", false); //鏄惁鎶芥 + FentityModel2.Add("FIsDefectProcess", false); //涓嶈壇澶勭悊 + FentityModel2.Add("FCanSale", false); //鍙攢鍞� + FentityModel2.Add("FIsMRBReview", false); //MRP璇勫 + FentityModel2.Add("FIsReturn", true); //鍒ら�� + FentityModel2.Add("FIsRelatedDefect", false); //涓嶈壇鍝佸叧鑱旀爣蹇� + Fentity2.Add(FentityModel2); + FentityModel.Add("FPolicyDetail", Fentity2); + + + + JArray Fentity3 = new JArray(); + JObject FentityModel3 = new JObject(); + FentityModel3.Add("FDetailID", "0");// + FentityModel3.Add("FSrcBillType", "PUR_ReceiveBill"); //婧愬崟绫诲瀷 + FentityModel3.Add("FSrcBillNo", HSLBillNo.ToString()); //鏀舵枡閫氱煡鍗曞崟鍙� + FentityModel3.Add("FSrcInterId", HSLInterID.ToString()); //鏀舵枡閫氱煡鍗曚富ID + FentityModel3.Add("FSrcEntryId", HSLEntryID.ToString()); //鏀舵枡閫氱煡鍗曞瓙ID + FentityModel3.Add("FSrcEntrySeq", HSLSeQ.ToString()); //婧愬崟琛屽彿 + FentityModel3.Add("FOrderType", new JObject() { ["FID"] = "PUR_PurchaseOrder" }); // 璁㈠崟绫诲瀷 + FentityModel3.Add("FOrderBillNo", HSourceBillNo.ToString()); //璁㈠崟鍗曞彿 + FentityModel3.Add("FOrderId", HSourceInterID.ToString()); //璁㈠崟涓籌D + FentityModel3.Add("FOrderEntryId", HSourceEntryID.ToString()); //璁㈠崟瀛怚D + FentityModel3.Add("FOrderEntrySeq", HSeQ.ToString()); //璁㈠崟琛屽彿 + Fentity3.Add(FentityModel3); + FentityModel.Add("FReferDetail", Fentity3); + + + JArray Fentity4 = new JArray(); + JObject FentityModel4 = new JObject(); + FentityModel4.Add("FEntity_Link_FRuleId", "QM_PURReceive2Inspect"); //鍗曟嵁杞崲瑙勫垯 + FentityModel4.Add("FEntity_Link_FSTableName", "T_PUR_RECEIVEENTRY"); //鏀舵枡閫氱煡鍗曞瓙琛� + FentityModel4.Add("FEntity_Link_FSBillId", HSLInterID.ToString()); //鏀舵枡閫氱煡鍗曚富鍐呯爜 + FentityModel4.Add("FEntity_Link_FSId", HSLEntryID.ToString()); //鏀舵枡閫氱煡鍗曞瓙鍐呯爜 + FentityModel4.Add("FEntity_Link_FBaseAcceptQty", HRightQty.ToString()); // + FentityModel4.Add("FEntity_Link_FBaseAcceptQtyOld", HRightQty.ToString()); // + FentityModel4.Add("FEntity_Link_FBaseInspectQtyOld", HRightQty.ToString()); // + FentityModel4.Add("FEntity_Link_FInspectQtyOld", HRightQty.ToString()); // + Fentity4.Add(FentityModel4); + FentityModel.Add("FEntity_Link", Fentity4); + + + + Fentity.Add(FentityModel); + model.Add("FEntity", Fentity); //鏄庣粏淇℃伅 + JObject jsonRoot = new JObject() + { + ["Creator"] = "", + ["NeedUpDateFields"] = new JArray(), + ["NeedReturnFields"] = new JArray(), + ["IsDeleteEntry"] = "false", + ["SubSystemId"] = "", + ["IsVerifyBaseDataField"] = "false", + //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + ["Model"] = model + }; + + string result = InvokeHelper.Save("QM_InspectBill", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨 + //鍒ゆ柇淇濆瓨鏄惁鎴愬姛 + if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("鏉ユ枡妫�楠屽崟淇濆瓨閿欒jsonRoot:" + jsonRoot); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍚屾閲戣澏浜戝け璐ワ紒鍗曞彿:{HBillNo.ToString()}" + jsonRoot; + objJsonResult.data = null; + return objJsonResult; + } + //鎻愪氦瀹℃牳 + string result1 = string.Empty; + string result2 = string.Empty; + var fID = JObject.Parse(result)["Result"]["Id"].ToString(); + var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); + var json = new + { + Ids = fID, + }; + + K3CloudApiClient client = new K3CloudApiClient("http://47.96.97.237/k3cloud"); + // K3CloudApiClient client = new K3CloudApiClient("http://192.168.80.90/k3cloud/"); + + + + result1 = InvokeHelper.Submit("QM_InspectBill", JsonConvert.SerializeObject(json));//鎻愪氦 + result2 = InvokeHelper.Audit("QM_InspectBill", JsonConvert.SerializeObject(json));//鎻愪氦 + if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result; + objJsonResult.data = null; + return objJsonResult; + } + else + { + string jsonStr = "{" + + " \"FileName\":\"" + HFileName + "\"," + + " \"FormId\":\"QM_InspectBill\"," + + " \"IsLast\":\"true\"," + + " \"InterId\":\"" + HInterID + "\"," + + " \"BillNO\":\"" + HBillNo + "\"," + + " \"AliasFileName\":\"test\"," + + " \"SendByte\":\"" + a + "\"," + + "}"; + + var ret = client.AttachmentUpload(jsonStr); + } + + oCN.Commit(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + + + + + + ///// <summary> + ///// 鐢熸垚閲戣澏浜戞潵鏂欐楠屽崟 + ///// </summary> + ///// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + ///// <returns></returns> + //[Route("QCStockInCheckBill/set_SaveQCStockInCheckBill_Json")] + //[HttpGet] + //public object set_SaveQCStockInCheckBill_Json(string HZJOrgNumber, string HMaterNumber, string HUnitNumber, + // double HCheckQty, double HRightQty, double HBadQty, + // string HCheckResult, string HSupNumber, + // string HUseResult, Int64 HSeQ, Int64 HSourceInterID, + // Int64 HSourceEntryID, string HSourceBillNo, string user, + // Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID, + // Int64 HMaterID, string HSourceBillType, Int64 HSLInterID, + // Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID,ref string sErrMsg) + //{ + // WebS.WebService1 oWebs1 = new WebS.WebService1(); + + + // //oWebs1.Url = "http://localhost:9099/WebService1.asmx"; + // //K3CloudApiClient client = new K3CloudApiClient("http://192.168.80.90/k3cloud/"); + // if (oWebs1.set_SaveQcStockInCheckBill_New(HZJOrgNumber, HMaterNumber, HUnitNumber, HCheckQty, HRightQty, HBadQty + // , HCheckResult, HSupNumber, HUseResult, HSeQ, HSourceInterID + // , HSourceEntryID, HSourceBillNo, user, HWHID, HSPID + // , HSupID, HKeeperID, HMaterID, HSourceBillType, HSLInterID + // , HSLEntryID, HSLBillNo, HSLSeQ, HBillNo, HInterID + // , ref sErrMsg)) + // { + // objJsonResult.code = "0"; + // objJsonResult.count = 1; + // objJsonResult.Message = "鐢熸垚鍗曟嵁鎴愬姛锛�"; + // objJsonResult.data = null; + // return objJsonResult; + // } + // else + // { + // objJsonResult.code = "0"; + // objJsonResult.count = 0; + // objJsonResult.Message = "鐢熸垚鍗曟嵁澶辫触锛�"; + // objJsonResult.data = sErrMsg; + // return objJsonResult; + // } + //} + + + + + + + + /// <summary> + /// 鐢熸垚閲戣澏浜戜骇鍝佹楠屽崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("SCStockInCheckBill/set_SaveSCStockInCheckBill_Json")] + [HttpGet] + public object set_SaveSCStockInCheckBill_Json(string HZJOrgNumber, string HMaterNumber, string HUnitNumber, + double HCheckQty, double HRightQty, double HBadQty, + string HCheckResult, string HSupNumber, string HWHNumber, + string HUseResult, Int64 HSeQ, Int64 HSourceInterID, + Int64 HSourceEntryID, string HSourceBillNo, string user, + Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID, + Int64 HMaterID, string HSourceBillType, Int64 HSLInterID, + Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ) + { + try + { + //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + Int64 HInterID = DBUtility.ClsPub.CreateBillID("7501", ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode("7501", ref DBUtility.ClsPub.sExeReturnInfo, true); + + //淇濆瓨 + //oCN.BeginTran(); + //鐢熸垚浜у搧妫�楠屽崟 + //oCN.RunProc("Insert Into QC_POStockInCheckBillMain " + + //"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + //",HYear,HPeriod,HRemark,HSupID,HMaterID" + + //",HInstockQty,HCheckQty,HRightQty,HBadQty,HFirstCheckEmp" + + //",HCheckerResult,HSteelStoveNo,HSteelCompReport,HAspect,HSize" + + //") " + + //" values('7503','7503'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + //",DATENAME(YEAR,GETDATE()),0,''," + HSupID.ToString() + "," + HMaterID.ToString() + + //",'" + HCheckQty.ToString() + "','" + HCheckQty.ToString() + "','" + HRightQty.ToString() + "','" + HBadQty.ToString() + "','" + HKeeperID.ToString() + "'" + + //",'" + HCheckResult.ToString() + "','', '','',''" + + //") "); + ////鐢熶骇姹囨姤鍗曞瓙琛� + //oCN.RunProc("Insert into QC_POStockInCheckBillSub " + + // " (HInterID,HEntryID,HCloseMan,HCloseType" + + // ",HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" + + // ",HRelationQty,HRelationMoney,HQCCheckClassID,HQCCheckItemID,HQCStd," + + // "HResult,HQCRelValue,HProcCheckEmp,HProcCheckTime" + + // ") values(" + // + HInterID.ToString() + ",1,'',''" + + // ",''," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','" + HSourceBillType.ToString() + "'" + + // ",0,0,0,0,''" + + // ",'" + HCheckResult.ToString() + "','" + HCheckResult.ToString() + "','" + HKeeperID.ToString() + "',getdate()" + + // ") "); + //鍚屾閲戣澏 + //璁块棶閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + if (isSuccess == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + objJsonResult.data = null; + return objJsonResult; + } + + + JObject model = new JObject(); + model.Add("FBillTypeID", new JObject() { ["Fnumber"] = "JYD002_SYS" }); //鍗曟嵁绫诲瀷 浜у搧妫�楠屽崟JYD002_SYS + model.Add("FBusinessType", "3"); //涓氬姟绫诲瀷 + model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡 + model.Add("FSourceOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //鏉ユ簮缁勭粐 + model.Add("FInspectOrgId", new JObject() { ["Fnumber"] = HZJOrgNumber.ToString() }); //璐ㄦ缁勭粐 + model.Add("FISSYNCED", "false");// 鏄惁宸插悓姝� + model.Add("FBillNo", HBillNo); + + JArray Fentity = new JArray(); + JObject FentityModel = new JObject(); + FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });// 鐗╂枡鍐呯爜 + FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//璁¢噺鍗曚綅鍐呯爜 + FentityModel.Add("FInspectQty", HCheckQty.ToString());// 妫�楠屾暟閲� + FentityModel.Add("FQualifiedQty", HRightQty.ToString());// 鍚堟牸鏁伴噺 + FentityModel.Add("FUnqualifiedQty", HBadQty.ToString());// 涓嶅悎鏍兼暟閲� + FentityModel.Add("FInspectResult", HCheckResult.ToString());// 妫�楠岀粨鏋� + FentityModel.Add("FQCStatus", "1");// 璐ㄦ鐘舵�� + FentityModel.Add("FIsRelated", false);// 涓嶈壇鍝佸叧鑱旀爣蹇� + FentityModel.Add("FSrcBillType0", "SFC_OperationReport");// 婧愬崟绫诲瀷 + FentityModel.Add("FBaseUnitId", new JObject() { ["Fnumber"] = HUnitNumber.ToString() });//鍩烘湰鍗曚綅 + FentityModel.Add("FBaseInspectQty", HCheckQty.ToString());//鍩烘湰鍗曚綅妫�楠屾暟閲� + //FentityModel.Add("FSupplierId", new JObject() { ["Fnumber"] = HSupNumber.ToString() }); // 渚涘簲鍟� + //FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = HWHNumber.ToString() }); // 浠撳簱 + FentityModel.Add("FInspectTimes", "1"); // 妫�楠屾鏁� + FentityModel.Add("FTimeUnit", "24");//鏃堕棿鍗曚綅 + FentityModel.Add("FSAMPLEDAMAGEBEARER", "2");//鏍锋湰鐮村潖鎵挎媴鏂� + FentityModel.Add("FISFIRSTINSPECT", false);//棣栨 + FentityModel.Add("FBaseQualifiedQty", HRightQty.ToString());//鍩烘湰鍗曚綅鍚堟牸鏁� + FentityModel.Add("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//甯佸埆 + FentityModel.Add("FIsSplitRow ", false);// 鏄惁鎷嗗垎琛� + + JArray Fentity2 = new JArray(); + JObject FentityModel2 = new JObject(); + FentityModel2.Add("FPolicyMaterialId", new JObject() { ["Fnumber"] = HMaterNumber.ToString() });// 鐗╂枡鍐呯爜 + FentityModel2.Add("FPolicyStatus", "1"); //鐘舵�� + FentityModel2.Add("FPolicyQty", HRightQty.ToString()); //鏁伴噺 + FentityModel2.Add("FBasePolicyQty", HRightQty.ToString()); //鍩烘湰鍗曚綅鏁伴噺 + FentityModel2.Add("FUsePolicy", HUseResult.ToString()); //浣跨敤鍐崇瓥 + FentityModel2.Add("FIsCheck", false); //鏄惁鎶芥 + FentityModel2.Add("FIsDefectProcess", false); //涓嶈壇澶勭悊 + FentityModel2.Add("FCanSale", false); //鍙攢鍞� + FentityModel2.Add("FIsMRBReview", false); //MRP璇勫 + FentityModel2.Add("FIsReturn", true); //鍒ら�� + FentityModel2.Add("FIsRelatedDefect", false); //涓嶈壇鍝佸叧鑱旀爣蹇� + Fentity2.Add(FentityModel2); + FentityModel.Add("FPolicyDetail", Fentity2); + + + + JArray Fentity3 = new JArray(); + JObject FentityModel3 = new JObject(); + FentityModel3.Add("FDetailID", "0");// + FentityModel3.Add("FSrcBillType", "SFC_OperationReport"); //婧愬崟绫诲瀷 + FentityModel3.Add("FSrcBillNo", HSLBillNo.ToString()); //宸ュ簭姹囨姤鍗曞崟鍙� + FentityModel3.Add("FSrcInterId", HSLInterID.ToString()); //宸ュ簭姹囨姤鍗曚富ID + FentityModel3.Add("FSrcEntryId", HSLEntryID.ToString()); //宸ュ簭姹囨姤鍗曞瓙ID + FentityModel3.Add("FSrcEntrySeq", HSLSeQ.ToString()); //宸ュ簭姹囨姤鍗曡鍙� + FentityModel3.Add("FOrderType", new JObject() { ["FID"] = "PRD_MO" }); // 鐢熶骇璁㈠崟绫诲瀷 + FentityModel3.Add("FOrderBillNo", HSourceBillNo.ToString()); //鐢熶骇璁㈠崟鍗曞彿 + FentityModel3.Add("FOrderId", HSourceInterID.ToString()); //鐢熶骇璁㈠崟涓籌D + FentityModel3.Add("FOrderEntryId", HSourceEntryID.ToString()); //鐢熶骇璁㈠崟瀛怚D + FentityModel3.Add("FOrderEntrySeq", HSeQ.ToString()); //鐢熶骇璁㈠崟琛屽彿 + Fentity3.Add(FentityModel3); + FentityModel.Add("FReferDetail", Fentity3); + + + JArray Fentity4 = new JArray(); + JObject FentityModel4 = new JObject(); + FentityModel4.Add("FEntity_Link_FRuleId", "QM_OperRpt2Inspect"); //鍗曟嵁杞崲瑙勫垯 + FentityModel4.Add("FEntity_Link_FSTableName", "T_SFC_OPTRPTENTRY"); //宸ュ簭姹囨姤鍗曞瓙琛� + FentityModel4.Add("FEntity_Link_FSBillId", HSLInterID.ToString()); //宸ュ簭姹囨姤鍗曚富ID + FentityModel4.Add("FEntity_Link_FSId", HSLEntryID.ToString()); //宸ュ簭姹囨姤鍗曞瓙ID + FentityModel4.Add("FEntity_Link_FBaseAcceptQty", HRightQty.ToString()); // + FentityModel4.Add("FEntity_Link_FBaseAcceptQtyOld", HRightQty.ToString()); // + FentityModel4.Add("FEntity_Link_FBaseInspectQtyOld", HRightQty.ToString()); // + FentityModel4.Add("FEntity_Link_FInspectQtyOld", HRightQty.ToString()); // + Fentity4.Add(FentityModel4); + FentityModel.Add("FEntity_Link", Fentity4); + + + //JArray Fentity3 = new JArray(); + //JObject FentityModel3 = new JObject(); + //FentityModel3.Add("FSrcBillType", "SFC_OperationReport"); //婧愬崟绫诲瀷 + //FentityModel3.Add("FSrcBillNo", HSLBillNo.ToString()); //宸ュ簭姹囨姤鍗曞崟鍙� + //FentityModel3.Add("FSrcInterId", HSLInterID.ToString()); //宸ュ簭姹囨姤鍗曚富ID + //FentityModel3.Add("FSrcEntryId", HSLEntryID.ToString()); //宸ュ簭姹囨姤鍗曞瓙ID + //FentityModel3.Add("FSrcEntrySeq", HSLSeQ.ToString()); //宸ュ簭姹囨姤鍗曡鍙� + //FentityModel3.Add("FOrderType", new JObject() { ["FID"] = "PUR_PurchaseOrder" }); // 宸ュ簭璁″垝绫诲瀷 + //FentityModel3.Add("FOrderBillNo", HSourceBillNo.ToString()); //宸ュ簭璁″垝鍗曞彿 + //FentityModel3.Add("FOrderId", HSourceInterID.ToString()); //宸ュ簭璁″垝涓籌D + //FentityModel3.Add("FOrderEntryId", HSourceEntryID.ToString()); //宸ュ簭璁″垝瀛怚D + //FentityModel3.Add("FOrderEntrySeq", HSeQ.ToString()); //宸ュ簭璁″垝琛屽彿 + //Fentity3.Add(FentityModel3); + //FentityModel.Add("FReferDetail", Fentity3); + Fentity.Add(FentityModel); + model.Add("FEntity", Fentity); //鏄庣粏淇℃伅 + + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + DataSet ds = oCN.RunProcReturn("select HCheckdate from Sc_ProcessReportMain where hbillno = '" + HSourceBillNo + "'", "Sc_ProcessReportMain"); + DateTime HCheckDate = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["HCheckdate"]); + JObject jsonRoot = new JObject() + { + ["Creator"] = "", + ["NeedUpDateFields"] = new JArray(), + ["NeedReturnFields"] = new JArray(), + ["IsDeleteEntry"] = "false", + ["SubSystemId"] = "", + ["IsVerifyBaseDataField"] = "false", + ["F_PGKJ_Date"] = HCheckDate.ToString(), + //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + ["Model"] = model + }; + + string result = InvokeHelper.Save("QM_InspectBill", JsonConvert.SerializeObject(jsonRoot));//淇濆瓨 + //鍒ゆ柇淇濆瓨鏄惁鎴愬姛 + if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + LogService.Write("鏉ユ枡妫�楠屽崟淇濆瓨閿欒jsonRoot:" + jsonRoot); + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍚屾閲戣澏浜戝け璐ワ紒鍗曞彿:{HBillNo.ToString()}" + result; + objJsonResult.data = null; + return objJsonResult; + } + //鎻愪氦瀹℃牳 + string result1 = string.Empty; + string result2 = string.Empty; + var fID = JObject.Parse(result)["Result"]["Id"].ToString(); + var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString(); + var json = new + { + Ids = fID, + }; + result1 = InvokeHelper.Submit("QM_InspectBill", JsonConvert.SerializeObject(json));//鎻愪氦 + result2 = InvokeHelper.Audit("QM_InspectBill", JsonConvert.SerializeObject(json));//鎻愪氦 + if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"鏉ユ枡妫�楠屽崟鍙凤細{fBillNo}锛屾彁浜ゅけ璐�" + result; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.Commit(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + /// <summary> /// 杩斿洖鐢熶骇姹囨姤鍗曞垪琛� ///鍙傛暟锛歴tring sql銆� @@ -103,20 +1937,30 @@ /// </summary> [Route("Sc_ProcessMangement/MES_Sc_ProcessReportList_Json")] [HttpGet] - public object MES_Sc_ProcessReportList_Json(string sWhere) + public object MES_Sc_ProcessReportList_Json(string sWhere, string user) { DataSet ds; try { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBillQuery", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愭煡璇�!"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessReportList ", "h_v_Sc_ProcessReportList"); + ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessReportList order by hmainid desc", "h_v_Sc_ProcessReportList"); } else { string sql1 = "select * from h_v_Sc_ProcessReportList where 1 = 1 "; - string sql = sql1 + sWhere; + string sql = sql1 + sWhere + " order by hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessReportList"); } } @@ -144,11 +1988,11 @@ try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - if (HInterID<=0) + if (HInterID <= 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "HInterID灏忎簬0锛�" ; + objJsonResult.Message = "HInterID灏忎簬0锛�"; objJsonResult.data = null; return objJsonResult; } @@ -161,9 +2005,9 @@ inner join Gy_Department s2 on s1.HDeptID=s2.HItemID and s1.HInterID=" + HInterID; ds = oCN.RunProcReturn(sql1, "Sc_ProcessReportMain"); - + } - + } catch (Exception e) { @@ -200,12 +2044,12 @@ else { - string sql1 =@"select [hmainid], [鏃ユ湡], [鍗曟嵁鍙穄, [HDeptID], [閮ㄩ棬浠g爜], [閮ㄩ棬], [HMaterID], [鐗╂枡浠g爜], [鐗╂枡鍚嶇О], [瑙勬牸鍨嬪彿], [HUnitID], [璁¢噺鍗曚綅浠g爜], [璁¢噺鍗曚綅], [HprocID], + string sql1 = @"select [hmainid], [鏃ユ湡], [鍗曟嵁鍙穄, [HDeptID], [閮ㄩ棬浠g爜], [閮ㄩ棬], [HMaterID], [鐗╂枡浠g爜], [鐗╂枡鍚嶇О], [瑙勬牸鍨嬪彿], [HUnitID], [璁¢噺鍗曚綅浠g爜], [璁¢噺鍗曚綅], [HprocID], [宸ュ簭浠g爜], [宸ュ簭], [HGroupID], [鐝粍浠g爜], [鐝粍鍚嶇О], [HSourceID], [璧勬簮浠g爜], [鐢熶骇璧勬簮], [HWorkerID], [鑱屽憳浠g爜], [鑱屽憳], [hsubid], [鏁伴噺], [璁″垝寮�宸ユ棩鏈焆, [璁″垝瀹屽伐鏃ユ湡], [璁″垝宸ユ椂], [琛ㄤ綋澶囨敞], [HICMOInterID], [鐢熶骇浠诲姟鍗曞彿], [HSeOrderInterID], [閿�鍞鍗曞彿], [琛ㄥご澶囨敞], [鍒跺崟浜篯, [鍒跺崟鏃ユ湡], [瀹℃牳浜篯, [瀹℃牳鏃ユ湡], [淇敼浜篯, [淇敼鏃ユ湡], [鍏抽棴浜篯, [鍏抽棴鏃ユ湡], [浣滃簾浜篯, [浣滃簾鏃ユ湡], [婧愬崟涓诲唴鐮乚, [婧愬崟瀛愬唴鐮乚, [婧愬崟鍗曞彿], [婧愬崟绫诲瀷], [琛屽叧闂汉], [HBillType], [HQtyDecimal], [HPriceDecimal] from h_v_Sc_ProcessSendWorkList -where hmainid=(select HSourceID from Sc_ProcessReportSub where HInterID="+HInterID+")"; +where hmainid=(select HSourceID from Sc_ProcessReportSub where HInterID=" + HInterID + ")"; ds = oCN.RunProcReturn(sql1, "h_v_Sc_ProcessSendWorkList"); @@ -223,10 +2067,11 @@ } #region 宸ュ簭璁″垝鍗� - - #region 宸ュ簭璁″垝鍗曞垪琛� List<ClsSc_ProcessPlanSub> DetailColl = new List<ClsSc_ProcessPlanSub>(); ClsSc_ProcessPlanMain omodel = new ClsSc_ProcessPlanMain(); + ClsSc_ProcessPlan oBill = new ClsSc_ProcessPlan(); + + #region 宸ュ簭璁″垝鍗曞垪琛� /// <summary> /// 杩斿洖鐢熶骇宸ュ簭璁″垝鍗曞垪琛� ///鍙傛暟锛歴tring sql銆� @@ -234,22 +2079,33 @@ /// </summary> [Route("Sc_ProcessMangement/MES_Sc_ProcessPlanMain_Json")] [HttpGet] - public object MES_Sc_ProcessPlanMain_Json(string sWhere) + public object MES_Sc_ProcessPlanMain_Json(string sWhere, string user) { DataSet ds; try { + + if (!DBUtility.ClsPub.Security_Log("Sc_ProcessPlan_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愭煡璇�!"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessPlanList ", "h_v_Sc_ProcessPlanList"); + ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessPlanList order by hmainid desc ", "h_v_Sc_ProcessPlanList"); } else { string sql1 = "select * from h_v_Sc_ProcessPlanList where 1 = 1 "; - string sql = sql1 + sWhere; + string sql = sql1 + sWhere + " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessPlanList"); } + } catch (Exception e) { @@ -263,7 +2119,7 @@ } #endregion - #region 淇濆瓨/缂栬緫 + #region 宸ュ簭璁″垝鍗� 淇濆瓨/缂栬緫 //宸ュ簭璁″垝鍗� 淇濆瓨/缂栬緫 [Route("Sc_ProcessMangement/AddBill")] [HttpPost] @@ -299,8 +2155,19 @@ int hentryid = int.Parse(sArray[2].ToString());//瀛愯〃鐨勯『搴廼d int OperationType = int.Parse(sArray[3].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 + string user = sArray[4].ToString();//鐢ㄦ埛鍚� try { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_ProcessPlan_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愮紪杈�!"; + objJsonResult.data = null; + return objJsonResult; + } + omodel = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_ProcessPlanMain>(msg2); string BillType = "3715"; @@ -316,7 +2183,7 @@ ",HRemark,HInnerBillNo,HMaker,HMakeDate" + ") " + " values(" + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + BillType + "','" + BillType + "'," + omodel.HInterID.ToString() + - ",'" + omodel.HDate.ToShortDateString() + "','" + omodel.HBillNo + "'," + omodel.HBillStatus.ToString() + "," + omodel.HCheckItemNowID.ToString() + "," + omodel.HCheckItemNextID.ToString() + + ",'" + omodel.HDate.ToShortDateString() + "','" + omodel.HBillNo + "'," + (omodel.HBillStatus = 1) + "," + omodel.HCheckItemNowID.ToString() + "," + omodel.HCheckItemNextID.ToString() + "," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'," + omodel.HMaterID.ToString() + ",'" + omodel.HMaterNumber + "'," + omodel.HUnitID.ToString() + ",'" + omodel.HUnitNumber + "'," + omodel.HPlanQty.ToString() + ",'" + omodel.HPlanBeginDate.ToShortDateString() + "','" + omodel.HPlanEndDate.ToShortDateString() + "','" + omodel.HExplanation + "'" + ",'" + omodel.HRemark + "','" + omodel.HInnerBillNo + "','" + omodel.HMaker + "',getdate()" + @@ -351,7 +2218,7 @@ " where HInterID=" + omodel.HInterID.ToString()); //鍒犻櫎瀛愯〃 - oCN.RunProc("Delete From Sc_ProcessPlanSub where HInterID = " + omodel.HInterID.ToString()+ " and hentryid="+ hentryid); + oCN.RunProc("Delete From Sc_ProcessPlanSub where HInterID = " + omodel.HInterID.ToString() + " and hentryid=" + hentryid); } //淇濆瓨瀛愯〃 objJsonResult = AddBillSub(msg3, hentryid); @@ -398,7 +2265,7 @@ ",HBeginDayQty,HBeginFixQty,HFixWorkDays,HTrunWorkDays,HReadyTimes" + ",HReadyTime,HQueueTime,HMoveTime,HBatchNo" + ") values(" - + omodel.HInterID.ToString() + "," +(hentryid==-1?i: hentryid) + ",'" + oSub.HBillNo + "'," + oSub.HProcNo.ToString() + "," + oSub.HProcID.ToString() + "," + oSub.HWorkingQty.ToString() + + + omodel.HInterID.ToString() + "," + (hentryid == -1 ? i : hentryid) + ",'" + oSub.HBillNo + "'," + oSub.HProcNo.ToString() + "," + oSub.HProcID.ToString() + "," + oSub.HWorkingQty.ToString() + ",'" + oSub.HProcNumber + "','" + oSub.HWorkRemark + "'," + oSub.HCenterID.ToString() + "," + oSub.HDeptID.ToString() + ",'" + oSub.HDeptNumber + "'" + "," + oSub.HGroupID.ToString() + ",'" + oSub.HGroupNumber + "'," + oSub.HWorkerID.ToString() + ",'" + oSub.HWorkerNumber + "'," + oSub.HSourceID.ToString() + "," + oSub.HQty.ToString() + ",'" + oSub.HTimeUnit + "'," + oSub.HPlanWorkTimes.ToString() + ",'" + oSub.HPlanBeginDate.ToString() + "','" + oSub.HPlanEndDate.ToString() + "'" + @@ -419,7 +2286,247 @@ } #endregion + #region 宸ュ簭璁″垝鍗� 瀹℃牳/鍙嶅鏍� + [Route("Sc_ProcessMangement/CheckDeOAuditBill")] + [HttpGet] + public object CheckDeOAuditBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "Sc_ProcessPlan_Check"; //璇ユā鍧楃殑瀹℃牳鍔熻兘 + DBUtility.ClsPub.CurUserName = CurUserName;//瀛樺偍鐢ㄦ埛鍚� + + try + { + //鍒ゆ柇鏄惁鏈夊鏍告潈闄� + if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍒ゆ柇id鏄惁澶т簬0 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ID灏忎簬0"; + objJsonResult.data = null; + return objJsonResult; + } + + //杞崲id + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); + + //鏌ヨ瀹℃牳鐨勮繖鏉℃暟鎹� + ds = oCN.RunProcReturn("select * from Sc_ProcessPlanMain where HInterID='" + HInterID + "'", "Sc_ProcessPlanMain"); + + if (ds.Tables[0].Rows.Count > 0) + { + string HCloseMan = ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();//鍏抽棴浜� + string HDeleteMan = ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();//浣滃簾浜� + string HChecker = ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();//瀹℃牳浜� + + if (HCloseMan != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍗曟嵁宸插叧闂�,涓嶈兘瀹℃牳"; + objJsonResult.data = null; + return objJsonResult; + } + if (HDeleteMan != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍗曟嵁宸蹭綔搴�,涓嶈兘瀹℃牳"; + objJsonResult.data = null; + return objJsonResult; + } + //IsAudit==0 瀹℃牳 + if (IsAudit == 0) + { + if (HChecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鏁版嵁宸插鏍�"; + objJsonResult.data = null; + return objJsonResult; + } + } + //IsAudit==1 鍙嶅鏍� + if (IsAudit == 1) + { + if (HChecker == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鏁版嵁鏈鏍�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�;鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + //瀹℃牳鎻愪氦 + if (IsAudit == 0) + { + if (CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) + { + 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; + } + } + //鍙嶅鏍告彁浜� + if (IsAudit == 1) + { + if (AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) + { + 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栧弽瀹℃牳澶辫触" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + + } + //瀹℃牳 + public bool CheckBill(Int64 lngBillKey, ref string sReturn) + { + try + { + string HChecker = DBUtility.ClsPub.CurUserName;//鐢ㄦ埛鍚� + oCN.BeginTran();//鎵撳紑浜嬪姟 + oCN.RunProc("update Sc_ProcessPlanMain set HChecker='" + HChecker + "',HCheckDate='" + DateTime.Now + "',HBillStatus=2 where HInterID='" + lngBillKey + "'"); + oCN.Commit();//鍏抽棴浜嬪姟 + sReturn = "瀹℃牳鍗曟嵁鎴愬姛!"; + return true; + } + catch (Exception e) + { + sReturn = e.Message; + throw (e); + } + } + //鍙嶅鏍� + public bool AbandonCheck(Int64 lngBillKey, ref string sReturn) + { + try + { + string HChecker = DBUtility.ClsPub.CurUserName;//鐢ㄦ埛鍚� + oCN.BeginTran();//鎵撳紑浜嬪姟 + oCN.RunProc("update Sc_ProcessPlanMain set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID='" + lngBillKey + "'"); + oCN.Commit();//鍏抽棴浜嬪姟 + sReturn = "鍙嶅鏍稿崟鎹垚鍔�!"; + return true; + } + catch (Exception e) + { + sReturn = e.Message; + throw (e); + } + } #endregion + + #region 宸ュ簭璁″垝鍗� 鍒犻櫎 + [Route("Sc_ProcessMangement/DeleteProcessBill")] + [HttpGet] + public object MouldDeleteBill(long HInterID, string User, string ModRightNameDelete) + { + try + { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, false, User)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鍒犻櫎鏉冮檺"; + objJsonResult.data = null; + return objJsonResult; + } + + oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + + if (oBill.omodel.HChecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬瀹℃牳鐘舵��,涓嶈兘鍒犻櫎!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬垹闄�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #endregion + /// <summary> /// 杩斿洖鐢熶骇宸ュ簭娲惧伐鍗曞垪琛� /// </summary> @@ -427,20 +2534,30 @@ /// <returns></returns> [Route("Sc_ProcessMangement/MES_Sc_ProcessSendWorkMain_Json")] [HttpGet] - public object MES_Sc_ProcessSendWorkMain_Json(string sWhere) + public object MES_Sc_ProcessSendWorkMain_Json(string sWhere, string user) { DataSet ds; try { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_ProcessSendWork_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愭煡璇�!"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessSendWorkList ", "h_v_Sc_ProcessSendWorkList"); + ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessSendWorkList order by hmainid desc ", "h_v_Sc_ProcessSendWorkList"); } else { string sql1 = "select * from h_v_Sc_ProcessSendWorkList where 1 = 1 "; - string sql = sql1 + sWhere; + string sql = sql1 + sWhere + " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessSendWorkList"); } } @@ -462,7 +2579,7 @@ /// <returns></returns> [Route("SaveProcessSendWork")] [HttpPost] - public object SaveProcessSendWork([FromBody]JObject msg) + public object SaveProcessSendWork([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); @@ -470,17 +2587,29 @@ string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); + string user = sArray[2].ToString();//鐢ㄦ埛鍚� + string UserName = ""; ListModels oListModels = new ListModels(); try { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_ProcessSendWork_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愮紪杈�!"; + objJsonResult.data = null; + return objJsonResult; + } + DAL.ClsSc_ProcessSendWork Sendwork = new DAL.ClsSc_ProcessSendWork(); List<Model.ClsSc_ProcessSendWorkMain> lsmain = new List<Model.ClsSc_ProcessSendWorkMain>(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); lsmain = oListModels.getObjectByJson_SendWorkMain(msg2); - foreach ( Model.ClsSc_ProcessSendWorkMain oItem in lsmain) + foreach (Model.ClsSc_ProcessSendWorkMain oItem in lsmain) { UserName = oItem.HMaker; oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); @@ -547,7 +2676,7 @@ objJsonResult.data = 1; return objJsonResult; } - if (Convert.ToInt32( sendworksub.HQty) > Convert.ToInt32( oItemSub.璁″垝鏁伴噺)) + if (Convert.ToInt32(sendworksub.HQty) > Convert.ToInt32(oItemSub.璁″垝鏁伴噺)) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -571,7 +2700,7 @@ sendworksub.HCloseType = false; sendworksub.HSourceBillType = oItemSub.HBillType; lss.Add(sendworksub);//鍏堟妸鏁版嵁瀛樻斁鍒版淳宸ュ崟瀛愯〃闆嗗悎閲� - + } if (lss.Count > 0) @@ -646,11 +2775,23 @@ string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); + string user = sArray[2].ToString(); + string UserName = ""; ListModels oListModels = new ListModels(); try { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("WW_EntrustProcSendWorkBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愮紪杈�!"; + objJsonResult.data = null; + return objJsonResult; + } + WebAPI.DLL.ClsSc_ProcessSendWork Sendwork = new WebAPI.DLL.ClsSc_ProcessSendWork(); List<WebAPI.Models.ClsSc_ProcessSendWorkMain> lsmain = new List<WebAPI.Models.ClsSc_ProcessSendWorkMain>(); msg2 = msg2.Replace("\\", ""); @@ -709,7 +2850,7 @@ sendworksub.HWorkerNumber = ""; //--鎿嶄綔宸ヤ唬鐮� sendworksub.HWorkerID = 0; //--鎿嶄綔宸D sendworksub.HGroupNumber = ""; //鐝粍浠g爜 - sendworksub.HGroupID =0; //--鐝粍ID + sendworksub.HGroupID = 0; //--鐝粍ID sendworksub.HSourceNumber = ""; //--鐢熶骇璧勬簮浠g爜 //--鐢熶骇璧勬簮ID sendworksub.HProcNumber = ""; //--宸ュ簭浠g爜 @@ -847,20 +2988,30 @@ /// <returns></returns> [Route("Sc_ProcessMangement/MES_QC_NoPassProdCheckBill_Json")] [HttpGet] - public object MES_QC_NoPassProdCheckBill_Json(string sWhere) + public object MES_QC_NoPassProdCheckBill_Json(string sWhere, string user) { DataSet ds; try { + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBillQuery", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select top 500 * from h_v_QC_NoPassProdCheckBillList ", "h_v_QC_NoPassProdCheckBillList"); + ds = oCN.RunProcReturn("select top 500 * from h_v_QC_NoPassProdCheckBillList order by hmainid desc ", "h_v_QC_NoPassProdCheckBillList"); } else { string sql1 = "select * from h_v_QC_NoPassProdCheckBillList where 1 = 1 "; - string sql = sql1 + sWhere; + string sql = sql1 + sWhere + " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdCheckBillList"); } } @@ -876,13 +3027,300 @@ } /// <summary> + /// 涓嶅悎鏍艰瘎瀹� 鍒犻櫎 + /// </summary> + /// <param name="HInterID"></param> + /// <param name="user"></param> + /// <returns></returns> + [Route("Sc_ProcessMangement/ProcessMangementDeleteBill")] + [HttpGet] + public object ProcessMangementDeleteBill(string HInterID, string user) + { + try + { + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBill_Drop", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬垹闄�"; + objJsonResult.data = null; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from h_v_QC_NoPassProdCheckBillList where hmainid =" + HInterID + " ", "h_v_QC_NoPassProdCheckBillList"); + + if (ds.Tables[0].Rows[0]["瀹℃牳浜�"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�,涓嶈兘鍒犻櫎!"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + oCN.RunProc("Delete from QC_NoPassProdCheckBillMain where HInterID=" + HInterID); + oCN.RunProc("Delete from QC_NoPassProdCheckBillSub where HInterID=" + HInterID); + oCN.Commit(); + + objJsonResult.code = "1"; + 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; + } + } + + #region 涓嶅悎鏍艰瘎瀹� 瀹℃牳/鍙嶅鏍� + [Route("Sc_ProcessMangement/AuditProcessMangement")] + [HttpGet] + public object AuditProcessMangement(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdCheckBill_Check"; //璇ユā鍧楃殑瀹℃牳鍔熻兘 + DBUtility.ClsPub.CurUserName = CurUserName;//瀛樺偍鐢ㄦ埛鍚� + try + { + ////鍒ゆ柇鏄惁鏈夊鏍告潈闄� + if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ID灏忎簬0"; + objJsonResult.data = null; + return objJsonResult; + } + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID);//鏁版嵁杞崲 + + //鏌ヨ瀹℃牳鐨勬暟鎹� + ds = oCN.RunProcReturn("select * from QC_NoPassProdCheckBillMain where HInterID='" + HInterID + "'", "QC_NoPassProdCheckBillMain"); + + if (ds.Tables[0].Rows.Count > 0) + { + var hcloseman = ds.Tables[0].Rows[0]["HCloseMan"].ToString();//鍏抽棴浜� + var hdeleteman = ds.Tables[0].Rows[0]["HDeleteMan"].ToString();//浣滃簾浜� + var hchecker = ds.Tables[0].Rows[0]["HChecker"].ToString();//瀹℃牳浜� + + if (hcloseman != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍗曟嵁宸插叧闂�,鏃犳硶瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (hdeleteman != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍗曟嵁宸蹭綔搴�,鏃犳硶瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + //IsAudit==0 瀹℃牳 + if (IsAudit == 1) + { + if (hchecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍗曟嵁宸插鏍�,鏃犳硶鍐嶆瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + //IsAudit==1 鍙嶅鏍� + if (IsAudit == 2) + { + if (hchecker == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍗曟嵁鏈鏍�,鏃犳硶鍙嶅鏍�!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�;鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + //瀹℃牳鎻愪氦 + if (IsAudit == 1) + { + oCN.RunProc(" Update QC_NoPassProdCheckBillMain set HChecker='" + CurUserName + "',HCheckDate='" + DateTime.Now + "',HBillStatus=2 Where HBillType='7509' and HInterID=" + HInterID); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅鏍告彁浜� + if (IsAudit == 2) + { + oCN.RunProc(" Update QC_NoPassProdCheckBillMain set HChecker='',HCheckDate=null,HBillStatus=0 Where HBillType='7509' and HInterID=" + HInterID); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍告垚鍔�!"; + objJsonResult.data = null; + return objJsonResult; + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栧弽瀹℃牳澶辫触" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + + #region 涓嶈壇鍝佸鐞嗗崟鍏抽棴/鍙嶅叧闂姛鑳� + [Route("Sc_ProcessMangement/CloseSc_ProcessMangement")] + [HttpGet] + public object CloseSc_ProcessMangement(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBill_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; + BillOld.MvarItemKey = "QC_NoPassProdCheckBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 鍏抽棴 2 鍙嶅叧闂� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴 + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶉渶瑕佸啀鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + } + //鍏抽棴鍗曟嵁 + if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂� + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插弽鍏抽棴!涓嶉渶瑕佸啀鍙嶅叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + } + //鍙嶅叧闂崟鎹� + if (!BillOld.CancelClose(Int64.Parse(HInterID), 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 + + + + /// <summary> /// PDA宸ュ簭姹囨姤鍗曚繚瀛� /// </summary> /// <param name="msg"></param> /// <returns></returns> [Route("SaveProcessReport")] [HttpPost] - public object SaveProcessReport([FromBody] JObject msg) + public object SaveProcessReport([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); @@ -893,7 +3331,7 @@ List<WebAPI.Models.Sc_ProcessReportViewModel> ls = new List<WebAPI.Models.Sc_ProcessReportViewModel>(); ls = oListModels.getObjectByJson_Report(msg1); int i = 0; - + foreach (Models.Sc_ProcessReportViewModel ItemView in ls) { i++; @@ -902,23 +3340,23 @@ //宸ュ簭姹囨姤鍗曚富琛ㄤ繚瀛� ReportMain.HBillType = "3714"; ReportMain.HBillNo = ItemView.HBillNo; - ReportMain.HMakeDate=DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); - ReportMain.HYear=DBUtility.ClsPub.isLong(DateTime.Now.Year); + ReportMain.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); + ReportMain.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); ReportMain.HDate = DateTime.Now; ReportMain.HMaker = ItemView.HEmp; ReportMain.HCloseType = false; ReportMain.HPlanQty = (double)ItemView.HQty; ReportMain.HMainSourceInterID = ItemView.HInterID; - ReportMain.HInterID =0; + ReportMain.HInterID = 0; ReportMain.HPeriod = 1; ReportMain.HBillSubType = "3714"; ReportMain.HBillStatus = 0; ReportMain.HCheckItemNowID = 0; ReportMain.HCheckItemNextID = 0; - ReportMain.HICMOInterID= (long)ItemView.HICMOInterID; - ReportMain.HICMOBillNo=ItemView.HICMOBillNo; + ReportMain.HICMOInterID = (long)ItemView.HICMOInterID; + ReportMain.HICMOBillNo = ItemView.HICMOBillNo; ReportMain.HDeptID = (long)ItemView.HDeptID; - ReportMain.HDeptNumber =ItemView.HDeptNumber; + ReportMain.HDeptNumber = ItemView.HDeptNumber; ReportMain.HGroupID = (long)ItemView.HGroupID; ReportMain.HGroupNumber = ItemView.HGroupNumber; ReportMain.HMaterID = (long)ItemView.HMaterID; @@ -930,7 +3368,7 @@ ReportMain.HExplanation = ""; ReportMain.HInnerBillNo = ""; ReportMain.HSupID = 0; - + //淇濆瓨鍒版眹鎶ュ崟涓昏〃 @@ -949,15 +3387,15 @@ ReportSub.HQty = (double)ItemView.HQty; ReportSub.HProcID = ItemView.HProcID; ReportSub.HProcNumber = ItemView.HProcNumber; - ReportSub.HOutPrice =0; + ReportSub.HOutPrice = 0; ReportSub.HOutMoney = 0; ReportSub.HSourceID = (long)ItemView.HSourceID; ReportSub.HEmpNumber = ""; ReportSub.HRelBeginDate = DateTime.Now; ReportSub.HRelEndDate = DateTime.Now; - ReportSub.HTimes =3; + ReportSub.HTimes = 3; ReportSub.HSeOrderInterID = 0; - ReportSub.HSeOrderEntryID =0; + ReportSub.HSeOrderEntryID = 0; ReportSub.HSeOrderBillNo = ""; ReportSub.HProcPlanInterID = 0; ReportSub.HProcPlanBillNo = ""; @@ -967,44 +3405,44 @@ ReportSub.HRelationMoney = 0; ReportSub.HMaterID = (long)ItemView.HMaterID; ReportSub.HMaterNumber = ItemView.HMaterNumber; - ReportSub.HCheckQty =0; - ReportSub.HBadCount =0; - ReportSub.HWasterQty =0; - ReportSub.HWasterQty2 =0; - ReportSub.HPrice =0; - ReportSub.HMoney =0; - ReportSub.HProcPlanInterID =0; - ReportSub.HProcPlanEntryID =0; - ReportSub.HProcPlanBillNo =""; - ReportSub.HSourceEntryID =0; - ReportSub.HSourceBillType =""; - ReportSub.HRelationQty =0; - ReportSub.HRelationMoney =0; - ReportSub.HBadPrirce =0; - ReportSub.HBadMoney =0; - ReportSub.HWasterPrice =0; - ReportSub.HWasterMoney =0; - ReportSub.HQualityRate =0; - ReportSub.HSecUnitQty1 =0; - ReportSub.HSecUnitRate1=0; - ReportSub.HSecUnitQty2=0; - ReportSub.HSecUnitRate2=0; - ReportSub.HUsingQty=0; - ReportSub.HSelfBadCount=0; - ReportSub.HPreBadCount=0; - ReportSub.HPayMentQty=0; - ReportSub.HOtherDeduct=0; - ReportSub.HRelPay=0; - ReportSub.HOtherItem1=""; - ReportSub.HOtherItem2=""; - ReportSub.HOtherItem3=""; - ReportSub.HOtherItem4=""; - ReportSub.HOtherItem5=""; - ReportSub.HPackType=""; - ReportSub.HCheckEmpID=0; - ReportSub.HWeight=0; - ReportSub.HBatchNo=""; - + ReportSub.HCheckQty = 0; + ReportSub.HBadCount = 0; + ReportSub.HWasterQty = 0; + ReportSub.HWasterQty2 = 0; + ReportSub.HPrice = 0; + ReportSub.HMoney = 0; + ReportSub.HProcPlanInterID = 0; + ReportSub.HProcPlanEntryID = 0; + ReportSub.HProcPlanBillNo = ""; + ReportSub.HSourceEntryID = 0; + ReportSub.HSourceBillType = ""; + ReportSub.HRelationQty = 0; + ReportSub.HRelationMoney = 0; + ReportSub.HBadPrirce = 0; + ReportSub.HBadMoney = 0; + ReportSub.HWasterPrice = 0; + ReportSub.HWasterMoney = 0; + ReportSub.HQualityRate = 0; + ReportSub.HSecUnitQty1 = 0; + ReportSub.HSecUnitRate1 = 0; + ReportSub.HSecUnitQty2 = 0; + ReportSub.HSecUnitRate2 = 0; + ReportSub.HUsingQty = 0; + ReportSub.HSelfBadCount = 0; + ReportSub.HPreBadCount = 0; + ReportSub.HPayMentQty = 0; + ReportSub.HOtherDeduct = 0; + ReportSub.HRelPay = 0; + ReportSub.HOtherItem1 = ""; + ReportSub.HOtherItem2 = ""; + ReportSub.HOtherItem3 = ""; + ReportSub.HOtherItem4 = ""; + ReportSub.HOtherItem5 = ""; + ReportSub.HPackType = ""; + ReportSub.HCheckEmpID = 0; + ReportSub.HWeight = 0; + ReportSub.HBatchNo = ""; + //淇濆瓨鍒版眹鎶ュ崟瀛愯〃 ReportModel.DetailColl.Add(ReportSub); } @@ -1080,17 +3518,28 @@ /// <returns></returns> [Route("SaveProcessReportList")] [HttpPost] - public object SaveProcessReportList([FromBody] JObject msg) + public object SaveProcessReportList([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 msg3 = sArray[1].ToString(); + + string user = sArray[2].ToString();//鐢ㄦ埛鍚� string UserName; ListModels oListModels = new ListModels(); try { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愮紪杈�!"; + objJsonResult.data = null; + return objJsonResult; + } DAL.ClsSc_ProcessReport ReportModel = new DAL.ClsSc_ProcessReport(); List<Model.ClsSc_ProcessReportMain> lsmain = new List<Model.ClsSc_ProcessReportMain>(); msg2 = msg2.Replace("\\", ""); @@ -1132,7 +3581,7 @@ List<Model.ClsSc_ProcessReportSub> lsReportSub = new List<Model.ClsSc_ProcessReportSub>(); foreach (WebAPI.Models.Sc_ProcessSendWorkViewModel ItemView in ls) { - + i++; Model.ClsSc_ProcessReportSub reportSub = new Model.ClsSc_ProcessReportSub(); if (ItemView.鏁伴噺 <= 0) @@ -1158,8 +3607,8 @@ reportSub.HRemark = ""; reportSub.HCloseMan = ReportModel.omodel.HCloseMan; reportSub.HCloseType = false; - reportSub.HEmpID =0; - reportSub.HICMOBillNo =""; + reportSub.HEmpID = 0; + reportSub.HICMOBillNo = ""; reportSub.HICMOInterID = (long)ItemView.HICMOInterID; reportSub.HRemark = ""; reportSub.HSourceBillType = "3712"; @@ -1225,7 +3674,7 @@ lsReportSub.Add(reportSub); } - if (lsReportSub.Count>0) + if (lsReportSub.Count > 0) { //鐒跺悗鍦ㄥ惊鐜繚瀛樺埌姹囨姤浣嗗瓙琛� foreach (Model.ClsSc_ProcessReportSub item in lsReportSub) @@ -1294,19 +3743,30 @@ /// <returns></returns> [Route("SaveBadReasonList")] [HttpPost] - public object SaveBadReasonList([FromBody] JObject msg) + public object SaveBadReasonList([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 msg3 = sArray[1].ToString(); + string user = sArray[2].ToString(); - string UserName=""; + string UserName = ""; ListModels oListModels = new ListModels(); try { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄�"; + objJsonResult.data = null; + return objJsonResult; + } + DLL.ClsQC_NoPassProdCheckBill oBill = new DLL.ClsQC_NoPassProdCheckBill(); List<Model.ClsQC_NoPassProdCheckBillMain> lsmain = new List<Model.ClsQC_NoPassProdCheckBillMain>(); msg2 = msg2.Replace("\\", ""); @@ -1315,7 +3775,7 @@ foreach (Model.ClsQC_NoPassProdCheckBillMain oItem in lsmain) { //oItem.HMaker = ""; - UserName=oItem.HMaker; + UserName = oItem.HMaker; oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); @@ -1323,7 +3783,7 @@ oItem.HBillSubType = "7509"; oItem.HBillStatus = 1; oItem.HPeriod = 0; - oItem.HGroupName =""; + oItem.HGroupName = ""; oItem.HSourceID = 0; oItem.HICMOInterID = 0; oItem.HICMOBillNo = ""; @@ -1343,7 +3803,7 @@ oItem.HMainSourceInterID = oItem.HInterID; oItem.HInterID = 0; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); - if (DBUtility.ClsPub.isStrNull(oItem.HDate)=="") + if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -1352,7 +3812,7 @@ return objJsonResult; } oBill.omodel = oItem; - } + } //琛ㄤ綋鏁版嵁 //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆� msg3 = msg3.Substring(1, msg3.Length - 2); @@ -1370,8 +3830,8 @@ break; } //灏嗗墠鍙颁复鏃跺瓨鏀剧殑鍊间紶杩囨潵鐨勫�艰祴缁欏搴旂殑涓嶈壇鏁伴噺瀛楁 - oItemSub.HBadQty = Convert.ToDecimal( oItemSub.HMRBChecker); - if (oItemSub.HBadQty<=0) + oItemSub.HBadQty = Convert.ToDecimal(oItemSub.HMRBChecker); + if (oItemSub.HBadQty <= 0) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -1379,7 +3839,7 @@ objJsonResult.data = 1; return objJsonResult; } - if ((double)oItemSub.HBadQty >oBill.omodel.HPlanQty ) + if ((double)oItemSub.HBadQty > oBill.omodel.HPlanQty) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -1387,7 +3847,7 @@ objJsonResult.data = 1; return objJsonResult; } - if (DBUtility.ClsPub.isStrNull(oItemSub.HWasterReasonName)=="") + if (DBUtility.ClsPub.isStrNull(oItemSub.HWasterReasonName) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -1414,7 +3874,7 @@ oItemSub.HBadPCSQty = 0; oItemSub.HQCResultID = 0; oBill.DetailColl.Add(oItemSub); - + } //淇濆瓨鍓嶅垽鏂�(鍗曟嵁鍙烽噸澶嶏紝绗斿綍椤圭洰) //淇濆瓨 @@ -1467,10 +3927,10 @@ /// <returns></returns> [Route("CloseProcessReportList")] [HttpGet] - public object CloseProcessReportList(int HInterID,int IsClose,string CurUserName) + public object CloseProcessReportList(int HInterID, int IsClose, string CurUserName) { DataSet ds; - string ModRightNameCheck = "Sc_ProcessReport_check"; + string ModRightNameCheck = "Sc_ProcessReport_check"; try { //瀹℃牳鏉冮檺 @@ -1503,7 +3963,7 @@ } var HChecker = ds.Tables[0].Rows[0]["HChecker"].ToString(); var HCloseMan = ds.Tables[0].Rows[0]["HCloseMan"].ToString(); - + if (IsClose == 0) { if (HCloseMan.Trim() != "" || HChecker.Trim() == "") @@ -1520,8 +3980,8 @@ objJsonResult.Message = "* 鍗曟嵁鍏抽棴鎴愬姛锛�"; objJsonResult.data = null; return objJsonResult; ; - } - else if(IsClose==1) + } + else if (IsClose == 1) { if (HCloseMan.Trim() == "" || HChecker.Trim() == "") { @@ -1548,7 +4008,7 @@ return objJsonResult; ; } - + } catch (Exception e) { @@ -1583,7 +4043,7 @@ objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; objJsonResult.data = null; - return objJsonResult; + return objJsonResult; } SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (HInterID <= 0) @@ -1601,11 +4061,11 @@ objJsonResult.count = 0; objJsonResult.Message = "娌℃湁杩欎釜鍗曟嵁锛屾棤娉曞鏍革紒"; objJsonResult.data = null; - return objJsonResult; + return objJsonResult; } var HChecker = ds.Tables[0].Rows[0]["HChecker"].ToString();//鍙栧鏍镐汉 - var HMaker=ds.Tables[0].Rows[0]["HMaker"].ToString();//鍙栧埗鍗曚汉 - var HCloseMan=ds.Tables[0].Rows[0]["HCloseMan"].ToString();//鍙栧叧闂汉 + var HMaker = ds.Tables[0].Rows[0]["HMaker"].ToString();//鍙栧埗鍗曚汉 + var HCloseMan = ds.Tables[0].Rows[0]["HCloseMan"].ToString();//鍙栧叧闂汉 if (IsAudit == 0) { if (HChecker.Trim() != "" || HChecker.Trim() == HMaker || HCloseMan != "") @@ -1622,7 +4082,7 @@ objJsonResult.count = 1; objJsonResult.Message = "* 鍗曟嵁瀹℃牳鎴愬姛锛�"; objJsonResult.data = null; - return objJsonResult; + return objJsonResult; } else if (IsAudit == 1) { @@ -1640,7 +4100,7 @@ objJsonResult.count = 1; objJsonResult.Message = "* 鍗曟嵁鍙嶅鏍告垚鍔燂紒"; objJsonResult.data = null; - return objJsonResult; + return objJsonResult; } else { @@ -1648,7 +4108,7 @@ objJsonResult.count = 0; objJsonResult.Message = "鍗曟嵁鏃犳硶瀹℃牳锛�"; objJsonResult.data = null; - return objJsonResult; + return objJsonResult; } @@ -1670,20 +4130,30 @@ /// <returns></returns> [Route("Sc_ProcessMangement/MES_WW_EntrustProcSendWorkBill_Json")] [HttpGet] - public object MES_WW_EntrustProcSendWorkBill_Json(string sqlWhere) + public object MES_WW_EntrustProcSendWorkBill_Json(string sqlWhere, string user) { DataSet ds; try { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("WW_EntrustProcSendWorkBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愭煡璇�!"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { - ds = oCN.RunProcReturn("select top 500 * from h_v_WW_EntrustProcSendWorkBillList ", "h_v_WW_EntrustProcSendWorkBillList"); + ds = oCN.RunProcReturn("select top 500 * from h_v_WW_EntrustProcSendWorkBillList order by hmainid desc ", "h_v_WW_EntrustProcSendWorkBillList"); } else { string sql1 = "select * from h_v_WW_EntrustProcSendWorkBillList where 1 = 1 "; - string sql = sql1 + sqlWhere; + string sql = sql1 + sqlWhere + " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_WW_EntrustProcSendWorkBillList"); } } @@ -1705,11 +4175,21 @@ /// <returns></returns> [Route("Sc_ProcessMangement/MES_WW_EntrustProcessReportBill_Json")] [HttpGet] - public object MES_WW_EntrustProcessReportBill_Json(string sqlWhere) + public object MES_WW_EntrustProcessReportBill_Json(string sqlWhere, string user) { DataSet ds; try { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("WW_EntrustProcessReportBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愭煡璇�!"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { @@ -1740,20 +4220,30 @@ /// <returns></returns> [Route("Sc_ProcessMangement/MES_WW_EntrustProcessSendOutBillList_Json")] [HttpGet] - public object MES_WW_EntrustProcessSendOutBillList_Json(string sqlWhere) + public object MES_WW_EntrustProcessSendOutBillList_Json(string sqlWhere, string user) { DataSet ds; try { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("WW_EntrustProcessSendOutBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愭煡璇�!"; + objJsonResult.data = null; + return objJsonResult; + } + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { - ds = oCN.RunProcReturn("select top 500 * from h_v_WW_EntrustProcessSendOutBillList ", "h_v_WW_EntrustProcessSendOutBillList"); + ds = oCN.RunProcReturn("select top 500 * from h_v_WW_EntrustProcessSendOutBillList order by hmainid desc ", "h_v_WW_EntrustProcessSendOutBillList"); } else { string sql1 = "select * from h_v_WW_EntrustProcessSendOutBillList where 1 = 1 "; - string sql = sql1 + sqlWhere; + string sql = sql1 + sqlWhere + " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_WW_EntrustProcessSendOutBillList"); } } @@ -1784,11 +4274,23 @@ string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); + string user = sArray[2].ToString();//鐢ㄦ埛鍚� + string UserName = ""; ListModels oListModels = new ListModels(); try { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("WW_EntrustProcessReportBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愮紪杈�!"; + objJsonResult.data = null; + return objJsonResult; + } + WebAPI.DLL.ClsWW_EntrustProcessReportBill Sendwork = new WebAPI.DLL.ClsWW_EntrustProcessReportBill(); List<WebAPI.Models.ClsWW_EntrustProcessReportBillMain> lsmain = new List<WebAPI.Models.ClsWW_EntrustProcessReportBillMain>(); msg2 = msg2.Replace("\\", ""); @@ -1848,7 +4350,7 @@ objJsonResult.data = 1; return objJsonResult; } - + sendworksub.HEntryID = i; sendworksub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); @@ -1975,7 +4477,7 @@ ReportMain.HCloseType = false; ReportMain.HPrintQty = 0; ReportMain.HMainSourceBillType = "3740"; - ReportMain.HMainSourceInterID =0; + ReportMain.HMainSourceInterID = 0; ReportMain.HMainSourceBillNo = ItemView.HWW_BillNo; ReportMain.HInterID = 0; ReportMain.HPeriod = 1; @@ -1986,7 +4488,7 @@ ReportMain.HDeptID = Convert.ToInt32(ItemView.HDeptID); ReportMain.HExplanation = ""; ReportMain.HInnerBillNo = ""; - ReportMain.HSupID =Convert.ToInt32( ItemView.HSupID); + ReportMain.HSupID = Convert.ToInt32(ItemView.HSupID); //淇濆瓨鍒版眹鎶ュ崟涓昏〃 @@ -2003,7 +4505,7 @@ ReportSub.HCloseType = false; ReportSub.HSourceBillType = "3740"; ReportSub.HQty = Convert.ToDecimal(ItemView.HQty); - ReportSub.HProcID =Convert.ToInt32( ItemView.HProcID); + ReportSub.HProcID = Convert.ToInt32(ItemView.HProcID); ReportSub.HTimes = 0; ReportSub.HSeOrderInterID = 0; ReportSub.HSeOrderEntryID = 0; @@ -2092,11 +4594,23 @@ string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); + string user = sArray[1].ToString();//鐢ㄦ埛鍚� + string UserName = ""; ListModels oListModels = new ListModels(); try { + //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� + if (!DBUtility.ClsPub.Security_Log("WW_EntrustProcessSendOutBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愮紪杈�!"; + objJsonResult.data = null; + return objJsonResult; + } + WebAPI.DLL.ClsWW_EntrustProcessSendOutBill Sendwork = new WebAPI.DLL.ClsWW_EntrustProcessSendOutBill(); List<WebAPI.Models.ClsWW_EntrustProcessSendOutBillMain> lsmain = new List<WebAPI.Models.ClsWW_EntrustProcessSendOutBillMain>(); msg2 = msg2.Replace("\\", ""); @@ -2403,7 +4917,7 @@ WorkOrdersub.HSourceInterID = oItemSub.hmainid.Value; //--婧愬崟id WorkOrdersub.HSourceEntryID = oItemSub.hsubid.Value; //--婧愬崟瀛怚D WorkOrdersub.HSourceBillNo = oItemSub.鍗曟嵁鍙�; //--婧愬崟鍗曞彿 - WorkOrdersub.HSourceBillType= oItemSub.HBillType; //--婧愬崟绫诲瀷 + WorkOrdersub.HSourceBillType = oItemSub.HBillType; //--婧愬崟绫诲瀷 WorkOrdersub.HRelationQty = 0; //--鍏宠仈鏁伴噺 WorkOrdersub.HRelationMoney = 0; //--鍏宠仈閲戦 WorkOrdersub.HOrderBillNo = ""; //--閿�鍞鍗曞彿 @@ -2413,9 +4927,9 @@ WorkOrdersub.HQty = (double)oItemSub.璁″垝鏁伴噺; //--璁㈠崟鏁伴噺 WorkOrdersub.HEntrustType = "3739"; //--濮斿绫诲瀷 WorkOrdersub.HNextProcName = ""; //--涓嬮亾宸ュ簭 - WorkOrdersub.HPrice =0; //鍔犲伐璐� + WorkOrdersub.HPrice = 0; //鍔犲伐璐� WorkOrdersub.HOutQty = 0; //--鍏宠仈鍙戝嚭鏁伴噺 - WorkOrdersub.HInQty =0; //--鍏宠仈鎺ユ敹鏁伴噺 + WorkOrdersub.HInQty = 0; //--鍏宠仈鎺ユ敹鏁伴噺 WorkOrdersub.HBackSupDate = DateTime.Now; //--瀹為檯浜よ揣鏃ユ湡 WorkOrdersub.HInDate = DateTime.Now; //--浜よ揣鏃ユ湡 WorkOrdersub.HWorkProcFlow = ""; //--宸ヨ壓娴� @@ -2505,7 +5019,3474 @@ } } + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 鏂板/缂栬緫 + [Route("Sc_ProcessMangement/SaveQC_NoPassProdRequestBill")] + [HttpPost] + public object SaveQC_NoPassProdRequestBill([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 msg3 = sArray[1].ToString(); //瀛愯〃 + string refSav = sArray[1].ToString();//鎿嶄綔鏂瑰紡鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 + string msg4 = sArray[2].ToString();//鐢ㄦ埛鍚� + + DBUtility.ClsPub.CurUserName = msg4; + + string UserName = ""; + string s = ""; + ListModels oListModels = new ListModels(); + try + { + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("QC_NoPassProdRequestBillMain_Edit", 1, false, msg4)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + // QC_NoPassProdRequestBill + DAL.ClsQC_NoPassProdRequestBill oBill = new DAL.ClsQC_NoPassProdRequestBill(); + List<Model.ClsQC_NoPassProdRequestBillMain> lsmain = new List<Model.ClsQC_NoPassProdRequestBillMain>(); + msg2 = msg2.Replace("\\", ""); + msg2 = msg2.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_QC_NoPassProdRequestBill(msg2); + foreach (Model.ClsQC_NoPassProdRequestBillMain oItem in lsmain) + { + if (refSav == "Add") + { + //鍗曟嵁鍙锋槸鍚﹂噸澶� + if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒"; + objJsonResult.data = 1; + return objJsonResult; + } + } + if (refSav == "Update") + { + if (oBill.ShowBill(oItem.HInterID, ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙紪杈� + if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = s + "锛屼笉鍏佽淇敼"; + objJsonResult.data = 1; + return objJsonResult; + } + } + UserName = oItem.HMaker; //鍒跺崟浜� + oItem.HBillType = "7512"; + oItem.HBillSubType = "7512"; + + oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); + oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); + + 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 (refSav == "Add") + { + + bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); + } + else if (refSav == "Update") + { + bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + bResult = false; + } + if (bResult) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 缂栬緫鍥炴樉鍒楄〃 + + [Route("Sc_ProcessMangement/Edit_QC_NoPassProdRequestBill")] + [HttpGet] + public object Edit_QC_NoPassProdRequestBill(string HID) + { + try + { + List<object> columnNameList = new List<object>(); + + string sql = "select * from h_v_QC_NoPassProdRequestBillMainList where hmainid='" + HID + "'"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdRequestBillMainList"); + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 鍒楄〃 + + [Route("Sc_ProcessMangement/Get_QC_NoPassProdRequestBillList")] + [HttpGet] + public object Get_QC_NoPassProdRequestBillList(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdRequestBillMain_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + string sql = "select * from h_v_QC_NoPassProdRequestBillMainList order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdRequestBillMainList"); + } + else + { + string sql1 = "select * from h_v_QC_NoPassProdRequestBillMainList where 1 = 1 "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdRequestBillMainList"); + } + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 鍒犻櫎 + + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdRequestBill")] + [HttpGet] + public object DeleteQC_NoPassProdRequestBill(string HInterID, string user) + { + try + { + string s = ""; + DAL.ClsQC_NoPassProdRequestBill BillOld = new DAL.ClsQC_NoPassProdRequestBill(); + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdRequestBillMain_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙垹闄� + if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdRequestBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdRequestBill_BeforeDelCtrl"); + 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; + } + //================================================================================== + + + + oCN.BeginTran(); + + oCN.RunProc("delete from QC_NoPassProdRequestBillMain where HInterID = " + HInterID); + oCN.RunProc("delete from QC_NoPassProdRequestBillSub where HInterID= " + HInterID); + + //鍒犻櫎鍚庢帶鍒�================================================================================== + string sql2 = "exec h_p_QC_NoPassProdRequestBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_QC_NoPassProdRequestBill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + s = ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //============================================================================================== + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 瀹℃牳/鍙嶅鏍� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/AuditQC_NoPassProdRequestBill")] + [HttpGet] + public object AuditQC_NoPassProdRequestBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdRequestBillMain_Check"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdRequestBill oBill = new DAL.ClsQC_NoPassProdRequestBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣� + if (IsAudit == 0) //瀹℃牳鎻愪氦 + { + oCN.BeginTran(); + + //璁板綍杩斿洖淇℃伅 + string msg = ""; + + + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdRequestBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdRequestBill_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 (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdRequestBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg; + objJsonResult.data = null; + return objJsonResult; + } + else + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍告彁浜� + { + + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_QC_NoPassProdRequestBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdRequestBill_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; + } + //=========================================================== + + //鍙嶅鏍告彁浜bandonCheck + if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdRequestBill_AfterUnCheckCtrl", CurUserName, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 鍏抽棴/鍙嶅叧闂� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param> + /// <param name="CurUserName">鍏抽棴浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/CloseQC_NoPassProdRequestBill")] + [HttpGet] + public object CloseQC_NoPassProdRequestBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdRequestBillMain_Close"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdRequestBill oBill = new DAL.ClsQC_NoPassProdRequestBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //鍏抽棴鍒ゆ柇 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅叧闂垽鏂� + { + if (oBill.omodel.HCloseMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣� + if (IsAudit == 0) //鍏抽棴鎻愪氦 + { + //鍏抽棴鎻愪氦 + if (oBill.CloseBill(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.CancelClose(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触鎴栬�呭弽鍏抽棴澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$敵璇峰崟 浣滃簾/鍙嶄綔搴� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param> + /// <param name="CurUserName">浣滃簾浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdRequestBill")] + [HttpGet] + public object DeleteQC_NoPassProdRequestBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdRequestBillMain_Drop"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdRequestBill oBill = new DAL.ClsQC_NoPassProdRequestBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //浣滃簾鍒ゆ柇 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶄綔搴熷垽鏂� + { + if (oBill.omodel.HDeleteMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣� + if (IsAudit == 0) //浣滃簾鎻愪氦 + { + //浣滃簾鎻愪氦 + if (oBill.Cancelltion(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.AbandonCancelltion(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 鏂板/缂栬緫 + [Route("Sc_ProcessMangement/SaveQC_NoPassProdDisposeBill")] + [HttpPost] + public object SaveQC_NoPassProdDisposeBill([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 msg3 = sArray[1].ToString(); //瀛愯〃 + string refSav = sArray[1].ToString();//鎿嶄綔鏂瑰紡鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 + string msg4 = sArray[2].ToString();//鐢ㄦ埛鍚� + + DBUtility.ClsPub.CurUserName = msg4; + + string UserName = ""; + string s = ""; + ListModels oListModels = new ListModels(); + try + { + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("QC_NoPassProdDisposeBillMain_Edit", 1, false, msg4)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + // QC_NoPassProdDisposeBill + DAL.ClsQC_NoPassProdDisposeBill oBill = new DAL.ClsQC_NoPassProdDisposeBill(); + List<Model.ClsQC_NoPassProdDisposeBillMain> lsmain = new List<Model.ClsQC_NoPassProdDisposeBillMain>(); + msg2 = msg2.Replace("\\", ""); + msg2 = msg2.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_QC_NoPassProdDisposeBill(msg2); + foreach (Model.ClsQC_NoPassProdDisposeBillMain oItem in lsmain) + { + if (refSav == "Add") + { + //鍗曟嵁鍙锋槸鍚﹂噸澶� + if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒"; + objJsonResult.data = 1; + return objJsonResult; + } + } + if (refSav == "Update") + { + if (oBill.ShowBill(oItem.HInterID, ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙紪杈� + if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = s + "锛屼笉鍏佽淇敼"; + objJsonResult.data = 1; + return objJsonResult; + } + } + UserName = oItem.HMaker; //鍒跺崟浜� + oItem.HBillType = "7514"; + oItem.HBillSubType = "7514"; + + oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); + oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); + + 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 (refSav == "Add") + { + + bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); + } + else if (refSav == "Update") + { + bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + bResult = false; + } + if (bResult) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 缂栬緫鍥炴樉鍒楄〃 + + [Route("Sc_ProcessMangement/Edit_QC_NoPassProdDisposeBill")] + [HttpGet] + public object Edit_QC_NoPassProdDisposeBill(string HID) + { + try + { + List<object> columnNameList = new List<object>(); + + string sql = "select * from h_v_QC_NoPassProdDisposeBillMain_Edit where hmainid='" + HID + "'"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdDisposeBillMain_Edit"); + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 鍒楄〃 + + [Route("Sc_ProcessMangement/Get_QC_NoPassProdDisposeBillList")] + [HttpGet] + public object Get_QC_NoPassProdDisposeBillList(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdDisposeBillMain_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + string sql = "select * from h_v_QC_NoPassProdDisposeBillMainList order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdDisposeBillMainList"); + } + else + { + string sql1 = "select * from h_v_QC_NoPassProdDisposeBillMainList where 1 = 1 "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdDisposeBillMainList"); + } + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 鍒犻櫎 + + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdDisposeBill")] + [HttpGet] + public object DeleteQC_NoPassProdDisposeBill(string HInterID, string user) + { + try + { + string s = ""; + DAL.ClsQC_NoPassProdDisposeBill BillOld = new DAL.ClsQC_NoPassProdDisposeBill(); + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdDisposeBillMain_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙垹闄� + if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdDisposeBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdDisposeBill_BeforeDelCtrl"); + 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; + } + //================================================================================== + + + + oCN.BeginTran(); + + oCN.RunProc("delete from QC_NoPassProdDisposeBillMain where HInterID = " + HInterID); + oCN.RunProc("delete from QC_NoPassProdDisposeBillSub where HInterID= " + HInterID); + + //鍒犻櫎鍚庢帶鍒�================================================================================== + string sql2 = "exec h_p_QC_NoPassProdDisposeBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_QC_NoPassProdDisposeBill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + s = ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //============================================================================================== + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 瀹℃牳/鍙嶅鏍� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/AuditQC_NoPassProdDisposeBill")] + [HttpGet] + public object AuditQC_NoPassProdDisposeBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdDisposeBillMain_Check"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdDisposeBill oBill = new DAL.ClsQC_NoPassProdDisposeBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣� + if (IsAudit == 0) //瀹℃牳鎻愪氦 + { + oCN.BeginTran(); + + //璁板綍杩斿洖淇℃伅 + string msg = ""; + + + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdDisposeBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdDisposeBill_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 (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdDisposeBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg; + objJsonResult.data = null; + return objJsonResult; + } + else + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍告彁浜� + { + + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_QC_NoPassProdDisposeBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdDisposeBill_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; + } + //=========================================================== + + //鍙嶅鏍告彁浜bandonCheck + if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdDisposeBill_AfterUnCheckCtrl", CurUserName, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 鍏抽棴/鍙嶅叧闂� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param> + /// <param name="CurUserName">鍏抽棴浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/CloseQC_NoPassProdDisposeBill")] + [HttpGet] + public object CloseQC_NoPassProdDisposeBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdDisposeBillMain_Close"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdDisposeBill oBill = new DAL.ClsQC_NoPassProdDisposeBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //鍏抽棴鍒ゆ柇 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅叧闂垽鏂� + { + if (oBill.omodel.HCloseMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣� + if (IsAudit == 0) //鍏抽棴鎻愪氦 + { + //鍏抽棴鎻愪氦 + if (oBill.CloseBill(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.CancelClose(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触鎴栬�呭弽鍏抽棴澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 浣滃簾/鍙嶄綔搴� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param> + /// <param name="CurUserName">浣滃簾浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdDisposeBill")] + [HttpGet] + public object DeleteQC_NoPassProdDisposeBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdDisposeBillMain_Drop"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdDisposeBill oBill = new DAL.ClsQC_NoPassProdDisposeBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //浣滃簾鍒ゆ柇 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶄綔搴熷垽鏂� + { + if (oBill.omodel.HDeleteMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣� + if (IsAudit == 0) //浣滃簾鎻愪氦 + { + //浣滃簾鎻愪氦 + if (oBill.Cancelltion(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.AbandonCancelltion(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗗崟 鍑虹珯鍗曚笅鎺ㄦ煡璇� + + [Route("Sc_ProcessMangement/Get_Sc_StationOutBill")] + [HttpGet] + public object Get_Sc_StationOutBill(string HID) + { + try + { + List<object> columnNameList = new List<object>(); + + string sql = "select * from h_v_MES_StationOutBillList where hmainid='" + HID + "'"; + ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList"); + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 鏂板/缂栬緫 + [Route("Sc_ProcessMangement/SaveQC_NoPassProdDisposeCheckBill")] + [HttpPost] + public object SaveQC_NoPassProdDisposeCheckBill([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 msg3 = sArray[1].ToString(); //瀛愯〃 + string refSav = sArray[1].ToString();//鎿嶄綔鏂瑰紡鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 + string msg4 = sArray[2].ToString();//鐢ㄦ埛鍚� + + DBUtility.ClsPub.CurUserName = msg4; + + string UserName = ""; + string s = ""; + ListModels oListModels = new ListModels(); + try + { + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("QC_NoPassProdDisposeCheckBillMain_Edit", 1, false, msg4)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + // QC_NoPassProdDisposeCheckBill + DAL.ClsQC_NoPassProdDisposeCheckBill oBill = new DAL.ClsQC_NoPassProdDisposeCheckBill(); + List<Model.ClsQC_NoPassProdDisposeCheckBillMain> lsmain = new List<Model.ClsQC_NoPassProdDisposeCheckBillMain>(); + msg2 = msg2.Replace("\\", ""); + msg2 = msg2.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_QC_NoPassProdDisposeCheckBill(msg2); + foreach (Model.ClsQC_NoPassProdDisposeCheckBillMain oItem in lsmain) + { + if (refSav == "Add") + { + //鍗曟嵁鍙锋槸鍚﹂噸澶� + if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒"; + objJsonResult.data = 1; + return objJsonResult; + } + } + if (refSav == "Update") + { + if (oBill.ShowBill(oItem.HInterID, ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙紪杈� + if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = s + "锛屼笉鍏佽淇敼"; + objJsonResult.data = 1; + return objJsonResult; + } + } + UserName = oItem.HMaker; //鍒跺崟浜� + oItem.HBillType = "7515"; + oItem.HBillSubType = "7515"; + + oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); + oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); + + 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 (refSav == "Add") + { + + bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); + } + else if (refSav == "Update") + { + bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + bResult = false; + } + if (bResult) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 缂栬緫鍥炴樉鍒楄〃 + + [Route("Sc_ProcessMangement/Edit_QC_NoPassProdDisposeCheckBill")] + [HttpGet] + public object Edit_QC_NoPassProdDisposeCheckBill(string HID,int num,string HBillNo, string HInterID) + { + try + { + List<object> columnNameList = new List<object>(); + // num =1 浠h〃 鏂板椤甸潰杩涜閫夌潃婧愬崟 閫氳繃 鏌ヨ 澶勭悊鍗� 鎵惧嚭 鐢宠鍗� + //num =2 浠h〃 缂栬緫鍥炴樉 + if (num==1) + { + string sql1 = "select * from h_v_QC_NoPassProdDisposeBillMain_EditPlus where 澶勭悊鍗曟嵁鍙�='" + HBillNo + "' and hinterid='"+ HInterID + "'"; + ds = oCN.RunProcReturn(sql1, "h_v_QC_NoPassProdDisposeCheckBillMain_Edit"); + } + else if(num ==2) + { + string sql = "select * from h_v_QC_NoPassProdDisposeCheckBillMain_Edit where hmainid='" + HID + "'"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdDisposeCheckBillMain_Edit"); + } + + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 鍒楄〃 + + [Route("Sc_ProcessMangement/Get_QC_NoPassProdDisposeCheckBillList")] + [HttpGet] + public object Get_QC_NoPassProdDisposeCheckBillList(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdDisposeCheckBillMain_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + string sql = "select * from h_v_QC_NoPassProdDisposeCheckBillMainList order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdDisposeCheckBillMainList"); + } + else + { + string sql1 = "select * from h_v_QC_NoPassProdDisposeCheckBillMainList where 1 = 1 "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdDisposeCheckBillMainList"); + } + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 鍒犻櫎 + + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdDisposeCheckBill")] + [HttpGet] + public object DeleteQC_NoPassProdDisposeCheckBill(string HInterID, string user) + { + try + { + string s = ""; + DAL.ClsQC_NoPassProdDisposeCheckBill BillOld = new DAL.ClsQC_NoPassProdDisposeCheckBill(); + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdDisposeCheckBillMain_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙垹闄� + if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdDisposeCheckBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdDisposeCheckBill_BeforeDelCtrl"); + 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; + } + //================================================================================== + + + + oCN.BeginTran(); + + oCN.RunProc("delete from QC_NoPassProdDisposeCheckBillMain where HInterID = " + HInterID); + oCN.RunProc("delete from QC_NoPassProdDisposeCheckBillSub where HInterID= " + HInterID); + + //鍒犻櫎鍚庢帶鍒�================================================================================== + string sql2 = "exec h_p_QC_NoPassProdDisposeCheckBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_QC_NoPassProdDisposeCheckBill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + s = ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //============================================================================================== + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 瀹℃牳/鍙嶅鏍� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/AuditQC_NoPassProdDisposeCheckBill")] + [HttpGet] + public object AuditQC_NoPassProdDisposeCheckBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdDisposeCheckBillMain_Check"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdDisposeCheckBill oBill = new DAL.ClsQC_NoPassProdDisposeCheckBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣� + if (IsAudit == 0) //瀹℃牳鎻愪氦 + { + oCN.BeginTran(); + + //璁板綍杩斿洖淇℃伅 + string msg = ""; + + + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdDisposeCheckBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdDisposeCheckBill_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 (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdDisposeCheckBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg; + objJsonResult.data = null; + return objJsonResult; + } + else + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍告彁浜� + { + + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_QC_NoPassProdDisposeCheckBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdDisposeCheckBill_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; + } + //=========================================================== + + //鍙嶅鏍告彁浜bandonCheck + if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdDisposeCheckBill_AfterUnCheckCtrl", CurUserName, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 鍏抽棴/鍙嶅叧闂� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param> + /// <param name="CurUserName">鍏抽棴浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/CloseQC_NoPassProdDisposeCheckBill")] + [HttpGet] + public object CloseQC_NoPassProdDisposeCheckBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdDisposeCheckBillMain_Close"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdDisposeCheckBill oBill = new DAL.ClsQC_NoPassProdDisposeCheckBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //鍏抽棴鍒ゆ柇 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅叧闂垽鏂� + { + if (oBill.omodel.HCloseMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣� + if (IsAudit == 0) //鍏抽棴鎻愪氦 + { + //鍏抽棴鎻愪氦 + if (oBill.CloseBill(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.CancelClose(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触鎴栬�呭弽鍏抽棴澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹″鐞嗛獙鏀跺崟 浣滃簾/鍙嶄綔搴� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param> + /// <param name="CurUserName">浣滃簾浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdDisposeCheckBill")] + [HttpGet] + public object DeleteQC_NoPassProdDisposeCheckBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdDisposeCheckBillMain_Drop"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdDisposeCheckBill oBill = new DAL.ClsQC_NoPassProdDisposeCheckBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //浣滃簾鍒ゆ柇 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶄綔搴熷垽鏂� + { + if (oBill.omodel.HDeleteMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣� + if (IsAudit == 0) //浣滃簾鎻愪氦 + { + //浣滃簾鎻愪氦 + if (oBill.Cancelltion(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.AbandonCancelltion(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 鏂板/缂栬緫 + [Route("Sc_ProcessMangement/SaveQC_NoPassProdConclusionBill")] + [HttpPost] + public object SaveQC_NoPassProdConclusionBill([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 msg3 = sArray[1].ToString(); //瀛愯〃 + string refSav = sArray[1].ToString();//鎿嶄綔鏂瑰紡鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 + string msg4 = sArray[2].ToString();//鐢ㄦ埛鍚� + + DBUtility.ClsPub.CurUserName = msg4; + + string UserName = ""; + string s = ""; + ListModels oListModels = new ListModels(); + try + { + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("QC_NoPassProdConclusionBillMain_Edit", 1, false, msg4)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + // QC_NoPassProdConclusionBill + DAL.ClsQC_NoPassProdConclusionBill oBill = new DAL.ClsQC_NoPassProdConclusionBill(); + List<Model.ClsQC_NoPassProdConclusionBillMain> lsmain = new List<Model.ClsQC_NoPassProdConclusionBillMain>(); + msg2 = msg2.Replace("\\", ""); + msg2 = msg2.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_QC_NoPassProdConclusionBill(msg2); + foreach (Model.ClsQC_NoPassProdConclusionBillMain oItem in lsmain) + { + if (refSav == "Add") + { + //鍗曟嵁鍙锋槸鍚﹂噸澶� + if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒"; + objJsonResult.data = 1; + return objJsonResult; + } + } + if (refSav == "Update") + { + if (oBill.ShowBill(oItem.HInterID, ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙紪杈� + if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = s + "锛屼笉鍏佽淇敼"; + objJsonResult.data = 1; + return objJsonResult; + } + } + UserName = oItem.HMaker; //鍒跺崟浜� + oItem.HBillType = "7513"; + oItem.HBillSubType = "7513"; + + oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); + oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); + + 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 (refSav == "Add") + { + + bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); + } + else if (refSav == "Update") + { + bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + bResult = false; + } + if (bResult) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 缂栬緫鍥炴樉鍒楄〃 + + [Route("Sc_ProcessMangement/Edit_QC_NoPassProdConclusionBill")] + [HttpGet] + public object Edit_QC_NoPassProdConclusionBill(string HID) + { + try + { + List<object> columnNameList = new List<object>(); + + string sql = "select * from h_v_QC_NoPassProdConclusionBillMain_Edit where hmainid='" + HID + "'"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdConclusionBillMain_Edit"); + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 鍒楄〃 + + [Route("Sc_ProcessMangement/Get_QC_NoPassProdConclusionBillList")] + [HttpGet] + public object Get_QC_NoPassProdConclusionBillList(string sWhere, string user) + { + try + { + List<object> columnNameList = new List<object>(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdConclusionBillMain_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + string sql = "select * from h_v_QC_NoPassProdConclusionBillMainList order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdConclusionBillMainList"); + } + else + { + string sql1 = "select * from h_v_QC_NoPassProdConclusionBillMainList where 1 = 1 "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; + ds = oCN.RunProcReturn(sql, "h_v_QC_NoPassProdConclusionBillMainList"); + } + + //娣诲姞鍒楀悕 + 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 ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 鍒犻櫎 + + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdConclusionBill")] + [HttpGet] + public object DeleteQC_NoPassProdConclusionBill(string HInterID, string user) + { + try + { + string s = ""; + DAL.ClsQC_NoPassProdConclusionBill BillOld = new DAL.ClsQC_NoPassProdConclusionBill(); + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdConclusionBillMain_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (HInterID == null || HInterID.Equals("")) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹湁璇紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒ゆ柇鏄惁鍙垹闄� + if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdConclusionBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdConclusionBill_BeforeDelCtrl"); + 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; + } + //================================================================================== + + + + oCN.BeginTran(); + + oCN.RunProc("delete from QC_NoPassProdConclusionBillMain where HInterID = " + HInterID); + oCN.RunProc("delete from QC_NoPassProdConclusionBillSub where HInterID= " + HInterID); + + //鍒犻櫎鍚庢帶鍒�================================================================================== + string sql2 = "exec h_p_QC_NoPassProdConclusionBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_QC_NoPassProdConclusionBill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + s = ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //============================================================================================== + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 瀹℃牳/鍙嶅鏍� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/AuditQC_NoPassProdConclusionBill")] + [HttpGet] + public object AuditQC_NoPassProdConclusionBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdConclusionBillMain_Check"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdConclusionBill oBill = new DAL.ClsQC_NoPassProdConclusionBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣� + if (IsAudit == 0) //瀹℃牳鎻愪氦 + { + oCN.BeginTran(); + + //璁板綍杩斿洖淇℃伅 + string msg = ""; + + + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_QC_NoPassProdConclusionBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdConclusionBill_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 (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdConclusionBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg; + objJsonResult.data = null; + return objJsonResult; + } + else + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍告彁浜� + { + + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_QC_NoPassProdConclusionBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_QC_NoPassProdConclusionBill_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; + } + //=========================================================== + + //鍙嶅鏍告彁浜bandonCheck + if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_QC_NoPassProdConclusionBill_AfterUnCheckCtrl", CurUserName, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 鍏抽棴/鍙嶅叧闂� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param> + /// <param name="CurUserName">鍏抽棴浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/CloseQC_NoPassProdConclusionBill")] + [HttpGet] + public object CloseQC_NoPassProdConclusionBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdConclusionBillMain_Close"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdConclusionBill oBill = new DAL.ClsQC_NoPassProdConclusionBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oBill.omodel.HChecker.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //鍏抽棴鍒ゆ柇 + { + if (oBill.omodel.HCloseMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅叧闂垽鏂� + { + if (oBill.omodel.HCloseMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣� + if (IsAudit == 0) //鍏抽棴鎻愪氦 + { + //鍏抽棴鎻愪氦 + if (oBill.CloseBill(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.CancelClose(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触鎴栬�呭弽鍏抽棴澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 涓嶈壇鍝佽瘎瀹$粨璁哄崟 浣滃簾/鍙嶄綔搴� + /// <summary> + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param> + /// <param name="CurUserName">浣滃簾浜�</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/DeleteQC_NoPassProdConclusionBill")] + [HttpGet] + public object DeleteQC_NoPassProdConclusionBill(int HInterID, int IsAudit, string CurUserName) + { + string ModRightNameCheck = "QC_NoPassProdConclusionBillMain_Drop"; + DBUtility.ClsPub.CurUserName = CurUserName; + try + { + //妫�鏌ユ潈闄� + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //HInterID鏁版嵁鍒ゆ柇 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsQC_NoPassProdConclusionBill oBill = new DAL.ClsQC_NoPassProdConclusionBill(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁 + { + if (oBill.omodel.HChecker.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (IsAudit == 0) //浣滃簾鍒ゆ柇 + { + if (oBill.omodel.HDeleteMan.Trim() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶄綔搴熷垽鏂� + { + if (oBill.omodel.HDeleteMan.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + + + //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣� + if (IsAudit == 0) //浣滃簾鎻愪氦 + { + //浣滃簾鎻愪氦 + if (oBill.Cancelltion(lngBillKey, 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; + } + } + if (IsAudit == 1) //鍙嶅叧闂彁浜� + { + //鍙嶅叧闂彁浜� + if (oBill.AbandonCancelltion(lngBillKey, 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; + } + } + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #endregion } } \ No newline at end of file -- Gitblit v1.9.1