天津投入产出系统后端
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.

804 lines
32 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;
3 years ago
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;
3 years ago
private string planMATERIAL_CODE = string.Empty;
private string FR = string.Empty;
3 years ago
/// <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;
3 years ago
//cbsource.Insert(0, new QMAPP.FJC.Entity.Basic.ProcessRoute { ROUTE_NAME = "", ROUTE_CODE = "" });
cbRoutes.DisplayMember = "ROUTE_NAME";
cbRoutes.ValueMember = "ROUTE_CODE";
cbRoutes.DataSource = cbsource;
3 years ago
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;
3 years ago
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;
2 years ago
2 years ago
// 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);
3 years ago
comboBox1.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged);
3 years ago
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";
2 years ago
if (cbRoutes.Text.Contains("018D") || cbRoutes.Text.Contains("278D"))
{
var count = Convert.ToInt32(cbListRowcount.Text) / 2;
2 years ago
var orderlist = new List<FJC.Entity.ProductionPlan.WorkOrder>();
var orderlistF = _agent.InvokeServiceFunction<List<FJC.Entity.ProductionPlan.WorkOrder>>("TJWorkOrderBLL_GetOrderUnPrinted018DF", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString());
var orderlistR = _agent.InvokeServiceFunction<List<FJC.Entity.ProductionPlan.WorkOrder>>("TJWorkOrderBLL_GetOrderUnPrinted018DR", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString());
for (var i = 0; i < count; i++)
{
if (string.IsNullOrEmpty(FR) || FR == "前")
{
if (i < orderlistF.Count)
orderlist.Add(orderlistF[i]);
if (i < orderlistR.Count)
orderlist.Add(orderlistR[i]);
}
else if (FR == "后")
{
if (i < orderlistR.Count)
orderlist.Add(orderlistR[i]);
if (i < orderlistF.Count)
orderlist.Add(orderlistF[i]);
}
}
this.dgvPlan.DataSource = orderlist;
}
else
{
#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;
}
2 years ago
}
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);
2 years ago
if (string.IsNullOrEmpty(cbListRowcount.Text))
cbListRowcount.Text = "1";
var setting = new
{
2 years ago
ListRowcount = int.Parse("100"),
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();
2 years ago
StringBuilder dataline = new StringBuilder();
3 years ago
var TMPPath = string.Empty;
var DATPath = string.Empty;
foreach (var label in labeldata)
{
3 years ago
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}\",\"{15}\"\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],//装配详细信息
3 years ago
texts[5],//装配详细信息
3 years ago
texts[6],//装配详细信息
texts[7],//装配详细信息
label.MATERIALCODE,//
label.Remark
);
2 years ago
if (label.OrderNo.Contains("018D") || label.OrderNo.Contains("278D"))
3 years ago
{
TMPPath = "PlanLabelTMPPath8D";
DATPath = "PlanLabelDATPath8D";
}
else
{
TMPPath = "PlanLabelTMPPath";
DATPath = "PlanLabelDATPath";
}
}
2 years ago
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
3 years ago
(), System.Configuration.ConfigurationManager.AppSettings[TMPPath].ToString
(), System.Configuration.ConfigurationManager.AppSettings[DATPath].ToString
());
#endregion
}
2 years ago
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;
}
}
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)
{
2 years ago
try
{
2 years ago
if (dgvPlan.Rows.Count == 0)
{
MessageBox.Show("当前生产线没有未打印标签的计划工单!");
2 years ago
// return;
2 years ago
}
tsbPrint.Enabled = false;
var order1 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[0].DataBoundItem;
2 years ago
var orders = new List<FJC.Entity.ProductionPlan.WorkOrder>();
orders.Add(order1);
2 years ago
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);
2 years ago
if ((orders[0].MATERIAL_NAME.Substring(0, 7) != orders2[0].MATERIAL_NAME.Substring(0, 7)) && !orders[0].MATERIAL_CODE.Contains("018D") && !orders[0].MATERIAL_CODE.Contains("278D"))
2 years ago
{
MessageBox.Show("计划工单即将变换配置,请注意!");
}
}
2 years ago
List<LabelData> labels = new List<LabelData>();
2 years ago
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);
2 years ago
LabelData labeldata = new LabelData();
3 years ago
2 years ago
labeldata.MATERIALCODE = orders[0].MATERIAL_CODE;
3 years ago
2 years ago
labeldata.PlanDate = orders[0].PLAN_DATE;
if (book != null)
{
2 years ago
labeldata.Class = " " + book.CarModel.Substring(book.CarModel.Length - 3, 3);
2 years ago
labeldata.Description = book.Text;
labeldata.OrderNo = book.CarModel + positioncode + data;
2 years ago
if (orders[0].MATERIAL_CODE.Contains("018D")|| orders[0].MATERIAL_CODE.Contains("278D"))
{
var bookS = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetPHRASEBOOK", labeldata.Class.Trim());
labeldata.Remark = bookS.Text;
}
2 years ago
}
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);
2 years ago
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始打印" + labeldata.OrderNo);
2 years ago
PrintLabel(labels);
2 years ago
2 years ago
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始变成打印状态" + labeldata.OrderNo);
2 years ago
//变更打印状态 0=>1
_agent.InvokeServiceFunction<int>("WorkOrderBLL_SetOrderPrinted", orders[0].PID);
2 years ago
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始插入记录" + labeldata.OrderNo);
2 years ago
InsertProduct(labeldata.OrderNo, orders[0].MATERIAL_CODE, comboBox1.SelectedValue.ToString());
2 years ago
WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 插入结束" + labeldata.OrderNo);
2 years ago
if ((orders[0].MATERIAL_CODE.Contains("018D") || orders[0].MATERIAL_CODE.Contains("278D")) && orders[0].MATERIAL_NAME.Contains("前"))
FR = "后";
2 years ago
else if ((orders[0].MATERIAL_CODE.Contains("018D") || orders[0].MATERIAL_CODE.Contains("278D")) && orders[0].MATERIAL_NAME.Contains("后"))
FR = "前";
2 years ago
BindPlanView();
tsbPrint.Enabled = true;
2 years ago
}
2 years ago
catch (Exception ee)
3 years ago
{
2 years ago
MessageBox.Show("打印出现异常!" + ee.Message);
3 years ago
}
}
public string GetNameCode(string Name)
{
var Code = "";
if (!string.IsNullOrEmpty(Name))
{
2 years ago
if (Name.Contains("左前"))
Code = "FL";
2 years ago
else if (Name.Contains("左后"))
Code = "RL";
else if (Name.Contains("右前"))
Code = "FR";
else if (Name.Contains("右后"))
Code = "RR";
return Code;
}
else
return null;
}
3 years ago
3 years ago
/// <summary>
///
/// </summary>
/// <param name="ProductCode"></param>
/// <param name="Material_Code"></param>
2 years ago
public void InsertProduct(string ProductCode, string Material_Code, string prepare)
3 years ago
{
#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;
2 years ago
if (prepare.Contains("左"))
{
newProduct.WORKCELL_CODE = "DP_L_PREPARE1";
3 years ago
2 years ago
newProduct.WORKLOC_CODE = "DP_L_PREPARELOC1";
}
else if (prepare.Contains("右"))
{
newProduct.WORKCELL_CODE = "DP_R_PREPARE1";
3 years ago
2 years ago
newProduct.WORKLOC_CODE = "DP_R_PREPARELOC1";
}
else
{
newProduct.WORKCELL_CODE = "PREPARE1";
newProduct.WORKLOC_CODE = "DP_PREPARELOC1";
}
2 years ago
3 years ago
newProduct.WORKCENTER_CODE = "WORK770B";
newProduct.MATERIAL_TYPE = "DP_FINASSY";
newProduct.USINGSTATE = "0";
#endregion
//新增
//ProductHelper.Insert(newProduct);
_agent.InvokeServiceFunction<DataResult<int>>("ProductBLL_Insert", newProduct);
}
3 years ago
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
SaveSetting();
BindPlanView();
}
3 years ago
/// <summary>
/// 批量打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton1_Click(object sender, EventArgs e)
{
var count = 0;
2 years ago
3 years ago
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;
2 years ago
3 years ago
for (var i = 0; i < count; i++)
{
System.Threading.Thread.Sleep(1000);
3 years ago
3 years ago
var orders = new List<FJC.Entity.ProductionPlan.WorkOrder>();
var order1 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[i].DataBoundItem;
orders.Add(order1);
2 years ago
if ((i + 1) < count)
2 years ago
{
var orders2 = new List<FJC.Entity.ProductionPlan.WorkOrder>();
var order2 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[i + 1].DataBoundItem;
orders2.Add(order2);
2 years ago
if ((orders[0].MATERIAL_NAME.Substring(0, 7) != orders2[0].MATERIAL_NAME.Substring(0, 7)) && !orders[0].MATERIAL_CODE.Contains("018D") && !orders[0].MATERIAL_CODE.Contains("278D"))
2 years ago
{
MessageBox.Show("计划工单即将变换配置,请注意!");
}
}
3 years ago
toolStripButton1.Enabled = false;
2 years ago
3 years ago
List<LabelData> labels = new List<LabelData>();
var data = DateTime.Now.ToString("yyyyMMddHHmmssfff");
data = data.Substring(2, data.Length - 2);
2 years ago
3 years ago
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;
2 years ago
if (orders[0].MATERIAL_CODE.Contains("018D")|| orders[0].MATERIAL_CODE.Contains("278D"))
2 years ago
{
2 years ago
var bookS = _agent.InvokeServiceFunction<FJC.Entity.FIS.FISPhraseBook>("FISPhraseBLL_GetPHRASEBOOK", orders[0].MATERIAL_CODE.Substring(5, 3).Trim());
2 years ago
labeldata.Remark = bookS.Text;
}
2 years ago
3 years ago
}
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);
2 years ago
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始打印" + labeldata.OrderNo);
2 years ago
2 years ago
PrintLabel(labels);
3 years ago
2 years ago
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始变成打印状态" + labeldata.OrderNo);
3 years ago
//变更打印状态 0=>1
_agent.InvokeServiceFunction<int>("WorkOrderBLL_SetOrderPrinted", orders[0].PID);
2 years ago
2 years ago
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始插入记录" + labeldata.OrderNo);
2 years ago
InsertProduct(labeldata.OrderNo, orders[0].MATERIAL_CODE, comboBox1.SelectedValue.ToString());
2 years ago
if ((orders[0].MATERIAL_CODE.Contains("018D") || orders[0].MATERIAL_CODE.Contains("278D")) && orders[0].MATERIAL_NAME.Contains("前"))
FR = "后";
2 years ago
else if ((orders[0].MATERIAL_CODE.Contains("018D") || orders[0].MATERIAL_CODE.Contains("278D")) && orders[0].MATERIAL_NAME.Contains("后"))
FR = "前";
2 years ago
//WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 插入结束" + labeldata.OrderNo);
3 years ago
}
BindPlanView();
toolStripButton1.Enabled = true;
}
3 years ago
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();
}
/// <summary>
/// 刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SelectStripButton_Click(object sender, EventArgs e)
{
BindPlanView();
}
3 years ago
}
2 years ago
class Direction
{
3 years ago
public string Code { get; set; }
public string Name { get; set; }
}
class LabelData
{
public string OrderNo { get; set; }
3 years ago
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; }
public string Remark { get; set; }
}
}