|  |  | 
 |  |  |                 double HPeriod = DateTime.Now.Month; | 
 |  |  |                 string HRemark = list[0].HRemark;//备注 | 
 |  |  |                 long HICMOInterID = list[0].HICMOInterID;//任务单ID | 
 |  |  |                 long HICMOEntryID = list[0].HICMOEntryID;//任务单子ID | 
 |  |  |                 string HICMOBillNo = list[0].HICMOBillNo;//任务单 | 
 |  |  |                 long HProcPlanInterID = 0; | 
 |  |  |                 long HProcPlanEntryID = 0; | 
 |  |  | 
 |  |  |                 string HOrderProcNO = list[0].HOrderProcNO;//订单跟踪号 | 
 |  |  |                 long HPRDOrgID = list[0].HPRDOrgID;//组织ID | 
 |  |  |                 double HmaterOutqty = list[0].HmaterOutqty;//白坯发布 | 
 |  |  |                 long HMaterToSourceInterID = list[0].HMaterToSourceInterID;//上料防错单ID | 
 |  |  |                 string HMaterToSourceBillNo = list[0].HMaterToSourceBillNo;//上料防错单单据号 | 
 |  |  |                 //单据完整性判断 | 
 |  |  |                 if (HMaterID <= 0) | 
 |  |  |                 { | 
 |  |  | 
 |  |  |                     ",'" + HProcNo + "','" + HOrderProcNO + "','" + HMainInterID + "'," + HPRDOrgID + | 
 |  |  |                     ","+ HmaterOutqty + ") "); | 
 |  |  |  | 
 |  |  |                     if(HMaterToSourceInterID!=0) | 
 |  |  |                     { | 
 |  |  |                         //生成上料防错单 | 
 |  |  |                         //插入子表 | 
 |  |  |                         oCN.RunProc("EXEC h_p_Sc_MaterToSourceBillSub_Insert " + HMaterToSourceInterID.ToString() + ",'" + HMaterToSourceBillNo + "'"); | 
 |  |  |                         //插入主表 | 
 |  |  |                         oCN.RunProc("Insert Into Sc_MaterToSourceBillMain   " + | 
 |  |  |                         "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + | 
 |  |  |                         ",HYear,HPeriod,HRemark,HMaker,HMakeDate,HChecker,HCheckDate" + | 
 |  |  |                         ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" + | 
 |  |  |                         ",HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HICMOInterID,HICMOEntryID,HICMOBillNo" + | 
 |  |  |                         ",HSourceID,HProcID,HMaterID,HSourceBarCode,HEquipID,HWorkerID,HWorkerBarCode" + | 
 |  |  |                         ",HGroupID,HProcNo,HStockOrgID" + | 
 |  |  |                         ") " + | 
 |  |  |                         " values('3786','3790'," + HMaterToSourceInterID.ToString() + ",'" + HMaterToSourceBillNo + "',convert(varchar(10),getdate(),120)" + | 
 |  |  |                         ",year(getdate()),month(getdate()),'工序进站绑定生成','" + HMaker + "',getdate(),'" + HMaker + "',getdate()" + | 
 |  |  |                         "," + HInterID.ToString() + ",0,'" + HBillNo + "','3790'" + | 
 |  |  |                         "," + HProcExchInterID.ToString() + "," + HProcExchEntryID.ToString() + ",'" + HProcExchBillNo + "'," + HICMOInterID.ToString() + "," + HICMOEntryID.ToString() + ",'" + HICMOBillNo + "'" + | 
 |  |  |                         "," + HSourceID.ToString() + "," + HProcID.ToString() + "," + HMaterID.ToString() + ",'',0,0,''" + | 
 |  |  |                         "," + HGroupID.ToString() + "," + HProcNo.ToString() + "," + HPRDOrgID.ToString() + | 
 |  |  |                         ") "); | 
 |  |  |                     } | 
 |  |  |                     //写入日志 | 
 |  |  |                     LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工序进站单据:" + HBillNo); | 
 |  |  |                     oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增工序进站单据:" + HBillNo + "','LMES-工序进站模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                 } | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                  | 
 |  |  |                 //ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_QtyCtrl " + HInterID + "", "h_p_MES_StationInBill_QtyCtrl"); | 
 |  |  |                 //if (ds == null) | 
 |  |  |                 //{ | 
 |  |  |                 //    oCN.RollBack(); | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = "判断数量失败!"; | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |                 //if (ds.Tables[0].Rows.Count == 0) | 
 |  |  |                 //{ | 
 |  |  |                 //    oCN.RollBack(); | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = "判断数量失败!"; | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |                 //if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") | 
 |  |  |                 //{ | 
 |  |  |                 //    oCN.RollBack(); | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_QtyCtrl " + HInterID + "", "h_p_MES_StationInBill_QtyCtrl"); | 
 |  |  |                 if (ds == null) | 
 |  |  |                 { | 
 |  |  |                     oCN.RollBack(); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "判断数量失败!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 if (ds.Tables[0].Rows.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     oCN.RollBack(); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "判断数量失败!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") | 
 |  |  |                 { | 
 |  |  |                     oCN.RollBack(); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_In " + HInterID + ",1"); | 
 |  |  |                 //判断是否是 首道工序 | 
 |  |  |                 ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a  " + | 
 |  |  | 
 |  |  |                         objJsonResult.Verify = "N"; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //测试语句=========================================================================================================== | 
 |  |  |                 string msg_str = ""; | 
 |  |  |                 string sql_str = "select a.HQty HQty_Main,b.HQty HQty_Sub " + | 
 |  |  |                             "from Sc_ProcessExchangeBillMain as a " + | 
 |  |  |                             "inner join Sc_ProcessExchangeBillSub as b on a.HInterID = b.HInterID " + | 
 |  |  |                             "where a.HInterID = " + HProcExchInterID; | 
 |  |  |                 DataSet ds_str = oCN.RunProcReturn(sql_str, "Sc_ProcessExchangeBillMain"); | 
 |  |  |                 if (ds_str.Tables[0].Rows.Count > 0) | 
 |  |  |                 { | 
 |  |  |                     msg_str = "HQty_Main:" + ds_str.Tables[0].Rows[0]["HQty_Main"].ToString() + ";HQty_Sub:"; | 
 |  |  |                     for (int j = 0; j < ds_str.Tables[0].Rows.Count; j++) | 
 |  |  |                     { | 
 |  |  |                         msg_str += ds_str.Tables[0].Rows[j]["HQty_Sub"].ToString() + ","; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改工序进站单据:" + HBillNo + "[工序流转卡号:" + HProcExchBillNo + "]" + msg_str + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','新增或修改单据'", ref DBUtility.ClsPub.sExeReturnInfo); | 
 |  |  |                 //============================================================================================================== | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = "新增单据成功!"; | 
 |  |  | 
 |  |  |                 return true; | 
 |  |  |             } | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 工序进站接收单流水号回车获取工序信息,并根据系统参数判断进站单是否绑定配件清单 20240621 | 
 |  |  |         [Route("Cj_StationInBill/HProcNo_KeyDown")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object HProcNo_KeyDown(string HBillNo, string HProcExchBillNo, Int64 HProcNo, string HMaker) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 if (HProcExchBillNo.Equals("")) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "流转卡没有扫描,或者没有按回车键,请扫描流转卡或在流转卡文本框中按回车键!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //获取系统参数 | 
 |  |  |                 string sErrMsg = ""; | 
 |  |  |                 if (oSystemParameter.ShowBill(ref sErrMsg) == true) | 
 |  |  |                 { | 
 |  |  |                     string MES_StationInBill_LineBindCtl = "N"; //进站接收时是否绑定该工序的配件清单(Y是需要绑定,N不需要绑定) | 
 |  |  |                     string MES_StationInBill_DefQty = "4";      //工序进站时默认带入数量(1.流转卡数,2.上道合格数量,3.物料最小包装数量,4.不带入) | 
 |  |  |                     MES_StationInBill_LineBindCtl = oSystemParameter.omodel.MES_StationInBill_LineBindCtl; | 
 |  |  |                     MES_StationInBill_DefQty = oSystemParameter.omodel.MES_StationInBill_DefQty; | 
 |  |  |  | 
 |  |  |                     ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_HProcNo_KeyDown '" + HBillNo + "','" + HProcExchBillNo + "'," + HProcNo.ToString() + ",'" + MES_StationInBill_LineBindCtl + "','" + MES_StationInBill_DefQty + "','" + HMaker + "'", "h_p_MES_StationInBill_HProcNo_KeyDown"); | 
 |  |  |  | 
 |  |  |                     if (ds == null || ds.Tables[0].Rows.Count == 0) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "工序号错误或者当前工序号不允许进站,请重新输入!"; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "成功!"; | 
 |  |  |                     objJsonResult.data = ds.Tables[0]; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "获取系统参数失败! " + sErrMsg; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "工序进站接收单流水号获取信息失败!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  | 
 |  |  | Where a.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID} | 
 |  |  | ) a | 
 |  |  | inner join ( | 
 |  |  | select a.HICMOInterID,a.HICMOEntryID, b.HProcID  | 
 |  |  | select a.HICMOInterID,a.HICMOEntryID,isnull(c.HItemID,0) HProcID  | 
 |  |  | from Sc_PPBomBillMain a with(nolock)  | 
 |  |  | inner join Sc_PPBomBillSub b with(nolock)  on a.HInterID=b.HInterID | 
 |  |  | Where b.HKeyMaterID_Line<>0 | 
 |  |  | left join Gy_Process c on b.HProcName = c.HName | 
 |  |  | )b on a.HICMOInterID=b.HICMOInterID and a.HICMOEntryID=b.HICMOEntryID and a.HProcID=b.HProcID", "Sc_ProcessExchangeBillMain"); | 
 |  |  |  | 
 |  |  |                     if (ds.Tables[0].Rows.Count > 0) { | 
 |  |  | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 返回工序进站接收单列表-分页 | 
 |  |  |         [Route("Cj_StationInBill/get_Display_ByPage")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object get_Display_ByPage(string sWhere, string user, string Organization, int page, int size, string HBillSubType) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 List<object> columnNameList = new List<object>(); | 
 |  |  |  | 
 |  |  |                 if (HBillSubType == "SUB") | 
 |  |  |                 { | 
 |  |  |                     //判断是否有查询权限 | 
 |  |  |                     if (!DBUtility.ClsPub.Security_Log("Cj_StationInBill_Sub_Query", 1, false, user)) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "开工单无查询权限!"; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     //判断是否有查询权限 | 
 |  |  |                     if (!DBUtility.ClsPub.Security_Log("Cj_StationInBill_Query", 1, false, user)) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "进站单无查询权限!"; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 sWhere = sWhere.Replace("'", "''"); | 
 |  |  |  | 
 |  |  |                 if (sWhere == null || sWhere.Equals("")) | 
 |  |  |                 { | 
 |  |  |                     ds = oCN.RunProcReturn("exec h_p_MES_StationInBillList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_MES_StationInBillList"); | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     ds = oCN.RunProcReturn("exec h_p_MES_StationInBillList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_MES_StationInBillList"); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //添加列名 | 
 |  |  |                 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));//获取到DataColumn列对象的列名 | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); | 
 |  |  |                 objJsonResult.Message = "Sucess!"; | 
 |  |  |                 objJsonResult.list = columnNameList; | 
 |  |  |                 objJsonResult.data = ds.Tables[0]; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "查询数据异常,请与管理员联系!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 编辑前判断 | 
 |  |  |         [Route("Cj_StationInBill/set_ShowBillJudge")] | 
 |  |  |         [HttpGet] |