You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
758 lines
29 KiB
758 lines
29 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMAPP.ServicesAgent;
|
|
using QMAPP.MD.Entity;
|
|
using QMAPP.Entity;
|
|
using QMFrameWork.Data;
|
|
using System.Configuration;
|
|
using System.Threading;
|
|
|
|
namespace QMAPP.WinForm.Forms.TianJin
|
|
{
|
|
public partial class TJPrintPlanLabel : Form
|
|
{
|
|
QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent();
|
|
List<QMAPP.FJC.Entity.Basic.ProcessRoute> cbsource = null;
|
|
|
|
private string planMATERIAL_CODE = string.Empty;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public TJPrintPlanLabel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载工艺路线
|
|
/// </summary>
|
|
private void LoadProcessRoute()
|
|
{
|
|
var routes = _agent.InvokeServiceFunction<DataResult<List<QMAPP.FJC.Entity.Basic.ProcessRoute>>>
|
|
("ProcessRouteBLL_GetProcessRouteList", new QMAPP.FJC.Entity.Basic.ProcessRoute { }).Result;
|
|
routes = routes.OrderBy(p => p.ROUTE_CODE).ToList();
|
|
|
|
cbsource = routes;
|
|
//cbsource.Insert(0, new QMAPP.FJC.Entity.Basic.ProcessRoute { ROUTE_NAME = "", ROUTE_CODE = "" });
|
|
cbRoutes.DisplayMember = "ROUTE_NAME";
|
|
cbRoutes.ValueMember = "ROUTE_CODE";
|
|
cbRoutes.DataSource = cbsource;
|
|
|
|
var listDir = new List<Direction>();
|
|
listDir.Add(new Direction { Code = "左", Name = "左侧" });
|
|
listDir.Add(new Direction { Code = "右", Name = "右侧" });
|
|
comboBox1.DisplayMember = "Name";
|
|
comboBox1.ValueMember = "Code";
|
|
comboBox1.DataSource = listDir;
|
|
|
|
var listSHIFT = new List<Direction>();
|
|
listSHIFT.Add(new Direction { Code = "A", Name = "A班" });
|
|
listSHIFT.Add(new Direction { Code = "B", Name = "B班" });
|
|
listSHIFT.Add(new Direction { Code = "C", Name = "C班" });
|
|
comboBox2.DisplayMember = "Name";
|
|
comboBox2.ValueMember = "Code";
|
|
comboBox2.DataSource = listSHIFT;
|
|
|
|
// tsbPrint.Enabled = false;
|
|
}
|
|
|
|
#region 加载列表显示设置
|
|
/// <summary>
|
|
/// 加载列表显示设置
|
|
/// </summary>
|
|
private void LoadViewSetting()
|
|
{
|
|
#region 加载列表显示设置
|
|
string filepath = ConfigurationManager.AppSettings["SaveFilePath"];
|
|
filepath = string.Format("{0}ViewSetting.cfg", filepath);
|
|
|
|
var setting = new { ListRowcount = 20, RefreshRate = 5 };
|
|
if (System.IO.File.Exists(filepath))
|
|
{
|
|
string settingstring = System.IO.File.ReadAllText(filepath);
|
|
setting = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(settingstring, setting);
|
|
}
|
|
cbListRowcount.Text = setting.ListRowcount.ToString();
|
|
//cbRefreshRate.Text = string.Format("{0}s", setting.RefreshRate);
|
|
cbPlanFilter.SelectedIndex = 1;
|
|
|
|
cbListRowcount.SelectedIndexChanged += new EventHandler(cbListRowcount_SelectedIndexChanged);
|
|
//cbRefreshRate.SelectedIndexChanged += new EventHandler(cbRefreshRate_SelectedIndexChanged);
|
|
cbPlanFilter.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged);
|
|
comboBox1.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged);
|
|
comboBox2.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged);
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
#region 列表定时刷新
|
|
private void cbListRowcount_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
SaveSetting();
|
|
BindPlanView();
|
|
}
|
|
/// <summary>
|
|
/// 发送指令或者接受完成指令刷新列表
|
|
/// </summary>
|
|
public void BindPlanView()
|
|
{
|
|
#region 刷新生产计划
|
|
dgvPlan.AutoGenerateColumns = false;
|
|
this.dgvPlan.DataSource = new List<FJC.Entity.ProductionPlan.WorkOrder>();
|
|
|
|
|
|
try
|
|
{
|
|
DataPage dataPage = new DataPage();
|
|
dataPage.PageSize = int.Parse(cbListRowcount.Text);
|
|
dataPage.PageIndex = 1;
|
|
dataPage.SortExpression = " ROWVALUE ASC";
|
|
//操作开始时间
|
|
//if (string.IsNullOrEmpty(this.dtpCREATEDATESTART.Text.Trim()) == false)
|
|
//{
|
|
// searchModel.BeginTime = Convert.ToDateTime((this.dtpCREATEDATESTART.Value).ToString("yyyy-MM-dd") + " 00:00:00");
|
|
//}
|
|
////操作结束时间
|
|
//if (string.IsNullOrEmpty(this.dtpCREATEDATEEND.Text.Trim()) == false)
|
|
//{
|
|
// searchModel.EndTime = Convert.ToDateTime((this.dtpCREATEDATEEND.Value).ToString("yyyy-MM-dd") + " 23:59:59");
|
|
//}
|
|
#region 服务查询
|
|
var orderlist = _agent.InvokeServiceFunction<List<FJC.Entity.ProductionPlan.WorkOrder>>("TJWorkOrderBLL_GetOrderUnPrinted", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString());
|
|
#endregion
|
|
this.dgvPlan.DataSource = orderlist;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WriteLog.WriteError(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
timecounter = 0;
|
|
}
|
|
#endregion
|
|
}
|
|
private void cbRefreshRate_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
SaveSetting();
|
|
}
|
|
private void cbPlanFilter_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindPlanView();
|
|
SaveSetting();
|
|
}
|
|
|
|
private void SaveSetting()
|
|
{
|
|
string filepath = ConfigurationManager.AppSettings["SaveFilePath"];
|
|
filepath = string.Format("{0}ViewSetting.cfg", filepath);
|
|
var setting = new
|
|
{
|
|
ListRowcount = int.Parse(cbListRowcount.Text),
|
|
RefreshRate = int.Parse("20"),
|
|
//PlanFilter = cbPlanFilter.SelectedIndex
|
|
};
|
|
string settingstring = Newtonsoft.Json.JsonConvert.SerializeObject(setting);
|
|
System.IO.File.WriteAllText(filepath, settingstring);
|
|
}
|
|
int timecounter = 0;
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
if (!tsbOrderOperation.DropDown.Visible)
|
|
{
|
|
timecounter += 1;
|
|
if (timecounter > int.Parse("20"))//计时达到刷新时间
|
|
{
|
|
BindPlanView();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void PrintLabel(List<LabelData> labeldata)
|
|
{
|
|
#region 计划标签打印
|
|
//string xmlPath = System.Configuration.ConfigurationSettings.AppSettings["XmlName"].ToString(); ;
|
|
//BarcodeLib.BarCodeGenerate g = new BarcodeLib.BarCodeGenerate( xmlPath);
|
|
//bool b = g.PrintBarCode(_operationServiceParam.main.MAINCODE);
|
|
QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo();
|
|
StringBuilder dataline=new StringBuilder();
|
|
var TMPPath = string.Empty;
|
|
var DATPath = string.Empty;
|
|
foreach (var label in labeldata)
|
|
{
|
|
string[] texts = new string[8];
|
|
|
|
var sourcetext = label.Description.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
for (int i = 0; i < texts.Length && i < sourcetext.Length; i++)
|
|
{
|
|
texts[i] = sourcetext[i];
|
|
}
|
|
|
|
//OrderNo,OrderType,PlanDate,Name,Class,CarModel,Text1,Text2,Text3,Text4,Text5,Text6
|
|
dataline.AppendFormat("\"{0}\",\"{1}\",\"{2:yyyy-MM-dd HH:mm:ss}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",\"{13}\",\"{14}\"\r\n",
|
|
label.OrderNo,//计划号
|
|
label.OrderType,//计划类型(0:FIS,1:STOCK,2:INSERT)
|
|
label.PlanDate,//计划日期
|
|
label.MaterialName,//总成物料名称
|
|
label.Class,//
|
|
label.CarModel,//车型
|
|
texts[0],//装配详细信息
|
|
texts[1],//装配详细信息
|
|
texts[2],//装配详细信息
|
|
texts[3],//装配详细信息
|
|
texts[4],//装配详细信息
|
|
texts[5],//装配详细信息
|
|
texts[6],//装配详细信息
|
|
texts[7],//装配详细信息
|
|
label.MATERIALCODE//
|
|
);
|
|
if (label.OrderNo.Contains("018D"))
|
|
{
|
|
TMPPath = "PlanLabelTMPPath8D";
|
|
DATPath = "PlanLabelDATPath8D";
|
|
}
|
|
else
|
|
{
|
|
TMPPath = "PlanLabelTMPPath";
|
|
DATPath = "PlanLabelDATPath";
|
|
}
|
|
|
|
}
|
|
|
|
ll.BarCode=dataline.ToString().TrimEnd('\r','\n');
|
|
ll.PrinterName = "";
|
|
QM.Assist.PrintUtil.LabelList2.Add(ll);
|
|
QM.Assist.PrintUtil pu = new QM.Assist.PrintUtil();
|
|
pu.PrintLabel2(System.Configuration.ConfigurationManager.AppSettings["proPath"].ToString
|
|
(), System.Configuration.ConfigurationManager.AppSettings[TMPPath].ToString
|
|
(), System.Configuration.ConfigurationManager.AppSettings[DATPath].ToString
|
|
());
|
|
|
|
#endregion
|
|
}
|
|
|
|
private void PrintPlanLabel_Load(object sender, EventArgs e)
|
|
{
|
|
LoadViewSetting();
|
|
LoadProcessRoute();
|
|
//如果工位已设定
|
|
if (ClientContext.MachineInfo != null && !string.IsNullOrEmpty(ClientContext.MachineInfo.PID))
|
|
{
|
|
//this.comMachine.SelectedValue = ClientContext.MachineInfo.MACHINECODDE;
|
|
var route = _agent.InvokeServiceFunction<QMAPP.FJC.Entity.Basic.ProcessRoute>
|
|
("ProcessRouteBLL_GetRouteByMachine", ClientContext.MachineInfo.MACHINECODDE);
|
|
if (route != null)
|
|
{
|
|
this.cbRoutes.SelectedValue = route.ROUTE_CODE;
|
|
this.cbRoutes.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
this.cbRoutes.Enabled = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.cbRoutes.Enabled = true;
|
|
}
|
|
BindPlanView();
|
|
cbRoutes.SelectedIndexChanged += new EventHandler(cbRoutes_SelectedIndexChanged);
|
|
}
|
|
|
|
void cbRoutes_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindPlanView();
|
|
}
|
|
#region 工单操作
|
|
|
|
#region 取消挂起
|
|
/// <summary>
|
|
/// 取消挂起
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsmiCancelSuspend_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvPlan.SelectedRows.Count <= 0)
|
|
{
|
|
MessageBox.Show("请选择一条工单进行取消挂起操作!");
|
|
return;
|
|
}
|
|
List<string> ids = new List<string>();
|
|
foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows)
|
|
{
|
|
var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem;
|
|
if (!int.Equals(order.STATE, 4))
|
|
{
|
|
MessageBox.Show("只可取消状态为挂起的工单!");
|
|
return;
|
|
}
|
|
ids.Add(order.PID);
|
|
}
|
|
_agent.InvokeServiceFunction<int>(B9IPCService.WorkOrderBLL_CancelSuspend.ToString(), ids);
|
|
BindPlanView();
|
|
}
|
|
#endregion
|
|
|
|
#region 删除工单
|
|
/// <summary>
|
|
/// 删除工单
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsmiDeleteOrder_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvPlan.SelectedRows.Count <= 0)
|
|
{
|
|
MessageBox.Show("请选择一条工单进行删除操作!");
|
|
return;
|
|
}
|
|
List<string> ids = new List<string>();
|
|
foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows)
|
|
{
|
|
var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem;
|
|
if (!int.Equals(order.STATE, 4))
|
|
{
|
|
MessageBox.Show("只可删除状态为挂起的工单!");
|
|
return;
|
|
}
|
|
ids.Add(order.PID);
|
|
}
|
|
_agent.InvokeServiceFunction<int>(B9IPCService.WorkOrderBLL_DeleteOrder.ToString(), ids);
|
|
BindPlanView();
|
|
}
|
|
#endregion
|
|
|
|
#region 重置工单
|
|
/// <summary>
|
|
/// 重置工单
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsmiResetOrder_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvPlan.SelectedRows.Count <= 0)
|
|
{
|
|
MessageBox.Show("请选择一条工单进行重置操作!");
|
|
return;
|
|
}
|
|
List<string> ids = new List<string>();
|
|
foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows)
|
|
{
|
|
var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem;
|
|
if (!int.Equals(order.STATE, 4))
|
|
{
|
|
MessageBox.Show("只可重置状态为挂起的工单!");
|
|
return;
|
|
}
|
|
ids.Add(order.PID);
|
|
}
|
|
_agent.InvokeServiceFunction<int>(B9IPCService.WorkOrderBLL_ResetOrder.ToString(), ids);
|
|
BindPlanView();
|
|
}
|
|
#endregion
|
|
|
|
#region 挂起工单
|
|
/// <summary>
|
|
/// 挂起工单
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsmiSuspendOrder_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvPlan.SelectedRows.Count <= 0)
|
|
{
|
|
MessageBox.Show("请选择一条工单进行挂起操作!");
|
|
return;
|
|
}
|
|
List<string> ids = new List<string>();
|
|
foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows)
|
|
{
|
|
var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem;
|
|
if (int.Equals(order.STATE, 2))
|
|
{
|
|
MessageBox.Show("不能挂起正在执行的工单!");
|
|
return;
|
|
}
|
|
ids.Add(order.PID);
|
|
}
|
|
_agent.InvokeServiceFunction<int>(B9IPCService.WorkOrderBLL_SuspendOrder.ToString(), ids);
|
|
BindPlanView();
|
|
}
|
|
#endregion
|
|
|
|
#region 回收工单
|
|
/// <summary>
|
|
/// 回收工单
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tsmiTakebackOrder_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvPlan.SelectedRows.Count <= 0)
|
|
{
|
|
MessageBox.Show("请选择一条工单进行回收操作!");
|
|
return;
|
|
}
|
|
List<string> ids = new List<string>();
|
|
foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows)
|
|
{
|
|
var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem;
|
|
if (!int.Equals(order.STATE, 4))
|
|
{
|
|
MessageBox.Show("只可回收状态为挂起的工单!");
|
|
return;
|
|
}
|
|
ids.Add(order.PID);
|
|
}
|
|
_agent.InvokeServiceFunction<int>(B9IPCService.WorkOrderBLL_TakeBack.ToString(), ids);
|
|
BindPlanView();
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 工单列表选择发送变化时延时自动刷新
|
|
/// <summary>
|
|
/// 工单列表选择发送变化时延时自动刷新
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void dgvPlan_SelectionChanged(object sender, EventArgs e)
|
|
{
|
|
timecounter = -10;
|
|
}
|
|
#endregion
|
|
|
|
#region 设置计划工单列状态、颜色
|
|
/// <summary>
|
|
/// 设置计划工单列状态、颜色
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void dgvPlan_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
|
|
{
|
|
var WORKORDER_STATE_TEXT = new string[] { "初始", "确认", "执行中", "完成", "挂起" };
|
|
var row = dgvPlan.Rows[e.RowIndex];
|
|
var order = (FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem;
|
|
if (order.STATE >= 0 && order.STATE < WORKORDER_STATE_TEXT.Length)
|
|
{
|
|
row.Cells[dgcState.Name].Value = WORKORDER_STATE_TEXT[order.STATE];
|
|
}
|
|
if (order.STATE == FJC.Entity.EnumGeter.WorkOrderState.Suspended.GetHashCode())
|
|
{
|
|
row.DefaultCellStyle.BackColor = Color.LightGray;
|
|
row.DefaultCellStyle.ForeColor = Color.Gray;
|
|
}
|
|
if (order.STATE == FJC.Entity.EnumGeter.WorkOrderState.Executing.GetHashCode())
|
|
{
|
|
row.DefaultCellStyle.BackColor = Color.YellowGreen;
|
|
dgvPlan.ClearSelection();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void tsbPrint_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (dgvPlan.Rows.Count == 0)
|
|
{
|
|
MessageBox.Show("当前生产线没有未打印标签的计划工单!");
|
|
// return;
|
|
}
|
|
tsbPrint.Enabled = false;
|
|
var order1 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[0].DataBoundItem;
|
|
|
|
var orders = new List<FJC.Entity.ProductionPlan.WorkOrder>();
|
|
orders.Add(order1);
|
|
if (dgvPlan.Rows.Count > 1)
|
|
{
|
|
var orders2 = new List<FJC.Entity.ProductionPlan.WorkOrder>();
|
|
var order2 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[1].DataBoundItem;
|
|
orders2.Add(order2);
|
|
if (orders[0].MATERIAL_NAME.Substring(0, 7) != orders2[0].MATERIAL_NAME.Substring(0, 7))
|
|
{
|
|
MessageBox.Show("计划工单即将变换配置,请注意!");
|
|
}
|
|
}
|
|
|
|
List<LabelData> labels = new List<LabelData>();
|
|
|
|
var data = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
data = data.Substring(2, data.Length - 2);
|
|
//var codematch = System.Text.RegularExpressions.Regex.Match(order.PBOM_CODE, "_[LR][FR]_");
|
|
string positioncode = GetNameCode(orders[0].MATERIAL_NAME);
|
|
var book = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetFisPhraseBook", orders[0].MATERIAL_CODE + "", positioncode);
|
|
|
|
LabelData labeldata = new LabelData();
|
|
|
|
labeldata.MATERIALCODE = orders[0].MATERIAL_CODE;
|
|
|
|
|
|
labeldata.PlanDate = orders[0].PLAN_DATE;
|
|
if (book != null)
|
|
{
|
|
labeldata.Class = " " + book.CarModel.Substring(book.CarModel.Length-3, 3);
|
|
labeldata.Description = book.Text;
|
|
labeldata.OrderNo = book.CarModel + positioncode + data;
|
|
}
|
|
var mcresult = _agent.InvokeServiceFunction<DataResult<Material>>("MaterialBLL_Get", new Material { MATERIAL_CODE = orders[0].MATERIAL_CODE });
|
|
var material = mcresult.IsSuccess ? mcresult.Result : null;
|
|
if (material != null)
|
|
{
|
|
labeldata.MaterialName = material.MATERIAL_SHORT;
|
|
labeldata.CarModel = material.PROJECTCODE;
|
|
}
|
|
labels.Add(labeldata);
|
|
|
|
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始打印" + labeldata.OrderNo);
|
|
|
|
// PrintLabel(labels);
|
|
|
|
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始变成打印状态" + labeldata.OrderNo);
|
|
|
|
//变更打印状态 0=>1
|
|
_agent.InvokeServiceFunction<int>("WorkOrderBLL_SetOrderPrinted", orders[0].PID);
|
|
|
|
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始插入记录" + labeldata.OrderNo);
|
|
|
|
InsertProduct(labeldata.OrderNo, orders[0].MATERIAL_CODE, comboBox1.SelectedValue.ToString());
|
|
|
|
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 插入结束" + labeldata.OrderNo);
|
|
|
|
BindPlanView();
|
|
tsbPrint.Enabled = true;
|
|
|
|
|
|
}
|
|
catch (Exception ee)
|
|
{
|
|
MessageBox.Show("打印出现异常!"+ee.Message);
|
|
}
|
|
}
|
|
public string GetNameCode(string Name)
|
|
{
|
|
var Code = "";
|
|
if (!string.IsNullOrEmpty(Name))
|
|
{
|
|
if(Name.Contains("左前"))
|
|
Code = "FL";
|
|
else if(Name.Contains("左后"))
|
|
Code = "RL";
|
|
else if (Name.Contains("右前"))
|
|
Code = "FR";
|
|
else if (Name.Contains("右后"))
|
|
Code = "RR";
|
|
return Code;
|
|
}
|
|
else
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="ProductCode"></param>
|
|
/// <param name="Material_Code"></param>
|
|
public void InsertProduct(string ProductCode,string Material_Code,string prepare)
|
|
{
|
|
#region 组成新增产品实例
|
|
Product newProduct = new Product();
|
|
|
|
newProduct.PID = Guid.NewGuid().ToString();
|
|
|
|
newProduct.PRODUCTTYPE = string.Empty;
|
|
|
|
newProduct.PRODUCTCODE = ProductCode;
|
|
|
|
newProduct.PRODUCTSOURCE = "0";
|
|
|
|
newProduct.MACHINENAME = "门板打印";
|
|
|
|
newProduct.MACHINECODDE = "门板打印";
|
|
|
|
newProduct.MATERIAL_CODE = Material_Code;
|
|
|
|
newProduct.STATUS = "0";
|
|
|
|
newProduct.OUTFLAG = "0";
|
|
|
|
newProduct.CAPACITY = 1;
|
|
|
|
newProduct.USINGCOUNT = 0;
|
|
if (prepare.Contains("左"))
|
|
{
|
|
newProduct.WORKCELL_CODE = "DP_L_PREPARE1";
|
|
|
|
newProduct.WORKLOC_CODE = "DP_L_PREPARELOC1";
|
|
}
|
|
else if (prepare.Contains("右"))
|
|
{
|
|
newProduct.WORKCELL_CODE = "DP_R_PREPARE1";
|
|
|
|
newProduct.WORKLOC_CODE = "DP_R_PREPARELOC1";
|
|
}
|
|
else
|
|
{
|
|
newProduct.WORKCELL_CODE = "PREPARE1";
|
|
|
|
newProduct.WORKLOC_CODE = "DP_PREPARELOC1";
|
|
}
|
|
|
|
|
|
newProduct.WORKCENTER_CODE = "WORK770B";
|
|
|
|
newProduct.MATERIAL_TYPE = "DP_FINASSY";
|
|
|
|
newProduct.USINGSTATE = "0";
|
|
|
|
#endregion
|
|
|
|
//新增
|
|
//ProductHelper.Insert(newProduct);
|
|
_agent.InvokeServiceFunction<DataResult<int>>("ProductBLL_Insert", newProduct);
|
|
}
|
|
|
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
SaveSetting();
|
|
BindPlanView();
|
|
}
|
|
/// <summary>
|
|
/// 批量打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
|
{
|
|
var count = 0;
|
|
|
|
if (dgvPlan.Rows.Count == 0)
|
|
{
|
|
MessageBox.Show("当前生产线没有未打印标签的计划工单!");
|
|
}
|
|
if (int.Parse(cbListRowcount.Text) <= dgvPlan.Rows.Count)
|
|
count = int.Parse(cbListRowcount.Text);
|
|
else
|
|
count = dgvPlan.Rows.Count;
|
|
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
System.Threading.Thread.Sleep(3000);
|
|
|
|
var orders = new List<FJC.Entity.ProductionPlan.WorkOrder>();
|
|
|
|
var order1 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[i].DataBoundItem;
|
|
orders.Add(order1);
|
|
|
|
if ((i+1)< count)
|
|
{
|
|
var orders2 = new List<FJC.Entity.ProductionPlan.WorkOrder>();
|
|
var order2 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[i + 1].DataBoundItem;
|
|
orders2.Add(order2);
|
|
if (orders[0].MATERIAL_NAME.Substring(0, 7) != orders2[0].MATERIAL_NAME.Substring(0, 7))
|
|
{
|
|
MessageBox.Show("计划工单即将变换配置,请注意!");
|
|
}
|
|
}
|
|
|
|
toolStripButton1.Enabled = false;
|
|
|
|
List<LabelData> labels = new List<LabelData>();
|
|
|
|
var data = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
data = data.Substring(2, data.Length - 2);
|
|
|
|
string positioncode = GetNameCode(orders[0].MATERIAL_NAME);
|
|
var book = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetFisPhraseBook", orders[0].MATERIAL_CODE + "", positioncode);
|
|
|
|
LabelData labeldata = new LabelData();
|
|
|
|
labeldata.MATERIALCODE = orders[0].MATERIAL_CODE;
|
|
|
|
|
|
labeldata.PlanDate = orders[0].PLAN_DATE;
|
|
if (book != null)
|
|
{
|
|
labeldata.Class = " " + book.Class.Substring(0, 2);
|
|
labeldata.Description = book.Text;
|
|
labeldata.OrderNo = book.CarModel + positioncode + data;
|
|
}
|
|
var mcresult = _agent.InvokeServiceFunction<DataResult<Material>>("MaterialBLL_Get", new Material { MATERIAL_CODE = orders[0].MATERIAL_CODE });
|
|
var material = mcresult.IsSuccess ? mcresult.Result : null;
|
|
if (material != null)
|
|
{
|
|
labeldata.MaterialName = material.MATERIAL_SHORT;
|
|
labeldata.CarModel = material.PROJECTCODE;
|
|
}
|
|
labels.Add(labeldata);
|
|
|
|
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始打印" + labeldata.OrderNo);
|
|
|
|
PrintLabel(labels);
|
|
|
|
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始变成打印状态" + labeldata.OrderNo);
|
|
//变更打印状态 0=>1
|
|
_agent.InvokeServiceFunction<int>("WorkOrderBLL_SetOrderPrinted", orders[0].PID);
|
|
|
|
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始插入记录" + labeldata.OrderNo);
|
|
InsertProduct(labeldata.OrderNo, orders[0].MATERIAL_CODE, comboBox1.SelectedValue.ToString());
|
|
|
|
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 插入结束" + labeldata.OrderNo);
|
|
}
|
|
|
|
BindPlanView();
|
|
toolStripButton1.Enabled = true;
|
|
}
|
|
|
|
private void toolStripButton2_Click(object sender, EventArgs e)
|
|
{
|
|
PlanRePrintForm frm = new PlanRePrintForm(this);
|
|
frm.ShowDialog();
|
|
}
|
|
|
|
private void dtpCREATEDATESTART_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
BindPlanView();
|
|
}
|
|
|
|
private void dtpCREATEDATEEND_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
BindPlanView();
|
|
}
|
|
}
|
|
class Direction {
|
|
public string Code { get; set; }
|
|
public string Name { get; set; }
|
|
}
|
|
class LabelData
|
|
{
|
|
public string OrderNo { get; set; }
|
|
|
|
public string MATERIALCODE { get; set; }
|
|
|
|
public DateTime PlanDate { get; set; }
|
|
|
|
public string Class { get; set; }
|
|
|
|
public string Description { get; set; }
|
|
|
|
public string MaterialName { get; set; }
|
|
|
|
public string CarModel { get; set; }
|
|
|
|
public object[] OrderType { get; set; }
|
|
}
|
|
}
|
|
|