/// <summary> /// 获取新工单 /// </summary> /// <param name="productPKNO">产品PKNO</param> /// <param name="orderType">工单类型 1:原料入库;2:加工;3:成品出库;4:转换;5:换刀</param> /// <returns></returns> private MesJobOrder BuildNewJobOrder(string productPKNO, int orderType, string batchNO, DateTime dtCreateTime) { return(new MesJobOrder() { PKNO = CBaseData.NewGuid(), COMPANY_CODE = CBaseData.BelongCompPKNO, LINE_PKNO = CBaseData.CurLinePKNO, LINE_TASK_PKNO = "", // ITEM_PKNO = productPKNO, // TODO:暂无 JOB_ORDER_NO = TableNOHelper.GetNewNO("MES_JOB_ORDER.JOB_ORDER_NO", "J"), BATCH_NO = batchNO, ROUTING_DETAIL_PKNO = "", JOB_ORDER_TYPE = orderType, TASK_QTY = 1, COMPLETE_QTY = 0, ONLINE_QTY = 0, ONCE_QTY = 0, RUN_STATE = 10, //直接生产 CREATION_DATE = dtCreateTime, CREATED_BY = CBaseData.LoginNO, LAST_UPDATE_DATE = DateTime.Now, //最后修改日期 USE_FLAG = 1, REMARK = "", }); }
public AmAssetMasterNEdit() { InitializeComponent(); m_AssetMaster = new AmAssetMasterN() { ASSET_CODE = TableNOHelper.GetNewNO("AM_ASSET_MASTER_N.ASSET_CODE") }; this.gridLayout.DataContext = m_AssetMaster; IsNew = true; }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { PmTaskMaster taskMaster = gridItem.SelectedItem as PmTaskMaster; if (taskMaster == null) { return; } #region //TODO: 校验 #endregion PmTaskLine planLine = new PmTaskLine() { COMPANY_CODE = "", TASK_PKNO = taskMaster.PKNO, ITEM_PKNO = taskMaster.ITEM_PKNO, TASK_NO = TableNOHelper.GetNewNO("PmTaskLine.TASK_NO", "N"), TASK_START_TIME = taskMaster.TASK_START_TIME, TASK_FINISH_TIME = taskMaster.TASK_FINISH_TIME, TASK_QTY = taskMaster.TASK_QTY - taskMaster.LINE_QTY, PREPARED_QTY = 0, //准备完成数量 COMPLETE_QTY = 0, ONLINE_QTY = 0, ONCE_QTY = 0, RUN_STATE = 0, USE_FLAG = 1, //启用 }; gbItem.DataContext = planLine; dictBasic.Header = $"{HeaderName} 【分配产线】"; gbItem.IsCollapsed = false; gbItem.Visibility = Visibility.Visible; }
public bool StartCurrentProgerss() { if (curProcess.PROCESS_STATE == 1) //准备完成,未开始执行 { if (!string.IsNullOrEmpty(startCondition) && LimitConditions.Contains(startCondition)) //如果前面的Job存在需要判断该状态,则不执行当前的 { string sErrorInfo = $"等待执行"; if (mesJobOrder.PROCESS_INFO != sErrorInfo) { mesJobOrder.PROCESS_INFO = sErrorInfo; //生产执行信息 PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); } return(false); } #region 开始执行工序 共 5 步 string startCustomParam = ""; //开始执行的参数,增加到同步写入数据后面 /************ !!!工序开始的条件!!! ************/ #region 1. 检验当前执行的工序是否可以执行,启动条件 if (startTag != null) //启动条件为空则直接执行 { string checkValue = startTag.CUR_VALUE.Split('|')[0]; //当前执行条件的结果 string startValue = curAction.START_CONDITION_VALUE; //开始条件 string[] startValues = startValue.Split('|'); //多个开启条件 if ((string.IsNullOrEmpty(checkValue)) || (!startValues.Contains(checkValue))) //当前值不是工序开始检测值 { #region 条件不符合的 流程分支情况 if (curProcess.PROCESS_ACTION_TYPE == 4) //流程分支,不启用,直接往下运行 { #region 直接完成当前工序 #region 第一道工序处理 if (bFirstProcess) //第一道工序 { mesJobOrder.RUN_STATE = 20; //正在执行 mesJobOrder.ACT_START_TIME = DateTime.Now; //修改任务开始时间 mesJobOrder.PROCESS_INFO = "正常"; //生产执行信息 PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); } #endregion curProcess.PROCESS_STATE = 10; //直接完成 curProcess.PROCESS_END_TYPE = 1; curProcess.PROCESS_END_TIME = DateTime.Now; curProcess.REMARK = "条件不满足,不启用流程分支,直接执行现有流程。"; PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); return(false); //直接执行重新执行 #endregion } #endregion #region 判断条件不满足 string sErrorInfo = $"生产过程【{ctrolName}】开启条件【{startTag?.TAG_NAME}】不足,当前状态为【{checkValue}】,需要状态【{startValue}】"; if (mesJobOrder.PROCESS_INFO != sErrorInfo) { mesJobOrder.PROCESS_INFO = sErrorInfo; //生产执行信息 PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); } if (!LimitConditions.Contains(startCondition)) { LimitConditions.Add(startCondition); //起始条件不满足,则添加限制条件 } return(false); #endregion } } #endregion /************ !!!工序开始的条件满足,直接执行!!! ************/ Console.WriteLine($"========生产过程【{ctrolName}】开始条件【{startTag?.TAG_NAME}】满足,开始执行======="); #region 2. 启动流程分支 if (curProcess.PROCESS_ACTION_TYPE == 4) //流程分支 { string disableProcesses = curProcess.PROCESS_ACTION_PARAM1_VALUE; //禁用的流程 string enableProcesses = curProcess.PROCESS_ACTION_PARAM2_VALUE; //启用的流程 string stemp = $"触发流程分支.禁用流程[{disableProcesses}], 启用流程[{enableProcesses}]"; mesJobOrder.PROCESS_INFO = stemp; //生产执行信息 Console.WriteLine(stemp); #region 启动流程分支 if (!string.IsNullOrEmpty(disableProcesses)) { foreach (var disableP in disableProcesses.Split(';')) { MesProcessCtrol process = unFinishProcessCtrols.FirstOrDefault(c => c.PROCESS_INDEX == SafeConverter.SafeToInt(disableP, -1)); process.USE_FLAG = 0; //禁用 PServiceEvent?.Invoke(d => d.UpdateMesProcessCtrol(process)); } } if (!string.IsNullOrEmpty(enableProcesses)) { foreach (var enableP in enableProcesses.Split(';')) { MesProcessCtrol process = unFinishProcessCtrols.FirstOrDefault(c => c.PROCESS_INDEX == SafeConverter.SafeToInt(enableP, -1)); process.USE_FLAG = 1; //启用 PServiceEvent?.Invoke(d => d.UpdateMesProcessCtrol(process)); } } #endregion #region 更新数据 #region 加工控制 curProcess.PROCESS_STATE = 10; //直接完成 curProcess.PROCESS_END_TYPE = 1; curProcess.PROCESS_START_TIME = DateTime.Now.AddMilliseconds(-100); curProcess.PROCESS_END_TIME = DateTime.Now; curProcess.REMARK = $"流程分支条件满足,启用流程分支,禁用流程[{disableProcesses}], 启用流程[{enableProcesses}]"; PServiceEvent?.Invoke(d => d.UpdateMesProcessCtrol(curProcess)); #endregion #region Job处理 if (bFirstProcess) //第一道工序 { mesJobOrder.RUN_STATE = 20; //正在执行 mesJobOrder.ACT_START_TIME = DateTime.Now; //修改任务开始时间 } PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); #endregion DeviceMonitor.SetTagSettingValueById(curAction.START_CONDITION_TAG_PKNO, ""); //将检测结果置为空 //产品处理 if (productProcess != null) { productProcess.PRODUCT_STATE = curProcess.PROCESS_ACTION_TYPE; //当前状态 productProcess.LAST_UPDATE_DATE = DateTime.Now; var process = productProcess; PServiceEvent?.Invoke(d => d.UpdateMesProductProcess(process)); } #endregion return(false); //直接开启下一次流程 } //启动流程分支 #endregion //增加限制条件 if (!string.IsNullOrEmpty(startCondition) && !LimitConditions.Contains(startCondition)) //未完成的任务需要增加开始条件 { LimitConditions.Add(startCondition); } #region 3. 获取产品,第一道工序形成产品 if (bFirstProcess || (productProcess == null)) //第一道控制,且没有形成 { string productPKNO = CBaseData.NewGuid(); productProcess = new MesProductProcess() //生成新的产品 { PKNO = productPKNO, COMPANY_CODE = CBaseData.BelongCompPKNO, ITEM_PKNO = curProcess.ITEM_PKNO, JOB_ORDER_PKNO = curProcess.JOB_ORDER_PKNO, JOB_ORDER = curProcess.JOB_ORDER, SUB_JOB_ORDER_NO = curProcess.SUB_JOB_ORDER_NO, PRODUCT_CODE = TableNOHelper.GetNewNO("MesProductProcess.PRODUCT_CODE", "P"), PRODUCT_POSITION = "", //当前位置 CUR_ROCESS_CTROL_PKNO = curProcess.PKNO, //当前过程 RAW_NUMBER = curProcess.PROCESS_QTY, //原料数量 PRODUCT_NUMBER = curProcess.COMPLETE_QTY, //完成数量 QUALIFIED_NUMBER = curProcess.QUALIFIED_QTY, //合格品数量 PALLET_NO = curProcess.PALLET_NO, //托盘号 PRODUCT_STATE = -1, //尚未开始 CREATION_DATE = DateTime.Now, CREATED_BY = CBaseData.LoginNO, LAST_UPDATE_DATE = DateTime.Now, //最后修改日期 USE_FLAG = 1, REMARK = "", //备注 }; //生成新的产品 curProcess.CUR_PRODUCT_CODE_PKNO = productPKNO; //新产品编号 } else { curProcess.CUR_PRODUCT_CODE_PKNO = firstProcess.CUR_PRODUCT_CODE_PKNO; //将所有的产品 } #endregion #region 4. 执行当前工序 => 向设备写入数据 写 3 个值 int ret = 0; string error = ""; string tagPKNO = ""; string sTagValue = ""; bool bWriteSuccess = true; //写入设备成功标志 #region 4.1 写参数1 tagPKNO = curAction.EXECUTE_PARAM1_TAG_PKNO; sTagValue = GetDynamicValue(curProcess.PROCESS_ACTION_PARAM1_VALUE); if ((!string.IsNullOrEmpty(tagPKNO)) && (!string.IsNullOrEmpty(sTagValue))) { #region 多次重写 int iWrite = 0; while (iWrite < ReWriteCount) { ret = DeviceMonitor.WriteTagToDevice(tagPKNO, sTagValue, out error); if (ret == 0) { Thread.Sleep(100); //写入成功后暂停 break; } iWrite++; Thread.Sleep(100); } #endregion if (ret == 10) //写入设备失败 { string sErrorInfo = $"向设备写入参数1失败。错误为:{error}"; //生产执行信息 if (mesJobOrder.PROCESS_INFO != sErrorInfo) { mesJobOrder.PROCESS_INFO = sErrorInfo; //生产执行信息 PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); } Console.WriteLine(sErrorInfo); return(false); } if (ret == 0) { bWriteSuccess = true; //写入成功 } } #endregion #region 4.2 写参数2 tagPKNO = curAction.EXECUTE_PARAM2_TAG_PKNO; sTagValue = GetDynamicValue(curProcess.PROCESS_ACTION_PARAM2_VALUE); if ((!string.IsNullOrEmpty(tagPKNO)) && (!string.IsNullOrEmpty(sTagValue))) { #region 多次重写 int iWrite = 0; while (iWrite < ReWriteCount) { ret = DeviceMonitor.WriteTagToDevice(tagPKNO, sTagValue, out error); if (ret == 0) { Thread.Sleep(100); //写入成功后暂停 break; } iWrite++; Thread.Sleep(100); } #endregion if (ret == 10) //写入设备失败 { string sErrorInfo = $"向设备写入参数2失败。错误为:{error}"; //生产执行信息 if (mesJobOrder.PROCESS_INFO != sErrorInfo) { mesJobOrder.PROCESS_INFO = sErrorInfo; //生产执行信息 PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); } Console.WriteLine(sErrorInfo); return(false); } if (ret == 0) { bWriteSuccess = true; //写入成功 } } #endregion #region 4.3 写执行 tagPKNO = curAction.EXECUTE_TAG_PKNO; sTagValue = GetDynamicValue(curAction.EXECUTE_WRITE_VALUE) + "|" + (string.IsNullOrEmpty(curProcess.PROCESS_ACTION_PARAM1_VALUE) ? "0" : curProcess.PROCESS_ACTION_PARAM1_VALUE) + "|" + (string.IsNullOrEmpty(curProcess.PROCESS_ACTION_PARAM2_VALUE) ? "0" : curProcess.PROCESS_ACTION_PARAM2_VALUE) + "|" + (string.IsNullOrEmpty(startCustomParam) ? "0" : startCustomParam); if ((!string.IsNullOrEmpty(tagPKNO)) && (!string.IsNullOrEmpty(sTagValue.Replace("|", "")))) { #region 多次重写 int iWrite = 0; while (iWrite < ReWriteCount) { ret = DeviceMonitor.WriteTagToDevice(tagPKNO, sTagValue, out error); if (ret == 0) { //Thread.Sleep(100); //写入成功后暂停,最后不需要 break; } iWrite++; Thread.Sleep(100); } #endregion if (ret == 10) //写入设备失败 { string sErrorInfo = $"向设备写入开始动作值失败。错误为:{error}"; //生产执行信息 if (mesJobOrder.PROCESS_INFO != sErrorInfo) { mesJobOrder.PROCESS_INFO = sErrorInfo; //生产执行信息 PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); } Console.WriteLine(sErrorInfo); return(false); } if (ret == 0) { bWriteSuccess = true; //写入成功 } } #endregion if (bWriteSuccess) { Console.WriteLine("给设备发送指令成功.开始进行执行" + (string.IsNullOrEmpty(curProcess.SUB_JOB_ORDER_NO) ? curProcess.JOB_ORDER_PKNO : curProcess.SUB_JOB_ORDER_NO)); //给设备发送动作指令成功 } #endregion #region 5. 更新数据 共更新 4 个模块 #region 5.1 加工控制 curProcess.PROCESS_STATE = 2; //正在执行 curProcess.PROCESS_START_TYPE = 1; //自动开始 curProcess.PROCESS_START_TIME = DateTime.Now; PServiceEvent?.Invoke(d => d.UpdateMesProcessCtrol(curProcess)); #endregion #region 5.2 业务相关处理 if (curProcess.PROCESS_ACTION_TYPE == 11) //开始 出库 { mesJobOrder.ONLINE_QTY = curProcess.PROCESS_QTY; //在线数量 } if (bFirstProcess) //第一道工序,新增产品信息 { PServiceEvent?.Invoke(s => s.AddMesProductProcess(productProcess)); } string sError = ""; string result = DeviceProcessControl.BeginCurBusiness(curProcess, ref sError); //开始当前控制的业务 if (result != "OK") { mesJobOrder.PROCESS_INFO = $"业务开始执行发生错误,写入数据库错误! 具体:{sError}"; } #endregion #region 5.3 Job处理 if (bFirstProcess) //第一道工序 { mesJobOrder.RUN_STATE = 20; //正在执行 mesJobOrder.ACT_START_TIME = DateTime.Now; //修改任务开始时间 } PServiceEvent?.Invoke(d => d.UpdateMesJobOrder(mesJobOrder)); #endregion #region 5.4 将开始和结束条件 置空 DeviceMonitor.SetTagSettingValueById(curAction.START_CONDITION_TAG_PKNO, ""); //将检测结果置为空 FmsAssetTagSetting finishTag = DeviceMonitor.GetTagSettingById(curAction.FINISH_CONDITION_TAG_PKNO); if (finishTag != null) { if (finishTag.SAMPLING_MODE == 11) { finishTag.SAMPLING_MODE = 10; //按照条件开启 } DeviceMonitor.SetTagSettingValue(finishTag, ""); } #endregion #endregion #endregion if (startTag != null) { FMSControlService.iConditionStartAddPause = 500; //按条件启动后增加的延时 } FMSControlService.bStart = true; //本次订单已经启动过了 } return(true); }
private void button_Click_2(object sender, RoutedEventArgs e) { string newAssetNO = TableNOHelper.GetNewNO("AM_ASSET_MASTER_N.ASSET_CODE"); MessageBox.Show(newAssetNO); }
private void BtnAutoChange_Click(object sender, RoutedEventArgs e) { TmsToolsMaster mToolsMaster = GridControlInvTool.SelectedItem as TmsToolsMaster; TmsDeviceToolsPos mTmsDeviceToolsPos = GridControlDeviceTool.SelectedItem as TmsDeviceToolsPos; MesJobOrder jobOrder = null; WmsInventory inv = null; List <MesProcessCtrol> processCtrols = new List <MesProcessCtrol>(); #region 形成工单 jobOrder = new MesJobOrder() { PKNO = CBaseData.NewGuid(), COMPANY_CODE = CBaseData.BelongCompPKNO, LINE_PKNO = CBaseData.CurLinePKNO, LINE_TASK_PKNO = "", //产线任务PKNO ITEM_PKNO = "", // TODO:暂无 JOB_ORDER_NO = TableNOHelper.GetNewNO("MES_JOB_ORDER.JOB_ORDER_NO", "J"), BATCH_NO = "", ROUTING_DETAIL_PKNO = "", JOB_ORDER_TYPE = 2, //工单类型 1:原料入库;2:加工;3:成品出库;4:转换 TASK_QTY = 1, COMPLETE_QTY = 0, ONLINE_QTY = 0, ONCE_QTY = 0, RUN_STATE = 10, //直接生产 CREATION_DATE = DateTime.Now, CREATED_BY = CBaseData.LoginNO, LAST_UPDATE_DATE = DateTime.Now, //最后修改日期 USE_FLAG = 1, REMARK = "", }; #endregion #region 增加参数 Dictionary <string, string> ParamValues = new Dictionary <string, string>(); #endregion string sFormulaCode = "换刀"; List <FmsActionFormulaDetail> 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 = new MesProcessCtrol() { #region 标准信息 PKNO = CBaseData.NewGuid(), COMPANY_CODE = CBaseData.BelongCompPKNO, 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 = detail.FORMULA_DETAIL_NAME, //名称 PROCESS_DEVICE_PKNO = Replace(detail.PROCESS_DEVICE_PKNO, ParamValues), //生产设备 PROCESS_PROGRAM_NO = Replace(detail.PROCESS_PROGRAM_NO, ParamValues), //加工程序号 PROCESS_PROGRAM_CONTENT = detail.PROCESS_PROGRAM_CONTENT, //加工程序内容 PROCESS_INDEX = detail.PROCESS_INDEX, //工序顺序 BEGIN_ITEM_PKNO = Replace(detail.BEGIN_ITEM_PKNO, ParamValues), //生产前项目PKNO FINISH_ITEM_PKNO = Replace(detail.FINISH_ITEM_PKNO, ParamValues), //生产后项目PKNO BEGIN_POSITION = Replace(detail.BEGIN_POSITION, ParamValues), //生产前位置 FINISH_POSITION = Replace(detail.FINISH_POSITION, ParamValues), //生产后位置 PALLET_NO = detail.PALLET_NO, //托盘号 PROCESS_ACTION_TYPE = detail.PROCESS_ACTION_TYPE, //工序动作类型 PROCESS_ACTION_PKNO = detail.PROCESS_ACTION_PKNO, //工序动作控制PKNO PROCESS_ACTION_PARAM1_VALUE = Replace(detail.PROCESS_ACTION_PARAM1_VALUE, ParamValues), //工序动作参数1 PROCESS_ACTION_PARAM2_VALUE = Replace(detail.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 = detail.USE_FLAG, //启用标识 REMARK = "", //备注 }; processCtrols.Add(process); } Cursor = Cursors.Wait; wsPLM.UseService(s => s.AddMesJobOrder(jobOrder)); foreach (MesProcessCtrol processCtrol in processCtrols) { wsPLM.UseService(s => s.AddMesProcessCtrol(processCtrol)); } Cursor = Cursors.Arrow; MessageBox.Show("换刀下单成功."); GridControlInvTool.ItemsSource = ws.UseService(s => s.GetTmsToolsMasters("USE_FLAG > 0")).OrderBy(n => n.CREATION_DATE).ToList();; }
private void BtnAutoChange_Click(object sender, RoutedEventArgs e) { TmsToolsMaster mToolsMasterUp = GridControlInvTool.SelectedItem as TmsToolsMaster; //库存 TmsDeviceToolsPos mTmsDeviceToolsPos = GridControlDeviceTool.SelectedItem as TmsDeviceToolsPos; //机床刀位信息 if (mToolsMasterUp == null) { return; } if (mTmsDeviceToolsPos == null) { return; } AmAssetMasterN asset = ComAsset.SelectedItem as AmAssetMasterN; if (asset == null) { WPFMessageBox.ShowError("请选择机床信息!", "自动换刀管理"); return; } TmsToolsMaster mToolsMasterDown = ws.UseService(s => s.GetTmsToolsMasterById(mTmsDeviceToolsPos.TOOLS_PKNO)); if (mToolsMasterDown == null) { WPFMessageBox.ShowError("选中的需要换下的机床刀具信息不存在,请核实!", "自动换刀管理"); return; } MesJobOrder jobOrder = null; WmsInventory inv = null; List <MesProcessCtrol> processCtrols = new List <MesProcessCtrol>(); #region 形成工单 jobOrder = new MesJobOrder() { PKNO = CBaseData.NewGuid(), COMPANY_CODE = CBaseData.BelongCompPKNO, LINE_PKNO = CBaseData.CurLinePKNO, LINE_TASK_PKNO = "", //产线任务PKNO ITEM_PKNO = "", // TODO:暂无 JOB_ORDER_NO = TableNOHelper.GetNewNO("MES_JOB_ORDER.JOB_ORDER_NO", "J"), BATCH_NO = "自动换刀", ROUTING_DETAIL_PKNO = "", JOB_ORDER_TYPE = 2, //工单类型 1:原料入库;2:加工;3:成品出库;4:转换 TASK_QTY = 1, COMPLETE_QTY = 0, ONLINE_QTY = 0, ONCE_QTY = 0, RUN_STATE = 10, //直接生产 CREATION_DATE = DateTime.Now, CREATED_BY = CBaseData.LoginNO, LAST_UPDATE_DATE = DateTime.Now, //最后修改日期 USE_FLAG = 1, REMARK = "", }; #endregion #region 增加参数 Dictionary <string, string> ParamValues = new Dictionary <string, string>(); ParamValues.Add("{机床刀号}", mTmsDeviceToolsPos.TOOLS_POS_NO); //机床刀号 ParamValues.Add("{卸下刀具编号}", mToolsMasterDown.TOOLS_CODE.PadRight(25)); //卸下刀具编号 ParamValues.Add("{装上刀具编号}", mToolsMasterUp.TOOLS_CODE.PadRight(25)); //装上刀具编号 ParamValues.Add("{装上刀具PKNO}", mToolsMasterUp.PKNO); //装上刀具PKNO ParamValues.Add("{卸下刀具PKNO}", mToolsMasterDown.PKNO); //卸下刀具PKNO ParamValues.Add("{长度形状补偿}", SafeConverter.SafeToStr(mToolsMasterUp.COMPENSATION_SHAPE_LENGTH)); //长度形状补偿 - 装上 ParamValues.Add("{半径形状补偿}", SafeConverter.SafeToStr(mToolsMasterUp.COMPENSATION_SHAPE_DIAMETER)); //半径形状补偿 - 装上 ParamValues.Add("{卸下刀位PKNO}", mTmsDeviceToolsPos.PKNO); //卸下刀位PKNO ParamValues.Add("{装上刀位PKNO}", mTmsDeviceToolsPos.PKNO); //装上刀位PKNO ParamValues.Add("{装刀机床PKNO}", asset?.PKNO); //装刀机床PKNO #endregion string sFormulaCode = "换刀-" + asset.ASSET_CODE; List <FmsActionFormulaDetail> 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 = new MesProcessCtrol() { #region 标准信息 PKNO = CBaseData.NewGuid(), COMPANY_CODE = CBaseData.BelongCompPKNO, 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 = detail.FORMULA_DETAIL_NAME, //名称 PROCESS_DEVICE_PKNO = ProcessParamReplace.Replace(detail.PROCESS_DEVICE_PKNO, ParamValues), //生产设备 PROCESS_PROGRAM_NO = ProcessParamReplace.Replace(detail.PROCESS_PROGRAM_NO, ParamValues), //加工程序号 PROCESS_PROGRAM_CONTENT = detail.PROCESS_PROGRAM_CONTENT, //加工程序内容 PROCESS_INDEX = detail.PROCESS_INDEX, //工序顺序 BEGIN_ITEM_PKNO = ProcessParamReplace.Replace(detail.BEGIN_ITEM_PKNO, ParamValues), //生产前项目PKNO FINISH_ITEM_PKNO = ProcessParamReplace.Replace(detail.FINISH_ITEM_PKNO, ParamValues), //生产后项目PKNO BEGIN_POSITION = ProcessParamReplace.Replace(detail.BEGIN_POSITION, ParamValues), //生产前位置 FINISH_POSITION = ProcessParamReplace.Replace(detail.FINISH_POSITION, ParamValues), //生产后位置 PALLET_NO = detail.PALLET_NO, //托盘号 PROCESS_ACTION_TYPE = detail.PROCESS_ACTION_TYPE, //工序动作类型 PROCESS_ACTION_PKNO = detail.PROCESS_ACTION_PKNO, //工序动作控制PKNO PROCESS_ACTION_PARAM1_VALUE = ProcessParamReplace.Replace(detail.PROCESS_ACTION_PARAM1_VALUE, ParamValues), //工序动作参数1 PROCESS_ACTION_PARAM2_VALUE = ProcessParamReplace.Replace(detail.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 = detail.USE_FLAG, //启用标识 REMARK = "", //备注 }; processCtrols.Add(process); } Cursor = Cursors.Wait; wsPLM.UseService(s => s.AddMesJobOrder(jobOrder)); foreach (MesProcessCtrol processCtrol in processCtrols) { wsPLM.UseService(s => s.AddMesProcessCtrol(processCtrol)); } Cursor = Cursors.Arrow; MessageBox.Show("换刀下单成功."); GridControlInvTool.ItemsSource = ws.UseService(s => s.GetTmsToolsMasters("USE_FLAG > 0 AND TOOLS_POSITION = 1")).OrderBy(n => n.CREATION_DATE).ToList();; }