예제 #1
0
        private void BtnItemUse_Click(object sender, RoutedEventArgs e)
        {
            FmsActionFormulaMain main = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((main == null) || (string.IsNullOrEmpty(main.PKNO)))
            {
                return;
            }
            //可用明细
            FmsActionFormulaDetail detail = gridItem.SelectedItem as FmsActionFormulaDetail;

            if (detail == null)
            {
                return;
            }

            if (WPFMessageBox.ShowConfirm($"确定[{BtnItemUse.Content}]动作配方明细信息【{detail.FORMULA_DETAIL_NAME}】吗?", @"删除信息") == WPFMessageBoxResult.OK)
            {
                detail.USE_FLAG = (detail.USE_FLAG == 1) ? 0 : 1;
                ws.UseService(s => s.UpdateFmsActionFormulaDetail(detail));

                //可用成功.
                List <FmsActionFormulaDetail> details =
                    ws.UseService(s => s.GetFmsActionFormulaDetails($"FORMULA_CODE = {main.FORMULA_CODE} AND USE_FLAG >= 0"))
                    .OrderBy(c => c.PROCESS_INDEX)
                    .ToList();
                gridItem.ItemsSource = details;

                BindHelper.SetDictDataBindingGridItem(gbItem, gridItem);
            }
        }
예제 #2
0
        //向下
        private void BtnItemDown_Click(object sender, RoutedEventArgs e)
        {
            FmsActionFormulaDetail detail = gridItem.SelectedItem as FmsActionFormulaDetail;

            if (detail == null)
            {
                return;
            }

            List <FmsActionFormulaDetail> details = gridItem.ItemsSource as List <FmsActionFormulaDetail>;
            FmsActionFormulaDetail        up      = details?.FirstOrDefault(c => c.PROCESS_INDEX == detail.PROCESS_INDEX + 1);

            if (up == null)
            {
                return;
            }

            up.PROCESS_INDEX      = detail.PROCESS_INDEX; //上一个 - 1
            detail.PROCESS_INDEX += 1;                    //当前 - 1

            ws.UseService(s => s.UpdateFmsActionFormulaDetail(up));
            ws.UseService(s => s.UpdateFmsActionFormulaDetail(detail));

            tvMain_SelectedItemChanged(null, null);
            gridItem.SelectedItem = detail;
        }
예제 #3
0
        private void BtnItemAdd_Click(object sender, RoutedEventArgs e)
        {
            FmsActionFormulaMain main = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((main == null) || (string.IsNullOrEmpty(main.PKNO)))
            {
                return;
            }

            //添加明细
            dictBasic.Header   = "动作配方明细信息  【新增】";
            gbItem.IsCollapsed = false;
            gbItem.Visibility  = Visibility.Visible;

            List <FmsActionFormulaDetail> details = gridItem.ItemsSource as List <FmsActionFormulaDetail>;

            FmsActionFormulaDetail detail = new FmsActionFormulaDetail()
            {
                FORMULA_CODE  = main.FORMULA_CODE,
                PROCESS_INDEX = (details?.Count + 1) ?? 1,
                USE_FLAG      = 1,
            };

            gbItem.DataContext = detail;
        }
예제 #4
0
 /// <summary>
 /// 根据关键字段的值获取记录
 /// </summary>
 /// <param name="Id">关键字段的值</param>
 /// <returns>符合查询条件的记录</returns>
 public FmsActionFormulaDetail GetFmsActionFormulaDetailById(string Id)
 {
     using (IFmsActionFormulaDetailBLL FmsActionFormulaDetailBLL = BLLContainer.Resolve <IFmsActionFormulaDetailBLL>())
     {
         FmsActionFormulaDetail model = FmsActionFormulaDetailBLL.GetFirstOrDefault(Id);
         return(model);
     }
 }
예제 #5
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="mFmsActionFormulaDetail">模型</param>
 /// <returns>是否成功</returns>
 public bool UpdateFmsActionFormulaDetail(FmsActionFormulaDetail mFmsActionFormulaDetail)
 {
     if (mFmsActionFormulaDetail == null)
     {
         return(false);
     }
     using (IFmsActionFormulaDetailBLL FmsActionFormulaDetailBLL = BLLContainer.Resolve <IFmsActionFormulaDetailBLL>())
     {
         return(FmsActionFormulaDetailBLL.Update(mFmsActionFormulaDetail));
     }
 }
예제 #6
0
        private void BtnItemSave_Click(object sender, RoutedEventArgs e)
        {
            FmsActionFormulaMain main = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((main == null) || (string.IsNullOrEmpty(main.PKNO)))
            {
                return;
            }
            FmsActionFormulaDetail detail = gbItem.DataContext as FmsActionFormulaDetail;

            if (detail == null)
            {
                return;
            }

            #region  校验

            if (string.IsNullOrEmpty(detail.FORMULA_CODE))
            {
                WPFMessageBox.ShowWarring("请选择配方主信息。", "保存");
                return;
            }

            if (string.IsNullOrEmpty(detail.FORMULA_DETAIL_NAME))
            {
                WPFMessageBox.ShowWarring("请输入配方明细名称。", "保存");
                return;
            }

            #endregion

            if (string.IsNullOrEmpty(detail.PKNO)) //新增
            {
                detail.PKNO = CBaseData.NewGuid();

                ws.UseService(s => s.AddFmsActionFormulaDetail(detail));

                //重新刷新数据
                List <FmsActionFormulaDetail> details =
                    ws.UseService(s => s.GetFmsActionFormulaDetails($"FORMULA_CODE = {main.FORMULA_CODE} AND USE_FLAG >= 0"))
                    .OrderBy(c => c.PROCESS_INDEX)
                    .ToList();
                gridItem.ItemsSource = details;
            }
            else  //修改
            {
                ws.UseService(s => s.UpdateFmsActionFormulaDetail(detail));
            }
            //提示保存成功

            gbItem.IsCollapsed = true;
            gbItem.Visibility  = Visibility.Collapsed;
            BindHelper.SetDictDataBindingGridItem(gbItem, gridItem);
        }
예제 #7
0
 /// <summary>
 /// 按照关键字段删除
 /// </summary>
 /// <param name="Id">关键字段</param>
 /// <returns>是否成功</returns>
 public bool DelFmsActionFormulaDetail(string Id)
 {
     using (IFmsActionFormulaDetailBLL FmsActionFormulaDetailBLL = BLLContainer.Resolve <IFmsActionFormulaDetailBLL>())
     {
         try
         {
             FmsActionFormulaDetail item = FmsActionFormulaDetailBLL.GetFirstOrDefault(Id);
             return(FmsActionFormulaDetailBLL.Delete(item));
         }
         catch { return(false); }
     }
 }
예제 #8
0
        private void BtnItemCopy_Click(object sender, RoutedEventArgs e)
        {
            FmsActionFormulaMain m_MainInfo = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((m_MainInfo == null) || (string.IsNullOrEmpty(m_MainInfo.PKNO)))
            {
                return;
            }
            List <FmsActionFormulaDetail> details = ws.UseService(s => s.GetFmsActionFormulaDetails("FORMULA_CODE = " + m_MainInfo.FORMULA_CODE + ""));

            List <FmsActionFormulaDetail> newFormulaDetails    = new List <FmsActionFormulaDetail>();
            List <FmsActionControl>       newFmsActionControls = new List <FmsActionControl>();
            FmsActionFormulaMain          newFormulaMain       = m_MainInfo;

            newFormulaMain.PKNO         = Guid.NewGuid().ToString("N");
            newFormulaMain.FORMULA_NAME = "轮毂生产5(只下料,中间件检测)";
            newFormulaMain.FORMULA_CODE = "轮毂生产5 new";

            foreach (FmsActionFormulaDetail item in details)
            {
                FmsActionControl action = ws.UseService(s => s.GetFmsActionControlById(item.PROCESS_ACTION_PKNO));
                FmsActionControl newActionControlaction = action;
                #region 处理actionControl
                newActionControlaction.PKNO = Guid.NewGuid().ToString("N");
                newActionControlaction.START_CONDITION_TAG_PKNO  = GetTagPkno(newActionControlaction.START_CONDITION_TAG_PKNO);
                newActionControlaction.EXECUTE_PARAM1_TAG_PKNO   = GetTagPkno(newActionControlaction.EXECUTE_PARAM1_TAG_PKNO);
                newActionControlaction.EXECUTE_PARAM2_TAG_PKNO   = GetTagPkno(newActionControlaction.EXECUTE_PARAM2_TAG_PKNO);
                newActionControlaction.EXECUTE_TAG_PKNO          = GetTagPkno(newActionControlaction.EXECUTE_TAG_PKNO);
                newActionControlaction.FINISH_CONDITION_TAG_PKNO = GetTagPkno(newActionControlaction.FINISH_CONDITION_TAG_PKNO);
                #endregion

                FmsActionFormulaDetail newActionFormulaDetail = item;
                newActionFormulaDetail.PKNO                = Guid.NewGuid().ToString("N");
                newActionFormulaDetail.FORMULA_CODE        = newFormulaMain.FORMULA_CODE;
                newActionFormulaDetail.PROCESS_ACTION_PKNO = newActionControlaction.PKNO;
                newFormulaDetails.Add(newActionFormulaDetail);
                newFmsActionControls.Add(newActionControlaction);
            }
            foreach (var variable2 in newFormulaDetails)
            {
                ws.UseService(s => s.AddFmsActionFormulaDetail(variable2));
            }
            ws.UseService(s => s.AddFmsActionFormulaMain(newFormulaMain));
            foreach (var variable1 in newFmsActionControls)
            {
                ws.UseService(s => s.AddFmsActionControl(variable1));
            }
        }
예제 #9
0
        /// <summary>
        /// 形成过程控制信息
        /// </summary>
        /// <param name="jobOrder">订单</param>
        /// <param name="formulaDetail">配方明细</param>
        /// <param name="paramValues">参数</param>
        /// <returns></returns>
        private MesProcessCtrol BuildNewProcess(MesJobOrder jobOrder,
                                                FmsActionFormulaDetail formulaDetail, Dictionary <string, string> paramValues)
        {
            return(new MesProcessCtrol()
            {
                #region 标准信息

                PKNO = CBaseData.NewGuid(),
                COMPANY_CODE = CBaseData.BelongCompPKNO,
                ITEM_PKNO = jobOrder?.ITEM_PKNO,   //成品PKNO TODO:暂无
                JOB_ORDER_PKNO = jobOrder?.PKNO,
                JOB_ORDER = jobOrder?.JOB_ORDER_NO,
                SUB_JOB_ORDER_NO = "",
                ROUTING_DETAIL_PKNO = "",  //

                #endregion

                PROCESS_CTROL_NAME = formulaDetail.FORMULA_DETAIL_NAME,                                                            //名称
                PROCESS_DEVICE_PKNO = ProcessParamReplace.Replace(formulaDetail.PROCESS_DEVICE_PKNO, paramValues),                 //生产设备
                PROCESS_PROGRAM_NO = ProcessParamReplace.Replace(formulaDetail.PROCESS_PROGRAM_NO, paramValues),                   //加工程序号
                PROCESS_PROGRAM_CONTENT = formulaDetail.PROCESS_PROGRAM_CONTENT,                                                   //加工程序内容
                PROCESS_INDEX = formulaDetail.PROCESS_INDEX,                                                                       //工序顺序

                BEGIN_ITEM_PKNO = ProcessParamReplace.Replace(formulaDetail.BEGIN_ITEM_PKNO, paramValues),                         //生产前项目PKNO
                FINISH_ITEM_PKNO = ProcessParamReplace.Replace(formulaDetail.FINISH_ITEM_PKNO, paramValues),                       //生产后项目PKNO
                BEGIN_POSITION = ProcessParamReplace.Replace(formulaDetail.BEGIN_POSITION, paramValues),                           //生产前位置
                FINISH_POSITION = ProcessParamReplace.Replace(formulaDetail.FINISH_POSITION, paramValues),                         //生产后位置

                PALLET_NO = formulaDetail.PALLET_NO,                                                                               //托盘号
                PROCESS_ACTION_TYPE = formulaDetail.PROCESS_ACTION_TYPE,                                                           //工序动作类型
                PROCESS_ACTION_PKNO = formulaDetail.PROCESS_ACTION_PKNO,                                                           //工序动作控制PKNO

                PROCESS_ACTION_PARAM1_VALUE = ProcessParamReplace.Replace(formulaDetail.PROCESS_ACTION_PARAM1_VALUE, paramValues), //工序动作参数1
                PROCESS_ACTION_PARAM2_VALUE = ProcessParamReplace.Replace(formulaDetail.PROCESS_ACTION_PARAM2_VALUE, paramValues), //工序动作参数2

                CUR_PRODUCT_CODE_PKNO = "",                                                                                        //当前生产加工的产品编码PKNO
                PROCESS_QTY = 1,                                                                                                   //加工数量(上线数量)
                COMPLETE_QTY = 0,                                                                                                  //完成数量
                QUALIFIED_QTY = 0,                                                                                                 //合格数量
                PROCESS_STATE = 1,                                                                                                 //准备完成

                CREATION_DATE = DateTime.Now,                                                                                      //创建日期
                CREATED_BY = CBaseData.LoginNO,                                                                                    //创建人
                LAST_UPDATE_DATE = DateTime.Now,                                                                                   //最后修改日期
                USE_FLAG = formulaDetail.USE_FLAG,                                                                                 //启用标识
                REMARK = "",                                                                                                       //备注
            });
        }
예제 #10
0
 /// <summary>
 /// 按照关键字段删除
 /// </summary>
 /// <param name="Ids">关键字段数组</param>
 /// <returns>是否成功</returns>
 public bool DelFmsActionFormulaDetails(string[] Ids)
 {
     using (IFmsActionFormulaDetailBLL FmsActionFormulaDetailBLL = BLLContainer.Resolve <IFmsActionFormulaDetailBLL>())
     {
         try
         {
             List <FmsActionFormulaDetail> entitys = new List <FmsActionFormulaDetail>();
             foreach (string id in Ids)
             {
                 FmsActionFormulaDetail item = FmsActionFormulaDetailBLL.GetFirstOrDefault(id);
                 entitys.Add(item);
             }
             return(FmsActionFormulaDetailBLL.Delete(entitys));
         }
         catch { return(false); }
     }
 }
예제 #11
0
        private void CmbActionControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (gbItem.Visibility != Visibility.Visible)
            {
                return;
            }
            FmsActionFormulaDetail detail = gbItem.DataContext as FmsActionFormulaDetail;

            if ((detail == null) || (!string.IsNullOrEmpty(detail.PROCESS_DEVICE_PKNO)))
            {
                return;
            }

            FmsActionControl action = cmbActionControl.SelectedItem as FmsActionControl;

            detail.PROCESS_DEVICE_PKNO = action?.ASSET_CODE;
        }
예제 #12
0
        private void GridItem_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
        {
            FmsActionFormulaMain main = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((main == null) || (string.IsNullOrEmpty(main.PKNO)))
            {
                return;
            }

            FmsActionFormulaDetail detail = gridItem.SelectedItem as FmsActionFormulaDetail;

            if (detail == null)
            {
                return;
            }

            BtnItemUse.Content = (detail.USE_FLAG == 1) ? "禁用" : "启用";
        }
예제 #13
0
        private void GridItem_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
        {
            FmsActionFormulaMain main = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((main == null) || (string.IsNullOrEmpty(main.PKNO)))
            {
                return;
            }

            FmsActionFormulaDetail detail = gridItem.SelectedItem as FmsActionFormulaDetail;

            if (detail == null)
            {
                return;
            }

            BtnItemUse.Content = (detail.USE_FLAG == 1) ? "禁用" : "启用";

            FmsActionControl action = ws.UseService(s => s.GetFmsActionControlById(detail.PROCESS_ACTION_PKNO));

            if (action == null)
            {
                cmbCondition.SelectedValue = null;
                tbConditionValue.Text      = "";
                cmbExecute.SelectedValue   = null;
                tbExecuteValue.Text        = "";
                cmbParam1.SelectedValue    = null;
                cmbParam2.SelectedValue    = null;
                cmbFinish.SelectedValue    = null;
                tbFinishValue.Text         = "";
            }
            else
            {
                cmbCondition.SelectedValue = action.START_CONDITION_TAG_PKNO;
                tbConditionValue.Text      = action.START_CONDITION_VALUE;
                cmbExecute.SelectedValue   = action.EXECUTE_TAG_PKNO;
                tbExecuteValue.Text        = action.EXECUTE_WRITE_VALUE;
                cmbParam1.SelectedValue    = action.EXECUTE_PARAM1_TAG_PKNO;
                cmbParam2.SelectedValue    = action.EXECUTE_PARAM2_TAG_PKNO;
                cmbFinish.SelectedValue    = action.FINISH_CONDITION_TAG_PKNO;
                tbFinishValue.Text         = action.FINISH_CONDITION_VALUE;
            }
        }
예제 #14
0
        private void BtnItemSave_Click(object sender, RoutedEventArgs e)
        {
            FmsActionFormulaMain main = tvMain.SelectedItem as FmsActionFormulaMain;

            if ((main == null) || (string.IsNullOrEmpty(main.PKNO)))
            {
                return;
            }
            FmsActionFormulaDetail detail = gbItem.DataContext as FmsActionFormulaDetail;

            if (detail == null)
            {
                return;
            }

            #region  校验

            if (string.IsNullOrEmpty(detail.FORMULA_CODE))
            {
                WPFMessageBox.ShowWarring("请选择配方主信息。", "保存");
                return;
            }

            if (string.IsNullOrEmpty(detail.FORMULA_DETAIL_NAME))
            {
                WPFMessageBox.ShowWarring("请输入配方明细名称。", "保存");
                return;
            }

            #endregion

            if (string.IsNullOrEmpty(detail.PKNO)) //新增
            {
                detail.PKNO = CBaseData.NewGuid();

                FmsActionControl action = new FmsActionControl()
                {
                    PKNO        = CBaseData.NewGuid(),
                    ACTION_NAME = detail.FORMULA_DETAIL_NAME,
                    ACTION_TYPE = detail.PROCESS_ACTION_TYPE.ToString(),
                    START_CONDITION_TAG_PKNO  = string.IsNullOrEmpty(cmbCondition.Text)? "": cmbCondition.SelectedValue.ToString(),
                    START_CONDITION_VALUE     = tbConditionValue.Text,
                    EXECUTE_TAG_PKNO          = string.IsNullOrEmpty(cmbExecute.Text) ? "" : cmbExecute.SelectedValue.ToString(),
                    EXECUTE_WRITE_VALUE       = tbExecuteValue.Text,
                    EXECUTE_PARAM1_TAG_PKNO   = string.IsNullOrEmpty(cmbParam1.Text) ? "" : cmbParam1.SelectedValue.ToString(),
                    EXECUTE_PARAM2_TAG_PKNO   = string.IsNullOrEmpty(cmbParam2.Text) ? "" : cmbParam2.SelectedValue.ToString(),
                    FINISH_CONDITION_TAG_PKNO = string.IsNullOrEmpty(cmbFinish.Text) ? "" : cmbFinish.SelectedValue.ToString(),
                    FINISH_CONDITION_VALUE    = tbFinishValue.Text,
                };

                detail.PROCESS_ACTION_PKNO = action.PKNO;

                ws.UseService(s => s.AddFmsActionControl(action));

                ws.UseService(s => s.AddFmsActionFormulaDetail(detail));

                //重新刷新数据
                List <FmsActionFormulaDetail> details =
                    ws.UseService(s => s.GetFmsActionFormulaDetails($"FORMULA_CODE = {main.FORMULA_CODE} AND USE_FLAG >= 0"))
                    .OrderBy(c => c.PROCESS_INDEX)
                    .ToList();
                gridItem.ItemsSource = details;
            }
            else  //修改
            {
                FmsActionControl action = ws.UseService(s => s.GetFmsActionControlById(detail.PROCESS_ACTION_PKNO));
                if (action == null)
                {
                    action = new FmsActionControl()
                    {
                        PKNO        = CBaseData.NewGuid(),
                        ACTION_NAME = detail.FORMULA_DETAIL_NAME,
                        ACTION_TYPE = detail.PROCESS_ACTION_TYPE.ToString(),
                        START_CONDITION_TAG_PKNO  = string.IsNullOrEmpty(cmbCondition.Text) ? "" : cmbCondition.SelectedValue.ToString(),
                        START_CONDITION_VALUE     = tbConditionValue.Text,
                        EXECUTE_TAG_PKNO          = string.IsNullOrEmpty(cmbExecute.Text) ? "" : cmbExecute.SelectedValue.ToString(),
                        EXECUTE_WRITE_VALUE       = tbExecuteValue.Text,
                        EXECUTE_PARAM1_TAG_PKNO   = string.IsNullOrEmpty(cmbParam1.Text) ? "" : cmbParam1.SelectedValue.ToString(),
                        EXECUTE_PARAM2_TAG_PKNO   = string.IsNullOrEmpty(cmbParam2.Text) ? "" : cmbParam2.SelectedValue.ToString(),
                        FINISH_CONDITION_TAG_PKNO = string.IsNullOrEmpty(cmbFinish.Text) ? "" : cmbFinish.SelectedValue.ToString(),
                        FINISH_CONDITION_VALUE    = tbFinishValue.Text,
                    };

                    detail.PROCESS_ACTION_PKNO = action.PKNO;

                    ws.UseService(s => s.AddFmsActionControl(action));
                }
                else //修改控制
                {
                    action.ACTION_NAME = detail.FORMULA_DETAIL_NAME;
                    action.ACTION_TYPE = detail.PROCESS_ACTION_TYPE.ToString();
                    action.START_CONDITION_TAG_PKNO = string.IsNullOrEmpty(cmbCondition.Text)
                        ? ""
                        : cmbCondition.SelectedValue.ToString();
                    action.START_CONDITION_VALUE = tbConditionValue.Text;
                    action.EXECUTE_TAG_PKNO      =
                        string.IsNullOrEmpty(cmbExecute.Text) ? "" : cmbExecute.SelectedValue.ToString();
                    action.EXECUTE_WRITE_VALUE     = tbExecuteValue.Text;
                    action.EXECUTE_PARAM1_TAG_PKNO =
                        string.IsNullOrEmpty(cmbParam1.Text) ? "" : cmbParam1.SelectedValue.ToString();
                    action.EXECUTE_PARAM2_TAG_PKNO =
                        string.IsNullOrEmpty(cmbParam2.Text) ? "" : cmbParam2.SelectedValue.ToString();
                    action.FINISH_CONDITION_TAG_PKNO =
                        string.IsNullOrEmpty(cmbFinish.Text) ? "" : cmbFinish.SelectedValue.ToString();
                    action.FINISH_CONDITION_VALUE = tbFinishValue.Text;

                    ws.UseService(s => s.UpdateFmsActionControl(action));
                }

                ws.UseService(s => s.UpdateFmsActionFormulaDetail(detail));
            }

            //保存成功
            gbItem.IsCollapsed = true;
            gbItem.Visibility  = Visibility.Collapsed;
            BindHelper.SetDictDataBindingGridItem(gbItem, gridItem);
        }