public IList <CV_BPM_LINE> GetLine(string workshopID)
        {
            IList <CV_BPM_LINE> list = new List <CV_BPM_LINE>();

            if (!string.IsNullOrEmpty(workshopID))
            {
                CV_BPM_LINE_QueryParam line = new CV_BPM_LINE_QueryParam();
                line.WorkshopID = workshopID;
                list            = VLineBO.GetEntities(line);
                return(list);
            }
            return(list);
        }
        public HttpResponseMessage Addline(PM_BPM_LINE definitions)
        {
            definitions.CreatedOn = DateTime.Now;
            CV_BPM_LINE_QueryParam lineQueray = new CV_BPM_LINE_QueryParam();

            lineQueray.LineID = definitions.LineID;

            IList <CV_BPM_LINE> list = lineBO.GetEntities(lineQueray);

            if (list.Count != 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "该产线已经存在"));
            }
            else
            {
                definitions.CreatedOn = DateTime.Now;
                definitions.LineGuid  = Guid.NewGuid();
                if (string.IsNullOrEmpty(definitions.PlantID))
                {
                    definitions.PlantID = "H006";
                }
                definitions.UpdatedOn = DateTime.Now;
                if (string.IsNullOrEmpty(definitions.UpdatedBy))
                {
                    definitions.UpdatedBy = definitions.CreatedBy;
                }
                if (string.IsNullOrEmpty(definitions.WorkshopGuid.ToString()))
                {
                    IPM_BPM_WORKSHOPBO         WorkShopBO = ObjectContainer.BuildUp <IPM_BPM_WORKSHOPBO>();
                    PM_BPM_WORKSHOP_QueryParam pm         = new PM_BPM_WORKSHOP_QueryParam();
                    pm.WorkshopID = definitions.DepartID;
                    IList <PM_BPM_WORKSHOP> nn = WorkShopBO.GetEntities(pm);

                    if (nn.Count > 0)
                    {
                        definitions.WorkshopGuid = nn[0].WorkshopGuid;
                    }
                }

                PM_BPM_LINE mmExt = linebo.Insert(definitions);
                if (mmExt != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "新增成功"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, "新增失败"));
                }
            }
        }
        public IList <CV_BPM_LINE> GetVLine(CV_BPM_LINE_QueryParam line) //传入的参数是对象,用Post,不能用Get
        {
            IList <CV_BPM_LINE> list = new List <CV_BPM_LINE>();

            if (line != null)
            {
                list = VLineBO.GetEntities(line);
                List <CV_BPM_LINE> _list = (from l in list
                                            orderby l.LineID
                                            select l).ToList();
                return(_list);
            }
            return(list);
        }
        /// <summary>
        /// 按条件查询,可分页
        /// </summary>
        /// <param name="User"></param>
        /// <returns></returns>
        public IList <CV_BPM_LINE> GetLine(CV_BPM_LINE_QueryParam line) //传入的参数是对象,用Post,不能用Get
        {
            //return JsonConvert.SerializeObject(User);

            //return suppliersBO.GetAll();
            //return User.ID.ToString();
            IList <CV_BPM_LINE> list = new List <CV_BPM_LINE>();

            if (line != null)
            {
                list = lineBO.GetEntities(line);
                List <CV_BPM_LINE> _list = (from l in list
                                            orderby l.LineID
                                            select l).ToList();
                return(_list);
            }
            return(list);
        }
        public CustParentNode createTerminalTree()
        {
            CustParentNode parentNode = new CustParentNode()
            {
                value    = "root",
                title    = "工位设备管理",
                children = new List <CustLeafNode>()
            };
            CV_BPM_LINE_QueryParam     cv_lineParam     = new CV_BPM_LINE_QueryParam();
            CV_BPM_TERMINAL_QueryParam cv_terminalParam = new CV_BPM_TERMINAL_QueryParam();
            FactoryModelerController   modeler          = new FactoryModelerController();
            //获得所有工厂
            IList <PM_BPM_PLANT> plants = modeler.GetAllPlant();

            if (plants != null && plants.Count > 0)
            {
                //获得所有车间
                IList <FactoryModelerController.WORKSHOP> workshops = modeler.GetAllWorkShop();
                if (workshops != null && workshops.Count > 0)
                {
                    foreach (PM_BPM_PLANT plant in plants)
                    {
                        CustParentNode plantNode = new CustParentNode()
                        {
                            value    = plant.PlantGuid.ToString(),
                            title    = plant.PlantName,
                            children = new List <CustLeafNode>()
                        };
                        cv_lineParam.PlantGuid = plant.PlantGuid;
                        foreach (FactoryModelerController.WORKSHOP workshop in workshops)
                        {
                            //根据车间,产线Guid获得产线
                            cv_lineParam.WorkshopID = workshop.WorkshopID;
                            IList <CV_BPM_LINE> lines = modeler.GetVLine(cv_lineParam);
                            if (lines != null && lines.Count > 0)
                            {
                                CustParentNode workshopNode = new CustParentNode()
                                {
                                    value    = workshop.WorkshopID,
                                    title    = workshop.WorkshopID,
                                    children = new List <CustLeafNode>()
                                };

                                plantNode.children.Add(workshopNode);

                                foreach (CV_BPM_LINE line in lines)
                                {
                                    //获得某产线的工位
                                    cv_terminalParam.LineGuid = line.LineGuid;
                                    IList <CV_BPM_TERMINAL> terminals = modeler.GetVTerminals(cv_terminalParam);
                                    if (terminals != null && terminals.Count > 0)
                                    {
                                        CustParentNode lineNode = new CustParentNode()
                                        {
                                            value    = line.LineGuid.ToString(),
                                            title    = line.LineName,
                                            children = new List <CustLeafNode>()
                                        };
                                        workshopNode.children.Add(lineNode);
                                        foreach (CV_BPM_TERMINAL terminal in terminals)
                                        {
                                            CustLeafNode terminalNode = new CustLeafNode()
                                            {
                                                value  = terminal.TerminalGuid.ToString(),
                                                id     = terminal.TerminalID,
                                                title  = terminal.TerminalName + " " + terminal.TerminalID,
                                                isLeaf = true
                                            };
                                            lineNode.children.Add(terminalNode);
                                        }
                                    }
                                    else
                                    {
                                        CustLeafNode lineNode = new CustLeafNode()
                                        {
                                            value = line.LineGuid.ToString(),
                                            title = line.LineName
                                        };
                                        workshopNode.children.Add(lineNode);
                                    }
                                }
                            }
                            else
                            {
                                CustLeafNode workshopNode = new CustLeafNode()
                                {
                                    value = workshop.WorkshopID,
                                    title = workshop.WorkshopID
                                };
                                plantNode.children.Add(workshopNode);
                            }
                        }
                        parentNode.children.Add(plantNode);
                    }
                }
                else
                {
                    foreach (PM_BPM_PLANT plant in plants)
                    {
                        CustLeafNode plantNode = new CustLeafNode()
                        {
                            value = plant.PlantGuid.ToString(),
                            title = plant.PlantName
                        };
                        parentNode.children.Add(plantNode);
                    }
                }
            }
            return(parentNode);
        }