public bool ChangeAscmStatus(AscmWipDiscreteJobs ascmWipDiscreteJobs, string ascmStatus)
 {
     bool result = false;
     switch (ascmStatus)
     {
         case AscmWipDiscreteJobs.AscmStatusDefine.unPrepare:
             if (string.IsNullOrEmpty(ascmWipDiscreteJobs.ascmStatus))
             {
                 ascmWipDiscreteJobs.ascmStatus = AscmWipDiscreteJobs.AscmStatusDefine.unPrepare;
                 result = true;
             }
             break;
         case AscmWipDiscreteJobs.AscmStatusDefine.preparing:
             if (ascmWipDiscreteJobs.ascmStatus == AscmWipDiscreteJobs.AscmStatusDefine.unPrepare
                 || ascmWipDiscreteJobs.ascmStatus == AscmWipDiscreteJobs.AscmStatusDefine.unPick) //根据陈志宇要求,备料状态为“待领料”的作业,如果再次备料时,状态将更改为“备料中”
             {
                 ascmWipDiscreteJobs.ascmStatus = AscmWipDiscreteJobs.AscmStatusDefine.preparing;
                 result = true;
             }
             break;
         case AscmWipDiscreteJobs.AscmStatusDefine.unPick:
             if (ascmWipDiscreteJobs.ascmStatus == AscmWipDiscreteJobs.AscmStatusDefine.preparing)
             {
                 ascmWipDiscreteJobs.ascmStatus = AscmWipDiscreteJobs.AscmStatusDefine.unPick;
                 result = true;
             }
             break;
         case AscmWipDiscreteJobs.AscmStatusDefine.picked:
             if (ascmWipDiscreteJobs.ascmStatus == AscmWipDiscreteJobs.AscmStatusDefine.unPick)
             {
                 ascmWipDiscreteJobs.ascmStatus = AscmWipDiscreteJobs.AscmStatusDefine.picked;
                 result = true;
             }
             break;
         default: break;
     }
     return result;
 }
        public List<AscmWipDiscreteJobs> GetListForMonitor(YnPage ynPage, string sortName, string sortOrder, string queryWord,
                                                string whereOther, bool isSetWipEntities = true, bool isSetScheduleGroups = false,
                                                bool isSetMaterialItem = false, bool isSetLookupValues = false)
        {
            List<AscmWipDiscreteJobs> list = new List<AscmWipDiscreteJobs>();
            try
            {
                StringBuilder strSQL = new StringBuilder();
                strSQL.Append(" SELECT a.*, b.LEADERID, b.LEADERNAME, b.SUBSTATUS,b.ID as STATUSID, b.ISSTOP ");
                strSQL.Append(" FROM ASCM_WIP_DISCRETE_JOBS a  ");
                strSQL.Append(" LEFT JOIN ASCM_WIP_DISCRETE_JOBS_STATUS b on a.wipentityid=b.wipentityid ");
                strSQL.Append(" LEFT JOIN ASCM_WIP_ENTITIES c on a.wipentityid=c.wipentityid ");

                StringBuilder strSQLCount = new StringBuilder();
                strSQLCount.Append(" SELECT count(1) ");
                strSQLCount.Append(" FROM ASCM_WIP_DISCRETE_JOBS a ");
                strSQLCount.Append(" LEFT JOIN ASCM_WIP_DISCRETE_JOBS_STATUS b on a.wipentityid=b.wipentityid ");

                string where = "", whereQueryWord = "";
                if (!string.IsNullOrEmpty(queryWord))
                    whereQueryWord = " (description like '%" + queryWord.Trim() + "%')";
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereOther);
                if (!string.IsNullOrEmpty(where))
                {
                    strSQL.Append(" WHERE " + where);
                    strSQLCount.Append(" WHERE " + where);
                }

                string sort = " ORDER BY c.NAME, a.SCHEDULEDSTARTDATE ";
                strSQL.Append(sort);

                OracleParameter[] commandParameters = new OracleParameter[] {
                            new OracleParameter {
                                ParameterName = "i_sql",
                                OracleDbType = OracleDbType.Varchar2,
                                Size = 2000,
                                Value = strSQL.ToString(),
                                Direction = ParameterDirection.Input
                            },
                            new OracleParameter {
                                ParameterName = "i_sql_count",
                                OracleDbType = OracleDbType.Varchar2,
                                Size = 2000,
                                Value = strSQLCount.ToString(),
                                Direction = ParameterDirection.Input
                            },
                            new OracleParameter {
                                ParameterName = "i_pagesize",
                                OracleDbType = OracleDbType.Int32,
                                Value = ynPage.pageSize,
                                Direction = ParameterDirection.Input
                            },
                            new OracleParameter {
                                ParameterName = "i_currentpage",
                                OracleDbType = OracleDbType.Int32,
                                Value = ynPage.currentPage,
                                Direction = ParameterDirection.Input
                            },
                            new OracleParameter {
                                ParameterName = "o_totalcount",
                                OracleDbType = OracleDbType.Int32,
                                Direction = ParameterDirection.Output
                            },
                            new OracleParameter {
                                ParameterName = "o_pagecount",
                                OracleDbType = OracleDbType.Int32,
                                Direction = ParameterDirection.Output
                            },
                            new OracleParameter {
                                ParameterName = "o_cursor",
                                OracleDbType = OracleDbType.RefCursor,
                                Direction = ParameterDirection.Output
                            }
                        };

                ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession();
                OracleCommand command = (OracleCommand)session.Connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "cux_ascm_interface_utl.sp_exec_page";
                Array.ForEach<OracleParameter>(commandParameters, P => command.Parameters.Add(P));
                OracleDataAdapter da = new OracleDataAdapter(command);
                DataSet ds = new DataSet();
                da.Fill(ds);
                DataTable dt = ds.Tables[0];

                if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        AscmWipDiscreteJobs entity = new AscmWipDiscreteJobs();
                        object objValue = null;
                        int intVal = 0;
                        decimal decimalVal = 0;
                        objValue = dr["WIPENTITYID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.wipEntityId = intVal;
                        }

                        objValue = dr["ORGANIZATIONID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.organizationId = intVal;
                        }

                        objValue = dr["CREATEUSER"];
                        if (objValue != null)
                        {
                            entity.createUser = objValue.ToString();
                        }

                        objValue = dr["CREATETIME"];
                        if (objValue != null)
                        {
                            entity.createTime = objValue.ToString();
                        }

                        objValue = dr["MODIFYUSER"];
                        if (objValue != null)
                        {
                            entity.modifyUser = objValue.ToString();
                        }

                        objValue = dr["MODIFYTIME"];
                        if (objValue != null)
                        {
                            entity.modifyTime = objValue.ToString();
                        }

                        objValue = dr["REQUESTID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.requestId = intVal;
                        }

                        objValue = dr["PROGRAMID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.programId = intVal;
                        }

                        objValue = dr["STATUSTYPE"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.statusType = intVal;
                        }

                        objValue = dr["PRIMARYITEMID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.primaryItemId = intVal;
                        }

                        objValue = dr["JOBTYPE"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.jobType = intVal;
                        }

                        objValue = dr["WIPSUPPLYTYPE"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.wipSupplyType = intVal;
                        }

                        objValue = dr["DESCRIPTION"];
                        if (objValue != null)
                        {
                            entity.description = objValue.ToString();
                        }

                        objValue = dr["CLASSCODE"];
                        if (objValue != null)
                        {
                            entity.classCode = objValue.ToString();
                        }

                        objValue = dr["MATERIALACCOUNT"];
                        if (objValue != null && decimal.TryParse(objValue.ToString(), out decimalVal))
                        {
                            entity.materialAccount = decimalVal;
                        }

                        objValue = dr["SCHEDULEDSTARTDATE"];
                        if (objValue != null)
                        {
                            entity.scheduledStartDate = objValue.ToString();
                        }

                        objValue = dr["SCHEDULEDCOMPLETIONDATE"];
                        if (objValue != null)
                        {
                            entity.scheduledCompletionDate = objValue.ToString();
                        }

                        objValue = dr["BOMREVISIONDATE"];
                        if (objValue != null)
                        {
                            entity.bomRevisionDate = objValue.ToString();
                        }

                        objValue = dr["ROUTINGREVISIONDATE"];
                        if (objValue != null)
                        {
                            entity.routingRevisionDate = objValue.ToString();
                        }

                        objValue = dr["SCHEDULEGROUPID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.scheduleGroupId = intVal;
                        }

                        objValue = dr["PRODUCTIONLINE"];
                        if (objValue != null)
                        {
                            entity.productionLine = objValue.ToString();
                        }

                        objValue = dr["NETQUANTITY"];
                        if (objValue != null && decimal.TryParse(objValue.ToString(), out decimalVal))
                        {
                            entity.netQuantity = decimalVal;
                        }

                        objValue = dr["STARTQUANTITY"];
                        if (objValue != null && decimal.TryParse(objValue.ToString(), out decimalVal))
                        {
                            entity.startQuantity = decimalVal;
                        }

                        objValue = dr["QUANTITYCOMPLETED"];
                        if (objValue != null && decimal.TryParse(objValue.ToString(), out decimalVal))
                        {
                            entity.quantityCompleted = decimalVal;
                        }

                        objValue = dr["DATERELEASED"];
                        if (objValue != null)
                        {
                            entity.dateReleased = objValue.ToString();
                        }

                        objValue = dr["DATECLOSED"];
                        if (objValue != null)
                        {
                            entity.dateClosed = objValue.ToString();
                        }

                        objValue = dr["TEMPBINDCONTAINSN"];
                        if (objValue != null)
                        {
                            entity.tempBindContainSn = objValue.ToString();
                        }

                        objValue = dr["ASCMSTATUS"];
                        entity.ascmStatus = "";
                        if (objValue != null)
                        {
                            entity.ascmStatus = objValue.ToString();
                        }

                        objValue = dr["LEADERID"];
                        if (objValue != null)
                        {
                            entity.leaderId = objValue.ToString();
                        }

                        objValue = dr["LEADERNAME"];
                        if (objValue != null)
                        {
                            entity.leaderName = objValue.ToString();
                        }

                        objValue = dr["SUBSTATUS"];
                        entity.subStatus = "";
                        if (objValue != null)
                        {
                            entity.subStatus = objValue.ToString();
                        }

                        objValue = dr["STATUSID"];
                        if (objValue != null && int.TryParse(objValue.ToString(), out intVal))
                        {
                            entity.statusId = intVal;
                        }

                        objValue = dr["ISSTOP"];
                        if (objValue != null && objValue.ToString() == "1")
                        {
                            entity.isStop = true;
                        }

                        list.Add(entity);
                    }
                }

                int totalCount = 0;
                int.TryParse(commandParameters[4].Value.ToString(), out totalCount);
                ynPage.SetRecordCount(totalCount);

                int pageCount = 0;
                int.TryParse(commandParameters[5].Value.ToString(), out pageCount);
                ynPage.pageCount = pageCount;

                if (list.Count > 0)
                {
                    if (isSetWipEntities)
                        SetWipEntities(list);
                    if (isSetScheduleGroups)
                        SetScheduleGroups(list);
                    if (isSetMaterialItem)
                        SetMaterialItem(list);
                    if (isSetLookupValues)
                        SetLookupValues(list);
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmWipDiscreteJobs)", ex);
                throw ex;
            }

            return list;
        }