Exemplo n.º 1
0
        private void btnCancelAll_Click(object sender, RoutedEventArgs e)
        {
            List <MesJobOrder> mesJobOrders = gridorder.ItemsSource as List <MesJobOrder>;

            if (mesJobOrders == null)
            {
                return;
            }

            if (WPFMessageBox.ShowConfirm("确定要取消所有订单吗?", "取消所有订单") != WPFMessageBoxResult.OK)
            {
                return;
            }

            new Thread(new ThreadStart(delegate()
            {
                WaitLoading.SetWait(this);

                DeviceProcessControl.PauseByLine(CBaseData.CurLinePKNO); //暂停,防止任务直接执行
                Thread.Sleep(1000);
                List <MesJobOrder> jobs =
                    ws.UseService(s =>
                                  s.GetMesJobOrders(
                                      $"USE_FLAG = 1 AND RUN_STATE < 100 AND LINE_PKNO = '{CBaseData.CurLinePKNO}'"))
                    .OrderBy(c => c.CREATION_DATE).ToList();
                foreach (MesJobOrder job in jobs)
                {
                    job.ACT_FINISH_TIME = DateTime.Now;
                    job.RUN_STATE       = 102; //手动取消
                    ////mesJobOrder.ONCE_QTY = 1;//默认订单为1
                    ////mesJobOrder.COMPLETE_QTY = 1;
                    ws.UseService(s => s.UpdateMesJobOrder(job));

                    Thread.Sleep(100);

                    List <MesProcessCtrol> mesProcessCtrols =
                        ws.UseService(s => s.GetMesProcessCtrols("JOB_ORDER_PKNO = " + job.PKNO + ""));
                    if (mesProcessCtrols.Count < 0)
                    {
                        WaitLoading.SetDefault(this);
                        return;
                    }

                    foreach (var processCtrol in mesProcessCtrols)
                    {
                        processCtrol.PROCESS_STATE = 20; //不执行
                        ws.UseService(s => s.UpdateMesProcessCtrol(processCtrol));
                        Thread.Sleep(100);
                    }
                }

                DeviceProcessControl.RunByLine(CBaseData.CurLinePKNO); //启动动作流程

                GetPage();

                WaitLoading.SetDefault(this);
            })).Start();
        }
Exemplo n.º 2
0
        private void Btn_Start2Click(object sender, RoutedEventArgs e)
        {
            WcfClient <IPLMService> ws2     = new WcfClient <IPLMService>();
            string             LineCode     = CBaseData.CurLinePKNO;//加工单元
            List <MesJobOrder> mesJobOrders =
                ws2.UseService(s =>
                               s.GetMesJobOrders(
                                   $"USE_FLAG = 1 AND RUN_STATE < 100 AND LINE_PKNO = '{LineCode}'"))
                .OrderBy(c => c.CREATION_DATE).ToList();

            if (mesJobOrders.Count > 20)
            {
                WaitLoading.SetDefault(this);
                WPFMessageBox.ShowError("当前订单过多,请等待加工完成", "加工工单");
                return;
            }

            if (WPFMessageBox.ShowConfirm("确定下达加工工单么吗?\r\n" +
                                          "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n",
                                          "加工工单") != WPFMessageBoxResult.OK)
            {
                return;
            }

            //后台执行添加
            new Thread(delegate()
            {
                WaitLoading.SetWait(this);
                Thread.Sleep(1000);

                DateTime jobOrderTime = DateTime.Now.AddSeconds(-10);
                int iJobOrderIndex    = 0;

                List <MesJobOrder> jobOrders             = new List <MesJobOrder>();       //所有订单
                List <MesProcessCtrol> processCtrols     = new List <MesProcessCtrol>();   //控制流程
                List <WmsAllocationInfo> allocationInfos = new List <WmsAllocationInfo>(); //需要修改的货位

                Dictionary <string, string> ParamValues = new Dictionary <string, string>();
                MesJobOrder job     = null;
                string sFormulaCode = "";
                List <FmsActionFormulaDetail> formulaDetails;
                List <RsItemMaster> items = wsRsm.UseService(s => s.GetRsItemMasters("USE_FLAG = 1"));

                RsItemMaster gyroscope = items.FirstOrDefault(c => c.ITEM_NAME == "指尖陀螺"); //产品信息


                #region 2.车床上料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                                                         //ParamValues.Add("{加工数量}", this.txt_Qty2.Text);

                #endregion

                sFormulaCode = "车床上料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 3.加工中心上料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                                                         //ParamValues.Add("{加工数量}", this.txt_Qty2.Text);

                #endregion

                sFormulaCode = "加工中心上料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 4.1.AGV充电



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                                                         //ParamValues.Add("{加工数量}", this.txt_Qty2.Text);

                #endregion

                sFormulaCode = "AGV充电";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 4.2 加工中心先下料再上料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                                                         //ParamValues.Add("{加工数量}", this.txt_Qty2.Text); //生产设备

                #endregion

                sFormulaCode = "加工中心先下料再上料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 4.3.AGV充电



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                //ParamValues.Add("{加工数量}", this.txt_Qty2.Text); //生产设备

                #endregion

                sFormulaCode = "AGV充电";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 4.4 加工中心先下料再上料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                //ParamValues.Add("{加工数量}", this.txt_Qty2.Text); //生产设备

                #endregion

                sFormulaCode = "加工中心先下料再上料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion


                #region 4.3.AGV充电



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                //ParamValues.Add("{加工数量}", this.txt_Qty2.Text); //生产设备

                #endregion

                sFormulaCode = "AGV充电";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 4.4 加工中心先下料再上料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                //ParamValues.Add("{加工数量}", this.txt_Qty2.Text); //生产设备

                #endregion

                sFormulaCode = "加工中心先下料再上料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 4.3.AGV充电



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                //ParamValues.Add("{加工数量}", this.txt_Qty2.Text); //生产设备

                #endregion

                sFormulaCode = "AGV充电";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 5.加工中心下料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                                                         //ParamValues.Add("{加工数量}", this.txt_Qty2.Text);

                #endregion

                sFormulaCode = "加工中心下料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion

                #region 6.车床下料



                job = BuildNewJobOrder(gyroscope.PKNO, 2, "陀螺生产", jobOrderTime.AddSeconds(iJobOrderIndex++)); //--形成订单--
                jobOrders.Add(job);

                #region --设定参数--

                ParamValues.Clear();
                ParamValues.Add("{图片名称}", LaserPicName); //定制图片
                                                         //ParamValues.Add("{加工数量}", this.txt_Qty2.Text);

                #endregion

                sFormulaCode = "车床下料";

                #region 形成过程控制

                formulaDetails = wsFms.UseService(s =>
                                                  s.GetFmsActionFormulaDetails($"FORMULA_CODE = '{sFormulaCode}' AND USE_FLAG= 1"))
                                 .OrderBy(c => c.PROCESS_INDEX)
                                 .ToList();

                foreach (var detail in formulaDetails) //配方
                {
                    MesProcessCtrol process = BuildNewProcess(job, detail, ParamValues);

                    processCtrols.Add(process);
                }

                #endregion

                #endregion



                DeviceProcessControl.PauseByLine(CBaseData.CurLinePKNO); //暂停,防止任务直接执行

                #region 保存数据

                foreach (var allocationInfo in allocationInfos)
                {
                    ws.UseService(s => s.UpdateWmsAllocationInfo(allocationInfo));
                    Thread.Sleep(100);
                }

                foreach (var ctrol in processCtrols)
                {
                    wsPlm.UseService(s => s.AddMesProcessCtrol(ctrol));
                    Thread.Sleep(100);
                }

                foreach (var jobOrder in jobOrders) //订单
                {
                    wsPlm.UseService(s => s.AddMesJobOrder(jobOrder));
                    Thread.Sleep(100);
                }

                #endregion

                DeviceProcessControl.RunByLine(CBaseData.CurLinePKNO); //启动动作流程

                WaitLoading.SetDefault(this);

                WPFMessageBox.ShowInfo("FCS订单已下达", "指尖陀螺加工");
            }).Start();
        }
Exemplo n.º 3
0
        private void btnStop_Click(object sender, RoutedEventArgs e)
        {
            int ret = DeviceProcessControl.PauseByLine(cmbLine.SelectedValue?.ToString());

            btnPause.IsEnabled = (ret == 0);
        }