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.
1092 lines
45 KiB
1092 lines
45 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Linq;
|
|
using System.Linq;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.BandedGrid;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.Report.GridReport;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Collections;
|
|
using ICSSoft.Frame.DataConnect;
|
|
using ICSSoft.Frame.DataConnect.Action;
|
|
using ICSSoft.Frame.DataCollect;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormMaterialColect : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private ActionCheckStatus actionCheckStatus = new ActionCheckStatus();
|
|
private Hashtable listActionCheckStatus = new Hashtable();
|
|
private DataSet ds;
|
|
private DataTable dtzhu;
|
|
private DataTable dtone;
|
|
//资源
|
|
public string res = "";
|
|
string checkGroup = "";
|
|
string _RuningCard = "";
|
|
private ICSRES Resource;
|
|
String guid = AppConfig.GetGuid();
|
|
FormDataShow datashow = new FormDataShow();
|
|
private bool _NeedInputLotPart;
|
|
private ICSBaseModel _ICSBaseModel = null;
|
|
private ProductInfo productInfo = null;
|
|
private Hashtable listOpBomKeyParts = new Hashtable();
|
|
|
|
|
|
private string _inno;
|
|
private string INNO
|
|
{
|
|
get
|
|
{
|
|
return _inno;
|
|
}
|
|
set
|
|
{
|
|
_inno = value.Trim();
|
|
}
|
|
}
|
|
|
|
private const string opCollectAutoCollectLotPart = "0";
|
|
private const string opCollectNeedInputLotPart = "1";
|
|
private int _CollectedCount = 0;
|
|
|
|
private List<ICSOPBOMDETAIL> _OPBOMDetailList;
|
|
private ArrayList _OPBOMDetailArrayList = new ArrayList();
|
|
|
|
private List<ICSOPBOMDETAIL> _OPBOMDetailKeyPartList;
|
|
private ArrayList _OPBOMDetailKeyPartArrayList = new ArrayList();
|
|
|
|
private List<ICSMINNO> _PreparedLotPartList;
|
|
private ArrayList _PreparedLotPartArrayList = new ArrayList();
|
|
|
|
private List<ICSOPBOMDETAIL> _objBomDetailNotFilter;
|
|
ArrayList _InputPartList = new ArrayList();
|
|
|
|
private FramDataContext _domainDataProvider = null;
|
|
private FramDataContext DataProvider
|
|
{
|
|
get
|
|
{
|
|
return _domainDataProvider;
|
|
}
|
|
}
|
|
private DataCollectFacade _DataCollectFacade;
|
|
private ICSMINNOBLL _MinnoBll = null;
|
|
private bool _HaveCollectMaterial = false;
|
|
|
|
private int _FlowControl = -1;
|
|
private int FlowControl
|
|
{
|
|
get
|
|
{
|
|
return _FlowControl;
|
|
}
|
|
set
|
|
{
|
|
_FlowControl = value;
|
|
}
|
|
}
|
|
|
|
#region 构造函数
|
|
public FormMaterialColect()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
_domainDataProvider = new FramDataContext(AppConfig.AppConnectString);
|
|
_DataCollectFacade = new DataCollectFacade(this._domainDataProvider);
|
|
_ICSBaseModel = new ICSBaseModel(this._domainDataProvider);
|
|
|
|
}
|
|
public FormMaterialColect(string resource)
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
ds = new DataSet();
|
|
res = resource;
|
|
_domainDataProvider = new FramDataContext(AppConfig.AppConnectString);
|
|
_DataCollectFacade = new DataCollectFacade(this._domainDataProvider);
|
|
_ICSBaseModel = new ICSBaseModel(this._domainDataProvider);
|
|
}
|
|
#endregion
|
|
|
|
private void FormICSONWIPITEM_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FormResourceLogin formResourceLogin = new FormResourceLogin(this);
|
|
formResourceLogin.ShowDialog();
|
|
|
|
txtInfo.Text = "当前登陆资源是:" + res;
|
|
Resource = this._domainDataProvider.ICSRES.SingleOrDefault(a => a.RESCODE == this.res && a.WorkPoint == AppConfig.WorkPointCode);
|
|
|
|
string sql = @"select OPCODE
|
|
from ICSOP2RES
|
|
where RESCODE='" + res + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
string op = data.Rows[0]["OPCODE"].ToString();
|
|
txtOP.Text = "工序:" + op;
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#region 退出关闭
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
datashow.Close();
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
datashow.Close();
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
|
|
}
|
|
|
|
#endregion
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref System.Windows.Forms.Message m)
|
|
{
|
|
|
|
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 列表
|
|
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
#endregion
|
|
|
|
private void btnModify_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void txtRcard_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyChar == '\r')
|
|
{
|
|
if (txtInput.Text.Trim() == string.Empty)
|
|
{
|
|
if (string.IsNullOrEmpty(this.txtMo.Text.Trim()))
|
|
{
|
|
txtMessage.Text = "请输入序列号";
|
|
this.txtInput.Focus();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
txtMessage.Text += " \r\n请输入物料条码";
|
|
this.txtInput.Focus();
|
|
return;
|
|
}
|
|
}
|
|
Collect();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
txtMessage.Text += "\r\n"+ex.Message;
|
|
}
|
|
}
|
|
|
|
private void txtRcard_Validated(object sender, EventArgs e)
|
|
{
|
|
string sql = @"select b.MOCODE as mocode,b.ITEMCODE as itemcode,a.RCARD
|
|
from ICSMO2RCARD a
|
|
left join ICSMO b on a.MOCODE=b.MOCODE
|
|
where RCARD='"+txtInput.Text.Trim()+"' ";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0];
|
|
txtMo.Text = dt.Rows[0]["mocode"].ToString();
|
|
txtItemCode.Text = dt.Rows[0]["itemcode"].ToString();
|
|
|
|
Blind();
|
|
}
|
|
|
|
private void Blind()
|
|
{
|
|
//绑定
|
|
ds.Reset();
|
|
dtzhu = null;
|
|
dtone = null;
|
|
dtzhu = MainTable().Copy();
|
|
dtone = OneTable().Copy();
|
|
dtzhu.TableName = "one";
|
|
dtone.TableName = "two";
|
|
ds.Tables.Add(dtzhu);
|
|
ds.Tables.Add(dtone);
|
|
DataRelation dr = new DataRelation("Level1", new DataColumn[] { ds.Tables[0].Columns["CKGROUP"] }, new DataColumn[] { ds.Tables[1].Columns["ziCKGROUP"] });
|
|
ds.Relations.Add(dr);
|
|
}
|
|
|
|
public DataTable MainTable()
|
|
{
|
|
string sql=@"select a.CKGROUP,b.CKGROUPDESC
|
|
from ICSMODELOP2CKGROUP a
|
|
left join ICSOQCCKGROUP b on a.CKGROUP=b.CKGROUP
|
|
where a.ITEMCODE='{0}' and a.OPCODE in(select OPCODE from ICSOP2RES where RESCODE='{1}')";
|
|
sql = string.Format(sql,txtItemCode.Text,res);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
checkGroup = data.Rows[0]["CKGROUP"].ToString();
|
|
return data;
|
|
}
|
|
|
|
public DataTable OneTable()
|
|
{
|
|
string sql = @"select a.CKITEMCODE,a.CKITEMDESC,a.SetValueMin,a.SetValueMax,b.CKGROUP as ziCKGROUP
|
|
from ICSOQCCKLIST a
|
|
left join ICSOQCCKGROUP2LIST b on a.CKITEMCODE=b.CKITEMCODE
|
|
where b.CKGROUP in(select a.CKGROUP
|
|
from ICSMODELOP2CKGROUP a
|
|
left join ICSOQCCKGROUP b on a.CKGROUP=b.CKGROUP
|
|
where a.ITEMCODE='{0}' and a.OPCODE in(select OPCODE from ICSOP2RES where RESCODE='{1}'))";
|
|
sql = string.Format(sql, txtItemCode.Text, this.res);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return data;
|
|
}
|
|
|
|
private void lblTitle_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void txtMo_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void txtMo_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private bool GetOPBOMKeyparts()
|
|
{
|
|
OPBomKeyparts opBOMKeyparts = null;
|
|
Messages msgMo = new Messages();
|
|
try
|
|
{
|
|
//为改善性能
|
|
string strMoCode = this.txtMo.Text.Trim();
|
|
|
|
object[] objKeyParts = (object[])listOpBomKeyParts[strMoCode];
|
|
if (objKeyParts != null)
|
|
{
|
|
opBOMKeyparts = new OPBomKeyparts((List<ICSOPBOMDETAIL>)objKeyParts[0], Convert.ToInt32(objKeyParts[1]), this.DataProvider);
|
|
|
|
if (opBOMKeyparts != null && opBOMKeyparts.Count == 0)
|
|
{
|
|
throw new Exception(objKeyParts[2].ToString());
|
|
}
|
|
}
|
|
|
|
if (opBOMKeyparts == null)
|
|
{
|
|
DataCollect.ActionOnLineHelper onLine = new DataCollect.ActionOnLineHelper(this.DataProvider);
|
|
#region 先推途程,然后找OPBOM
|
|
ProductInfo product=null;
|
|
ICSMO mo = null;
|
|
Messages messages1 = onLine.GetIDInfoByMoCodeAndId(strMoCode, _RuningCard);
|
|
if (messages1.IsSuccess())
|
|
{
|
|
product = (ProductInfo)messages1.GetData().Values[0];
|
|
|
|
//如果归属工单,则做归属工单检查,否则做序列号途程检查
|
|
if (msgMo.GetData() != null) // 需要归属工单,做归属工单检查
|
|
{
|
|
ICSSoft.Frame.DataConnect.Message msgMoData = msgMo.GetData();
|
|
mo = (ICSMO)msgMoData.Values[0];
|
|
ActionGoToMO goToMO = new ActionGoToMO(this.DataProvider);
|
|
GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs(ActionType.DataCollectAction_GoMO, _RuningCard, AppConfig.UserCode,
|
|
this.res, product, mo.MOCODE);
|
|
messages1 = goToMO.CheckIn(MOActionEventArgs);
|
|
if (!MOActionEventArgs.PassCheck)
|
|
{
|
|
messages1 = onLine.CheckID(new CKeypartsActionEventArgs(ActionType.DataCollectAction_CollectINNO, _RuningCard, AppConfig.UserCode,
|
|
this.res, product, null));
|
|
}
|
|
}
|
|
else // 不需要归属工单,检查序列号途程
|
|
{
|
|
messages1 = onLine.CheckID(new CKeypartsActionEventArgs(ActionType.DataCollectAction_CollectINNO, _RuningCard, AppConfig.UserCode,
|
|
this.res, product, null));
|
|
}
|
|
if (messages1.IsSuccess() == false)
|
|
{
|
|
throw new Exception(" 产品序列号: " + this.txtInput.Text.Trim());
|
|
}
|
|
}
|
|
|
|
ICSMO moNew = (ICSMO)this.DataProvider.ICSMO.SingleOrDefault(a => a.MOCODE == this.txtMo.Text.Trim());
|
|
ICSOPBOMDETAILBLL opBOMFacade = new ICSOPBOMDETAILBLL(this.DataProvider);
|
|
|
|
_OPBOMDetailList = opBOMFacade.QueryOPBOMDetail(product.NowSimulation.ITEMCODE, string.Empty, string.Empty, moNew.MOBOM,
|
|
product.NowSimulation.ROUTECODE, product.NowSimulation.OPCODE, (int)MaterialType.CollectMaterial, true);
|
|
|
|
if (_OPBOMDetailList == null || _OPBOMDetailList.Count <= 0)
|
|
{
|
|
throw new Exception("产品序列号: " + this.txtInput.Text+",对应的工序BOM不存在");
|
|
}
|
|
_objBomDetailNotFilter = _OPBOMDetailList;
|
|
//过滤备选料
|
|
_OPBOMDetailList = FilterOPBOMDetail(_OPBOMDetailList);
|
|
|
|
if (_OPBOMDetailList == null || _OPBOMDetailList.Count <= 0)
|
|
{
|
|
throw new Exception("产品序列号: " + this.txtInput.Text + ",对应的工序BOM不存在");
|
|
}
|
|
//获取批控管上料资料
|
|
//注意:检查icsminno中的数据是否能对应到icsopbomdetail中
|
|
object[] tempMinNo = null;
|
|
_MinnoBll.QueryMINNO(strMoCode, product.NowSimulation.ROUTECODE,
|
|
product.NowSimulation.OPCODE, this.res, moNew.MOBIOSVER);
|
|
if (tempMinNo == null)
|
|
{
|
|
_PreparedLotPartList = null;
|
|
}
|
|
else
|
|
{
|
|
List<ICSMINNO> minnoList = new List<ICSMINNO>();
|
|
foreach (ICSMINNO minno in tempMinNo)
|
|
{
|
|
bool found = false;
|
|
if (_OPBOMDetailList != null)
|
|
{
|
|
foreach (ICSOPBOMDETAIL opBOMDetail in _objBomDetailNotFilter)
|
|
{
|
|
if ((minno.MITEMCODE == opBOMDetail.OBSITEMCODE || minno.MITEMCODE == opBOMDetail.OBITEMCODE)
|
|
&& opBOMDetail.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_LOT
|
|
)
|
|
{
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (found)
|
|
minnoList.Add(minno);
|
|
}
|
|
_PreparedLotPartList = minnoList;
|
|
}
|
|
|
|
_OPBOMDetailKeyPartList = opBOMFacade.GetOPBOMDetails(strMoCode,
|
|
product.NowSimulation.ROUTECODE, product.NowSimulation.OPCODE, true, true);
|
|
|
|
//过滤备选料
|
|
if (_OPBOMDetailKeyPartList != null)
|
|
{
|
|
_OPBOMDetailKeyPartList = FilterOPBOMDetail(_OPBOMDetailKeyPartList);
|
|
}
|
|
opBOMKeyparts = new OPBomKeyparts(_OPBOMDetailList, Convert.ToInt32(mo.IDMERGERULE), this.DataProvider);
|
|
if (_OPBOMDetailList != null && _OPBOMDetailList.Count > 0)
|
|
{
|
|
this.GetOPBOMDetailCount();
|
|
}
|
|
int _OPBOMDetailLotPartCount = 0;
|
|
if (_PreparedLotPartList != null)
|
|
_OPBOMDetailLotPartCount = _PreparedLotPartList.Count;
|
|
if (_OPBOMDetailKeyPartList != null && _NeedInputLotPart == false && _OPBOMDetailList.Count > (_OPBOMDetailKeyPartList.Count + _OPBOMDetailLotPartCount))
|
|
{
|
|
throw new Exception("产品序列号: " + this.txtInput.Text);
|
|
}
|
|
if (_OPBOMDetailKeyPartList == null && _NeedInputLotPart == false && _OPBOMDetailList.Count > _OPBOMDetailLotPartCount)
|
|
{
|
|
throw new Exception("产品序列号: " + this.txtInput.Text);
|
|
}
|
|
if (!listOpBomKeyParts.ContainsKey(mo.MOCODE))
|
|
{
|
|
string strMsg = "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCODE + " $CS_Param_RouteCode=" + product.NowSimulation.ROUTECODE + " $CS_Param_OPCode =" + product.NowSimulation.OPCODE;
|
|
listOpBomKeyParts.Add(mo.MOCODE, new object[] { _OPBOMDetailList, Convert.ToInt32(mo.IDMERGERULE), strMsg });
|
|
}
|
|
#endregion
|
|
}
|
|
//输出提示信息
|
|
if (!_NeedInputLotPart && _OPBOMDetailKeyPartList == null)
|
|
{
|
|
|
|
}
|
|
string materialCode = "";
|
|
string materialDesc = "";
|
|
if (_NeedInputLotPart == true && _OPBOMDetailList != null)
|
|
{
|
|
materialCode = ((ICSOPBOMDETAIL)_OPBOMDetailList[0]).OBSITEMCODE;
|
|
object objMaterial = this.DataProvider.ICSINVENTORY.SingleOrDefault() ;//获取料号信息
|
|
if (objMaterial != null)
|
|
{
|
|
materialDesc = ((ICSINVENTORY)objMaterial).INVDESC;
|
|
}
|
|
if (((ICSOPBOMDETAIL)_OPBOMDetailList[0]).OBITEMCONTYPE == "item_control_lot")
|
|
{
|
|
throw new Exception(">>$CS_PleaseInputLot>>$CS_Param_Lot=" + materialCode);
|
|
}
|
|
}
|
|
else if (_NeedInputLotPart == false && _OPBOMDetailKeyPartList != null)
|
|
{
|
|
materialCode = ((ICSOPBOMDETAIL)_OPBOMDetailKeyPartList[0]).OBSITEMCODE;
|
|
object objMaterial = this.DataProvider.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == materialCode && a.WorkPoint == AppConfig.WorkPointCode);//获取料号信息
|
|
if (objMaterial != null)
|
|
{
|
|
materialDesc = ((ICSINVENTORY)objMaterial).INVDESC;
|
|
}
|
|
}
|
|
else if (_NeedInputLotPart == false && _PreparedLotPartList == null && _OPBOMDetailKeyPartList == null)
|
|
{
|
|
throw new Exception("产品序列号: " + this.txtInput.Text.Trim());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("产品序列号: " + this.txtInput.Text.Trim()+ex.Message);
|
|
}
|
|
}
|
|
|
|
//自动采集所有Lot物料
|
|
private bool AutoCollectAllLotPart()
|
|
{
|
|
if (_PreparedLotPartList != null)
|
|
{
|
|
for (int i = 0; i < _PreparedLotPartList.Count; i++)
|
|
{
|
|
try
|
|
{
|
|
string moCode = ((ICSMINNO)_PreparedLotPartList[i]).MOCODE;
|
|
string mItemCode = ((ICSMINNO)_PreparedLotPartList[i]).MITEMCODE;
|
|
string barcode = ((ICSMINNO)_PreparedLotPartList[i]).MITEMPACKEDNO;
|
|
|
|
object opBomDetailNew = _objBomDetailNotFilter[0];
|
|
if (_objBomDetailNotFilter != null && _objBomDetailNotFilter.Count > 0)
|
|
{
|
|
for (int j = 0; j < _objBomDetailNotFilter.Count; j++)
|
|
{
|
|
if (((ICSOPBOMDETAIL)_objBomDetailNotFilter[j]).OBITEMCODE == mItemCode
|
|
|| ((ICSOPBOMDETAIL)_objBomDetailNotFilter[j]).OBSITEMCODE == ((ICSMINNO)_PreparedLotPartList[i]).MOBSITEMCODE)
|
|
{
|
|
opBomDetailNew = _objBomDetailNotFilter[j];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!CollectPart((ICSOPBOMDETAIL)opBomDetailNew, barcode))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception( "产品序列号: " + this.txtInput.Text.Trim());
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//获取ArrayList与Count
|
|
private void GetOPBOMDetailCount()
|
|
{
|
|
if (_OPBOMDetailList != null)
|
|
{
|
|
for (int i = 0; i < _OPBOMDetailList.Count; i++)
|
|
{
|
|
if (((ICSOPBOMDETAIL)_OPBOMDetailList[i]).OBITEMCONTYPE == "item_control_lot")
|
|
{
|
|
_OPBOMDetailArrayList.Add(_OPBOMDetailList[i]);
|
|
}
|
|
else
|
|
{
|
|
int number = Convert.ToInt32(((ICSOPBOMDETAIL)_OPBOMDetailList[i]).OBITEMQTY);
|
|
for (int j = 0; j < number; j++)
|
|
{
|
|
_OPBOMDetailArrayList.Add(_OPBOMDetailList[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (_OPBOMDetailKeyPartList != null)
|
|
{
|
|
for (int i = 0; i < _OPBOMDetailKeyPartList.Count; i++)
|
|
{
|
|
int number = Convert.ToInt32(((ICSOPBOMDETAIL)_OPBOMDetailKeyPartList[i]).OBITEMQTY);
|
|
for (int j = 0; j < number; j++)
|
|
{
|
|
_OPBOMDetailKeyPartArrayList.Add(_OPBOMDetailKeyPartList[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (_PreparedLotPartList != null)
|
|
{
|
|
for (int i = 0; i < _PreparedLotPartList.Count; i++)
|
|
{
|
|
int number = Convert.ToInt32(((ICSMINNO)_PreparedLotPartList[i]).QTY);
|
|
for (int j = 0; j < number; j++)
|
|
{
|
|
_PreparedLotPartArrayList.Add(_PreparedLotPartList[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//采集手工输入的物料
|
|
private bool CollectPart(ICSOPBOMDETAIL opBOMDetail, string materialSerialNo)
|
|
{
|
|
bool returnValue = false;
|
|
Messages msg = new Messages();
|
|
try
|
|
{
|
|
//获取MOCode
|
|
string moCode = this.txtMo.Text.ToString().Trim();
|
|
if (moCode.Length <= 0)
|
|
{
|
|
ICSSimulation sim = (ICSSimulation)_DataCollectFacade.GetSimulation(_RuningCard);
|
|
if (sim != null)
|
|
{
|
|
moCode = sim.MOCODE;
|
|
}
|
|
}
|
|
|
|
//解析获得MINNO
|
|
ICSMINNO newMINNO = new ICSMINNO();
|
|
opBOMDetail.MUSER = AppConfig.UserCode;
|
|
msg = _DataCollectFacade.GetMINNOByBarcode(opBOMDetail, materialSerialNo, moCode, _InputPartList, true, false, "collection", out newMINNO);
|
|
if (msg.IsSuccess())
|
|
{
|
|
if (newMINNO != null)
|
|
{
|
|
_InputPartList.Add((object)newMINNO);
|
|
}
|
|
_CollectedCount++;
|
|
returnValue = true;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("物料序列号: " + materialSerialNo);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception("物料序列号: " + materialSerialNo+","+e.Message);
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
//采集
|
|
private void Collect()
|
|
{
|
|
Messages messages = new Messages();
|
|
string RCard = txtInput.Text.ToUpper().Trim();
|
|
try
|
|
{
|
|
#region 输入产品序列号后
|
|
if (FlowControl == -1)
|
|
{
|
|
if (GetMoItem())
|
|
{
|
|
_RuningCard = _DataCollectFacade.GetRuningCard(RCard, this.txtMo.Text.Trim());
|
|
_NeedInputLotPart = true;
|
|
if (!GetOPBOMKeyparts())
|
|
{
|
|
return;
|
|
}
|
|
//如果BOM中没有Keypart,并且自动采集Lot料的方式,则整个采集工作可自动完成
|
|
if (!_NeedInputLotPart && _OPBOMDetailKeyPartList == null)
|
|
{
|
|
if (AutoCollectAllLotPart())
|
|
{
|
|
//Save();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 输入物料后
|
|
|
|
if (FlowControl >= 1)
|
|
{
|
|
//采集料号
|
|
ArrayList opBOMDetailToCollect = null;
|
|
opBOMDetailToCollect = _OPBOMDetailArrayList;
|
|
if (opBOMDetailToCollect != null)
|
|
{
|
|
if (_CollectedCount < opBOMDetailToCollect.Count)
|
|
{
|
|
try
|
|
{
|
|
CollectPart((ICSOPBOMDETAIL)opBOMDetailToCollect[_CollectedCount], RCard);
|
|
if (_CollectedCount < opBOMDetailToCollect.Count)
|
|
{
|
|
string materialDesc = "";
|
|
var objMaterial = this._domainDataProvider.ICSINVENTORY.SingleOrDefault( a=> a.INVCODE== ((ICSOPBOMDETAIL)opBOMDetailToCollect[_CollectedCount]).OBSITEMCODE && a.WorkPoint == AppConfig.WorkPointCode );
|
|
if (objMaterial != null)
|
|
{
|
|
materialDesc = ((ICSINVENTORY)objMaterial).INVDESC;
|
|
}
|
|
if (((ICSOPBOMDETAIL)opBOMDetailToCollect[_CollectedCount]).OBITEMCONTYPE == "item_control_keyparts")
|
|
{
|
|
throw new Exception(">>$CS_PleaseInputKeypart >>$CS_Param_KeypartItem=" + ((ICSOPBOMDETAIL)opBOMDetailToCollect[_CollectedCount]).OBSITEMCODE + "[" + materialDesc + "]");
|
|
}
|
|
else if (((ICSOPBOMDETAIL)opBOMDetailToCollect[_CollectedCount]).OBITEMCONTYPE == "item_control_lot")
|
|
{
|
|
throw new Exception(">>$CS_PleaseInputLot>>$CS_Param_Lot=" + ((ICSOPBOMDETAIL)opBOMDetailToCollect[_CollectedCount]).OBSITEMCODE + "[" + materialDesc + "]");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(" 产品序列号: " + this.txtInput.Text.Trim() +" , "+ e.Message);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
this.txtInput.Focus();
|
|
this.txtInput.Text = "";
|
|
FlowControl++;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
}
|
|
|
|
private Messages CheckInfo()
|
|
{
|
|
Messages messages = new Messages();
|
|
//判断是否是第一道工序,如果是则做归属工单 如果不是则做过站操作
|
|
ICSITEMROUTE2OP itemRoute2Op = _DataCollectFacade.GetMORouteFirstOperation(this.txtMo.Text.Trim());
|
|
|
|
//根据资源找到对应的工序
|
|
ICSOP2RES op2res = _ICSBaseModel.GetOperationByResource(res);
|
|
if (itemRoute2Op.OPCODE == op2res.OPCODE)
|
|
{
|
|
//先判断是不良品回流,如果是,则不走GOMO,如果不是则走GOMO
|
|
ICSTS icsts = CheckIsExistInICSTS(txtInput.Text.Trim());
|
|
if (icsts== null)
|
|
{
|
|
messages.AddMessages(RunGOMO(actionCheckStatus, this.txtInput.Text.Trim()));
|
|
if (!messages.IsSuccess())
|
|
{
|
|
listActionCheckStatus.Clear();
|
|
}
|
|
}
|
|
else if (icsts.TSSTATUS != "tsstatus_reflow")
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("当前工序未完成维修")));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ICSSimulation sim = GetSimulationByRCard(txtInput.Text.Trim());
|
|
if (sim == null)
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("该序列号未归属工单")));
|
|
}
|
|
//当前工序如果不是第一站工序
|
|
//判断是否有不良品回流
|
|
ICSTS icsts = CheckIsExistInICSTS(txtInput.Text.Trim());
|
|
if (icsts != null)
|
|
{
|
|
if (op2res.OPCODE == icsts.FRMOPCODE)
|
|
{
|
|
if (icsts.TSSTATUS != "tsstatus_reflow")
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("当前工序未完成维修")));
|
|
}
|
|
if (sim.OPCODE != op2res.OPCODE && icsts.FRMOPCODE ==
|
|
sim.OPCODE && icsts.TSSTATUS != "tsstatus_reflow")
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("工序" + icsts.FRMOPCODE + "未完成维修")));
|
|
}
|
|
}
|
|
}
|
|
return messages;
|
|
}
|
|
|
|
public ICSSimulation GetSimulationByRCard(string rCard)
|
|
{
|
|
string sql = @"select * from ICSSimulation
|
|
where RCARD = '" + rCard + "' order by MTIME desc";
|
|
var objs = this._domainDataProvider.ExecuteQuery<ICSSimulation>(sql).ToList();
|
|
if (objs == null || objs.Count < 1)
|
|
return null;
|
|
else
|
|
return (ICSSimulation)objs[0];
|
|
}
|
|
|
|
public ICSTS CheckIsExistInICSTS(string rcard)
|
|
{
|
|
string sql2 = @"select *
|
|
from ICSTS
|
|
where RCARD='" + rcard + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
var objs = this._domainDataProvider.ExecuteQuery<ICSTS>(sql2).ToList();
|
|
if (objs == null || objs.Count < 1)
|
|
return null;
|
|
else
|
|
return (ICSTS)objs[0];
|
|
}
|
|
|
|
//工单归属采集
|
|
private Messages RunGOMO(ActionCheckStatus actionCheckStatus, string rCard)
|
|
{
|
|
Messages messages = new Messages();
|
|
ActionOnLineHelper onLine = new ActionOnLineHelper(this._domainDataProvider);
|
|
actionCheckStatus.ProductInfo = productInfo;
|
|
//参数定义
|
|
GoToMOActionEventArgs args = new GoToMOActionEventArgs(ActionType.DataCollectAction_GoMO, rCard.Trim(),
|
|
AppConfig.UserCode,
|
|
this.res, productInfo, this.txtMo.Text.Trim());
|
|
|
|
//Laws Lu,执行工单采集并收集返回信息
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.AddMessages(onLine.Action(args, actionCheckStatus));
|
|
}
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, "$CS_GOMOSUCCESS $CS_Param_ID:" + rCard.Trim().ToString()));
|
|
this.txtInput.SelectAll();
|
|
this.txtInput.Focus();
|
|
}
|
|
return messages;
|
|
}
|
|
|
|
private bool GetMoItem()
|
|
{
|
|
string sql = @"select b.MOCODE as mocode,b.ITEMCODE as itemcode,c.INVNAME as itemdesc,a.RCARD
|
|
from ICSMO2RCARD a
|
|
left join ICSMO b on a.MOCODE=b.MOCODE
|
|
left join ICSINVENTORY c on b.ITEMCODE=c.INVCODE
|
|
where RCARD='" + this.txtInput.Text.Trim() + "' ";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (dt.Rows[0]["mocode"].ToString() != "")
|
|
{
|
|
txtMo.Text = dt.Rows[0]["mocode"].ToString();
|
|
}
|
|
if (dt.Rows[0]["itemcode"].ToString() != "")
|
|
{
|
|
txtItemCode.Text = dt.Rows[0]["itemcode"].ToString();
|
|
}
|
|
if (dt.Rows[0]["itemdesc"].ToString() != "")
|
|
{
|
|
txtItemName.Text = dt.Rows[0]["itemdesc"].ToString();
|
|
}
|
|
|
|
string sql2 = @"select ROUTECODE from ICSMO2ROUTE
|
|
where MOCODE='" + txtMo.Text + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql2 = string.Format(sql2);
|
|
DataTable data2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
|
|
string route = data2.Rows[0]["ROUTECODE"].ToString();
|
|
txtRoute.Text = "途程:" + route;
|
|
|
|
SetMsg(Color.White, "");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
SetMsg(Color.Red, "序列号不存在,请重新输入!");
|
|
this.txtInput.Text = "";
|
|
this.txtInput.Focus();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void SetMsg(Color color, string Msg)
|
|
{
|
|
txtMessage.Text = Msg;
|
|
txtMessage.ForeColor = color;
|
|
}
|
|
|
|
private void ClearPageData()
|
|
{
|
|
txtMo.Text = String.Empty;
|
|
txtItemCode.Text = String.Empty;
|
|
txtItemName.Text = String.Empty;
|
|
|
|
}
|
|
|
|
private void panelControl1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private List<ICSOPBOMDETAIL> FilterOPBOMDetail(List<ICSOPBOMDETAIL> bomDetailList)
|
|
{
|
|
List<ICSOPBOMDETAIL> filterList = new List<ICSOPBOMDETAIL>();
|
|
|
|
for (int i = 0; i < bomDetailList.Count; i++)
|
|
{
|
|
if (((ICSOPBOMDETAIL)bomDetailList[i]).OBITEMCONTYPE != BOMItemControlType.ITEM_CONTROL_KEYPARTS
|
|
&& ((ICSOPBOMDETAIL)bomDetailList[i]).OBITEMCONTYPE != BOMItemControlType.ITEM_CONTROL_LOT)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
bool found = false;
|
|
for (int j = 0; j < filterList.Count; j++)
|
|
{
|
|
if (((ICSOPBOMDETAIL)bomDetailList[i]).OBITEMCONTYPE == ((ICSOPBOMDETAIL)filterList[j]).OBSITEMCODE)
|
|
{
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!found)
|
|
{
|
|
filterList.Add(bomDetailList[i]);
|
|
}
|
|
}
|
|
|
|
return filterList;
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
Messages _Messages = new Messages();
|
|
ExtendSimulation lastSimulation = null;
|
|
|
|
this._domainDataProvider.Connection.Open();
|
|
this._domainDataProvider.Transaction = this._domainDataProvider.Connection.BeginTransaction();
|
|
|
|
ActionOnLineHelper onLine = new ActionOnLineHelper(this._domainDataProvider);
|
|
string rCard = this.txtInput.Text.Trim();
|
|
_Messages.AddMessages(CheckProduct(rCard));
|
|
actionCheckStatus = new ActionCheckStatus();
|
|
actionCheckStatus.ProductInfo = productInfo;
|
|
if (actionCheckStatus.ProductInfo != null)
|
|
{
|
|
actionCheckStatus.ProductInfo.Resource = Resource;
|
|
}
|
|
|
|
string strMoCode = this.txtMo.Text.Trim();
|
|
actionCheckStatus.MO = this._domainDataProvider.ICSMO.SingleOrDefault(a => a.MOCODE == strMoCode && a.WorkPoint == AppConfig.WorkPointCode);
|
|
|
|
if (listActionCheckStatus.ContainsKey(strMoCode))
|
|
{
|
|
actionCheckStatus = (ActionCheckStatus)listActionCheckStatus[strMoCode];
|
|
actionCheckStatus.ProductInfo = productInfo;
|
|
actionCheckStatus.ActionList = new ArrayList();
|
|
}
|
|
else
|
|
{
|
|
actionCheckStatus.NeedUpdateSimulation = false;
|
|
actionCheckStatus.NeedFillReport = false;
|
|
listActionCheckStatus.Add(strMoCode, actionCheckStatus);
|
|
}
|
|
|
|
#region 上料采集
|
|
|
|
//建议在上料采集界面和良品/不良品界面增加计数功能,当用户成功采集一个产品序列号后,
|
|
//计数器加一,同时该计数功能允许用户归零。每次打开界面时,计数器基数都是零,系统不需要保存计数器值
|
|
//bool flag = true;//标示是否采集成功
|
|
|
|
Messages messages1 = new Messages();
|
|
if (actionCheckStatus.ProductInfo == null)
|
|
{
|
|
messages1 = onLine.GetIDInfo(_RuningCard);
|
|
actionCheckStatus.ProductInfo = (ProductInfo)messages1.GetData().Values[0];
|
|
actionCheckStatus.ProductInfo.Resource = Resource;
|
|
lastSimulation = actionCheckStatus.ProductInfo.LastSimulation;
|
|
_Messages.AddMessages(messages1);
|
|
}
|
|
else //将上一个Action的NowSimulation设置为本Action的LastSimulation
|
|
{
|
|
if (actionCheckStatus.ActionList.Count > 0)
|
|
{
|
|
actionCheckStatus.ProductInfo = new ProductInfo();
|
|
actionCheckStatus.ProductInfo.NowSimulation = new ICSSimulation();
|
|
actionCheckStatus.ProductInfo.Resource = Resource;
|
|
actionCheckStatus.ProductInfo.LastSimulation =
|
|
new ExtendSimulation(((ActionEventArgs)actionCheckStatus.ActionList[actionCheckStatus.ActionList.Count - 1]).ProductInfo.NowSimulation);
|
|
}
|
|
}
|
|
|
|
if (_Messages.IsSuccess())
|
|
{
|
|
#region Check if key part was used
|
|
|
|
if (_InputPartList != null)
|
|
{
|
|
foreach (ICSMINNO minno in _InputPartList)
|
|
{
|
|
if (minno.EATTRIBUTE1 == MCardType.MCardType_Keyparts)
|
|
{
|
|
if (_DataCollectFacade.KeyPartUsed(minno.MITEMPACKEDNO, minno.MITEMCODE, false, _InputPartList))
|
|
{
|
|
messages1.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Error,"$CS_Error_KeyPartUsed"));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (messages1.IsSuccess())
|
|
{
|
|
ProductInfo product = actionCheckStatus.ProductInfo;
|
|
object[] objBomDetailLot = new object[_InputPartList.Count];
|
|
_InputPartList.CopyTo(objBomDetailLot);
|
|
if (objBomDetailLot != null)
|
|
{
|
|
messages1.AddMessages(onLine.ActionWithTransaction(new CINNOActionEventArgs(ActionType.DataCollectAction_CollectINNO, _RuningCard,
|
|
AppConfig.UserCode, this.res,
|
|
product, INNO
|
|
), actionCheckStatus, objBomDetailLot));
|
|
}
|
|
}
|
|
}
|
|
if (messages1.IsSuccess())
|
|
messages1.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, "$CS_CollectSuccess:" + _RuningCard));
|
|
|
|
_Messages.AddMessages(messages1);
|
|
#endregion
|
|
}
|
|
|
|
// 获得产品信息
|
|
private Messages GetProduct(string rcard)
|
|
{
|
|
Messages productmessages = new Messages();
|
|
ActionOnLineHelper dataCollect = new ActionOnLineHelper(this._domainDataProvider);
|
|
|
|
productmessages.AddMessages(dataCollect.GetIDInfo(rcard));
|
|
if (productmessages.IsSuccess())
|
|
{
|
|
productInfo = (ProductInfo)productmessages.GetData().Values[0];
|
|
}
|
|
else
|
|
{
|
|
productInfo = new ProductInfo();
|
|
}
|
|
return productmessages;
|
|
}
|
|
|
|
// 根据产品信息,决定部分控件的状态
|
|
private Messages CheckProduct(string rcard)
|
|
{
|
|
Messages messages = new Messages();
|
|
try
|
|
{
|
|
messages.AddMessages(GetProduct(rcard));
|
|
|
|
if (productInfo.LastSimulation != null)
|
|
{
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
messages.Add( new ICSSoft.Frame.DataConnect.Message(MessageType.Error, e.Message));
|
|
|
|
}
|
|
return messages;
|
|
}
|
|
|
|
// 清空数据
|
|
private void ClearVariables()
|
|
{
|
|
FlowControl = -1;
|
|
|
|
_OPBOMDetailArrayList = new ArrayList();
|
|
_OPBOMDetailKeyPartArrayList = new ArrayList();
|
|
|
|
_PreparedLotPartArrayList = new ArrayList();
|
|
|
|
_CollectedCount = 0;
|
|
_HaveCollectMaterial = false;
|
|
_RuningCard = string.Empty;
|
|
_InputPartList = new ArrayList();
|
|
listOpBomKeyParts = new Hashtable();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|