|  |  | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("Sc_MESBeginWorkBill/DeltetMESBeginWorkBill")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object DeltetMESBeginWorkBill(string HInterID,string UserName) | 
 |  |  |         public object DeltetMESBeginWorkBill(string HInterID, string UserName) | 
 |  |  |         { | 
 |  |  |             DBUtility.ClsPub.CurUserName = UserName; | 
 |  |  |             //编辑权限 | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log_second("MES_MESBeginWorkBill_Delete", 1, true, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log_second("MES_MESBeginWorkBill_Delete", 1, false, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  | 
 |  |  |         [HttpGet] | 
 |  |  |         public object AuditProcessReportList(int HInterID, int IsAudit, string CurUserName) | 
 |  |  |         { | 
 |  |  |             string ModRightNameCheck = "MES_MESBeginWorkBill_Check";  | 
 |  |  |             string ModRightNameCheck = "MES_MESBeginWorkBill_Check"; | 
 |  |  |             DBUtility.ClsPub.CurUserName = CurUserName; | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, true, CurUserName)) | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |         [HttpPost] | 
 |  |  |         public object SaveGetMESBeginWorkFrom([FromBody] JObject msg) | 
 |  |  |         { | 
 |  |  |          | 
 |  |  |  | 
 |  |  |             var _value = msg["msg"].ToString(); | 
 |  |  |             string msg1 = _value.ToString(); | 
 |  |  |             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
 |  |  | 
 |  |  |             string refSav = sArray[2].ToString(); | 
 |  |  |             DBUtility.ClsPub.CurUserName = UserName; | 
 |  |  |             //保存权限 | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log_second("MES_MESBeginWorkBill_Edit", 1, true, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log_second("MES_MESBeginWorkBill_Edit", 1, false, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         | 
 |  |  |  | 
 |  |  |             ListModels oListModels = new ListModels(); | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     DBUtility.ClsPub.CurUserName =oItem.HMaker; | 
 |  |  |                     ClsXt_SystemParameter oClsXt_SystemParameter = new ClsXt_SystemParameter(); | 
 |  |  |                     string sCapName = oClsXt_SystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                     if (sCapName.Contains("凯贝")) | 
 |  |  |                     { | 
 |  |  |                         DataTable dt = getInfodatanow(oItem.HSourceID.ToString()); | 
 |  |  |                         if (dt.Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             DataRow dr = dt.Rows[0]; | 
 |  |  |                             oItem.HRunStatus = dr["runStu"].ToString(); | 
 |  |  |                             oItem.HSourceBeginQty = Convert.ToDecimal(dr["countAll"]); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     DBUtility.ClsPub.CurUserName = oItem.HMaker; | 
 |  |  |                     oItem.HBillType = "3787"; | 
 |  |  |                     oItem.HBillSubType = "3787"; | 
 |  |  |                     oItem.HBillStatus = 1;   //单据状态(1未审,2审核通过,3关闭,4作废,5审核退回,6审核中,7已阅,8已回复,9结案,10验证,11下达,12开工,13申请审批,15申请检验,16 判定合格,17判定不合格)      | 
 |  |  | 
 |  |  |                 bool bResult; | 
 |  |  |                 if (oBill.omodel.HInterID == 0) | 
 |  |  |                 { | 
 |  |  |                     | 
 |  |  |  | 
 |  |  |                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                     if (bResult)  | 
 |  |  |                     if (bResult) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.HInterID = DBUtility.ClsPub.sExeReturnInfo; //返回主ID | 
 |  |  |                         //系统参数  自动审核 | 
 |  |  | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  | 
 |  |  |                 } | 
 |  |  |                 if (bResult) | 
 |  |  |                 { | 
 |  |  |                     | 
 |  |  |  | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "保存成功!"; | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         public DataTable getInfodatanow(string hsoucreID) | 
 |  |  |         { | 
 |  |  |             SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
 |  |  |             string sql = $" select HMacAddr, isnull(runStu,'')runStu, isnull(countAll,0)countAll from Gy_Source t1  left join HX_LIOTsys..Info_data_now t2 on t1.HMacAddr = t2.hid where t1.hitemid={hsoucreID}"; | 
 |  |  |             DataTable dt = oCn.RunProcReturn(sql, "dt").Tables[0]; | 
 |  |  |             return dt; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         #region  报工平台验证单据状态 | 
 |  |  |         [Route("Sc_MESBeginWorkBill/GetMESBeginWorkBillStaus")] | 
 |  |  | 
 |  |  |             return new SQLHelper.ClsCN().RunProcReturn(sql, "Sc_ICMOBillWorkQtyStatus_Tmp"); | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |          | 
 |  |  |  | 
 |  |  |         #region 报工平台产量汇验证汇报数量是否超出计划数量辑 | 
 |  |  |         /// <summary> | 
 |  |  |         ///  | 
 |  |  | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 ds = new SQLHelper.ClsCN().RunProcReturn("select isnull(sum(HQty),0) HQty,isnull(sum(HBadQty),0) HBadQty,isnull(sum(HWasterQty),0) HWasterQty   from Sc_ICMOBillWorkQtyStatus_Tmp with (nolock)" + sWhere, "Sc_ICMOBillWorkQtyStatus_Tmp"); | 
 |  |  |                 ds = new SQLHelper.ClsCN().RunProcReturn("select isnull(sum(HQty),0) HQty,isnull(sum(HBadCount),0) HBadQty,isnull(sum(HWasterQty),0) HWasterQty   from Sc_ICMOBillWorkQtyStatus_Tmp with (nolock)" + sWhere, "Sc_ICMOBillWorkQtyStatus_Tmp"); | 
 |  |  |                 if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  | 
 |  |  |                     if (bResult) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.HInterID = DBUtility.ClsPub.sExeReturnInfo; //返回主ID | 
 |  |  |                         //系统参数  自动审核 | 
 |  |  |                                                                                   //系统参数  自动审核 | 
 |  |  |                         string sReturn = ""; | 
 |  |  |                         if (oSystemParameter.ShowBill(ref sReturn) == true) | 
 |  |  |                         { | 
 |  |  | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("Sc_MESBeginWorkBill/MESProductAuditProcessReportList")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object MESProductAuditProcessReportList(int HSourceID,int HSourceInterID,int HSourceEntryID,string HSourceBillNo, int HICMOInterID,int HICMOEntryID, int HInterID, int IsAudit, string CurUserName) | 
 |  |  |         public object MESProductAuditProcessReportList(int HSourceID, int HSourceInterID, int HSourceEntryID, string HSourceBillNo, int HICMOInterID, int HICMOEntryID, int HInterID, int IsAudit, string CurUserName) | 
 |  |  |         { | 
 |  |  |             string ModRightNameCheck = "MES_ProcExchReport_Check"; | 
 |  |  |             DBUtility.ClsPub.CurUserName = CurUserName; | 
 |  |  | 
 |  |  |             { | 
 |  |  |                 string StrMessage = ""; | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!WebClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName,ref  StrMessage)) | 
 |  |  |                 if (!WebClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName, ref StrMessage)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                 if (IsAudit == 0) //审核提交 | 
 |  |  |                 { | 
 |  |  |                     //审核提交 | 
 |  |  |                     if (oBill.CheckBill(HSourceID, HSourceInterID,HSourceEntryID,HSourceBillNo,HICMOInterID, HICMOEntryID, lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) | 
 |  |  |                     if (oBill.CheckBill(HSourceID, HSourceInterID, HSourceEntryID, HSourceBillNo, HICMOInterID, HICMOEntryID, lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "1"; | 
 |  |  |                         objJsonResult.count = 1; | 
 |  |  | 
 |  |  |         #region 报工平台产量汇报删除 | 
 |  |  |         [Route("Sc_MESBeginWorkBill/DeltetMESProductReportBill")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object DeleteGetLineBindBillList(string HInterID,string HICMOInterID,string HICMOEntryID,string UserName) | 
 |  |  |         public object DeleteGetLineBindBillList(string HInterID, string HICMOInterID, string HICMOEntryID, string UserName) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 oCN.BeginTran(); | 
 |  |  |                 //查询产量汇报临时表数量 | 
 |  |  |                 ds = oCN.RunProcReturn("select isnull(HQty,0) HQty,isnull(HWasterQty,0) HWasterQty,isnull(HBadQty,0) HBadQty  from Sc_ICMOBillWorkQtyStatus_Tmp where HInterID='" + HInterID + "' and HICMOInterID='" + HICMOInterID + "' and HICMOEntryID='" + HICMOEntryID + "'", "Sc_ICMOBillWorkQtyStatus_Tmp"); | 
 |  |  |                 double HQty =double.Parse(ds.Tables[0].Rows[0]["HQty"].ToString()); | 
 |  |  |                 double HQty = double.Parse(ds.Tables[0].Rows[0]["HQty"].ToString()); | 
 |  |  |                 double HWasterQty = double.Parse(ds.Tables[0].Rows[0]["HWasterQty"].ToString()); | 
 |  |  |                 double HBadQty = double.Parse(ds.Tables[0].Rows[0]["HBadQty"].ToString()); | 
 |  |  |                 double sumqty = HQty + HBadQty + HWasterQty;  //汇报数量+不良+报废 | 
 |  |  |                 //更新产量装量临时表已汇报数量 | 
 |  |  |                 string sql1 = string.Format(@"update Sc_ICMOBillStatus_Tmp  set  HICMOStatus='1',HFinishFlag='0', HRelationInterID=0,HSplitRelationQty=HSplitRelationQty-" + sumqty + ",HDateFinishQty=HDateFinishQty-"+ sumqty + "   where  HICMOInterID='"+ HICMOInterID + "' and HICMOEntryID='"+ HICMOEntryID + "'"); | 
 |  |  |                                                               //更新产量装量临时表已汇报数量 | 
 |  |  |                 string sql1 = string.Format(@"update Sc_ICMOBillStatus_Tmp  set  HICMOStatus='1',HFinishFlag='0', HRelationInterID=0,HSplitRelationQty=HSplitRelationQty-" + sumqty + ",HDateFinishQty=HDateFinishQty-" + sumqty + "   where  HICMOInterID='" + HICMOInterID + "' and HICMOEntryID='" + HICMOEntryID + "'"); | 
 |  |  |                 oCN.RunProc(sql1); | 
 |  |  |                 //更新切换状态值 | 
 |  |  |                 string sql = string.Format(@"delete Sc_ICMOBillWorkQtyStatus_Tmp  where HInterID='" + HInterID + "'"); | 
 |  |  | 
 |  |  |         #region 报工平台报检申请保存 | 
 |  |  |         [Route("Sc_MESBeginWorkBill/SaveGetMESProductReportBillList")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object SaveGetMESProductReportBillList(string ScMaxWork,string HSourceBillType, string workcode,int HSourceID,int HICMOInterID,int HICMOEntryID,string HMaker,string Czybm) | 
 |  |  |         {    | 
 |  |  |         public object SaveGetMESProductReportBillList(string ScMaxWork, string HSourceBillType, string workcode, int HSourceID, int HICMOInterID, int HICMOEntryID, string HMaker, string Czybm) | 
 |  |  |         { | 
 |  |  |             ListModels oListModels = new ListModels(); | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 string sHSourceType = HSourceBillType; | 
 |  |  |                 string  BillType = "3711";  //单据类型 (生产汇报单) | 
 |  |  |                 //得到mainid | 
 |  |  |                  long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                 string BillType = "3711";  //单据类型 (生产汇报单) | 
 |  |  |                                            //得到mainid | 
 |  |  |                 long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                 //oCN.BeginTran(); | 
 |  |  |                 //根据单号、资源ID、订单主ID、订单子ID、制单人过滤产量汇报报检申请提交数据 | 
 |  |  |                 //string sql = string.Format(@"update Sc_ICMOBillWorkQtyStatus_Tmp set  | 
 |  |  | 
 |  |  |                 //ds = oCN.RunProcReturn("select top 1 * from  Sc_ICMOBillWorkQtyStatus_Tmp where HICMOReportInterID='" + HInterID + "' and HICMOReportBillNo='" + ScMaxWork + "'", "Sc_ICMOBillWorkQtyStatus_Tmp"); | 
 |  |  |                 //if (ds.Tables[0].Rows.Count <= 0) | 
 |  |  |                 //{ | 
 |  |  |                     //oCN.RollBack(); | 
 |  |  |                 //oCN.RollBack(); | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = "当前单据无产量汇报记录!"; | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |                 | 
 |  |  |  | 
 |  |  |                 WebS.ClsSc_ICMOReportBillMain model = new WebS.ClsSc_ICMOReportBillMain(); | 
 |  |  |                 model.HInterID = HInterID; | 
 |  |  |                 model.HBillNo = ScMaxWork; | 
 |  |  | 
 |  |  |                 //model.HPRDORGID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HPRDORGID"]); | 
 |  |  |                 model.HMainSourceInterID = HICMOInterID; | 
 |  |  |                 model.HMainSourceEntryID = HICMOEntryID; | 
 |  |  |                  | 
 |  |  |  | 
 |  |  |                 //oWebs.Timeout = 30000; | 
 |  |  |                 bool flag=oWebs.set_SaveICMOProductReportBill_Layui(model,workcode,HSourceID, sHSourceType, ref DBUtility.ClsPub.sErrInfo); | 
 |  |  |                 bool flag = oWebs.set_SaveICMOProductReportBill_Layui(model, workcode, HSourceID, sHSourceType, ref DBUtility.ClsPub.sErrInfo); | 
 |  |  |                 if (flag) | 
 |  |  |                 { | 
 |  |  |                     //oCN.Commit(); | 
 |  |  | 
 |  |  |                     objJsonResult.data = 1; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 else  | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     //oCN.RollBack(); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "保存失败!"+ flag+ ";"+ DBUtility.ClsPub.sErrInfo; | 
 |  |  |                     objJsonResult.Message = "保存失败!" + flag + ";" + DBUtility.ClsPub.sErrInfo; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |          | 
 |  |  |  | 
 |  |  |     } | 
 |  |  | } |