private void BtnAddIn_Click(object sender, RoutedEventArgs e) { gbItem.IsCollapsed = false; //新增&入库 dictInfo.Header = "刀具台账详细信息 【新增】"; dictInfo.Visibility = Visibility.Visible; TmsToolsMaster toolsMaster = new TmsToolsMaster() { COMPANY_CODE = "", USE_FLAG = 1, TOOLS_LIFE_METHOD = 1, TOOLS_LIFE_PLAN = 1000, TOOLS_LIFE_USED = 0, COMPENSATION_SHAPE_DIAMETER = 0, COMPENSATION_ABRASION_DIAMETER = 0, COMPENSATION_SHAPE_LENGTH = 0, COMPENSATION_ABRASION_LENGTH = 0, }; dictInfo.DataContext = toolsMaster; //入库 WmsInvOperate invOperate = new WmsInvOperate() { COMPANY_CODE = "", OPERATE_SOURCE = 1, OPERATE_NUM = 1, OPERATE_TYPE = 1, }; inbound.DataContext = invOperate; inbound.Visibility = Visibility.Visible; }
private void BtnOut_Click(object sender, RoutedEventArgs e) { TmsToolsMaster m_TmsToolsMaster = gridItem.SelectedItem as TmsToolsMaster; if (m_TmsToolsMaster == null) { return; } if (m_TmsToolsMaster.TOOLS_POSITION != 1) { System.Windows.Forms.MessageBox.Show("该刀具不在库,不能进行出库,请核实!", "出库", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } gbItem.IsCollapsed = false; //出库 WmsInvOperate invOperate = new WmsInvOperate() { COMPANY_CODE = "", MATERIAL_PKNO = m_TmsToolsMaster.PKNO, ALLOCATION_PKNO = m_TmsToolsMaster.TOOLS_POSITION_PKNO, //货位 OPERATE_SOURCE = 1, OPERATE_NUM = 1, OPERATE_TYPE = -1, //出库 OUT_TARGET = 0, //机床 }; outbound.DataContext = invOperate; outbound.Visibility = Visibility.Visible; }
private void BtnChange_Click(object sender, RoutedEventArgs e) { TmsToolsMaster mToolsMaster = GridControlInvTool.SelectedItem as TmsToolsMaster; TmsDeviceToolsPos mTmsDeviceToolsPos = GridControlDeviceTool.SelectedItem as TmsDeviceToolsPos; if (mToolsMaster != null) { if (mTmsDeviceToolsPos != null) { TmsToolsMaster mToolsMasterold = ws.UseService(s => s.GetTmsToolsMasterById(mTmsDeviceToolsPos.TOOLS_PKNO)); if (mToolsMasterold != null) { mToolsMasterold.TOOLS_POSITION = 0; mToolsMasterold.TOOLS_POSITION_PKNO = ""; ws.UseService(s => s.UpdateTmsToolsMaster(mToolsMasterold)); } mTmsDeviceToolsPos.TOOLS_PKNO = mToolsMaster.PKNO; mTmsDeviceToolsPos.TOOLS_STATE = 1; mTmsDeviceToolsPos.UPDATED_BY = CBaseData.LoginName; ws.UseService(s => s.UpdateTmsDeviceToolsPos(mTmsDeviceToolsPos)); } mToolsMaster.TOOLS_POSITION = 2; mToolsMaster.TOOLS_POSITION_PKNO = mTmsDeviceToolsPos.DEVICE_PKNO; ws.UseService(s => s.UpdateTmsToolsMaster(mToolsMaster)); GridControlInvTool.ItemsSource = ws.UseService(s => s.GetTmsToolsMasters("USE_FLAG > 0")); } }
private void BtnIn_Click(object sender, RoutedEventArgs e) { TmsToolsMaster m_TmsToolsMaster = gridItem.SelectedItem as TmsToolsMaster; if (m_TmsToolsMaster == null) { return; } if (m_TmsToolsMaster.TOOLS_POSITION == 1) { System.Windows.Forms.MessageBox.Show("该刀具已经在库,不能再进行入库,请核实!", "入库", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } gbItem.IsCollapsed = false; //入库 WmsInvOperate invOperate = new WmsInvOperate() { COMPANY_CODE = "", OPERATE_SOURCE = 1, OPERATE_NUM = 1, OPERATE_TYPE = 1, }; inbound.DataContext = invOperate; inbound.Visibility = Visibility.Visible; }
//装刀 private void bChangeUp_Click(object sender, System.Windows.RoutedEventArgs e) { TmsDeviceToolsPos toolsPos = gridChangeTools.SelectedItem as TmsDeviceToolsPos; if (toolsPos == null) { return; } if (string.IsNullOrEmpty(mainToolsNO)) //主轴刀号为空 { MessageBox.Show($"未获取到主轴上刀号信息,请先获取主轴刀号信息。", "装刀", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (mainToolsNO != toolsPos.TOOLS_POS_NO) //选中的刀号信息 { MessageBox.Show($"主轴上刀号为【{mainToolsNO}】,当前选中的需要装刀为【{toolsPos.TOOLS_POS_NO}】,不能装上该刀。", "装刀", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (toolsPos.TOOLS_STATE == 2) //等待装刀 { if (MessageBox.Show($"刀位[{toolsPos.TOOLS_POS_NO}]已经是等待装刀状态,确定要!装刀!吗?", "装刀", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } toolsPos.TOOLS_STATE = 1; //空位置 toolsPos.TOOLS_PKNO = toolsPos.NEW_TOOLS_PKNO; //将新刀装上 toolsPos.NEW_TOOLS_PKNO = ""; //清除新刀信息 } else //其他 { MessageBox.Show($"刀位[{toolsPos.TOOLS_POS_NO}]的状态不正确,不能进行装刀处理!", "装刀", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #region 刀具台账出库到机床 TmsToolsMaster toolsMaster = wsTMS.UseService(s => s.GetTmsToolsMasterById(toolsPos.TOOLS_PKNO)); if (toolsMaster != null) { toolsMaster.TOOLS_POSITION = 2; //出库到机床 toolsMaster.TOOLS_POSITION_PKNO = toolsPos.DEVICE_PKNO; //机床 wsTMS.UseService(s => s.UpdateTmsToolsMaster(toolsMaster)); //修改库存 } #endregion //TODO:与CNC通讯,装刀处理 //TODO:修改刀补 wsTMS.UseService(s => s.UpdateTmsDeviceToolsPos(toolsPos)); //完成换刀 GetPage(); }
public TmsToolsMaster GetTmsToolsMasterById(string Id) { using (ITmsToolsMasterBLL TmsToolsMasterBLL = BLLContainer.Resolve <ITmsToolsMasterBLL>()) { TmsToolsMaster model = TmsToolsMasterBLL.GetFirstOrDefault(Id); return(model); } }
/// <summary> /// 还刀动作 /// </summary> /// <param name="newToolPkno">库存出库刀具</param> /// <param name="oldToolPkno">机床上需要更换刀具</param> /// <param name="startingpos">起始位置</param> /// <param name="endpos">终点位置</param> private static void SendbackToolAction(string newToolPkno, string oldToolPkno, string startingpos, string endpos) { TmsToolsMaster mToolsMaster = ws.UseService(s => s.GetTmsToolsMasterById(oldToolPkno)); mToolsMaster.TOOLS_POSITION = 1;//库中 ws.UseService(s => s.UpdateTmsToolsMaster(mToolsMaster)); }
public bool AddTmsToolsMaster(TmsToolsMaster mTmsToolsMaster) { if (mTmsToolsMaster == null) { return(false); } using (ITmsToolsMasterBLL TmsToolsMasterBLL = BLLContainer.Resolve <ITmsToolsMasterBLL>()) { return(TmsToolsMasterBLL.Add(mTmsToolsMaster)); } }
public bool DelTmsToolsMaster(string Id) { using (ITmsToolsMasterBLL TmsToolsMasterBLL = BLLContainer.Resolve <ITmsToolsMasterBLL>()) { try { TmsToolsMaster item = TmsToolsMasterBLL.GetFirstOrDefault(Id); return(TmsToolsMasterBLL.Delete(item)); } catch { return(false); } } }
private void gridItem_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { TmsToolsMaster m_TmsToolsMaster = gridItem.SelectedItem as TmsToolsMaster; if (m_TmsToolsMaster == null) { return; } //修改 gbItem.IsCollapsed = false; dictInfo.Header = "刀具台账详细信息 【修改】"; dictInfo.Visibility = Visibility.Visible; }
private void BtnMod_Click(object sender, RoutedEventArgs e) { TmsToolsMaster m_TmsToolsMaster = gridItem.SelectedItem as TmsToolsMaster; if (m_TmsToolsMaster == null) { return; } //修改 gbItem.IsCollapsed = false; dictInfo.Header = "刀具台账详细信息 【修改】"; dictInfo.Visibility = Visibility.Visible; }
/// <summary> /// 装刀动作 /// </summary> /// <param name="newToolPkno">库存出库刀具</param> /// <param name="oldToolPkno">机床上需要更换刀具</param> /// <param name="startingpos">起始位置</param> /// <param name="endpos">终点位置</param> private static void InstallToolAction(string newToolPkno, string oldToolPkno, string startingpos, string endpos) { TmsToolsMaster mToolsMaster = ws.UseService(s => s.GetTmsToolsMasterById(newToolPkno)); mToolsMaster.TOOLS_POSITION = 2;//设备上 ws.UseService(s => s.UpdateTmsToolsMaster(mToolsMaster)); //刀位逻辑 todo:尚未完成先卸刀再装刀逻辑 TmsDeviceToolsPos mDeviceToolsPos = ws.UseService(s => s.GetTmsDeviceToolsPoss("TOOLS_PKNO = " + oldToolPkno + " ")).FirstOrDefault(); if (mDeviceToolsPos != null) { mDeviceToolsPos.TOOLS_PKNO = newToolPkno; } }
public bool DelTmsToolsMasters(string[] Ids) { using (ITmsToolsMasterBLL TmsToolsMasterBLL = BLLContainer.Resolve <ITmsToolsMasterBLL>()) { try { List <TmsToolsMaster> entitys = new List <TmsToolsMaster>(); foreach (string id in Ids) { TmsToolsMaster item = TmsToolsMasterBLL.GetFirstOrDefault(id); entitys.Add(item); } return(TmsToolsMasterBLL.Delete(entitys)); } catch { return(false); } } }
/// <summary> /// 换刀动作 /// </summary> /// <param name="newToolPkno">库存出库刀具</param> /// <param name="oldToolPkno">机床上需要更换刀具</param> /// <param name="startingpos">起始位置</param> /// <param name="endpos">终点位置</param> private static void ToolChangeAction(string newToolPkno, string oldToolPkno, string startingpos, string endpos) { //台账逻辑 TmsToolsMaster mToolsMasterNew = ws.UseService(s => s.GetTmsToolsMasterById(newToolPkno)); mToolsMasterNew.TOOLS_POSITION = 2;//设备上 ws.UseService(s => s.UpdateTmsToolsMaster(mToolsMasterNew)); TmsToolsMaster mToolsMasterOld = ws.UseService(s => s.GetTmsToolsMasterById(oldToolPkno)); mToolsMasterOld.TOOLS_POSITION = 1;//回库中 ws.UseService(s => s.UpdateTmsToolsMaster(mToolsMasterOld)); //刀位逻辑 TmsDeviceToolsPos mDeviceToolsPos = ws.UseService(s => s.GetTmsDeviceToolsPoss("TOOLS_PKNO = " + oldToolPkno + " ")).FirstOrDefault(); if (mDeviceToolsPos != null) { mDeviceToolsPos.TOOLS_PKNO = newToolPkno; } }
private void BtnDel_Click(object sender, RoutedEventArgs e) { //删除 TmsToolsMaster m_TmsToolsMaster = gridItem.SelectedItem as TmsToolsMaster; if (m_TmsToolsMaster == null) { return; } if (System.Windows.Forms.MessageBox.Show($"确定删除刀具台账信息【{m_TmsToolsMaster.TOOLS_NAME}】吗?", @"删除信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { m_TmsToolsMaster.USE_FLAG = -1; ws.UseService(s => s.UpdateTmsToolsMaster(m_TmsToolsMaster)); //删除成功. GetPage(); //重新加载 } }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { gbItem.IsCollapsed = false; //新增 dictInfo.Header = "刀具台账详细信息 【新增】"; dictInfo.Visibility = Visibility.Visible; TmsToolsMaster toolsMaster = new TmsToolsMaster() { COMPANY_CODE = "", USE_FLAG = 1, TOOLS_LIFE_METHOD = 1, TOOLS_LIFE_PLAN = 1000, TOOLS_LIFE_USED = 0, COMPENSATION_SHAPE_DIAMETER = 0, COMPENSATION_ABRASION_DIAMETER = 0, COMPENSATION_SHAPE_LENGTH = 0, COMPENSATION_ABRASION_LENGTH = 0, }; dictInfo.DataContext = toolsMaster; }
//排刀 private void bToolsBindDevice_Click(object sender, System.Windows.RoutedEventArgs e) { //排刀 string detailPKNO = SafeConverter.SafeToStr(ClassHelper.GetPropertyValue(gridToolsFinal.SelectedItem, "PKNO")); TmsDeviceToolsPos deviceToolsPos = wsTMS.UseService(s => s.GetTmsDeviceToolsPosById(detailPKNO)); if (deviceToolsPos == null) { return; } TmsToolsMaster toolsMaster = gridToolsInv.SelectedItem as TmsToolsMaster; if (toolsMaster == null) { MessageBox.Show($"请选择相应的库存刀具!", "排入刀具", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } TmsDeviceToolsPos check = wsTMS .UseService(s => s.GetTmsDeviceToolsPoss($"USE_FLAG = 1 AND DEVICE_PKNO = '{deviceToolsPos.DEVICE_PKNO}'")) .FirstOrDefault(c => c.TOOLS_PKNO == toolsMaster.PKNO || c.NEW_TOOLS_PKNO == toolsMaster.PKNO); #region 排刀 if (deviceToolsPos.TOOLS_STATE == 0) //空刀位 { if (check != null) { MessageBox.Show($"该刀具[{toolsMaster.TOOLS_CODE}]已经是{(check.TOOLS_STATE == 1 ? "在位" : "已排入")}状态,不能再排入!", "排入刀具", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } deviceToolsPos.TOOLS_STATE = 2; //已排入 //deviceToolsPos.TOOLS_PKNO = toolsMaster.PKNO; deviceToolsPos.NEW_TOOLS_PKNO = toolsMaster.PKNO; deviceToolsPos.UPDATED_BY = CBaseData.LoginName; deviceToolsPos.LAST_UPDATE_DATE = DateTime.Now; deviceToolsPos.UPDATED_INTROD += "【" + DateTime.Now + "】排入刀具. "; wsTMS.UseService(s => s.UpdateTmsDeviceToolsPos(deviceToolsPos)); } else if (deviceToolsPos.TOOLS_STATE == 1) //刀具在位 { MessageBox.Show($"刀位[{deviceToolsPos.TOOLS_POS_NO}]不为空,不能再排入刀。", "排入刀具", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (deviceToolsPos.TOOLS_STATE == 2) //已排入 { if (MessageBox.Show($"刀位[{deviceToolsPos.TOOLS_POS_NO}]已经是排入状态,确定要!取消排入!吗?", "排入刀具", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } deviceToolsPos.TOOLS_STATE = 0; //=>空 //deviceToolsPos.TOOLS_PKNO = ""; deviceToolsPos.NEW_TOOLS_PKNO = ""; deviceToolsPos.UPDATED_BY = CBaseData.LoginName; deviceToolsPos.LAST_UPDATE_DATE = DateTime.Now; deviceToolsPos.UPDATED_INTROD += "【" + DateTime.Now + "】取消排入. "; wsTMS.UseService(s => s.UpdateTmsDeviceToolsPos(deviceToolsPos)); } else if (deviceToolsPos.TOOLS_STATE == 2) //已经移除 => 更换 { if (check != null) { MessageBox.Show($"该刀具[{toolsMaster.TOOLS_CODE}]已经是{(check.TOOLS_STATE == 1 ? "在位" : "已排入")}状态,不能再排入!", "排入刀具", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } deviceToolsPos.TOOLS_STATE = 10; //=>更换 deviceToolsPos.NEW_TOOLS_PKNO = toolsMaster.PKNO; //刀具PKNO deviceToolsPos.UPDATED_BY = CBaseData.LoginName; deviceToolsPos.LAST_UPDATE_DATE = DateTime.Now; deviceToolsPos.UPDATED_INTROD += "【" + DateTime.Now + "】取消更换. "; wsTMS.UseService(s => s.UpdateTmsDeviceToolsPos(deviceToolsPos)); } else if (deviceToolsPos.TOOLS_STATE == 10) { if (MessageBox.Show($"刀位[{deviceToolsPos.TOOLS_POS_NO}]已经是更换刀具,确定要!取消更换!吗?", "排入刀具", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } deviceToolsPos.TOOLS_STATE = 1; //刀具在位 deviceToolsPos.NEW_TOOLS_PKNO = ""; //清空刀号 deviceToolsPos.UPDATED_BY = CBaseData.LoginName; deviceToolsPos.LAST_UPDATE_DATE = DateTime.Now; deviceToolsPos.UPDATED_INTROD += "【" + DateTime.Now + "】取消更换刀具. "; wsTMS.UseService(s => s.UpdateTmsDeviceToolsPos(deviceToolsPos)); } #endregion GetPage(); }
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();; }
//获取刀具补偿,需要读取zoller对刀仪数据--共享文件夹 private void BtnGetToolCompensation_Click(object sender, RoutedEventArgs e) { TmsToolsMaster m_TmsToolsMaster = gridItem.SelectedItem as TmsToolsMaster; if (m_TmsToolsMaster == null) { return; } string path = @"C:\\ZOLLER\\"; if (!Directory.Exists(path)) { try { Directory.CreateDirectory(path); } catch (Exception exception) { Console.WriteLine(exception); return; } } try { bool isHave = false; DirectoryInfo folder = new DirectoryInfo(path); foreach (FileInfo fileitem in folder.GetFiles("*.txt")) { Console.WriteLine(fileitem.FullName); if (fileitem.FullName.Contains(m_TmsToolsMaster.TOOLS_CODE)) { isHave = true; byte[] byData = new byte[10000]; char[] charData = new char[10000]; FileStream file = new FileStream(path + m_TmsToolsMaster.TOOLS_CODE + ".TXT", FileMode.Open); file.Seek(0, SeekOrigin.Begin); file.Read(byData, 0, 1000); //byData传进来的字节数组,用以接受FileStream对象中的数据,第2个参数是字节数组中开始写入数据的位置,它通常是0,表示从数组的开端文件中向数组写数据,最后一个参数规定从文件读多少字符. Decoder d = Encoding.UTF8.GetDecoder(); d.GetChars(byData, 0, byData.Length, charData, 0); Console.WriteLine(charData); string z = ""; bool flagz = false; string x = ""; bool flagx = false; int ncount = 0; foreach (char item in charData) { if (item == '\n') { ncount++; if (ncount > 1) { if (z == "") { flagz = true; } else { flagz = false; flagx = true; } } } if (flagz) { z += item; } if (flagx) { x += item; } } file.Close(); z = z.Split('\t')[10]; x = x.Split('\t')[10]; m_TmsToolsMaster.COMPENSATION_SHAPE_DIAMETER = decimal.Parse(x); m_TmsToolsMaster.COMPENSATION_SHAPE_LENGTH = decimal.Parse(z); text_X.Text = x; text_Z.Text = z; fileitem.Delete(); BFM.WPF.Base.Helper.BindHelper.SetDictDataBindingGridItem(dictInfo, gridItem); } } if (isHave == false) { WPFMessageBox.ShowError("未获取到刀补,请在对刀仪上生成刀补数据", "获取刀补"); } } catch (Exception exception) { WPFMessageBox.ShowError("未获取到刀补,请在对刀仪上生成刀补数据", "获取刀补"); Console.WriteLine("未获取到刀补,请在对刀仪上生成刀补数据"); } }
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 const int ReWriteCount = 3; //数据重写次数 //下发刀补 private void btnWriteToolsSet_Click(object sender, RoutedEventArgs e) { AmAssetMasterN asset = cmbDeviceInfo.SelectedItem as AmAssetMasterN; if (asset == null) { return; } TmsDeviceToolsPos mTmsDeviceToolsPos = gridItem.SelectedItem as TmsDeviceToolsPos; if (mTmsDeviceToolsPos == null) { return; } TmsToolsMaster tools = ws.UseService(s => s.GetTmsToolsMasterById(mTmsDeviceToolsPos.TOOLS_PKNO)); if (tools == null) { return; } if (WPFMessageBox.ShowConfirm($"确定要将机床【{asset.ASSET_NAME}】上刀号【{mTmsDeviceToolsPos.TOOLS_POS_NO}】的补偿值覆盖吗?", "下发刀补") != WPFMessageBoxResult.OK) { return; } Cursor = Cursors.Wait; string tagName = "写入刀补"; FmsAssetTagSetting tag = DeviceMonitor.GetTagSettings($"ASSET_CODE = '{asset.ASSET_CODE}' AND TAG_NAME = '{tagName}'").FirstOrDefault(); if (tag == null) { Cursor = Cursors.Arrow; return; } //0:长度(形状);1:长度(磨损);2:半径(形状);3:半径(磨损) List <string> values = new List <string>(); values.Add(mTmsDeviceToolsPos.TOOLS_POS_NO); //机床刀号 values.Add(tools.COMPENSATION_SHAPE_LENGTH.ToString()); //长度(形状) //values.Add(tools.COMPENSATION_ABRASION_LENGTH.ToString()); //长度(磨损) values.Add(tools.COMPENSATION_SHAPE_DIAMETER.ToString()); //半径(形状) //values.Add(tools.COMPENSATION_ABRASION_DIAMETER.ToString()); //半径(磨损) string offSetValue = string.Join("|", values.ToArray()); #region 发刀补 int iWrite = 0; int ret = 0; string error = ""; while (iWrite < ReWriteCount) { ret = DeviceMonitor.WriteTagToDevice(tag.PKNO, offSetValue, out error); if (ret == 0) { break; } iWrite++; Thread.Sleep(100); } #endregion Cursor = Cursors.Arrow; if (ret == 0) { WPFMessageBox.ShowTips("刀补值下发成功!", "下发刀补"); } }
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.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) //入库 { m_TmsToolsMaster.TOOLS_POSITION = 1; WmsInvOperate invOperate = inbound.DataContext as WmsInvOperate; if (invOperate != null) { m_TmsToolsMaster.TOOLS_POSITION_PKNO = invOperate.ALLOCATION_PKNO; } } if (outbound.Visibility == Visibility.Visible) //出库 { WmsInvOperate invOperate = outbound.DataContext as WmsInvOperate; if (invOperate != null) { 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); }
//卸刀 private void bChangeDown_Click(object sender, System.Windows.RoutedEventArgs e) { TmsDeviceToolsPos toolsPos = gridChangeTools.SelectedItem as TmsDeviceToolsPos; if (toolsPos == null) { return; } if (string.IsNullOrEmpty(mainToolsNO)) //主轴刀号为空 { MessageBox.Show($"未获取到主轴上刀号信息,请先获取主轴刀号信息。", "卸刀", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (mainToolsNO != toolsPos.TOOLS_POS_NO) //选中的刀号信息 { MessageBox.Show($"主轴上刀号为【{mainToolsNO}】,当前选中的需要卸刀为【{toolsPos.TOOLS_POS_NO}】,不能卸下该刀。", "卸刀", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (toolsPos.TOOLS_STATE == 3) //等待卸刀 { if (MessageBox.Show($"刀位[{toolsPos.TOOLS_POS_NO}]已经是等待卸刀状态,卸刀完成后不需要装刀,确定要!卸刀!吗?", "卸刀", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } toolsPos.TOOLS_STATE = 0; //空位置 } else if (toolsPos.TOOLS_STATE == 10) //等待更换 { if (MessageBox.Show($"刀位[{toolsPos.TOOLS_POS_NO}]已经是换刀状态,卸刀完成还需要进行装刀处理,确定要!卸刀!吗?", "卸刀", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } toolsPos.TOOLS_STATE = 2; //更换完成,等待装刀 } else //其他 { MessageBox.Show($"刀位[{toolsPos.TOOLS_POS_NO}]的状态不正确,不能进行卸刀处理!", "卸刀", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #region 刀具台账出库非机床 TmsToolsMaster toolsMaster = wsTMS.UseService(s => s.GetTmsToolsMasterById(toolsPos.TOOLS_PKNO)); if (toolsMaster != null) { toolsMaster.TOOLS_POSITION = 10; //出库,非机床 toolsMaster.TOOLS_POSITION_PKNO = ""; //已出库 wsTMS.UseService(s => s.UpdateTmsToolsMaster(toolsMaster)); //修改库存 } #endregion toolsPos.TOOLS_PKNO = ""; //将旧刀卸下 //TODO:与CNC通讯,卸刀处理 //TODO:修改刀补 wsTMS.UseService(s => s.UpdateTmsDeviceToolsPos(toolsPos)); GetPage(); }
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); }