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.
1410 lines
61 KiB
1410 lines
61 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Linq;
|
|
using System.Data.Linq;
|
|
using System.Xml.Linq;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Frame.DataCollect;
|
|
using ICSSoft.Frame.Helper;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ICSSoft.Frame.DataConnect.Action
|
|
{
|
|
|
|
public class ActionItem : IActionWithStatus, IActionWithStatusNew
|
|
{
|
|
private FramDataContext _domainDataProvider = null;
|
|
|
|
public ActionItem()
|
|
{
|
|
}
|
|
|
|
public ActionItem(FramDataContext domainDataProvider)
|
|
{
|
|
this._domainDataProvider = domainDataProvider;
|
|
}
|
|
|
|
public FramDataContext DataProvider
|
|
{
|
|
get
|
|
{
|
|
return _domainDataProvider;
|
|
}
|
|
}
|
|
|
|
//新增INNO上料记录
|
|
//允许记录Lot料的明细记录
|
|
public void InsertINNOOnWipItem(ActionEventArgs actionEventArgs, FramDataContext db, object[] OPBOMDetail)
|
|
{
|
|
|
|
string iNNO = ((CINNOActionEventArgs)actionEventArgs).INNO;
|
|
ICSSimulation simulation = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
|
|
ICSSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
|
|
|
|
object[] mINNOs = OPBOMDetail;
|
|
int i = 0;
|
|
if (mINNOs == null)
|
|
{
|
|
throw new Exception("$CS_INNO_NOT_EXIST");
|
|
}
|
|
foreach (ICSMINNO mINNO in mINNOs)
|
|
{
|
|
if (mINNO == null)
|
|
throw new Exception("$CS_INNOnotExist");
|
|
if (mINNO.MOCODE != simulation.MOCODE)
|
|
throw new Exception("$CS_INNOnotForMO $CS_Param_MOCode=" + mINNO.MOCODE);
|
|
if (mINNO.ROUTECODE != simulation.ROUTECODE)
|
|
throw new Exception("$CS_INNOnotForRoute $CS_Param_RouteCode=" + mINNO.ROUTECODE);
|
|
if (mINNO.OPCODE != simulation.OPCODE)
|
|
throw new Exception("$CS_INNOnotForOP $CS_Param_OPCode =" + mINNO.OPCODE);
|
|
if (mINNO.RESCODE != simulation.RESCODE)
|
|
throw new Exception("$CS_INNOnotForResource $CS_Param_ResourceCode=" + mINNO.RESCODE);
|
|
|
|
ICSONWIPITEM wipItem = new ICSONWIPITEM();
|
|
wipItem.MCARD = mINNO.ID;
|
|
wipItem.BIOS = mINNO.BIOS;
|
|
wipItem.DATECODE = mINNO.DATECODE;
|
|
wipItem.LOTNO = mINNO.LOTNO;/*ActionOnLineHelper.StringNull;*/
|
|
wipItem.MITEMCODE = mINNO.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
|
|
wipItem.PCBA = mINNO.PCBA;
|
|
wipItem.VENDORCODE = mINNO.VENDORCODE;
|
|
wipItem.VENDORITEMCODE = mINNO.VENDORITEMCODE;
|
|
wipItem.VERSION = mINNO.VERSION;
|
|
|
|
wipItem.MCARDTYPE = simulation.EATTRIBUTE1;
|
|
wipItem.ITEMCODE = simulation.ITEMCODE;
|
|
wipItem.RESCODE = simulation.RESCODE;
|
|
wipItem.ROUTECODE = simulation.ROUTECODE;
|
|
wipItem.RCARD = simulation.RCARD;
|
|
wipItem.RCARDSEQ = simulation.RCARDSEQ;
|
|
wipItem.SEGCODE = simulationReport.SEGCODE;
|
|
wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
|
|
wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
|
|
wipItem.SSCODE = simulationReport.SSCODE;
|
|
wipItem.TPCODE = simulationReport.TPCODE;
|
|
wipItem.MOCODE = simulation.MOCODE;
|
|
wipItem.MODELCODE = simulation.MODELCODE;
|
|
wipItem.OPCODE = simulation.OPCODE;
|
|
|
|
wipItem.MTIME = simulation.MTIME;
|
|
wipItem.MUSER = simulation.MUSER;
|
|
wipItem.MUSERName = simulation.MUSERName;
|
|
wipItem.WorkPoint = simulation.WorkPoint;
|
|
wipItem.QTY = mINNO.QTY;
|
|
wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
|
|
wipItem.MCARDTYPE = MCardType.MCardType_INNO;
|
|
wipItem.MSEQ = i;
|
|
//新增 采集类型
|
|
wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
|
|
wipItem.MOSEQ = simulation.MOSEQ;
|
|
|
|
db.ICSONWIPITEM.InsertOnSubmit(wipItem);
|
|
|
|
i++;
|
|
}
|
|
}
|
|
|
|
|
|
#region 扣料
|
|
|
|
public void UpdateStorageQty(ICSWareHouseLotInfo lotInfo, FramDataContext db, decimal qty)
|
|
{
|
|
var obj = db.ICSWareHouseInfo.SingleOrDefault(a => a.BinGUID == lotInfo.BinGUID && a.INVCode== lotInfo.INVCode && a.WHGUID == lotInfo.WHGUID && a.WorkPoint == AppConfig.WorkPointCode );
|
|
if (obj != null)
|
|
{
|
|
(obj as ICSWareHouseInfo).QTY = (obj as ICSWareHouseInfo).QTY - qty;
|
|
if ((obj as ICSWareHouseInfo).QTY == 0)
|
|
{
|
|
db.ICSWareHouseInfo.DeleteOnSubmit((obj as ICSWareHouseInfo));
|
|
}
|
|
}
|
|
}
|
|
|
|
//工单是否在扣料工单类型参数中
|
|
public bool IsInParams(object[] objs, string mocode)
|
|
{
|
|
//string motype = string.Empty;
|
|
//MOFacade mofacade = new MOFacade(this.DataProvider);
|
|
//MO mo = mofacade.GetMO(mocode) as MO;
|
|
//if (mo != null)
|
|
//{
|
|
// motype = mo.MOType;
|
|
//}
|
|
//if (objs != null && objs.Length > 0)
|
|
//{
|
|
// foreach (Parameter p in objs)
|
|
// {
|
|
// if (p.ParameterAlias == motype)
|
|
// {
|
|
// return false;
|
|
// }
|
|
// }
|
|
//}
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
public void DeductQty(ActionEventArgs actionEventArgs, FramDataContext db, ICSMINNO minno)
|
|
{
|
|
string type = "";
|
|
if (minno.EATTRIBUTE1 == "1")
|
|
{
|
|
type = BOMItemControlType.ITEM_CONTROL_LOT;
|
|
}
|
|
if (minno.EATTRIBUTE1 == "0")
|
|
{
|
|
type =BOMItemControlType.ITEM_CONTROL_KEYPARTS;
|
|
}
|
|
ProductInfo productionInfo = actionEventArgs.ProductInfo;
|
|
ICSSimulation sim = actionEventArgs.ProductInfo.NowSimulation;
|
|
string WorkPoint = actionEventArgs.ProductInfo.Resource.WorkPoint;
|
|
ICSMO mo = actionEventArgs.ProductInfo.CurrentMO;
|
|
if (mo == null)
|
|
{
|
|
mo = db.ICSMO.SingleOrDefault(a=> a.MOCODE==sim.MOCODE && a.WorkPoint == AppConfig.WorkPointCode) as ICSMO;
|
|
}
|
|
//获取当前工单号
|
|
string moCode = productionInfo.NowSimulation.MOCODE;
|
|
//获取当前工序号
|
|
string opCode = productionInfo.NowSimulation.OPCODE;
|
|
//获取当前产品好
|
|
string itemCode = productionInfo.NowSimulation.ITEMCODE;
|
|
//获取途程代码
|
|
string routeCode = productionInfo.NowSimulation.ROUTECODE;
|
|
string resCode = productionInfo.Resource.RESCODE;
|
|
string moBomVer = string.Empty;
|
|
|
|
DateTime dbDataTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
|
|
object objMo = db.ICSMO.SingleOrDefault(a => a.MOCODE == moCode && a.WorkPoint == AppConfig.WorkPointCode) as ICSMO;
|
|
|
|
if (objMo != null)
|
|
{
|
|
moBomVer = (objMo as ICSMO).MOBOM;
|
|
}
|
|
|
|
//获取存货名称
|
|
string MItemName =string.Empty;
|
|
ICSINVENTORY material;
|
|
|
|
//添加产品已上料扣料判断 tblonwip
|
|
string rCard = productionInfo.NowSimulation.RCARD;
|
|
decimal seq = productionInfo.NowSimulation.RCARDSEQ;
|
|
List<ICSONWIP> objOnWip = db.ICSONWIP.Where( a=> a.WorkPoint==AppConfig.WorkPointCode && a.RCARD == rCard && a.OPCODE == opCode&& a.MOCODE == moCode).ToList();
|
|
|
|
if (objOnWip != null && objOnWip.Count > 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//object[] objMoBoms = moFacade.QueryMoBom(sim.ITEMCODE,minno.MITEMCODE, sim.MOCODE);
|
|
//if (objMoBoms == null)
|
|
//{
|
|
// throw new Exception("$CS_ItemCode[" + minno.MITEMCODE + "]" + "$Error_NotExistInMoBOM" + String.Format("[$MOCode='{0}']", sim.MOCODE));
|
|
//}
|
|
|
|
object[] opbomObjs = opbomFacade.QueryOPBOMDetail(sim.ITEMCODE, minno.MITEMCODE, string.Empty, string.Empty, string.Empty, sim.ROUTECODE, opCode, (int)MaterialType.CollectMaterial, int.MinValue, int.MaxValue, orgid, true);
|
|
if (opbomObjs == null)
|
|
{
|
|
throw new Exception("$CS_ItemCode[" + minno.MITEMCODE + "]" + "$Error_NotExistInOPBOM" + String.Format("[$ItemCode='{0}']", sim.ItemCode));
|
|
}
|
|
|
|
object[] moRouteObjs = moFacade.QueryMORoutes(sim.MOCODE, sim.ROUTECODE);
|
|
if (moRouteObjs == null)
|
|
{
|
|
throw new Exception("$Error_MORouteNOExist");
|
|
}
|
|
|
|
bool iflag = false;
|
|
|
|
decimal iOPBOMItemQty = 0;
|
|
//需要比对的子阶料料号 比对成功的 只在工单生产BOM 中
|
|
if (opbomObjs == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//以工单标准BOM为基准,扣减当前工单的倒冲库存地(tblmo. EATTRIBUTE2)中相对应的库存信息:
|
|
|
|
//求得opbom中对应的料品
|
|
string TempMOBOMItemCode = string.Empty;
|
|
|
|
for (int j = 0; j < opbomObjs.Length; j++)
|
|
{
|
|
|
|
if (((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMCONTYPE == "item_control_lot")
|
|
{
|
|
object[] minnos = materialFacade.QueryLastMINNO(moCode, routeCode, opCode, resCode);
|
|
if (minnos != null && minnos.Length > 0)
|
|
{
|
|
foreach (ICSMINNO tem in minnos)
|
|
{
|
|
if (tem.MITEMCODE == ((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMCODE.ToUpper() || tem.MITEMCODE == ((ICSOPBOMDETAIL)opbomObjs[j]).OBSITEMCODE.ToUpper())
|
|
{
|
|
TempMOBOMItemCode = tem.MITEMCODE;
|
|
}
|
|
}
|
|
}
|
|
|
|
iOPBOMItemQty += (decimal)((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMQTY;
|
|
}
|
|
else if (((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMCONTYPE == "item_control_keyparts")
|
|
{
|
|
iOPBOMItemQty = 1;
|
|
|
|
//采集的物料做失效日期的检查逻辑
|
|
string lotno = string.Empty;
|
|
var keyparts = inventoryFacade.GetItemLotDetail(minno.MITEMPACKEDNO,minno.MITEMCODE);
|
|
if (keyparts != null)
|
|
{
|
|
lotno = (keyparts as ICSITEMLotDetail).Lotno;
|
|
}
|
|
else
|
|
{
|
|
lotno = minno.MITEMPACKEDNO;
|
|
}
|
|
|
|
var objItemLot = inventoryFacade.GetItemLot(lotno, minno.MITEMCODE);
|
|
if (objItemLot != null)
|
|
{
|
|
DateTime day = (objItemLot as ICSITEMLot).Exdate;
|
|
if (DateTime.Compare(day,dbDataTime) < 0) //如果失效日期小于当前日期,则报错
|
|
{
|
|
throw new Exception("$LotNO[" + lotno + "]" + "$MaterialCode[" + minno.MITEMCODE + "]" + "$Error_Material_Expired");
|
|
}
|
|
}
|
|
//end
|
|
}
|
|
}
|
|
|
|
//比对成功:子阶料料号一致 当前设置为TRUE
|
|
iflag = true;
|
|
if (iflag)//子阶料不存在, 即只在工单标准bom中
|
|
{
|
|
object[] objInfos = inventoryFacade.QueryStorageInfoByIDAndMCode(mo.EAttribute2, ((MOBOM)objMoBoms[n]).MOBOMItemCode.ToUpper());
|
|
if (objInfos == null)
|
|
{
|
|
throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
|
|
}
|
|
|
|
decimal total = inventoryFacade.GetStorageQty(mo.EAttribute2, ((MOBOM)objMoBoms[n]).MOBOMItemCode.ToUpper());
|
|
|
|
if (total < iOPBOMItemQty)
|
|
{
|
|
throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
|
|
}
|
|
|
|
#region //先判断备料批号中的数据量,不够扣减就退出
|
|
decimal temlotQty = 0;
|
|
object[] objStorageLotInfo = null;
|
|
object[] objStorageNextLotInfo = null;
|
|
if (type == "item_control_keyparts")
|
|
{
|
|
objStorageLotInfo = inventoryFacade.QueryStorageLot(minno.LotNO, mo.EAttribute2, ((MOBOM)objMoBoms[n]).MOBOMItemCode.ToUpper());
|
|
}
|
|
if (type == "item_control_lot")
|
|
{
|
|
string nextLotNo = string.Empty;
|
|
//for岗位备料支持替代料
|
|
object[] minnoss = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, TempMOBOMItemCode);
|
|
|
|
if (minnoss != null && minnoss.Length > 0)
|
|
{
|
|
nextLotNo = (minnoss[0] as ICSMINNO).Nextlotno;
|
|
}
|
|
|
|
objStorageLotInfo = inventoryFacade.QueryStorageLot((minnoss[0] as MINNO).LotNO, mo.EAttribute2, TempMOBOMItemCode);
|
|
objStorageNextLotInfo = inventoryFacade.QueryStorageLot(nextLotNo, mo.EAttribute2, TempMOBOMItemCode);
|
|
|
|
}
|
|
|
|
if (objStorageLotInfo != null)
|
|
{
|
|
foreach (StorageLotInfo lotInfo in objStorageLotInfo)
|
|
{
|
|
temlotQty += lotInfo.Lotqty;
|
|
}
|
|
}
|
|
|
|
if (objStorageNextLotInfo != null)
|
|
{
|
|
foreach (StorageLotInfo lotInfo in objStorageNextLotInfo)
|
|
{
|
|
temlotQty += lotInfo.Lotqty;
|
|
}
|
|
}
|
|
|
|
if (temlotQty < iOPBOMItemQty)
|
|
{
|
|
material = ((Domain.MOModel.Material)itemFacade.GetMaterial(minno.MItemCode, orgID));
|
|
|
|
throw new Exception("$CS_ItemCode[" + TempMOBOMItemCode + "-" + material.MaterialName + "]" + "$CS_DeductQty_ERROR");
|
|
}
|
|
#endregion
|
|
|
|
#region 数量可以扣减
|
|
|
|
if (objStorageLotInfo != null)
|
|
{
|
|
decimal tempQty = 0;
|
|
decimal tempIOPBOMItemQty = iOPBOMItemQty;
|
|
foreach (StorageLotInfo lotInfo in objStorageLotInfo)
|
|
{
|
|
// Add By Leo @2013-10-24 for 采集的物料做失效日期的检查逻辑
|
|
var objItemLot = inventoryFacade.GetItemLot( lotInfo.Lotno, minno.MItemCode);
|
|
if (objItemLot != null)
|
|
{
|
|
int day = (objItemLot as ItemLot).Exdate;
|
|
if (day < dbDataTime.DBDate) //如果失效日期小于当前日期,则报错
|
|
{
|
|
throw new Exception( "$LotNO[" + lotInfo.Lotno + "]" +"$MaterialCode[" + lotInfo .Mcode+ "]"+ "$Error_Material_Expired");
|
|
}
|
|
}
|
|
//end
|
|
|
|
tempQty += lotInfo.Lotqty;
|
|
|
|
if (iOPBOMItemQty >= lotInfo.Lotqty)
|
|
{
|
|
iOPBOMItemQty = iOPBOMItemQty - lotInfo.Lotqty;
|
|
inventoryFacade.DeleteStorageLotInfo(lotInfo);
|
|
|
|
this.UpdateStorageQty(lotInfo, inventoryFacade, lotInfo.Lotqty);
|
|
}
|
|
else
|
|
{
|
|
lotInfo.Lotqty = lotInfo.Lotqty - iOPBOMItemQty;
|
|
inventoryFacade.UpdateStorageLotInfo(lotInfo);
|
|
|
|
this.UpdateStorageQty(lotInfo, inventoryFacade, iOPBOMItemQty);
|
|
|
|
iOPBOMItemQty = 0;
|
|
}
|
|
|
|
}
|
|
|
|
if (tempQty == tempIOPBOMItemQty)
|
|
{
|
|
if (type == "item_control_lot")
|
|
{
|
|
//如果物料扣减为零后 add by andy 2010-11-30
|
|
object[] minnos = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, TempMOBOMItemCode, TempMOBOMItemCode);
|
|
|
|
if (minnos != null && minnos.Length > 0)
|
|
{
|
|
if (((MINNO)minnos[0]).Nextlotno.Trim() != "")
|
|
{
|
|
((MINNO)minnos[0]).MItemPackedNo = ((MINNO)minnos[0]).Nextlotno.Trim();
|
|
((MINNO)minnos[0]).LotNO = ((MINNO)minnos[0]).Nextlotno.Trim();
|
|
((MINNO)minnos[0]).Nextlotno = " ";
|
|
((MINNO)minnos[0]).Lotqty = ((MINNO)minnos[0]).Nextlotqty;
|
|
((MINNO)minnos[0]).Nextlotqty = 0;
|
|
materialFacade.UpdateMINNO(((MINNO)minnos[0]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (iOPBOMItemQty > 0)
|
|
{
|
|
if (objStorageNextLotInfo != null)
|
|
{
|
|
decimal temQty = 0;
|
|
foreach (StorageLotInfo lotInfo in objStorageNextLotInfo)
|
|
{
|
|
// Add By Leo @2013-10-24 for 采集的物料做失效日期的检查逻辑
|
|
var objItemLot = inventoryFacade.GetItemLot(lotInfo.Lotno, minno.MItemCode);
|
|
if (objItemLot != null)
|
|
{
|
|
int day = (objItemLot as ItemLot).Exdate;
|
|
if (day < dbDataTime.DBDate) //如果失效日期小于当前日期,则报错
|
|
{
|
|
//返回错误信息:物料[]对应的批号[]超过保存期限
|
|
throw new Exception( "$LotNO[" + lotInfo.Lotno + "]" +"$MaterialCode[" + lotInfo .Mcode+ "]"+ "$Error_Material_Expired");
|
|
}
|
|
}
|
|
//end
|
|
|
|
temQty += lotInfo.Lotqty;
|
|
if (iOPBOMItemQty >= lotInfo.Lotqty)
|
|
{
|
|
iOPBOMItemQty = iOPBOMItemQty - lotInfo.Lotqty;
|
|
inventoryFacade.DeleteStorageLotInfo(lotInfo);
|
|
this.UpdateStorageQty(lotInfo, inventoryFacade, lotInfo.Lotqty);
|
|
}
|
|
else
|
|
{
|
|
lotInfo.Lotqty = lotInfo.Lotqty - iOPBOMItemQty;
|
|
inventoryFacade.UpdateStorageLotInfo(lotInfo);
|
|
|
|
this.UpdateStorageQty(lotInfo, inventoryFacade, iOPBOMItemQty);
|
|
}
|
|
}
|
|
|
|
if (type == "item_control_lot")
|
|
{
|
|
//如果物料扣减为零后 add by andy 2010-11-30
|
|
object[] minnos = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, TempMOBOMItemCode, TempMOBOMItemCode);
|
|
|
|
if (minnos != null && minnos.Length > 0)
|
|
{
|
|
if (((MINNO)minnos[0]).Nextlotno.Trim() != "")
|
|
{
|
|
((MINNO)minnos[0]).MItemPackedNo = ((MINNO)minnos[0]).Nextlotno.Trim();
|
|
((MINNO)minnos[0]).LotNO = ((MINNO)minnos[0]).Nextlotno.Trim();
|
|
((MINNO)minnos[0]).Nextlotno = " ";
|
|
((MINNO)minnos[0]).Lotqty = ((MINNO)minnos[0]).Nextlotqty;
|
|
((MINNO)minnos[0]).Nextlotqty = 0;
|
|
materialFacade.UpdateMINNO(((MINNO)minnos[0]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
*/
|
|
|
|
#endregion
|
|
|
|
public Messages InsertLotOnWipItem(ActionEventArgs actionEventArgs, FramDataContext db, object[] OPBOMDetail)
|
|
{
|
|
DataCollectFacade dataCollectFacade = new DataCollectFacade(db);
|
|
|
|
Messages returnValue = new Messages();
|
|
|
|
string iNNO = ((CINNOActionEventArgs)actionEventArgs).INNO;
|
|
ICSSimulation simulation = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
|
|
ICSSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
|
|
|
|
object[] mINNOs = OPBOMDetail;
|
|
int i = 0;
|
|
if (mINNOs == null)
|
|
{
|
|
throw new Exception("$CS_INNO_NOT_EXIST");
|
|
}
|
|
foreach (ICSMINNO mINNO in mINNOs)
|
|
{
|
|
|
|
if (mINNO == null)
|
|
throw new Exception("$CS_INNOnotExist");
|
|
|
|
ICSONWIPITEM wipItem = new ICSONWIPITEM();
|
|
wipItem.MCARD = mINNO.ID;
|
|
wipItem.BIOS = mINNO.BIOS;
|
|
wipItem.DATECODE = mINNO.DATECODE;
|
|
wipItem.LOTNO = mINNO.LOTNO;/*ActionOnLineHelper.StringNull;*/
|
|
wipItem.MITEMCODE = mINNO.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
|
|
wipItem.PCBA = mINNO.PCBA;
|
|
wipItem.VENDORCODE = mINNO.VENDORCODE;
|
|
wipItem.VENDORITEMCODE = mINNO.VENDORITEMCODE;
|
|
wipItem.VERSION = mINNO.VERSION;
|
|
|
|
wipItem.MCARDTYPE = mINNO.EATTRIBUTE1;
|
|
|
|
wipItem.EATTRIBUTE1 = simulation.EATTRIBUTE1;
|
|
wipItem.ITEMCODE = simulation.ITEMCODE;
|
|
wipItem.RESCODE = simulation.RESCODE;
|
|
wipItem.ROUTECODE = simulation.ROUTECODE;
|
|
wipItem.RCARD = simulation.RCARD;
|
|
wipItem.RCARDSEQ = simulation.RCARDSEQ;
|
|
wipItem.SEGCODE = simulationReport.SEGCODE;
|
|
wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
|
|
wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
|
|
wipItem.SSCODE = simulationReport.SSCODE;
|
|
wipItem.TPCODE = simulationReport.TPCODE;
|
|
wipItem.MOCODE = simulation.MOCODE;
|
|
wipItem.MODELCODE = simulation.MODELCODE;
|
|
wipItem.OPCODE = simulation.OPCODE;
|
|
|
|
wipItem.MTIME = simulation.MTIME;
|
|
wipItem.MUSER = simulation.MUSER;
|
|
wipItem.MUSERName = simulation.MUSERName;
|
|
wipItem.WorkPoint = simulation.WorkPoint;
|
|
|
|
if (mINNO.QTY.ToString() != string.Empty && Convert.ToInt32(mINNO.QTY) != 0)
|
|
{
|
|
wipItem.QTY = mINNO.QTY;
|
|
}
|
|
else
|
|
{
|
|
wipItem.QTY = 1;
|
|
}
|
|
wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
|
|
wipItem.MSEQ = i;
|
|
//新增 采集类型
|
|
wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
|
|
wipItem.MOSEQ = simulation.MOSEQ;
|
|
|
|
db.ICSONWIPITEM.InsertOnSubmit(wipItem);
|
|
|
|
ICSSimulationReport simulationRpt = dataCollectFacade.GetLastSimulationReport(wipItem.MCARD);
|
|
if (simulationRpt != null)
|
|
{
|
|
simulationRpt.ISLOADEDPART = FormatHelper.BooleanToString(true);
|
|
simulationRpt.LOADEDRCARD = wipItem.RCARD;
|
|
dataCollectFacade.UpdateSimulationReport(simulationRpt);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
//单件料扣料时更新tblitemlotdetail.serialstatus =’UNSTORAGE’
|
|
//end add
|
|
// DeductQty(actionEventArgs, dataCollectFacade, mINNO);
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
//新增KeyParts上料记录
|
|
public void InsertKeyPartOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade)
|
|
{
|
|
|
|
OPBomKeyparts keyParts = ((CKeypartsActionEventArgs)actionEventArgs).Keyparts;
|
|
ICSSimulation simulation = ((CKeypartsActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
|
|
ICSSimulationReport simulationReport = ((CKeypartsActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
|
|
int n = keyParts.GetbomKeypartCount();
|
|
for (int i = 0; i < n; i++)
|
|
{
|
|
|
|
//MKeyPart keypart = keyParts.GetKeypart(i);
|
|
ICSONWIPITEM wipItem = new ICSONWIPITEM();
|
|
//wipItem.BIOS = keypart.BIOS;
|
|
//wipItem.MCARD = keypart.ID;
|
|
//wipItem.DATECODE = keypart.DATECODE;
|
|
//wipItem.LOTNO = keypart.LOTNO;/*ActionOnLineHelper.StringNull;*/
|
|
//wipItem.MITEMCODE = keypart.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
|
|
//wipItem.PCBA = keypart.PCBA;
|
|
//wipItem.VENDORCODE = keypart.VENDORCODE;
|
|
//wipItem.VENDORITEMCODE = keypart.VENDORITEMCODE;
|
|
//wipItem.VERSION = keypart.VERSION;
|
|
|
|
//wipItem.MCARDTYPE = keypart.EATTRIBUTE1;
|
|
|
|
wipItem.EATTRIBUTE1 = simulation.EATTRIBUTE1;
|
|
wipItem.ITEMCODE = simulation.ITEMCODE;
|
|
wipItem.RESCODE = simulation.RESCODE;
|
|
wipItem.ROUTECODE = simulation.ROUTECODE;
|
|
wipItem.RCARD = simulation.RCARD;
|
|
wipItem.RCARDSEQ = simulation.RCARDSEQ;
|
|
wipItem.SEGCODE = simulationReport.SEGCODE;
|
|
wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
|
|
wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
|
|
wipItem.SSCODE = simulationReport.SSCODE;
|
|
wipItem.TPCODE = simulationReport.TPCODE;
|
|
wipItem.MOCODE = simulation.MOCODE;
|
|
wipItem.MODELCODE = simulation.MODELCODE;
|
|
wipItem.OPCODE = simulation.OPCODE;
|
|
|
|
wipItem.MTIME = simulation.MTIME;
|
|
wipItem.MUSER = simulation.MUSER;
|
|
wipItem.MUSERName = simulation.MUSERName;
|
|
wipItem.WorkPoint = simulation.WorkPoint;
|
|
|
|
wipItem.QTY = 1;
|
|
wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
|
|
wipItem.MCARDTYPE = MCardType.MCardType_Keyparts;
|
|
wipItem.MSEQ = i;
|
|
//采集类型
|
|
wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
|
|
wipItem.MOSEQ = simulation.MOSEQ;
|
|
|
|
this._domainDataProvider.ICSONWIPITEM.InsertOnSubmit(wipItem);
|
|
|
|
// 修改KeyPart使用
|
|
if (FormatHelper.StringToBoolean(keyParts.GetOPBomDetail(wipItem.MITEMCODE).OpBomDetial.CHECKSTATUS) == true)
|
|
{
|
|
//ICSSimulationReport simulationRpt = dataCollectFacade.GetLastSimulationReport(keypart.Keypart);
|
|
//if (simulationRpt != null)
|
|
//{
|
|
// simulationRpt.ISLOADEDPART = FormatHelper.BooleanToString(true);
|
|
// simulationRpt.LOADEDRCARD = simulation.RCARD;
|
|
// dataCollectFacade.UpdateSimulationReport(simulationRpt);
|
|
//}
|
|
}
|
|
// Added end
|
|
|
|
//单件料扣料时更新tblitemlotdetail.serialstatus =’UNSTORAGE’
|
|
//InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);
|
|
//ICSITEMLotDetail itemLotDetail = (ICSITEMLotDetail)inventoryFacade.GetItemLotDetail(keypart.Keypart, keypart.MItemCode);
|
|
//if (itemLotDetail == null || itemLotDetail.SerialStatus != SerialStatus.SerialStatus_Storage)
|
|
//{
|
|
// throw new Exception("$CS_Error_SerialNotInStorage:" + keypart.Keypart);
|
|
//}
|
|
//else
|
|
//{
|
|
// itemLotDetail.SerialStatus = SerialStatus.SerialStatus_Unstorage;
|
|
// //inventoryFacade.UpdateItemLotDetail(itemLotDetail);
|
|
//}
|
|
//end add
|
|
|
|
//物料扣料
|
|
ICSMINNO minno = new ICSMINNO();
|
|
minno.LOTNO = wipItem.LOTNO;
|
|
//DeductQty(actionEventArgs, dataCollectFacade, minno);
|
|
|
|
}
|
|
}
|
|
|
|
//新增INNO上料记录
|
|
//允许记录Lot料的明细记录
|
|
public void InsertINNOOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade)
|
|
{
|
|
string iNNO = ((CINNOActionEventArgs)actionEventArgs).INNO;
|
|
ICSSimulation simulation = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
|
|
ICSSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
|
|
//MaterialFacade material = new MaterialFacade(_domainDataProvider);
|
|
object[] mINNOs = null;// material.GetLastMINNOs(iNNO);
|
|
int i = 0;
|
|
if (mINNOs == null)
|
|
{
|
|
throw new Exception("$CS_INNO_NOT_EXIST");
|
|
}
|
|
foreach (ICSMINNO mINNO in mINNOs)
|
|
{
|
|
if (mINNO == null)
|
|
throw new Exception("$CS_INNOnotExist");
|
|
if (mINNO.MOCODE != simulation.MOCODE)
|
|
throw new Exception("$CS_INNOnotForMO $CS_Param_MOCode=" + mINNO.MOCODE);
|
|
if (mINNO.ROUTECODE != simulation.ROUTECODE)
|
|
throw new Exception("$CS_INNOnotForRoute $CS_Param_RouteCode=" + mINNO.ROUTECODE);
|
|
if (mINNO.OPCODE != simulation.OPCODE)
|
|
throw new Exception("$CS_INNOnotForOP $CS_Param_OPCode =" + mINNO.OPCODE);
|
|
if (mINNO.RESCODE != simulation.RESCODE)
|
|
throw new Exception("$CS_INNOnotForResource $CS_Param_ResourceCode=" + mINNO.RESCODE);
|
|
|
|
ICSONWIPITEM wipItem = new ICSONWIPITEM();
|
|
wipItem.MCARD = iNNO;
|
|
wipItem.BIOS = mINNO.BIOS;
|
|
wipItem.DATECODE = mINNO.DATECODE;
|
|
wipItem.LOTNO = mINNO.MITEMPACKEDNO;//.LotNO;
|
|
wipItem.MITEMCODE = mINNO.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
|
|
wipItem.PCBA = mINNO.PCBA;
|
|
wipItem.VENDORCODE = mINNO.VENDORCODE;
|
|
wipItem.VENDORITEMCODE = mINNO.VENDORITEMCODE;
|
|
wipItem.VERSION = mINNO.VERSION;
|
|
|
|
wipItem.EATTRIBUTE1 = simulation.EATTRIBUTE1;
|
|
wipItem.ITEMCODE = simulation.ITEMCODE;
|
|
wipItem.RESCODE = simulation.RESCODE;
|
|
wipItem.ROUTECODE = simulation.ROUTECODE;
|
|
wipItem.RCARD = simulation.RCARD;
|
|
wipItem.RCARDSEQ = simulation.RCARDSEQ;
|
|
wipItem.SEGCODE = simulationReport.SEGCODE;
|
|
wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
|
|
wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
|
|
wipItem.SSCODE = simulationReport.SSCODE;
|
|
wipItem.TPCODE = simulationReport.TPCODE;
|
|
wipItem.MOCODE = simulation.MOCODE;
|
|
wipItem.MODELCODE = simulation.MODELCODE;
|
|
wipItem.OPCODE = simulation.OPCODE;
|
|
wipItem.MTIME = simulation.MTIME;
|
|
wipItem.MUSER = simulation.MUSER;
|
|
//wipItem.MAINTAINDATE = simulation.MaintainDate;
|
|
//wipItem.MaintainTime = simulation.MaintainTime;
|
|
//wipItem.MaintainUser = simulation.MaintainUser;
|
|
|
|
wipItem.QTY = mINNO.QTY;
|
|
wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
|
|
wipItem.MCARDTYPE = MCardType.MCardType_INNO;
|
|
wipItem.MSEQ = i;
|
|
//新增 采集类型
|
|
wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
|
|
wipItem.MOSEQ = simulation.MOSEQ;
|
|
dataCollectFacade.AddOnWIPItem(wipItem);
|
|
|
|
i++;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// ** 功能描述: 上料采集,包括INNO和KEYPARTS上料
|
|
/// 集成上料号,必须存在且对应于RESOURCE
|
|
/// KEYPARTS料的检查在前台已经做完
|
|
/// 事务必须在外面处理
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary>
|
|
/// <param name="actionEventArgs"></param>
|
|
/// <returns></returns>
|
|
public Messages Execute(ActionEventArgs actionEventArgs)
|
|
{
|
|
Messages messages = new Messages();
|
|
Messages msgAutoGoMO = new Messages();
|
|
try
|
|
{
|
|
// 检测自动归属工单
|
|
//ActionGoToMO actionGoToMO = new ActionGoToMO(this.DataProvider);
|
|
//msgAutoGoMO = actionGoToMO.AutoGoMO(actionEventArgs);
|
|
// Added end
|
|
|
|
ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
|
|
//填写SIMULATION 检查工单、ID、途程、操作
|
|
messages.AddMessages(dataCollect.CheckID(actionEventArgs));
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.AddMessages(dataCollect.Execute(actionEventArgs));
|
|
if (messages.IsSuccess())
|
|
{
|
|
DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
|
|
|
|
#region 填写上料信息表 分INNO、KEYPARTS TODO
|
|
if (actionEventArgs.ActionType == ActionType.DataCollectAction_CollectINNO)
|
|
{
|
|
|
|
InsertINNOOnWipItem(actionEventArgs, dataCollectFacade);
|
|
|
|
}
|
|
else
|
|
{
|
|
InsertKeyPartOnWipItem(actionEventArgs, dataCollectFacade);
|
|
}
|
|
#endregion
|
|
|
|
// 上料扣库存
|
|
// 新增 使用配置文件来控制物料模块是否使用
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
{
|
|
|
|
//wfacade.CollectMaterialStock(actionEventArgs.ProductInfo.NowSimulation.RCARD, actionEventArgs.ProductInfo.NowSimulation.RCARDSEQ.ToString(), actionEventArgs.ProductInfo.NowSimulation.MOCODE);
|
|
}
|
|
// Added end
|
|
|
|
|
|
////增加按资源统计产量
|
|
//#region 填写测试报表 按资源统计
|
|
//ReportHelper reportCollect = new ReportHelper(this.DataProvider);
|
|
//messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
|
|
// , actionEventArgs.ActionType, actionEventArgs.ProductInfo));
|
|
//#endregion
|
|
////
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
messages.Add(new Message(e));
|
|
}
|
|
|
|
if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
|
|
return messages;
|
|
else
|
|
{
|
|
msgAutoGoMO.IgnoreError();
|
|
msgAutoGoMO.AddMessages(messages);
|
|
return msgAutoGoMO;
|
|
}
|
|
}
|
|
|
|
//扩展一个带ActionCheckStatus参数的方法
|
|
public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
|
|
{
|
|
Messages messages = new Messages();
|
|
Messages msgAutoGoMO = new Messages();
|
|
try
|
|
{
|
|
// 检测自动归属工单
|
|
ActionGoToMO actionGoToMO = new ActionGoToMO(this.DataProvider);
|
|
msgAutoGoMO = actionGoToMO.AutoGoMO(actionEventArgs, actionCheckStatus);
|
|
// Added end
|
|
|
|
ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
|
|
//填写SIMULATION 检查工单、ID、途程、操作
|
|
messages.AddMessages(dataCollect.CheckID(actionEventArgs, actionCheckStatus));
|
|
|
|
if (messages.IsSuccess())
|
|
{
|
|
//上料检查 分INNO、KEYPARTS TODO
|
|
|
|
if (actionCheckStatus.NeedUpdateSimulation == true)
|
|
{
|
|
messages.AddMessages(dataCollect.Execute(actionEventArgs));
|
|
}
|
|
else
|
|
{
|
|
messages.AddMessages(dataCollect.Execute(actionEventArgs, actionCheckStatus));
|
|
}
|
|
|
|
if (messages.IsSuccess())
|
|
{
|
|
DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
|
|
#region 填写上料信息表 分INNO、KEYPARTS
|
|
if (actionEventArgs.ActionType == ActionType.DataCollectAction_CollectINNO)
|
|
{
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
{
|
|
//wfacade = ((CINNOActionEventArgs)actionEventArgs).Warehouse;
|
|
}
|
|
|
|
InsertINNOOnWipItem(actionEventArgs, dataCollectFacade);
|
|
|
|
}
|
|
else
|
|
{
|
|
InsertKeyPartOnWipItem(actionEventArgs, dataCollectFacade);
|
|
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
{
|
|
//wfacade = ((CKeypartsActionEventArgs)actionEventArgs).Warehouse;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
// 上料扣库存
|
|
//新增 使用配置文件来控制物料模块是否使用
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
{
|
|
//if (wfacade != null)
|
|
// wfacade.CollectMaterialStock(actionEventArgs.ProductInfo.NowSimulation.RCARD, actionEventArgs.ProductInfo.NowSimulation.RCARDSEQ.ToString(), actionEventArgs.ProductInfo.NowSimulation.MOCODE);
|
|
}
|
|
// Added end
|
|
//增加按资源统计产量
|
|
#region 填写测试报表 按资源统计
|
|
//如果需要更新报表
|
|
if (actionCheckStatus.NeedFillReport)
|
|
{
|
|
ReportHelper reportCollect = new ReportHelper(this.DataProvider);
|
|
//messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
|
|
// , actionEventArgs.ActionType, actionEventArgs.ProductInfo, actionCheckStatus));
|
|
}
|
|
|
|
//将Action加入列表
|
|
actionCheckStatus.ActionList.Add(actionEventArgs);
|
|
#endregion
|
|
//AMOI MARK END
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
messages.Add(new Message(e));
|
|
}
|
|
if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
|
|
return messages;
|
|
else
|
|
{
|
|
msgAutoGoMO.IgnoreError();
|
|
msgAutoGoMO.AddMessages(messages);
|
|
return msgAutoGoMO;
|
|
}
|
|
}
|
|
|
|
// Added end
|
|
|
|
//扩展一个带ActionCheckStatus和OPBOMDetail参数的方法
|
|
public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus, object[] OPBOMDetail)
|
|
{
|
|
Messages messages = new Messages();
|
|
Messages msgAutoGoMO = new Messages();
|
|
try
|
|
{
|
|
// 检测自动归属工单
|
|
ActionGoToMO actionGoToMO = new ActionGoToMO(this.DataProvider);
|
|
msgAutoGoMO = actionGoToMO.AutoGoMO(actionEventArgs, actionCheckStatus);
|
|
// Added end
|
|
|
|
ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
|
|
//填写SIMULATION 检查工单、ID、途程、操作
|
|
messages.AddMessages(dataCollect.CheckID(actionEventArgs, actionCheckStatus));
|
|
|
|
if (messages.IsSuccess())
|
|
{
|
|
if (actionCheckStatus.NeedUpdateSimulation == true)
|
|
{
|
|
messages.AddMessages(dataCollect.Execute(actionEventArgs));
|
|
}
|
|
else
|
|
{
|
|
messages.AddMessages(dataCollect.Execute(actionEventArgs, actionCheckStatus));
|
|
}
|
|
|
|
// BenQGuru.eMES.Material.WarehouseFacade wfacade = null;
|
|
if (messages.IsSuccess())
|
|
{
|
|
DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
|
|
#region 填写上料信息表 分INNO、KEYPARTS
|
|
if (actionEventArgs.ActionType == ActionType.DataCollectAction_CollectINNO)
|
|
{
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
{
|
|
//wfacade = ((CINNOActionEventArgs)actionEventArgs).Warehouse;
|
|
}
|
|
|
|
//messages.AddMessages(InsertLotOnWipItem(actionEventArgs, dataCollectFacade, OPBOMDetail));
|
|
//if (!messages.IsSuccess())
|
|
//{
|
|
// return messages;
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
InsertKeyPartOnWipItem(actionEventArgs, dataCollectFacade);
|
|
|
|
|
|
|
|
//if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
//{
|
|
// wfacade = ((CKeypartsActionEventArgs)actionEventArgs).Warehouse;
|
|
//}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
// 上料扣库存
|
|
// 新增 使用配置文件来控制物料模块是否使用
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
|
|
{
|
|
//BenQGuru.eMES.Material.WarehouseFacade wfacade = new WarehouseFacade(this.DataProvider);
|
|
//if (wfacade != null)
|
|
// wfacade.CollectMaterialStock(actionEventArgs.ProductInfo.NowSimulation.RCARD, actionEventArgs.ProductInfo.NowSimulation.RCARDSEQ.ToString(), actionEventArgs.ProductInfo.NowSimulation.MOCODE);
|
|
}
|
|
// Added end
|
|
|
|
// 增加按资源统计产量
|
|
#region 填写测试报表 按资源统计
|
|
//如果需要更新报表
|
|
if (actionCheckStatus.NeedFillReport)
|
|
{
|
|
ReportHelper reportCollect = new ReportHelper(this.DataProvider);
|
|
//messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
|
|
// , actionEventArgs.ActionType, actionEventArgs.ProductInfo, actionCheckStatus));
|
|
}
|
|
|
|
//将Action加入列表
|
|
actionCheckStatus.ActionList.Add(actionEventArgs);
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
messages.Add(new Message(e));
|
|
}
|
|
if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
|
|
return messages;
|
|
else
|
|
{
|
|
msgAutoGoMO.IgnoreError();
|
|
msgAutoGoMO.AddMessages(messages);
|
|
return msgAutoGoMO;
|
|
}
|
|
}
|
|
|
|
public const string MCardType_Keyparts = "0";
|
|
public const string MCardType_INNO = "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 文件名: ActionItem.cs
|
|
/// 描 述: 描述一个 KEYPARTS的BOM,包含一个主料,多个KEYPARTS
|
|
/// 版 本:
|
|
/// </summary>
|
|
public class OPBomKeypart
|
|
{
|
|
public ICSOPBOMDETAIL OpBomDetial;
|
|
public int Count;
|
|
public OPBomKeypart()
|
|
{
|
|
MKeyparts = new ArrayList();
|
|
}
|
|
public ArrayList MKeyparts;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 文件名: ActionItem.cs
|
|
/// 描 述: 描述一个BOM,包含多个主料,处理添加KEYPARTS的逻辑
|
|
/// 版 本:
|
|
/// </summary>
|
|
public class OPBomKeyparts
|
|
{
|
|
private List<ICSOPBOMDETAIL> _opBomDetials;
|
|
private int _iDMergeRule;
|
|
private FramDataContext _domainDataProvider;
|
|
/// <summary>
|
|
/// ** 功能描述: 上料采集
|
|
/// 会检查替代料,不处理试流料
|
|
/// 会根据工单换算数量提示上料个数
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary
|
|
//return messages;>
|
|
/// <param name="opBomDetials">需要上的所有的料</param>
|
|
/// <param name="iDMergeRule">换算数量</param>
|
|
/// <param name="domainDataProvider"></param>
|
|
public OPBomKeyparts(List<ICSOPBOMDETAIL> opBomDetials, int iDMergeRule, FramDataContext domainDataProvider)
|
|
{
|
|
_opBomDetials = opBomDetials;
|
|
_iDMergeRule = iDMergeRule;
|
|
_domainDataProvider = domainDataProvider;
|
|
_bomKeyparts = new ArrayList();
|
|
//记录所有的首选料料号
|
|
ArrayList sourceItemCodes = new ArrayList();
|
|
if (opBomDetials == null)
|
|
{
|
|
opBomDetials = new List<ICSOPBOMDETAIL>();
|
|
return;
|
|
}
|
|
for (int i = 0; i < opBomDetials.Count; i++)
|
|
{
|
|
ICSOPBOMDETAIL opBomDetial = (ICSOPBOMDETAIL)opBomDetials[i];
|
|
//挑选出首选料 OPBOMItemControlType
|
|
if (opBomDetial.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
|
|
{
|
|
if (opBomDetial.OBITEMCODE == opBomDetial.OBITEMCODE)
|
|
{
|
|
OPBomKeypart BomKeypart = new OPBomKeypart();
|
|
BomKeypart.OpBomDetial = opBomDetial;
|
|
this._count = this._count + Convert.ToInt32(opBomDetial.OBITEMQTY) * iDMergeRule;
|
|
|
|
_bomKeyparts.Add(BomKeypart);
|
|
sourceItemCodes.Add(opBomDetial.OBSITEMCODE);
|
|
}
|
|
}
|
|
}
|
|
for (int i = 0; i < opBomDetials.Count; i++)
|
|
{
|
|
ICSOPBOMDETAIL opBomDetial = (ICSOPBOMDETAIL)opBomDetials[i];
|
|
//挑选出首选料 挑出那些没有维护首选料的子阶料
|
|
if (opBomDetial.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
|
|
{
|
|
if (opBomDetial.OBITEMCODE != opBomDetial.OBSITEMCODE)
|
|
{
|
|
if (sourceItemCodes.IndexOf(opBomDetial.OBSITEMCODE) < 0)
|
|
{
|
|
OPBomKeypart BomKeypart = new OPBomKeypart();
|
|
BomKeypart.OpBomDetial = opBomDetial;
|
|
this._count = this._count + Convert.ToInt32(opBomDetial.OBITEMQTY) * iDMergeRule;
|
|
_bomKeyparts.Add(BomKeypart);
|
|
sourceItemCodes.Add(opBomDetial.OBSITEMCODE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private int _count = 0;
|
|
public int Count
|
|
{
|
|
get
|
|
{
|
|
return _count;
|
|
}
|
|
}
|
|
private ArrayList _bomKeyparts;
|
|
/// <summary>
|
|
/// ** 功能描述: 上料采集 增加一个KEYPARTS
|
|
/// 会检查替代料,不处理试流料
|
|
/// 会根据工单换算数量提示上料个数
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary>
|
|
/// <param name="keyPart"></param>
|
|
public Messages AddKeyparts(string keyPart, string moCode)
|
|
{
|
|
return AddKeyparts(keyPart, moCode, string.Empty);
|
|
}
|
|
/// <summary>
|
|
/// ** 功能描述: 上料采集 增加一个KEYPARTS
|
|
/// 会检查替代料,不处理试流料
|
|
/// 会根据工单换算数量提示上料个数
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary>
|
|
/// <param name="keyPart"></param>
|
|
public Messages AddKeyparts(string keyPart, string moCode, string runningCard)
|
|
{
|
|
Messages messages = new Messages();
|
|
//MaterialFacade material = new MaterialFacade(_domainDataProvider);
|
|
//object[] MKeyparts = material.QueryMKeyPart(string.Empty, keyPart, 0, 100);
|
|
//if (MKeyparts == null)
|
|
// throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
|
|
//if (MKeyparts.Length == 0)
|
|
// throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
|
|
//MKeyPart mKeyPart = null;
|
|
|
|
//ArrayList ar = new ArrayList();
|
|
//foreach (MKeyPart key in MKeyparts)
|
|
//{
|
|
// if (key.RunningCardStart.Length == keyPart.Length
|
|
// && String.Compare(key.RunningCardStart, keyPart, false) <= 0
|
|
// && String.Compare(key.RunningCardEnd, keyPart, false) >= 0)
|
|
// {
|
|
// mKeyPart = key;
|
|
// ar.Add(key);
|
|
// }
|
|
//}
|
|
//if (mKeyPart == null)
|
|
//{
|
|
// throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
|
|
//}
|
|
//int n = GetbomKeypart(mKeyPart.MItemCode);
|
|
//if (n < 0)
|
|
// throw new Exception("$CS_KeyPartNotForThisOP $CS_Param_Keypart=" + keyPart + " $CS_Param_KeypartItem=" + mKeyPart.MItemCode);
|
|
//else
|
|
//{
|
|
// OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[n];
|
|
// //检查是否重复
|
|
// for (int i = 0; i < BomKeypart.MKeyparts.Count; i++)
|
|
// {
|
|
// if (((MKeyPart)BomKeypart.MKeyparts[i]).Keypart == keyPart)
|
|
// throw new Exception("$CS_KeyPartRepeat");
|
|
// }
|
|
// if (BomKeypart.OpBomDetial.OBITEMQTY * _iDMergeRule <= BomKeypart.MKeyparts.Count)
|
|
// {
|
|
// throw new Exception("$CS_KeyPartOutofItemBomCount "
|
|
// + " $CS_Param_KeypartItem=" + mKeyPart.MItemCode);
|
|
// }
|
|
|
|
// MaterialFacade mf = new MaterialFacade(this._domainDataProvider);
|
|
// //RunningCard长度检查
|
|
// bool isExist = false;
|
|
|
|
// foreach (MKeyPart key in ar)
|
|
// {
|
|
// if (key.MoCode != moCode && key.MoCode != String.Empty)
|
|
// {
|
|
// throw new Exception("$CS_KEYPART_NOT_BELONG_MO $Domain_MO=" + moCode);
|
|
// }
|
|
// if (mf.RunningCardRangeCheck(key.MItemCode.ToString().ToUpper().Trim(), keyPart, key.Sequence.ToString().Trim()))
|
|
// {
|
|
// isExist = true;
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
// if (!isExist)
|
|
// {
|
|
// throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
|
|
// }
|
|
|
|
// // 检查KeyPart完工状态、是否已上料
|
|
// if (BomKeypart.OpBomDetial.ACTIONTYPE == (int)MaterialType.CollectMaterial)
|
|
// {
|
|
// if (FormatHelper.StringToBoolean(BomKeypart.OpBomDetial.CHECKSTATUS) == true)
|
|
// {
|
|
// Messages msg = CheckKeyPartStatus(keyPart);
|
|
// if (msg.IsSuccess() == false)
|
|
// {
|
|
// return msg;
|
|
// }
|
|
// }
|
|
// }
|
|
// else if (runningCard != string.Empty) // 下料
|
|
// {
|
|
// if (CheckKeyPartUnLoadStatus(keyPart, runningCard) == false)
|
|
// {
|
|
// messages.Add(new Message(MessageType.Error, "$DropMaterial_KeyPart_Not_On_RCard"));
|
|
// return messages;
|
|
// }
|
|
// }
|
|
// // Added end
|
|
|
|
// mKeyPart.Keypart = keyPart;
|
|
// BomKeypart.MKeyparts.Add(mKeyPart);
|
|
//}
|
|
return messages;
|
|
}
|
|
/// <summary>
|
|
/// ** 功能描述: 根据上料序号获取KEYPARTS
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary>
|
|
/// <param name="index"></param>
|
|
/// <returns></returns>
|
|
public object GetKeypart(int index)
|
|
{
|
|
int n = index;
|
|
for (int i = 0; i < _bomKeyparts.Count; i++)
|
|
{
|
|
OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[i];
|
|
if (n >= BomKeypart.MKeyparts.Count)
|
|
n = n - BomKeypart.MKeyparts.Count;
|
|
else
|
|
return (object)BomKeypart.MKeyparts[n];
|
|
}
|
|
throw new Exception("$CS_System_KeyPartsOutofCount");
|
|
}
|
|
/// <summary>
|
|
/// ** 功能描述: 根据料号获取对应的上料信息
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary>
|
|
/// <param name="bomItemCode"></param>
|
|
/// <returns></returns>
|
|
private int GetbomKeypart(string bomItemCode)
|
|
{
|
|
//先找到对应的主料号
|
|
string itemCode = string.Empty;
|
|
for (int i = 0; i < _opBomDetials.Count; i++)
|
|
{
|
|
ICSOPBOMDETAIL opBomDetail = (ICSOPBOMDETAIL)_opBomDetials[i];
|
|
if (opBomDetail.OBITEMCODE == bomItemCode || opBomDetail.OBSITEMCODE == bomItemCode)
|
|
{
|
|
//检查ITEMCONTROL
|
|
if (opBomDetail.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
|
|
itemCode = opBomDetail.OBSITEMCODE;
|
|
else
|
|
throw new Exception("$CS_ItemControl_Is_NotKeyparts $CS_Param_ItemControl=" + opBomDetail.OBITEMCONTYPE);
|
|
}
|
|
}
|
|
if (itemCode == string.Empty)
|
|
return -1;
|
|
//再添加
|
|
for (int i = 0; i < _bomKeyparts.Count; i++)
|
|
{
|
|
OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[i];
|
|
if (BomKeypart.OpBomDetial.OBSITEMCODE == itemCode)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
/// <summary>
|
|
/// ** 功能描述: 获取上料KEYPARTS总数
|
|
/// ** 修 改:
|
|
/// ** 日 期:
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public int GetbomKeypartCount()
|
|
{
|
|
int n = 0;
|
|
for (int i = 0; i < _bomKeyparts.Count; i++)
|
|
{
|
|
OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[i];
|
|
n = n + BomKeypart.MKeyparts.Count;
|
|
}
|
|
return n;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查KeyPart是否完工
|
|
/// 检查KeyPart是否可用
|
|
/// </summary>
|
|
public Messages CheckKeyPartStatus(string keyPartNo)
|
|
{
|
|
return CheckKeyPartStatus(keyPartNo, string.Empty);
|
|
}
|
|
/// <summary>
|
|
/// 检查KeyPart是否完工
|
|
/// 检查KeyPart是否可用
|
|
/// </summary>
|
|
public Messages CheckKeyPartStatus(string keyPartNo, string checkItemCode)
|
|
{
|
|
Messages msg = new Messages();
|
|
DataCollectFacade dcFacade = new DataCollectFacade(this._domainDataProvider);
|
|
ICSSimulationReport simulationRpt = dcFacade.GetLastSimulationReport(keyPartNo);
|
|
// 如果没有找到生产信息,则由用户决定是否保存
|
|
if (simulationRpt == null)
|
|
{
|
|
|
|
//SystemSettingFacade sysFacade = new SystemSettingFacade(this._domainDataProvider);
|
|
//object obj = sysFacade.GetParameter("ITEM_CONFIRM", "DATACOLLECT_ITEM");
|
|
//bool bConfirm = false;
|
|
//if (obj != null && ((Parameter)obj).ParameterAlias == "1")
|
|
//{
|
|
// bConfirm = true;
|
|
//}
|
|
//if (bConfirm == true)
|
|
//{
|
|
// string strMsg = UserControl.MutiLanguages.ParserString("$LoadKeyPart_NoSimulation_Confirm");
|
|
// if (System.Windows.Forms.MessageBox.Show(strMsg, string.Empty, System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
|
|
// {
|
|
// msg.Add(new Message(MessageType.Error, " "));
|
|
// return msg;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// msg.Add(new Message(MessageType.Error, "$LoadKeyPart_NotComplete"));
|
|
// return msg;
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
// 检查是否完工
|
|
if (FormatHelper.StringToBoolean(simulationRpt.ISCOM) == false)
|
|
{
|
|
msg.Add(new Message(MessageType.Error, "$LoadKeyPart_NotComplete"));
|
|
return msg;
|
|
}
|
|
// 检查是否良品
|
|
if (simulationRpt.PRODUCTSTATUS != ProductStatus.GOOD)
|
|
{
|
|
msg.Add(new Message(MessageType.Error, "$LoadKeyPart_Status_NG"));
|
|
return msg;
|
|
}
|
|
// 检查是否已上料
|
|
if (FormatHelper.StringToBoolean(simulationRpt.ISLOADEDPART) == true)
|
|
{
|
|
msg.Add(new Message(MessageType.Error, "$LoadKeyPart_KeyPart_Loaded_Already"));
|
|
return msg;
|
|
}
|
|
if (checkItemCode != null && checkItemCode != string.Empty && simulationRpt.ITEMCODE != checkItemCode)
|
|
{
|
|
msg.Add(new Message(MessageType.Error, "$Error_Inv_Product_Error"));
|
|
return msg;
|
|
}
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 检查KeyPart是否能做序列号上的下料操作
|
|
/// </summary>
|
|
public bool CheckKeyPartUnLoadStatus(string keyPartNo, string runningCard)
|
|
{
|
|
string strSql = "SELECT * FROM ICSONWIPITEM WHERE MCard='" + keyPartNo + "' ORDER BY MTime DESC ";
|
|
var objs = this._domainDataProvider.ExecuteQuery<ICSONWIPITEM>(strSql).ToList();
|
|
if (objs == null || objs.Count < 1)
|
|
return false;
|
|
ICSONWIPITEM item = (ICSONWIPITEM)objs[0];
|
|
// 如果KeyPart最后一次操作是上料
|
|
|
|
if (item.ACTIONTYPE == MaterialType.CollectMaterial.ToString())
|
|
{
|
|
// 对应的序列号是当前序列号
|
|
if (item.RCARD == runningCard)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
// 查询上料的序列号是不是经过序号转换
|
|
//BenQGuru.eMES.Material.CastDownHelper castHelper = new BenQGuru.eMES.Material.CastDownHelper(this._domainDataProvider);
|
|
//ArrayList arRcard = new ArrayList();
|
|
//castHelper.GetAllRCard(ref arRcard, runningCard);
|
|
//if (arRcard.Contains(item.RCARD) == true)
|
|
//{
|
|
// return true;
|
|
//}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
/// <summary>
|
|
/// 通过KeyPart料号查询OPBOM Detail
|
|
/// </summary>
|
|
public OPBomKeypart GetOPBomDetail(string bomItemCode)
|
|
{
|
|
int i = this.GetbomKeypart(bomItemCode);
|
|
if (i < 0)
|
|
return null;
|
|
return (OPBomKeypart)_bomKeyparts[i];
|
|
}
|
|
// Added end
|
|
|
|
}
|
|
|
|
}
|