示例#1
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            RsItemMaster mItemMaster = ComboBoxItem.SelectedItem as RsItemMaster;

            if (mItemMaster == null)
            {
                return;
            }
            List <QmsCheckParam> qmsCheckParams = ws.UseService(s =>
                                                                s.GetQmsCheckParams(" USE_FLAG = 1 AND ITEM_PKNO = " + mItemMaster.PKNO + ""));

            if (qmsCheckParams.Count < 0)
            {
                return;
            }
            QmsRoutingCheck mRoutingCheck = new QmsRoutingCheck();

            mRoutingCheck.PKNO          = Guid.NewGuid().ToString("N");
            mRoutingCheck.USE_FLAG      = 1;
            mRoutingCheck.CREATION_DATE = DateTime.Now;
            //必须赋予当前产品工艺的默认工序值
            mRoutingCheck.CHECK_PARAM_PKNO = qmsCheckParams.FirstOrDefault()?.PKNO;
            ws.UseService(s => s.AddQmsRoutingCheck(mRoutingCheck));
            GetGridControlRoutingCheck();
            Getdata();
        }
示例#2
0
 /// <summary>
 /// 根据关键字段的值获取记录
 /// </summary>
 /// <param name="Id">关键字段的值</param>
 /// <returns>符合查询条件的记录</returns>
 public RsItemMaster GetRsItemMasterById(string Id)
 {
     using (IRsItemMasterBLL RsItemMasterBLL = BLLContainer.Resolve <IRsItemMasterBLL>())
     {
         RsItemMaster model = RsItemMasterBLL.GetFirstOrDefault(Id);
         return(model);
     }
 }
示例#3
0
        private void View_Closed(object sender, EventArgs e)
        {
            ItemSelectView view = sender as ItemSelectView;

            m_RsItemMaster = view.Tag as RsItemMaster;
            if (m_RsItemMaster == null)
            {
                return;
            }
            txt_Item.Text = m_RsItemMaster.ITEM_NAME;
        }
示例#4
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="mRsItemMaster">模型</param>
 /// <returns>是否成功</returns>
 public bool UpdateRsItemMaster(RsItemMaster mRsItemMaster)
 {
     if (mRsItemMaster == null)
     {
         return(false);
     }
     using (IRsItemMasterBLL RsItemMasterBLL = BLLContainer.Resolve <IRsItemMasterBLL>())
     {
         return(RsItemMasterBLL.Update(mRsItemMaster));
     }
 }
示例#5
0
 /// <summary>
 /// 按照关键字段删除
 /// </summary>
 /// <param name="Id">关键字段</param>
 /// <returns>是否成功</returns>
 public bool DelRsItemMaster(string Id)
 {
     using (IRsItemMasterBLL RsItemMasterBLL = BLLContainer.Resolve <IRsItemMasterBLL>())
     {
         try
         {
             RsItemMaster item = RsItemMasterBLL.GetFirstOrDefault(Id);
             return(RsItemMasterBLL.Delete(item));
         }
         catch { return(false); }
     }
 }
示例#6
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            //新增
            dictInfo.Header    = "产品信息  【新增】";
            gbItem.IsCollapsed = false;
            gbItem.Visibility  = Visibility.Visible;

            RsItemMaster m_RsItemMaster = new RsItemMaster()
            {
                COMPANY_CODE = "",
                USE_FLAG     = 1,
            };

            gbItem.DataContext = m_RsItemMaster;
        }
示例#7
0
        private void GetPage()
        {
            QmsCheckParam   qmsCheckParam   = ws.UseService(s => s.GetQmsCheckParamById(m_qmsCheckMaster.CHECK_PARAM_PKNO));
            QmsRoutingCheck qmsRoutingCheck = ws.UseService(s => s.GetQmsRoutingCheckById(m_qmsCheckMaster.ROUTING_CHECK_PKNO));
            RsItemMaster    rsItemMaster    = ws2.UseService(s => s.GetRsItemMasterById(qmsCheckParam.ITEM_PKNO));
            RsRoutingDetail rsRoutingDetail =
                ws2.UseService(s => s.GetRsRoutingDetailById(qmsRoutingCheck.PROCESS_PKNO));

            TextCheckMode.Text   = m_qmsCheckMaster.CHK_MODE;
            TextName.Text        = m_qmsCheckMaster.CHECK_NO + System.Environment.NewLine + rsItemMaster.ITEM_NAME;
            TextCheckSize.Text   = qmsCheckParam.MIN_SIZE + "-" + qmsCheckParam.MAX_SIZE;
            TextRoutingName.Text = rsRoutingDetail.OP_NO + "  " + rsRoutingDetail.OP_NAME + " / " +
                                   qmsCheckParam.CHECK_NAME;
            TextDevice.Text = qmsCheckParam.CHECK_DEVICE;
        }
示例#8
0
        //增加物料确定
        private void View_Closed(object sender, EventArgs e)
        {
            ItemSelectView view          = sender as ItemSelectView;
            RsItemMaster   mRsItemMaster = view?.Tag as RsItemMaster;

            if (mRsItemMaster == null)
            {
                return;
            }

            if (treeList.SelectedItem == null || mRsItemMaster.MP_FLAG == "1")  //新增产品
            {
                RsBom mRsBom = new RsBom
                {
                    PKNO        = CBaseData.NewGuid(),
                    PARENT_PKNO = "0",
                    ITEM_PKNO   = mRsItemMaster.PKNO,      //当前物料PKNO

                    CHILD_NAME  = mRsItemMaster.ITEM_NAME, //当前物料信息
                    CHILD_NORM  = mRsItemMaster.ITEM_NORM,
                    CHILD_MODEL = mRsItemMaster.ITEM_SPECS,
                    USE_FLAG    = 1
                };

                _RSMService.UseService(s => s.AddRsBom(mRsBom));
            }
            else //增加物料
            {
                RsBom mRsBom = new RsBom
                {
                    PKNO        = CBaseData.NewGuid(),
                    PARENT_PKNO = (treeList.SelectedItem as RsBom)?.PKNO,        //父节点PKNO
                    ITEM_PKNO   = mRsItemMaster.PKNO,                            //当前物料PKNO

                    PARENT_NAME = (treeList.SelectedItem as RsBom)?.PARENT_NAME, //父节点Name

                    CHILD_NAME  = mRsItemMaster.ITEM_NAME,                       //当前物料信息
                    CHILD_NORM  = mRsItemMaster.ITEM_NORM,
                    CHILD_MODEL = mRsItemMaster.ITEM_SPECS,
                    USE_FLAG    = 1
                };

                _RSMService.UseService(s => s.AddRsBom(mRsBom));
            }

            Initialize();
        }
示例#9
0
 /// <summary>
 /// 按照关键字段删除
 /// </summary>
 /// <param name="Ids">关键字段数组</param>
 /// <returns>是否成功</returns>
 public bool DelRsItemMasters(string[] Ids)
 {
     using (IRsItemMasterBLL RsItemMasterBLL = BLLContainer.Resolve <IRsItemMasterBLL>())
     {
         try
         {
             List <RsItemMaster> entitys = new List <RsItemMaster>();
             foreach (string id in Ids)
             {
                 RsItemMaster item = RsItemMasterBLL.GetFirstOrDefault(id);
                 entitys.Add(item);
             }
             return(RsItemMasterBLL.Delete(entitys));
         }
         catch { return(false); }
     }
 }
示例#10
0
        private void gridItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            RsItemMaster mRsItemMaster = gridItem.SelectedItem as RsItemMaster;

            if (mRsItemMaster == null)
            {
                return;
            }

            if (flag == 1)
            {
                mRsItemMaster.MP_FLAG = "1";
            }

            this.Tag = mRsItemMaster;
            this.Close();
        }
示例#11
0
 private void treeList_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e)
 {
     if (this.treeList.SelectedItem != null && this.treeList.SelectedItem.ToString() != "False" &&
         this.treeList.SelectedItem.ToString() != "True")
     {
         gbMenuContent.DataContext = this.treeList.SelectedItem as RsBom;
         if (
             _RSMService.UseService(
                 s =>
                 s.GetRsBoms("")
                 .Where(c => c.PKNO == (this.treeList.SelectedItem as RsBom).PARENT_PKNO))
             .ToList()
             .Count > 0)
         {
             RsBom m_RsBom =
                 _RSMService.UseService(
                     s =>
                     s.GetRsBoms("")
                     .Where(c => c.PKNO == (this.treeList.SelectedItem as RsBom).PARENT_PKNO))
                 .ToList()[0];
             txt_ParentName.Text = m_RsBom.CHILD_NAME;
             RsItemMaster m_RsItemMaster = _RSMService.UseService(s => s.GetRsItemMasterById(m_RsBom.ITEM_PKNO));
             if (m_RsItemMaster != null)
             {
                 List <RsRoutingItem> m_RsRoutingItems = _RSMService.UseService(s => s.GetRsRoutingItems(" ITEM_PKNO = " + m_RsItemMaster.PKNO + ""));
                 if (m_RsRoutingItems.Count > 0)
                 {
                     RsRoutingHead m_RsRoutingHead = _RSMService.UseService(s => s.GetRsRoutingHeadById(m_RsRoutingItems[0].ROUTING_PKNO));
                     this.txt_RoutingName.Text = m_RsRoutingHead.ROUTING_NAME;
                     List <RsRoutingDetail> m_RsRoutingDetails =
                         _RSMService.UseService(
                             s =>
                             s.GetRsRoutingDetails("ROUTING_PKNO = " + m_RsRoutingItems[0].ROUTING_PKNO + ""))
                         .OrderBy(c => c.OP_INDEX)
                         .ToList();
                     combo_Op.ItemsSource = m_RsRoutingDetails;
                     if (m_RsBom.OP_NO != null)
                     {
                         combo_Op.Text = m_RsBom.OP_NO;
                     }
                 }
             }
         }
     }
 }
示例#12
0
        private void GridControlRoutingCheck_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e)
        {
            RsItemMaster         mItemMaster   = ComboBoxItem.SelectedItem as RsItemMaster;
            List <RsRoutingItem> rsRoutingItem = ws2.UseService(s => s.GetRsRoutingItems(""));

            foreach (var item in rsRoutingItem)
            {
                if (mItemMaster != null && mItemMaster.PKNO == item.ITEM_PKNO)
                {
                    List <RsRoutingDetail> rsRoutingDetails = ws2.UseService(s =>
                                                                             s.GetRsRoutingDetails("USE_FLAG = 1 AND ROUTING_PKNO = " + item.ROUTING_PKNO + ""));
                    CmbProcessPkno.ItemsSource = rsRoutingDetails;
                }
            }

            QmsRoutingCheck mRoutingCheck = GridControlRoutingCheck.SelectedItem as QmsRoutingCheck;

            groupBox.DataContext = mRoutingCheck;
        }
示例#13
0
        private void BtnDel_Click(object sender, RoutedEventArgs e)
        {
            //删除
            RsItemMaster m_RsItemMaster = gridItem.SelectedItem as RsItemMaster;

            if (m_RsItemMaster == null)
            {
                return;
            }
            if (System.Windows.Forms.MessageBox.Show($"确定删除基础信息【{m_RsItemMaster.ITEM_NAME}】吗?",
                                                     @"删除信息",
                                                     MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                m_RsItemMaster.USE_FLAG = -1;
                ws.UseService(s => s.UpdateRsItemMaster(m_RsItemMaster));

                //删除成功.
                GetPage();  //重新加载
            }
        }
示例#14
0
        private void GetGridControlRoutingCheck()
        {
            RsItemMaster         m_ItemMaster   = ComboBoxItem.SelectedItem as RsItemMaster;
            List <QmsCheckParam> qmsCheckParams = ws.UseService(s =>
                                                                s.GetQmsCheckParams(" USE_FLAG = 1 AND ITEM_PKNO = " + m_ItemMaster.PKNO + ""));
            List <QmsRoutingCheck> qmsRoutingChecks         = ws.UseService(s => s.GetQmsRoutingChecks(" USE_FLAG = 1"));
            List <QmsRoutingCheck> qmsRoutingCheckForParams = new List <QmsRoutingCheck>();

            foreach (var itemCheckParam in qmsCheckParams)
            {
                foreach (var itQmsRoutingCheck in qmsRoutingChecks)
                {
                    if (itQmsRoutingCheck.CHECK_PARAM_PKNO == itemCheckParam.PKNO)
                    {
                        qmsRoutingCheckForParams.Add(itQmsRoutingCheck);
                    }
                }
            }
            GridControlRoutingCheck.ItemsSource = qmsRoutingCheckForParams;
        }
示例#15
0
 private List <RsItemMaster> Createm_RsItemMasters(DataTable dt)
 {
     m_RsItemMasters = new List <RsItemMaster>();
     for (int i = 2; i < dt.Rows.Count; i++)
     {
         RsItemMaster m_RsItemMaster = new RsItemMaster();
         m_RsItemMaster.PKNO       = Guid.NewGuid().ToString("N");
         m_RsItemMaster.DRAWING_NO = dt.Rows[i][0].ToString();
         m_RsItemMaster.ITEM_NAME  = dt.Rows[i][1].ToString();
         m_RsItemMaster.ITEM_SPECS = dt.Rows[i][2].ToString();
         m_RsItemMaster.ITEM_NORM  = dt.Rows[i][3].ToString();
         m_RsItemMaster.NORM_CLASS = SafeConverter.SafeToInt(dt.Rows[i][4].ToString());
         //m_RsItemMaster.THEORETICAL_WEIGHT =int.Parse( dt.Rows[i][6].ToString());
         //m_RsItemMaster.KEY_PART_NORM = dt.Rows[i][5].ToString();
         m_RsItemMaster.USE_FLAG         = int.Parse(dt.Rows[i][7].ToString());
         m_RsItemMaster.REMARK           = dt.Rows[i][8].ToString();
         m_RsItemMaster.CREATION_DATE    = DateTime.Now;
         m_RsItemMaster.CREATED_BY       = CBaseData.LoginName;
         m_RsItemMaster.LAST_UPDATE_DATE = DateTime.Now;  //最后修改日期
         m_RsItemMasters.Add(m_RsItemMaster);
     }
     return(m_RsItemMasters);
 }
示例#16
0
        private void BtnMod_Click(object sender, RoutedEventArgs e)
        {
            this.combo_routing.Text = "";
            RsItemMaster m_RsItemMaster = gridItem.SelectedItem as RsItemMaster;


            List <RsRoutingItem> m_RsRoutingItems = ws.UseService(s => s.GetRsRoutingItems(" ITEM_PKNO = " + m_RsItemMaster.PKNO + ""));

            if (m_RsRoutingItems.Count > 0)
            {
                RsRoutingHead m_RsRoutingHead = ws.UseService(s => s.GetRsRoutingHeadById(m_RsRoutingItems[0].ROUTING_PKNO));
                this.combo_routing.Text = m_RsRoutingHead.ROUTING_NAME;
            }

            if (m_RsItemMaster == null)
            {
                return;
            }
            //修改
            dictInfo.Header    = "产品信息  【修改】";
            gbItem.IsCollapsed = false;
            gbItem.Visibility  = Visibility.Visible;
        }
示例#17
0
        private void bSave_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (cmbRoutingMain.SelectedValue == null)
            {
                return;
            }

            #region 创建生产过程

            //生产线数据
            PmTaskLine taskLine = cmbTask.SelectedItem as PmTaskLine;
            //产品数据
            string       itemPKNO = cmbProduct.SelectedValue.ToString();
            RsItemMaster product  = wsRSM.UseService(s => s.GetRsItemMasterById(itemPKNO));
            if (product == null)
            {
                MessageBox.Show("产品信息不存在,请核实.", "完成生产准备", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //准备完成
            List <MesProcessCtrol> processCtrols    = new List <MesProcessCtrol>();
            List <RsRoutingDetail> rsRoutingDetails = gridProcessInfo.ItemsSource as List <RsRoutingDetail>;

            //已创建加工数量
            int     qty         = CheckPlanQTY(taskLine.TASK_NO);
            decimal preparedQty = 0;
            decimal.TryParse(tbTaskQty.Text.ToString(), out preparedQty);
            if (preparedQty <= 0)
            {
                MessageBox.Show("请输入正确的任务数量.", "完成生产准备", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            #region 判断加工数量

            if (tbTaskQty.Text.ToString() == "")
            {
                MessageBox.Show($"请输入数量", "未输入数量", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (int.Parse(tbTaskQty.Text.ToString()) + qty > taskLine.TASK_QTY)
            {
                MessageBox.Show($"输入数量超出订单加工数量", "数量超限", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion

            AmAssetMasterN mainDevice = cmbAssetInfo.SelectedItem as AmAssetMasterN;

            if (mainDevice == null)
            {
                MessageBox.Show("请选择主控PLC", "完成生产准备", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            #region 创建工单表

            MesJobOrder jobOrder = new MesJobOrder()
            {
                PKNO                = Guid.NewGuid().ToString("N"),
                COMPANY_CODE        = "",
                LINE_PKNO           = taskLine.LINE_PKNO, //产线信息
                LINE_TASK_PKNO      = taskLine.PKNO,
                ITEM_PKNO           = itemPKNO,
                JOB_ORDER_NO        = taskLine.TASK_NO + lbBatchIndex.Content.ToString(),
                BATCH_NO            = lbBatchIndex.Content.ToString(),
                ROUTING_DETAIL_PKNO = cmbRoutingMain.SelectedValue.ToString(),
                TASK_QTY            = preparedQty,
                COMPLETE_QTY        = 0,
                ONLINE_QTY          = 0,
                ONCE_QTY            = 0,
                RUN_STATE           = 1, //准备完成
                CREATION_DATE       = DateTime.Now,
                CREATED_BY          = CBaseData.LoginName,
                USE_FLAG            = 1,
                REMARK              = "",
            };

            #endregion

            List <MesProcessCtrol> newMesProcessCtrols = new List <MesProcessCtrol>();

            int iProcessIndex = 0;

            string DeviceInfos = "";
            string Programs    = "";

            #region 获取加工设备、程序号

            foreach (RsRoutingDetail item in rsRoutingDetails)
            {
                if (string.IsNullOrEmpty(item.WC_ABV))
                {
                    MessageBox.Show($"工序【{item.OP_NAME}】加工设备不能为空,请选择加工设备!",
                                    "完成生产准备", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                AmAssetMasterN device = wsEAM.UseService(s => s.GetAmAssetMasterNById(item.WC_ABV));
                if (device == null)
                {
                    MessageBox.Show($"工序【{item.OP_NAME}】加工设备,请选择加工设备!",
                                    "完成生产准备", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                DeviceInfos += device.ASSET_LABEL;  //设备
                Programs    += item.NC_PRO_NAME;    //程序号
            }

            #endregion

            wsPLM.UseService(s => s.AddMesJobOrder(jobOrder));  //添加工单

            #region 添加加工工序,共5步

            FmsActionControl ctrl1 =
                wsFMS.UseService(s => s.GetFmsActionControls($"ASSET_CODE = '{mainDevice.ASSET_CODE}' AND ACTION_NAME = '发送产品信息'"))
                .FirstOrDefault();      //
            FmsActionControl ctrl2 =
                wsFMS.UseService(s => s.GetFmsActionControls($"ASSET_CODE = '{mainDevice.ASSET_CODE}' AND ACTION_NAME = '发送数量'"))
                .FirstOrDefault();      //
            FmsActionControl ctrl3 =
                wsFMS.UseService(s => s.GetFmsActionControls($"ASSET_CODE = '{mainDevice.ASSET_CODE}' AND ACTION_NAME = '发送设备及程序号'"))
                .FirstOrDefault();      //
            FmsActionControl ctrl4 =
                wsFMS.UseService(s => s.GetFmsActionControls($"ASSET_CODE = '{mainDevice.ASSET_CODE}' AND ACTION_NAME = '订单确认'"))
                .FirstOrDefault();      //
            FmsActionControl ctrl5 =
                wsFMS.UseService(s => s.GetFmsActionControls($"ASSET_CODE = '{mainDevice.ASSET_CODE}' AND ACTION_NAME = '订单完成'"))
                .FirstOrDefault();      //

            #region 1.第一步发送产品信息

            MesProcessCtrol step1 = new MesProcessCtrol()
            {
                PKNO                        = CBaseData.NewGuid(),
                COMPANY_CODE                = "",
                JOB_ORDER_PKNO              = jobOrder.PKNO,
                JOB_ORDER                   = cmbTask.Text + lbBatchIndex.Content, //工单编号
                ITEM_PKNO                   = jobOrder.ITEM_PKNO,                  //产品PKNO
                SUB_JOB_ORDER_NO            = "",
                ROUTING_DETAIL_PKNO         = "",                                  //工序编号(工艺路线明细)为空,不按照工艺进行控制
                PROCESS_DEVICE_PKNO         = mainDevice.PKNO,                     //加工设备为 主控PLC
                PROCESS_INDEX               = 0,
                PROCESS_ACTION_TYPE         = 0,
                PROCESS_ACTION_PKNO         = (ctrl1 == null) ? "" : ctrl1.PKNO,
                PROCESS_ACTION_PARAM1_VALUE = product.ITEM_ABV, //产品简称
                PROCESS_ACTION_PARAM2_VALUE = "",
                CUR_PRODUCT_CODE_PKNO       = "",
                PROCESS_QTY                 = preparedQty,
                COMPLETE_QTY                = 0,
                QUALIFIED_QTY               = 0,
                PROCESS_STATE               = 1,
                CREATION_DATE               = DateTime.Now,
                CREATED_BY                  = CBaseData.LoginName,
                USE_FLAG                    = 1,
                REMARK                      = "系统自动形成",
            };

            #endregion end 1

            #region 2.第二步发送数量

            MesProcessCtrol step2 = new MesProcessCtrol()
            {
                PKNO                        = CBaseData.NewGuid(),
                COMPANY_CODE                = "",
                JOB_ORDER_PKNO              = jobOrder.PKNO,
                JOB_ORDER                   = cmbTask.Text + lbBatchIndex.Content, //工单编号
                ITEM_PKNO                   = jobOrder.ITEM_PKNO,                  //产品PKNO
                SUB_JOB_ORDER_NO            = "",
                ROUTING_DETAIL_PKNO         = "",                                  //工序编号(工艺路线明细)为空,不按照工艺进行控制
                PROCESS_DEVICE_PKNO         = mainDevice.PKNO,                     //加工设备为 主控PLC
                PROCESS_INDEX               = 1,
                PROCESS_ACTION_TYPE         = 0,
                PROCESS_ACTION_PKNO         = (ctrl2 == null) ? "" : ctrl2.PKNO,
                PROCESS_ACTION_PARAM1_VALUE = preparedQty.ToString(), //数量
                PROCESS_ACTION_PARAM2_VALUE = "",
                CUR_PRODUCT_CODE_PKNO       = "",
                PROCESS_QTY                 = preparedQty,
                COMPLETE_QTY                = 0,
                QUALIFIED_QTY               = 0,
                PROCESS_STATE               = 1,
                CREATION_DATE               = DateTime.Now,
                CREATED_BY                  = CBaseData.LoginName,
                USE_FLAG                    = 1,
                REMARK                      = "系统自动形成",
            };

            #endregion end 2

            #region 3.第三步发送设备及程序号

            MesProcessCtrol step3 = new MesProcessCtrol()
            {
                PKNO                        = CBaseData.NewGuid(),
                COMPANY_CODE                = "",
                JOB_ORDER_PKNO              = jobOrder.PKNO,
                JOB_ORDER                   = cmbTask.Text + lbBatchIndex.Content, //工单编号
                ITEM_PKNO                   = jobOrder.ITEM_PKNO,                  //产品PKNO
                SUB_JOB_ORDER_NO            = "",
                ROUTING_DETAIL_PKNO         = "",                                  //工序编号(工艺路线明细)为空,不按照工艺进行控制
                PROCESS_DEVICE_PKNO         = mainDevice.PKNO,                     //加工设备为 主控PLC
                PROCESS_INDEX               = 2,
                PROCESS_ACTION_TYPE         = 0,
                PROCESS_ACTION_PKNO         = (ctrl3 == null) ? "" : ctrl3.PKNO,
                PROCESS_ACTION_PARAM1_VALUE = DeviceInfos, //设备ID
                PROCESS_ACTION_PARAM2_VALUE = Programs,    //程序号
                CUR_PRODUCT_CODE_PKNO       = "",
                PROCESS_QTY                 = preparedQty,
                COMPLETE_QTY                = 0,
                QUALIFIED_QTY               = 0,
                PROCESS_STATE               = 1,
                CREATION_DATE               = DateTime.Now,
                CREATED_BY                  = CBaseData.LoginName,
                USE_FLAG                    = 1,
                REMARK                      = "系统自动形成",
            };

            #endregion end 3

            #region 4.第四步发送订单确认

            MesProcessCtrol step4 = new MesProcessCtrol()
            {
                PKNO                        = CBaseData.NewGuid(),
                COMPANY_CODE                = "",
                JOB_ORDER_PKNO              = jobOrder.PKNO,
                JOB_ORDER                   = cmbTask.Text + lbBatchIndex.Content, //工单编号
                ITEM_PKNO                   = jobOrder.ITEM_PKNO,                  //产品PKNO
                SUB_JOB_ORDER_NO            = "",
                ROUTING_DETAIL_PKNO         = "",                                  //工序编号(工艺路线明细)为空,不按照工艺进行控制
                PROCESS_DEVICE_PKNO         = mainDevice.PKNO,                     //加工设备为 主控PLC
                PROCESS_INDEX               = 3,
                PROCESS_ACTION_TYPE         = 0,
                PROCESS_ACTION_PKNO         = (ctrl4 == null) ? "" : ctrl4.PKNO,
                PROCESS_ACTION_PARAM1_VALUE = cmbTask.Text + lbBatchIndex.Content, //订单ID
                PROCESS_ACTION_PARAM2_VALUE = "",                                  //
                CUR_PRODUCT_CODE_PKNO       = "",
                PROCESS_QTY                 = preparedQty,
                COMPLETE_QTY                = 0,
                QUALIFIED_QTY               = 0,
                PROCESS_STATE               = 1,
                CREATION_DATE               = DateTime.Now,
                CREATED_BY                  = CBaseData.LoginName,
                USE_FLAG                    = 1,
                REMARK                      = "系统自动形成",
            };

            #endregion end 4

            #region 5.第五步订单完成

            MesProcessCtrol step5 = new MesProcessCtrol()
            {
                PKNO                        = CBaseData.NewGuid(),
                COMPANY_CODE                = "",
                JOB_ORDER_PKNO              = jobOrder.PKNO,
                JOB_ORDER                   = cmbTask.Text + lbBatchIndex.Content, //工单编号
                ITEM_PKNO                   = jobOrder.ITEM_PKNO,                  //产品PKNO
                SUB_JOB_ORDER_NO            = "",
                ROUTING_DETAIL_PKNO         = "",                                  //工序编号(工艺路线明细)为空,不按照工艺进行控制
                PROCESS_DEVICE_PKNO         = mainDevice.PKNO,                     //加工设备为 主控PLC
                PROCESS_INDEX               = 4,
                PROCESS_ACTION_TYPE         = 0,
                PROCESS_ACTION_PKNO         = (ctrl5 == null) ? "" : ctrl5.PKNO,
                PROCESS_ACTION_PARAM1_VALUE = "", //
                PROCESS_ACTION_PARAM2_VALUE = "", //
                CUR_PRODUCT_CODE_PKNO       = "",
                PROCESS_QTY                 = preparedQty,
                COMPLETE_QTY                = 0,
                QUALIFIED_QTY               = 0,
                PROCESS_STATE               = 1,
                CREATION_DATE               = DateTime.Now,
                CREATED_BY                  = CBaseData.LoginName,
                USE_FLAG                    = 1,
                REMARK                      = "系统自动形成",
            };

            #endregion end 5

            wsPLM.UseService(s => s.AddMesProcessCtrol(step1));
            wsPLM.UseService(s => s.AddMesProcessCtrol(step2));
            wsPLM.UseService(s => s.AddMesProcessCtrol(step3));
            wsPLM.UseService(s => s.AddMesProcessCtrol(step4));
            wsPLM.UseService(s => s.AddMesProcessCtrol(step5));

            #endregion

            #endregion

            //修改产线任务的完成数量
            taskLine.PREPARED_QTY += preparedQty;
            if (taskLine.RUN_STATE == 0)
            {
                taskLine.RUN_STATE = 1;
            }
            wsPLM.UseService(s => s.UpdatePmTaskLine(taskLine));

            cmbTask.ItemsSource =
                wsPLM.UseService(s => s.GetPmTaskLines("USE_FLAG = 1 AND RUN_STATE < 10 ")) //未完成的
                .Where(c => c.TASK_QTY > c.PREPARED_QTY)
                .OrderBy(c => c.CREATION_DATE)
                .ToList();     //生产线任务

            cmbTask.SelectedIndex       = -1;
            gridProcessInfo.ItemsSource = null;
        }
示例#18
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            //保存dictInfo
            TmsToolsMaster m_TmsToolsMaster = dictInfo.DataContext as TmsToolsMaster;

            if (m_TmsToolsMaster == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(m_TmsToolsMaster.TOOLS_CODE))
            {
                System.Windows.Forms.MessageBox.Show("请输入刀具编码!", "保存", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrEmpty(m_TmsToolsMaster.PKNO)) //新增
            {
                TmsToolsMaster check =
                    ws.UseService(s => s.GetTmsToolsMasters($"TOOLS_CODE = '{m_TmsToolsMaster.TOOLS_CODE}'"))
                    .FirstOrDefault();
                if (check != null)
                {
                    System.Windows.Forms.MessageBox.Show("该刀具编码已经存在,不能新增相同的刀具编码!", "保存", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                m_TmsToolsMaster.PKNO = Guid.NewGuid().ToString("N");

                //m_TmsToolsMaster.ITEM_PKNO = mrRsItemMaster.PKNO;
                m_TmsToolsMaster.CREATION_DATE    = DateTime.Now;
                m_TmsToolsMaster.CREATED_BY       = CBaseData.LoginName;
                m_TmsToolsMaster.LAST_UPDATE_DATE = DateTime.Now;

                ws.UseService(s => s.AddTmsToolsMaster(m_TmsToolsMaster));
            }
            else  //修改、入库、出库
            {
                TmsToolsMaster check =
                    ws.UseService(
                        s =>
                        s.GetTmsToolsMasters(
                            $"TOOLS_CODE = '{m_TmsToolsMaster.TOOLS_CODE}' AND PKNO <> '{m_TmsToolsMaster.PKNO}'"))
                    .FirstOrDefault();
                if (check != null)
                {
                    System.Windows.Forms.MessageBox.Show("该刀具编码已经存在,不能修改为该刀具编码!", "保存", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                m_TmsToolsMaster.LAST_UPDATE_DATE = DateTime.Now;
                m_TmsToolsMaster.UPDATED_BY       = CBaseData.LoginName;

                if (inbound.Visibility == Visibility.Visible) //入库 todo:需要调用WMS接口进行入库联动
                {
                    //相应追加ITEM表数据
                    RsItemMaster mrRsItemMaster = null;
                    if (m_TmsToolsMaster.ITEM_PKNO != null)
                    {
                        mrRsItemMaster = wsRSM.UseService(s => s.GetRsItemMasterById(m_TmsToolsMaster.ITEM_PKNO));
                    }
                    if (mrRsItemMaster == null)
                    {
                        mrRsItemMaster                  = new RsItemMaster();
                        mrRsItemMaster.PKNO             = Guid.NewGuid().ToString("N");
                        mrRsItemMaster.NORM_CLASS       = 101;                              //刀具录入
                        mrRsItemMaster.ITEM_NAME        = m_TmsToolsMaster.TOOLS_NAME;
                        mrRsItemMaster.DRAWING_NO       = m_TmsToolsMaster.TOOLS_TYPE_PKNO; //图号储存刀具类型
                        mrRsItemMaster.USE_FLAG         = 1;
                        mrRsItemMaster.CREATION_DATE    = DateTime.Now;
                        mrRsItemMaster.CREATED_BY       = CBaseData.LoginName;
                        mrRsItemMaster.LAST_UPDATE_DATE = DateTime.Now;  //最后修改日期
                        wsRSM.UseService(s => s.AddRsItemMaster(mrRsItemMaster));
                        m_TmsToolsMaster.ITEM_PKNO = mrRsItemMaster.PKNO;
                    }
                    m_TmsToolsMaster.TOOLS_POSITION = 1;
                    WmsInvOperate invOperate = inbound.DataContext as WmsInvOperate;
                    m_TmsToolsMaster.TOOLS_POSITION_PKNO = invOperate.ALLOCATION_PKNO;
                }
                ////todo:出库不在本次实施范围
                //if (outbound.Visibility == Visibility.Visible) //出库
                //{
                //    WmsInvOperate invOperate = outbound.DataContext as WmsInvOperate;
                //    m_TmsToolsMaster.TOOLS_POSITION = invOperate.OUT_TARGET;
                //    m_TmsToolsMaster.TOOLS_POSITION_PKNO = invOperate.INSTALL_POS;
                //}

                ws.UseService(s => s.UpdateTmsToolsMaster(m_TmsToolsMaster));
            }

            GetPage();  //重新加载

            gbItem.IsCollapsed = true;

            dictInfo.Visibility = Visibility.Collapsed;
            inbound.Visibility  = Visibility.Collapsed;
            outbound.Visibility = Visibility.Collapsed;
            BindHelper.SetDictDataBindingGridItem(dictInfo, gridItem);
        }
示例#19
0
        /// <summary>
        /// 读取设备线程
        /// </summary>
        private void TheadCheckData()
        {
            while (!CBaseData.AppClosing)
            {
                Thread.Sleep(200); //暂停
                try
                {
                    for (int i = 1; i <= 5; i++)
                    {
                        string basicAddress     = "[fuzhou]MES.JG.SB_" + i.ToString(); //基本地址
                        string qingqiuAddress   = ".Qing_qiu";                         //请求
                        string gongyiIDAddress  = ".Gongyi_ID";                        //工艺ID
                        string chanpinIDAddress = ".chanpin_ID";                       //产品ID
                        string querenAddress    = ".que_ren";                          //确认地址
                        querenAddress.Substring(0, 1);
                        FmsAssetTagSetting tag_qingqiu =
                            DeviceMonitor.GetTagSettings($"TAG_ADDRESS = '{basicAddress}{qingqiuAddress}'")
                            .FirstOrDefault();

                        if ((tag_qingqiu == null) || (tag_qingqiu.CUR_VALUE != "1"))
                        {
                            continue;
                        }

                        #region 触发请求

                        FmsAssetTagSetting tag_gongyi =
                            DeviceMonitor.GetTagSettings($"TAG_ADDRESS = '{basicAddress}{gongyiIDAddress}'")
                            .FirstOrDefault();     //工艺ID
                        if (tag_gongyi == null)
                        {
                            continue;
                        }

                        FmsAssetTagSetting tag_chanpin =
                            DeviceMonitor.GetTagSettings($"TAG_ADDRESS = '{basicAddress}{chanpinIDAddress}'")
                            .FirstOrDefault();     //产品ID
                        if (tag_chanpin == null)
                        {
                            continue;
                        }

                        FmsAssetTagSetting tag_queren =
                            DeviceMonitor.GetTagSettings($"TAG_ADDRESS = '{basicAddress}{querenAddress}'")
                            .FirstOrDefault();     //确认
                        if (tag_queren == null)
                        {
                            continue;
                        }

                        EmCheckResult checkResult = EmCheckResult.NoCheck; //无校验

                        #region 1.校验程序号

                        AmAssetMasterN checkDevice =
                            wsEAM.UseService(s => s.GetAmAssetMasterNs($"USE_FLAG = 1 AND ASSET_TYPE = '机床' AND ASSET_LABEL = '{i.ToString()}'"))
                            .FirstOrDefault();

                        if (checkDevice == null)
                        {
                            Console.WriteLine("...error:没有相应的机床设备.");
                            continue;
                        }

                        FmsAssetTagSetting tag_focas =
                            DeviceMonitor.GetTagSettings(
                                $"ASSET_CODE = '{checkDevice.ASSET_CODE}' AND TAG_ADDRESS = '程序号'")
                            .FirstOrDefault();     //获取程序号

                        if ((tag_focas != null) &&
                            (tag_focas.CUR_VALUE == tag_gongyi.CUR_VALUE)) //程序号相同
                        {
                            checkResult = EmCheckResult.Success;
                        }
                        else
                        {
                            checkResult = EmCheckResult.ProgramError;
                        }

                        #endregion

                        #region 2.校验产品

                        MesJobOrder curJob =
                            wsPlm.UseService(s => s.GetMesJobOrders($"RUN_STATE = 3 AND LINE_PKNO = '{CBaseData.CurLinePKNO}'")).FirstOrDefault(); //开工确认完成的

                        if (curJob != null)
                        {
                            RsItemMaster itemMaster =
                                wsRSM.UseService(s => s.GetRsItemMasterById(curJob.ITEM_PKNO));

                            if ((itemMaster != null) && (itemMaster.ITEM_ABV == tag_chanpin.CUR_VALUE))
                            {
                                if (checkResult == EmCheckResult.Success)  //程序校验成功
                                {
                                    checkResult = EmCheckResult.Success;
                                }
                            }
                            else
                            {
                                checkResult = EmCheckResult.ProductError;
                            }
                        }
                        else
                        {
                            checkResult = EmCheckResult.ProductError;
                        }

                        #endregion

                        #region 向PLC反馈

                        FmsAssetCommParam deviceComm =
                            ws.UseService(
                                s => s.GetFmsAssetCommParams(
                                    $"ASSET_CODE = '{tag_qingqiu.ASSET_CODE}' AND USE_FLAG = 1")).FirstOrDefault();  //反馈设备

                        string        error = "";
                        OperateResult ret   = DeviceHelper.WriteDataByAddress(deviceComm.ASSET_CODE,
                                                                              deviceComm.INTERFACE_TYPE, deviceComm.COMM_ADDRESS,
                                                                              tag_queren.PKNO, tag_queren.TAG_ADDRESS,
                                                                              ((int)checkResult).ToString()); //反馈

                        #endregion

                        if (!ret.IsSuccess)
                        {
                            Console.WriteLine("...error:向设备" + tag_queren.ASSET_CODE + "反馈确认结果失败。");
                        }

                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("...error:生产过程校验错误,错误为:" + ex.Message);
                }
            }
        }
示例#20
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            //保存
            RsItemMaster m_RsItemMaster = gbItem.DataContext as RsItemMaster;

            if (m_RsItemMaster == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(m_RsItemMaster.PKNO)) //新增
            {
                m_RsItemMaster.PKNO             = Guid.NewGuid().ToString("N");
                m_RsItemMaster.NORM_CLASS       = ConvertNormEnum(comboNorm.Text);
                m_RsItemMaster.CREATION_DATE    = DateTime.Now;
                m_RsItemMaster.CREATED_BY       = CBaseData.LoginName;
                m_RsItemMaster.LAST_UPDATE_DATE = DateTime.Now;  //最后修改日期
                ws.UseService(s => s.AddRsItemMaster(m_RsItemMaster));

                //关系中间表RsRoutingItem插入信息
                RsRoutingItem m_RsRoutingItem = new RsRoutingItem();
                m_RsRoutingItem.PKNO             = Guid.NewGuid().ToString("N");
                m_RsRoutingItem.ITEM_PKNO        = m_RsItemMaster.PKNO;
                m_RsRoutingItem.CREATION_DATE    = DateTime.Now;
                m_RsRoutingItem.LAST_UPDATE_DATE = DateTime.Now;  //最后修改日期
                m_RsRoutingItem.CREATED_BY       = CBaseData.LoginName;

                RsRoutingHead m_RsRoutingHead = combo_routing.SelectedItem as RsRoutingHead;
                if (m_RsRoutingHead != null)
                {
                    m_RsRoutingItem.ROUTING_PKNO = m_RsRoutingHead.PKNO;
                    ws.UseService(s => s.AddRsRoutingItem(m_RsRoutingItem));
                }
            }
            else  //修改
            {
                m_RsItemMaster.NORM_CLASS       = ConvertNormEnum(comboNorm.Text);
                m_RsItemMaster.LAST_UPDATE_DATE = DateTime.Now;
                m_RsItemMaster.UPDATED_BY       = CBaseData.LoginName;
                ws.UseService(s => s.UpdateRsItemMaster(m_RsItemMaster));
                //关系中间表RsRoutingItem修改信息

                List <RsRoutingItem> m_RsRoutingItems = ws.UseService(s => s.GetRsRoutingItems(" ITEM_PKNO = " + m_RsItemMaster.PKNO + ""));
                if (m_RsRoutingItems.Count > 0)
                {
                    RsRoutingHead m_RsRoutingHead = combo_routing.SelectedItem as RsRoutingHead;
                    if (m_RsRoutingHead != null)
                    {
                        m_RsRoutingItems[0].ROUTING_PKNO = m_RsRoutingHead.PKNO;
                    }
                    ws.UseService(s => s.UpdateRsRoutingItem(m_RsRoutingItems[0]));
                }
                else
                {
                    //关系中间表RsRoutingItem插入信息
                    RsRoutingItem m_RsRoutingItem = new RsRoutingItem();
                    m_RsRoutingItem.PKNO             = Guid.NewGuid().ToString("N");
                    m_RsRoutingItem.ITEM_PKNO        = m_RsItemMaster.PKNO;
                    m_RsRoutingItem.CREATION_DATE    = DateTime.Now;
                    m_RsRoutingItem.LAST_UPDATE_DATE = DateTime.Now;  //最后修改日期
                    m_RsRoutingItem.CREATED_BY       = CBaseData.LoginName;

                    RsRoutingHead m_RsRoutingHead = combo_routing.SelectedItem as RsRoutingHead;
                    if (m_RsRoutingHead != null)
                    {
                        m_RsRoutingItem.ROUTING_PKNO = m_RsRoutingHead.PKNO;
                        ws.UseService(s => s.AddRsRoutingItem(m_RsRoutingItem));
                    }
                }
            }

            GetPage();  //重新加载

            gbItem.IsCollapsed = true;
            gbItem.Visibility  = Visibility.Collapsed;
            BindHelper.SetDictDataBindingGridItem(gbItem, gridItem);
        }
示例#21
0
        private Action <int, int, string, string, int, string> _showAlloc; //显示界面信息

        private void RefreshAllocation()
        {
            #region 创建显示信息的函数,提高效率

            _showAlloc = (col, lay, allInfo, goodsNO, allocProportion, palletInfo) =>
            {
                //myShelf.RefreshAlloInfo(col, lay, allInfo, goodsNO, allocProportion, palletInfo);
            };

            #endregion

            WcfClient <IWMSService> wsWMS  = new WcfClient <IWMSService>();
            WcfClient <IRSMService> wsRsm1 = new WcfClient <IRSMService>();

            while (!CBaseData.AppClosing)
            {
                if (!bRefreshAllo)
                {
                    Thread.Sleep(500);
                    continue;
                }

                try
                {
                    //获取货位及库存状态
                    List <WmsAllocationInfo> allocations = wsWMS.UseService(s =>
                                                                            s.GetWmsAllocationInfos($"USE_FLAG = 1 AND AREA_PKNO = '{areaPKNO}'"));
                    List <WmsInventory> inventories = wsWMS.UseService(s => s.GetWmsInventorys($"AREA_PKNO = '{areaPKNO}'"));  //库存信息

                    for (int col = 1; col <= totalColumn; col++)
                    {
                        for (int lay = 1; lay <= totalLayer; lay++)
                        {
                            WmsAllocationInfo allocation =
                                allocations.FirstOrDefault(c => c.ALLOCATION_COL == col && c.ALLOCATION_LAY == lay);

                            var    col1           = col;
                            var    lay1           = lay;
                            string allInfo        = "";
                            string goodsNO        = "";
                            int    alloproportion = -1; //禁用
                            string palletInfo     = "";

                            if (allocation != null)
                            {
                                alloproportion = SafeConverter.SafeToInt(allocation.ALLOCATION_STATE);
                                palletInfo     = allocation.ALLOCATION_NAME;

                                var inv = inventories.FirstOrDefault(c => c.ALLOCATION_PKNO == allocation.PKNO);
                                if (inv != null)  //有库存
                                {
                                    goodsNO = inv.MATERIAL_PKNO;
                                    RsItemMaster item =
                                        wsRsm1.UseService(s => s.GetRsItemMasterById(inv.MATERIAL_PKNO));
                                    if (item != null)
                                    {
                                        allInfo = item.ITEM_NAME + " (" + inv.INVENTORY_NUM?.ToString("f0") + ")";
                                    }
                                }
                            }

                            //显示信息
                            Dispatcher.BeginInvoke(_showAlloc, col1, lay1, allInfo, goodsNO, alloproportion, palletInfo);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                Thread.Sleep(1000);
            }
        }
示例#22
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();
        }