华恒Mes鼎捷代码
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

5 months ago
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using ICSSoft.Frame.Data.Entity;
  5. using System.Linq;
  6. using System.Data.Linq;
  7. using System.Xml.Linq;
  8. using ICSSoft.Base.Config.AppConfig;
  9. using ICSSoft.Frame.DataCollect;
  10. using ICSSoft.Frame.Helper;
  11. using System.Windows.Forms;
  12. namespace ICSSoft.Frame.DataConnect.Action
  13. {
  14. public class ActionItem : IActionWithStatus, IActionWithStatusNew
  15. {
  16. private FramDataContext _domainDataProvider = null;
  17. public ActionItem()
  18. {
  19. }
  20. public ActionItem(FramDataContext domainDataProvider)
  21. {
  22. this._domainDataProvider = domainDataProvider;
  23. }
  24. public FramDataContext DataProvider
  25. {
  26. get
  27. {
  28. return _domainDataProvider;
  29. }
  30. }
  31. //����INNO���ϼ�¼
  32. //������¼Lot�ϵ���ϸ��¼
  33. public void InsertINNOOnWipItem(ActionEventArgs actionEventArgs, FramDataContext db, object[] OPBOMDetail)
  34. {
  35. string iNNO = ((CINNOActionEventArgs)actionEventArgs).INNO;
  36. ICSSimulation simulation = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
  37. ICSSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
  38. object[] mINNOs = OPBOMDetail;
  39. int i = 0;
  40. if (mINNOs == null)
  41. {
  42. throw new Exception("$CS_INNO_NOT_EXIST");
  43. }
  44. foreach (ICSMINNO mINNO in mINNOs)
  45. {
  46. if (mINNO == null)
  47. throw new Exception("$CS_INNOnotExist");
  48. if (mINNO.MOCODE != simulation.MOCODE)
  49. throw new Exception("$CS_INNOnotForMO $CS_Param_MOCode=" + mINNO.MOCODE);
  50. if (mINNO.ROUTECODE != simulation.ROUTECODE)
  51. throw new Exception("$CS_INNOnotForRoute $CS_Param_RouteCode=" + mINNO.ROUTECODE);
  52. if (mINNO.OPCODE != simulation.OPCODE)
  53. throw new Exception("$CS_INNOnotForOP $CS_Param_OPCode =" + mINNO.OPCODE);
  54. if (mINNO.RESCODE != simulation.RESCODE)
  55. throw new Exception("$CS_INNOnotForResource $CS_Param_ResourceCode=" + mINNO.RESCODE);
  56. ICSONWIPITEM wipItem = new ICSONWIPITEM();
  57. wipItem.MCARD = mINNO.ID;
  58. wipItem.BIOS = mINNO.BIOS;
  59. wipItem.DATECODE = mINNO.DATECODE;
  60. wipItem.LOTNO = mINNO.LOTNO;/*ActionOnLineHelper.StringNull;*/
  61. wipItem.MITEMCODE = mINNO.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
  62. wipItem.PCBA = mINNO.PCBA;
  63. wipItem.VENDORCODE = mINNO.VENDORCODE;
  64. wipItem.VENDORITEMCODE = mINNO.VENDORITEMCODE;
  65. wipItem.VERSION = mINNO.VERSION;
  66. wipItem.MCARDTYPE = simulation.EATTRIBUTE1;
  67. wipItem.ITEMCODE = simulation.ITEMCODE;
  68. wipItem.RESCODE = simulation.RESCODE;
  69. wipItem.ROUTECODE = simulation.ROUTECODE;
  70. wipItem.RCARD = simulation.RCARD;
  71. wipItem.RCARDSEQ = simulation.RCARDSEQ;
  72. wipItem.SEGCODE = simulationReport.SEGCODE;
  73. wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
  74. wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
  75. wipItem.SSCODE = simulationReport.SSCODE;
  76. wipItem.TPCODE = simulationReport.TPCODE;
  77. wipItem.MOCODE = simulation.MOCODE;
  78. wipItem.MODELCODE = simulation.MODELCODE;
  79. wipItem.OPCODE = simulation.OPCODE;
  80. wipItem.MTIME = simulation.MTIME;
  81. wipItem.MUSER = simulation.MUSER;
  82. wipItem.MUSERName = simulation.MUSERName;
  83. wipItem.WorkPoint = simulation.WorkPoint;
  84. wipItem.QTY = mINNO.QTY;
  85. wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
  86. wipItem.MCARDTYPE = MCardType.MCardType_INNO;
  87. wipItem.MSEQ = i;
  88. //���� �ɼ�����
  89. wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
  90. wipItem.MOSEQ = simulation.MOSEQ;
  91. db.ICSONWIPITEM.InsertOnSubmit(wipItem);
  92. i++;
  93. }
  94. }
  95. #region ����
  96. public void UpdateStorageQty(ICSWareHouseLotInfo lotInfo, FramDataContext db, decimal qty)
  97. {
  98. var obj = db.ICSWareHouseInfo.SingleOrDefault(a => a.BinGUID == lotInfo.BinGUID && a.INVCode== lotInfo.INVCode && a.WHGUID == lotInfo.WHGUID && a.WorkPoint == AppConfig.WorkPointCode );
  99. if (obj != null)
  100. {
  101. (obj as ICSWareHouseInfo).QTY = (obj as ICSWareHouseInfo).QTY - qty;
  102. if ((obj as ICSWareHouseInfo).QTY == 0)
  103. {
  104. db.ICSWareHouseInfo.DeleteOnSubmit((obj as ICSWareHouseInfo));
  105. }
  106. }
  107. }
  108. //�����Ƿ��ڿ��Ϲ������Ͳ�����
  109. public bool IsInParams(object[] objs, string mocode)
  110. {
  111. //string motype = string.Empty;
  112. //MOFacade mofacade = new MOFacade(this.DataProvider);
  113. //MO mo = mofacade.GetMO(mocode) as MO;
  114. //if (mo != null)
  115. //{
  116. // motype = mo.MOType;
  117. //}
  118. //if (objs != null && objs.Length > 0)
  119. //{
  120. // foreach (Parameter p in objs)
  121. // {
  122. // if (p.ParameterAlias == motype)
  123. // {
  124. // return false;
  125. // }
  126. // }
  127. //}
  128. return true;
  129. }
  130. /*
  131. public void DeductQty(ActionEventArgs actionEventArgs, FramDataContext db, ICSMINNO minno)
  132. {
  133. string type = "";
  134. if (minno.EATTRIBUTE1 == "1")
  135. {
  136. type = BOMItemControlType.ITEM_CONTROL_LOT;
  137. }
  138. if (minno.EATTRIBUTE1 == "0")
  139. {
  140. type =BOMItemControlType.ITEM_CONTROL_KEYPARTS;
  141. }
  142. ProductInfo productionInfo = actionEventArgs.ProductInfo;
  143. ICSSimulation sim = actionEventArgs.ProductInfo.NowSimulation;
  144. string WorkPoint = actionEventArgs.ProductInfo.Resource.WorkPoint;
  145. ICSMO mo = actionEventArgs.ProductInfo.CurrentMO;
  146. if (mo == null)
  147. {
  148. mo = db.ICSMO.SingleOrDefault(a=> a.MOCODE==sim.MOCODE && a.WorkPoint == AppConfig.WorkPointCode) as ICSMO;
  149. }
  150. //��ȡ��ǰ������
  151. string moCode = productionInfo.NowSimulation.MOCODE;
  152. //��ȡ��ǰ������
  153. string opCode = productionInfo.NowSimulation.OPCODE;
  154. //��ȡ��ǰ��Ʒ��
  155. string itemCode = productionInfo.NowSimulation.ITEMCODE;
  156. //��ȡ;�̴���
  157. string routeCode = productionInfo.NowSimulation.ROUTECODE;
  158. string resCode = productionInfo.Resource.RESCODE;
  159. string moBomVer = string.Empty;
  160. DateTime dbDataTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  161. object objMo = db.ICSMO.SingleOrDefault(a => a.MOCODE == moCode && a.WorkPoint == AppConfig.WorkPointCode) as ICSMO;
  162. if (objMo != null)
  163. {
  164. moBomVer = (objMo as ICSMO).MOBOM;
  165. }
  166. //��ȡ��������
  167. string MItemName =string.Empty;
  168. ICSINVENTORY material;
  169. //���Ӳ�Ʒ�����Ͽ����ж� tblonwip
  170. string rCard = productionInfo.NowSimulation.RCARD;
  171. decimal seq = productionInfo.NowSimulation.RCARDSEQ;
  172. List<ICSONWIP> objOnWip = db.ICSONWIP.Where( a=> a.WorkPoint==AppConfig.WorkPointCode && a.RCARD == rCard && a.OPCODE == opCode&& a.MOCODE == moCode).ToList();
  173. if (objOnWip != null && objOnWip.Count > 0)
  174. {
  175. return;
  176. }
  177. //object[] objMoBoms = moFacade.QueryMoBom(sim.ITEMCODE,minno.MITEMCODE, sim.MOCODE);
  178. //if (objMoBoms == null)
  179. //{
  180. // throw new Exception("$CS_ItemCode[" + minno.MITEMCODE + "]" + "$Error_NotExistInMoBOM" + String.Format("[$MOCode='{0}']", sim.MOCODE));
  181. //}
  182. 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);
  183. if (opbomObjs == null)
  184. {
  185. throw new Exception("$CS_ItemCode[" + minno.MITEMCODE + "]" + "$Error_NotExistInOPBOM" + String.Format("[$ItemCode='{0}']", sim.ItemCode));
  186. }
  187. object[] moRouteObjs = moFacade.QueryMORoutes(sim.MOCODE, sim.ROUTECODE);
  188. if (moRouteObjs == null)
  189. {
  190. throw new Exception("$Error_MORouteNOExist");
  191. }
  192. bool iflag = false;
  193. decimal iOPBOMItemQty = 0;
  194. //��Ҫ�ȶԵ��ӽ����Ϻ� �ȶԳɹ��� ֻ�ڹ�������BOM ��
  195. if (opbomObjs == null)
  196. {
  197. return;
  198. }
  199. //�Թ�����׼BOMΪ��׼,�ۼ���ǰ�����ĵ��������أ�tblmo. EATTRIBUTE2��������Ӧ�Ŀ�����Ϣ��
  200. //����opbom�ж�Ӧ����Ʒ
  201. string TempMOBOMItemCode = string.Empty;
  202. for (int j = 0; j < opbomObjs.Length; j++)
  203. {
  204. if (((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMCONTYPE == "item_control_lot")
  205. {
  206. object[] minnos = materialFacade.QueryLastMINNO(moCode, routeCode, opCode, resCode);
  207. if (minnos != null && minnos.Length > 0)
  208. {
  209. foreach (ICSMINNO tem in minnos)
  210. {
  211. if (tem.MITEMCODE == ((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMCODE.ToUpper() || tem.MITEMCODE == ((ICSOPBOMDETAIL)opbomObjs[j]).OBSITEMCODE.ToUpper())
  212. {
  213. TempMOBOMItemCode = tem.MITEMCODE;
  214. }
  215. }
  216. }
  217. iOPBOMItemQty += (decimal)((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMQTY;
  218. }
  219. else if (((ICSOPBOMDETAIL)opbomObjs[j]).OBITEMCONTYPE == "item_control_keyparts")
  220. {
  221. iOPBOMItemQty = 1;
  222. //�ɼ���������ʧЧ���ڵļ����߼�
  223. string lotno = string.Empty;
  224. var keyparts = inventoryFacade.GetItemLotDetail(minno.MITEMPACKEDNO,minno.MITEMCODE);
  225. if (keyparts != null)
  226. {
  227. lotno = (keyparts as ICSITEMLotDetail).Lotno;
  228. }
  229. else
  230. {
  231. lotno = minno.MITEMPACKEDNO;
  232. }
  233. var objItemLot = inventoryFacade.GetItemLot(lotno, minno.MITEMCODE);
  234. if (objItemLot != null)
  235. {
  236. DateTime day = (objItemLot as ICSITEMLot).Exdate;
  237. if (DateTime.Compare(day,dbDataTime) < 0) //����ʧЧ����С�ڵ�ǰ���ڣ��򱨴�
  238. {
  239. throw new Exception("$LotNO[" + lotno + "]" + "$MaterialCode[" + minno.MITEMCODE + "]" + "$Error_Material_Expired");
  240. }
  241. }
  242. //end
  243. }
  244. }
  245. //�ȶԳɹ����ӽ����Ϻ�һ�� ��ǰ����ΪTRUE
  246. iflag = true;
  247. if (iflag)//�ӽ��ϲ����ڣ� ��ֻ�ڹ�����׼bom��
  248. {
  249. object[] objInfos = inventoryFacade.QueryStorageInfoByIDAndMCode(mo.EAttribute2, ((MOBOM)objMoBoms[n]).MOBOMItemCode.ToUpper());
  250. if (objInfos == null)
  251. {
  252. throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
  253. }
  254. decimal total = inventoryFacade.GetStorageQty(mo.EAttribute2, ((MOBOM)objMoBoms[n]).MOBOMItemCode.ToUpper());
  255. if (total < iOPBOMItemQty)
  256. {
  257. throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
  258. }
  259. #region //���жϱ��������е��������������ۼ����˳�
  260. decimal temlotQty = 0;
  261. object[] objStorageLotInfo = null;
  262. object[] objStorageNextLotInfo = null;
  263. if (type == "item_control_keyparts")
  264. {
  265. objStorageLotInfo = inventoryFacade.QueryStorageLot(minno.LotNO, mo.EAttribute2, ((MOBOM)objMoBoms[n]).MOBOMItemCode.ToUpper());
  266. }
  267. if (type == "item_control_lot")
  268. {
  269. string nextLotNo = string.Empty;
  270. //for��λ����֧��������
  271. object[] minnoss = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, TempMOBOMItemCode);
  272. if (minnoss != null && minnoss.Length > 0)
  273. {
  274. nextLotNo = (minnoss[0] as ICSMINNO).Nextlotno;
  275. }
  276. objStorageLotInfo = inventoryFacade.QueryStorageLot((minnoss[0] as MINNO).LotNO, mo.EAttribute2, TempMOBOMItemCode);
  277. objStorageNextLotInfo = inventoryFacade.QueryStorageLot(nextLotNo, mo.EAttribute2, TempMOBOMItemCode);
  278. }
  279. if (objStorageLotInfo != null)
  280. {
  281. foreach (StorageLotInfo lotInfo in objStorageLotInfo)
  282. {
  283. temlotQty += lotInfo.Lotqty;
  284. }
  285. }
  286. if (objStorageNextLotInfo != null)
  287. {
  288. foreach (StorageLotInfo lotInfo in objStorageNextLotInfo)
  289. {
  290. temlotQty += lotInfo.Lotqty;
  291. }
  292. }
  293. if (temlotQty < iOPBOMItemQty)
  294. {
  295. material = ((Domain.MOModel.Material)itemFacade.GetMaterial(minno.MItemCode, orgID));
  296. throw new Exception("$CS_ItemCode[" + TempMOBOMItemCode + "-" + material.MaterialName + "]" + "$CS_DeductQty_ERROR");
  297. }
  298. #endregion
  299. #region �������Կۼ�
  300. if (objStorageLotInfo != null)
  301. {
  302. decimal tempQty = 0;
  303. decimal tempIOPBOMItemQty = iOPBOMItemQty;
  304. foreach (StorageLotInfo lotInfo in objStorageLotInfo)
  305. {
  306. // Add By Leo @2013-10-24 for �ɼ���������ʧЧ���ڵļ����߼�
  307. var objItemLot = inventoryFacade.GetItemLot( lotInfo.Lotno, minno.MItemCode);
  308. if (objItemLot != null)
  309. {
  310. int day = (objItemLot as ItemLot).Exdate;
  311. if (day < dbDataTime.DBDate) //����ʧЧ����С�ڵ�ǰ���ڣ��򱨴�
  312. {
  313. throw new Exception( "$LotNO[" + lotInfo.Lotno + "]" +"$MaterialCode[" + lotInfo .Mcode+ "]"+ "$Error_Material_Expired");
  314. }
  315. }
  316. //end
  317. tempQty += lotInfo.Lotqty;
  318. if (iOPBOMItemQty >= lotInfo.Lotqty)
  319. {
  320. iOPBOMItemQty = iOPBOMItemQty - lotInfo.Lotqty;
  321. inventoryFacade.DeleteStorageLotInfo(lotInfo);
  322. this.UpdateStorageQty(lotInfo, inventoryFacade, lotInfo.Lotqty);
  323. }
  324. else
  325. {
  326. lotInfo.Lotqty = lotInfo.Lotqty - iOPBOMItemQty;
  327. inventoryFacade.UpdateStorageLotInfo(lotInfo);
  328. this.UpdateStorageQty(lotInfo, inventoryFacade, iOPBOMItemQty);
  329. iOPBOMItemQty = 0;
  330. }
  331. }
  332. if (tempQty == tempIOPBOMItemQty)
  333. {
  334. if (type == "item_control_lot")
  335. {
  336. //�������Ͽۼ�Ϊ���� add by andy 2010-11-30
  337. object[] minnos = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, TempMOBOMItemCode, TempMOBOMItemCode);
  338. if (minnos != null && minnos.Length > 0)
  339. {
  340. if (((MINNO)minnos[0]).Nextlotno.Trim() != "")
  341. {
  342. ((MINNO)minnos[0]).MItemPackedNo = ((MINNO)minnos[0]).Nextlotno.Trim();
  343. ((MINNO)minnos[0]).LotNO = ((MINNO)minnos[0]).Nextlotno.Trim();
  344. ((MINNO)minnos[0]).Nextlotno = " ";
  345. ((MINNO)minnos[0]).Lotqty = ((MINNO)minnos[0]).Nextlotqty;
  346. ((MINNO)minnos[0]).Nextlotqty = 0;
  347. materialFacade.UpdateMINNO(((MINNO)minnos[0]));
  348. }
  349. }
  350. }
  351. }
  352. }
  353. if (iOPBOMItemQty > 0)
  354. {
  355. if (objStorageNextLotInfo != null)
  356. {
  357. decimal temQty = 0;
  358. foreach (StorageLotInfo lotInfo in objStorageNextLotInfo)
  359. {
  360. // Add By Leo @2013-10-24 for �ɼ���������ʧЧ���ڵļ����߼�
  361. var objItemLot = inventoryFacade.GetItemLot(lotInfo.Lotno, minno.MItemCode);
  362. if (objItemLot != null)
  363. {
  364. int day = (objItemLot as ItemLot).Exdate;
  365. if (day < dbDataTime.DBDate) //����ʧЧ����С�ڵ�ǰ���ڣ��򱨴�
  366. {
  367. //���ش�����Ϣ:����[]��Ӧ������[]������������
  368. throw new Exception( "$LotNO[" + lotInfo.Lotno + "]" +"$MaterialCode[" + lotInfo .Mcode+ "]"+ "$Error_Material_Expired");
  369. }
  370. }
  371. //end
  372. temQty += lotInfo.Lotqty;
  373. if (iOPBOMItemQty >= lotInfo.Lotqty)
  374. {
  375. iOPBOMItemQty = iOPBOMItemQty - lotInfo.Lotqty;
  376. inventoryFacade.DeleteStorageLotInfo(lotInfo);
  377. this.UpdateStorageQty(lotInfo, inventoryFacade, lotInfo.Lotqty);
  378. }
  379. else
  380. {
  381. lotInfo.Lotqty = lotInfo.Lotqty - iOPBOMItemQty;
  382. inventoryFacade.UpdateStorageLotInfo(lotInfo);
  383. this.UpdateStorageQty(lotInfo, inventoryFacade, iOPBOMItemQty);
  384. }
  385. }
  386. if (type == "item_control_lot")
  387. {
  388. //�������Ͽۼ�Ϊ���� add by andy 2010-11-30
  389. object[] minnos = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, TempMOBOMItemCode, TempMOBOMItemCode);
  390. if (minnos != null && minnos.Length > 0)
  391. {
  392. if (((MINNO)minnos[0]).Nextlotno.Trim() != "")
  393. {
  394. ((MINNO)minnos[0]).MItemPackedNo = ((MINNO)minnos[0]).Nextlotno.Trim();
  395. ((MINNO)minnos[0]).LotNO = ((MINNO)minnos[0]).Nextlotno.Trim();
  396. ((MINNO)minnos[0]).Nextlotno = " ";
  397. ((MINNO)minnos[0]).Lotqty = ((MINNO)minnos[0]).Nextlotqty;
  398. ((MINNO)minnos[0]).Nextlotqty = 0;
  399. materialFacade.UpdateMINNO(((MINNO)minnos[0]));
  400. }
  401. }
  402. }
  403. }
  404. }
  405. #endregion
  406. }
  407. }
  408. */
  409. #endregion
  410. public Messages InsertLotOnWipItem(ActionEventArgs actionEventArgs, FramDataContext db, object[] OPBOMDetail)
  411. {
  412. DataCollectFacade dataCollectFacade = new DataCollectFacade(db);
  413. Messages returnValue = new Messages();
  414. string iNNO = ((CINNOActionEventArgs)actionEventArgs).INNO;
  415. ICSSimulation simulation = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
  416. ICSSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
  417. object[] mINNOs = OPBOMDetail;
  418. int i = 0;
  419. if (mINNOs == null)
  420. {
  421. throw new Exception("$CS_INNO_NOT_EXIST");
  422. }
  423. foreach (ICSMINNO mINNO in mINNOs)
  424. {
  425. if (mINNO == null)
  426. throw new Exception("$CS_INNOnotExist");
  427. ICSONWIPITEM wipItem = new ICSONWIPITEM();
  428. wipItem.MCARD = mINNO.ID;
  429. wipItem.BIOS = mINNO.BIOS;
  430. wipItem.DATECODE = mINNO.DATECODE;
  431. wipItem.LOTNO = mINNO.LOTNO;/*ActionOnLineHelper.StringNull;*/
  432. wipItem.MITEMCODE = mINNO.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
  433. wipItem.PCBA = mINNO.PCBA;
  434. wipItem.VENDORCODE = mINNO.VENDORCODE;
  435. wipItem.VENDORITEMCODE = mINNO.VENDORITEMCODE;
  436. wipItem.VERSION = mINNO.VERSION;
  437. wipItem.MCARDTYPE = mINNO.EATTRIBUTE1;
  438. wipItem.EATTRIBUTE1 = simulation.EATTRIBUTE1;
  439. wipItem.ITEMCODE = simulation.ITEMCODE;
  440. wipItem.RESCODE = simulation.RESCODE;
  441. wipItem.ROUTECODE = simulation.ROUTECODE;
  442. wipItem.RCARD = simulation.RCARD;
  443. wipItem.RCARDSEQ = simulation.RCARDSEQ;
  444. wipItem.SEGCODE = simulationReport.SEGCODE;
  445. wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
  446. wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
  447. wipItem.SSCODE = simulationReport.SSCODE;
  448. wipItem.TPCODE = simulationReport.TPCODE;
  449. wipItem.MOCODE = simulation.MOCODE;
  450. wipItem.MODELCODE = simulation.MODELCODE;
  451. wipItem.OPCODE = simulation.OPCODE;
  452. wipItem.MTIME = simulation.MTIME;
  453. wipItem.MUSER = simulation.MUSER;
  454. wipItem.MUSERName = simulation.MUSERName;
  455. wipItem.WorkPoint = simulation.WorkPoint;
  456. if (mINNO.QTY.ToString() != string.Empty && Convert.ToInt32(mINNO.QTY) != 0)
  457. {
  458. wipItem.QTY = mINNO.QTY;
  459. }
  460. else
  461. {
  462. wipItem.QTY = 1;
  463. }
  464. wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
  465. wipItem.MSEQ = i;
  466. //���� �ɼ�����
  467. wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
  468. wipItem.MOSEQ = simulation.MOSEQ;
  469. db.ICSONWIPITEM.InsertOnSubmit(wipItem);
  470. ICSSimulationReport simulationRpt = dataCollectFacade.GetLastSimulationReport(wipItem.MCARD);
  471. if (simulationRpt != null)
  472. {
  473. simulationRpt.ISLOADEDPART = FormatHelper.BooleanToString(true);
  474. simulationRpt.LOADEDRCARD = wipItem.RCARD;
  475. dataCollectFacade.UpdateSimulationReport(simulationRpt);
  476. }
  477. i++;
  478. //�����Ͽ���ʱ����tblitemlotdetail.serialstatus =��UNSTORAGE��
  479. //end add
  480. // DeductQty(actionEventArgs, dataCollectFacade, mINNO);
  481. }
  482. return returnValue;
  483. }
  484. //����KeyParts���ϼ�¼
  485. public void InsertKeyPartOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade)
  486. {
  487. OPBomKeyparts keyParts = ((CKeypartsActionEventArgs)actionEventArgs).Keyparts;
  488. ICSSimulation simulation = ((CKeypartsActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
  489. ICSSimulationReport simulationReport = ((CKeypartsActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
  490. int n = keyParts.GetbomKeypartCount();
  491. for (int i = 0; i < n; i++)
  492. {
  493. //MKeyPart keypart = keyParts.GetKeypart(i);
  494. ICSONWIPITEM wipItem = new ICSONWIPITEM();
  495. //wipItem.BIOS = keypart.BIOS;
  496. //wipItem.MCARD = keypart.ID;
  497. //wipItem.DATECODE = keypart.DATECODE;
  498. //wipItem.LOTNO = keypart.LOTNO;/*ActionOnLineHelper.StringNull;*/
  499. //wipItem.MITEMCODE = keypart.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
  500. //wipItem.PCBA = keypart.PCBA;
  501. //wipItem.VENDORCODE = keypart.VENDORCODE;
  502. //wipItem.VENDORITEMCODE = keypart.VENDORITEMCODE;
  503. //wipItem.VERSION = keypart.VERSION;
  504. //wipItem.MCARDTYPE = keypart.EATTRIBUTE1;
  505. wipItem.EATTRIBUTE1 = simulation.EATTRIBUTE1;
  506. wipItem.ITEMCODE = simulation.ITEMCODE;
  507. wipItem.RESCODE = simulation.RESCODE;
  508. wipItem.ROUTECODE = simulation.ROUTECODE;
  509. wipItem.RCARD = simulation.RCARD;
  510. wipItem.RCARDSEQ = simulation.RCARDSEQ;
  511. wipItem.SEGCODE = simulationReport.SEGCODE;
  512. wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
  513. wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
  514. wipItem.SSCODE = simulationReport.SSCODE;
  515. wipItem.TPCODE = simulationReport.TPCODE;
  516. wipItem.MOCODE = simulation.MOCODE;
  517. wipItem.MODELCODE = simulation.MODELCODE;
  518. wipItem.OPCODE = simulation.OPCODE;
  519. wipItem.MTIME = simulation.MTIME;
  520. wipItem.MUSER = simulation.MUSER;
  521. wipItem.MUSERName = simulation.MUSERName;
  522. wipItem.WorkPoint = simulation.WorkPoint;
  523. wipItem.QTY = 1;
  524. wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
  525. wipItem.MCARDTYPE = MCardType.MCardType_Keyparts;
  526. wipItem.MSEQ = i;
  527. //�ɼ�����
  528. wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
  529. wipItem.MOSEQ = simulation.MOSEQ;
  530. this._domainDataProvider.ICSONWIPITEM.InsertOnSubmit(wipItem);
  531. // �޸�KeyPartʹ��
  532. if (FormatHelper.StringToBoolean(keyParts.GetOPBomDetail(wipItem.MITEMCODE).OpBomDetial.CHECKSTATUS) == true)
  533. {
  534. //ICSSimulationReport simulationRpt = dataCollectFacade.GetLastSimulationReport(keypart.Keypart);
  535. //if (simulationRpt != null)
  536. //{
  537. // simulationRpt.ISLOADEDPART = FormatHelper.BooleanToString(true);
  538. // simulationRpt.LOADEDRCARD = simulation.RCARD;
  539. // dataCollectFacade.UpdateSimulationReport(simulationRpt);
  540. //}
  541. }
  542. // Added end
  543. //�����Ͽ���ʱ����tblitemlotdetail.serialstatus =��UNSTORAGE��
  544. //InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);
  545. //ICSITEMLotDetail itemLotDetail = (ICSITEMLotDetail)inventoryFacade.GetItemLotDetail(keypart.Keypart, keypart.MItemCode);
  546. //if (itemLotDetail == null || itemLotDetail.SerialStatus != SerialStatus.SerialStatus_Storage)
  547. //{
  548. // throw new Exception("$CS_Error_SerialNotInStorage:" + keypart.Keypart);
  549. //}
  550. //else
  551. //{
  552. // itemLotDetail.SerialStatus = SerialStatus.SerialStatus_Unstorage;
  553. // //inventoryFacade.UpdateItemLotDetail(itemLotDetail);
  554. //}
  555. //end add
  556. //���Ͽ���
  557. ICSMINNO minno = new ICSMINNO();
  558. minno.LOTNO = wipItem.LOTNO;
  559. //DeductQty(actionEventArgs, dataCollectFacade, minno);
  560. }
  561. }
  562. //����INNO���ϼ�¼
  563. //������¼Lot�ϵ���ϸ��¼
  564. public void InsertINNOOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade)
  565. {
  566. string iNNO = ((CINNOActionEventArgs)actionEventArgs).INNO;
  567. ICSSimulation simulation = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
  568. ICSSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
  569. //MaterialFacade material = new MaterialFacade(_domainDataProvider);
  570. object[] mINNOs = null;// material.GetLastMINNOs(iNNO);
  571. int i = 0;
  572. if (mINNOs == null)
  573. {
  574. throw new Exception("$CS_INNO_NOT_EXIST");
  575. }
  576. foreach (ICSMINNO mINNO in mINNOs)
  577. {
  578. if (mINNO == null)
  579. throw new Exception("$CS_INNOnotExist");
  580. if (mINNO.MOCODE != simulation.MOCODE)
  581. throw new Exception("$CS_INNOnotForMO $CS_Param_MOCode=" + mINNO.MOCODE);
  582. if (mINNO.ROUTECODE != simulation.ROUTECODE)
  583. throw new Exception("$CS_INNOnotForRoute $CS_Param_RouteCode=" + mINNO.ROUTECODE);
  584. if (mINNO.OPCODE != simulation.OPCODE)
  585. throw new Exception("$CS_INNOnotForOP $CS_Param_OPCode =" + mINNO.OPCODE);
  586. if (mINNO.RESCODE != simulation.RESCODE)
  587. throw new Exception("$CS_INNOnotForResource $CS_Param_ResourceCode=" + mINNO.RESCODE);
  588. ICSONWIPITEM wipItem = new ICSONWIPITEM();
  589. wipItem.MCARD = iNNO;
  590. wipItem.BIOS = mINNO.BIOS;
  591. wipItem.DATECODE = mINNO.DATECODE;
  592. wipItem.LOTNO = mINNO.MITEMPACKEDNO;//.LotNO;
  593. wipItem.MITEMCODE = mINNO.MITEMCODE;/*ActionOnLineHelper.StringNull;*/
  594. wipItem.PCBA = mINNO.PCBA;
  595. wipItem.VENDORCODE = mINNO.VENDORCODE;
  596. wipItem.VENDORITEMCODE = mINNO.VENDORITEMCODE;
  597. wipItem.VERSION = mINNO.VERSION;
  598. wipItem.EATTRIBUTE1 = simulation.EATTRIBUTE1;
  599. wipItem.ITEMCODE = simulation.ITEMCODE;
  600. wipItem.RESCODE = simulation.RESCODE;
  601. wipItem.ROUTECODE = simulation.ROUTECODE;
  602. wipItem.RCARD = simulation.RCARD;
  603. wipItem.RCARDSEQ = simulation.RCARDSEQ;
  604. wipItem.SEGCODE = simulationReport.SEGCODE;
  605. wipItem.SHIFTCODE = simulationReport.SHIFTCODE;
  606. wipItem.SHIFTTYPECODE = simulationReport.SHIFTTYPECODE;
  607. wipItem.SSCODE = simulationReport.SSCODE;
  608. wipItem.TPCODE = simulationReport.TPCODE;
  609. wipItem.MOCODE = simulation.MOCODE;
  610. wipItem.MODELCODE = simulation.MODELCODE;
  611. wipItem.OPCODE = simulation.OPCODE;
  612. wipItem.MTIME = simulation.MTIME;
  613. wipItem.MUSER = simulation.MUSER;
  614. //wipItem.MAINTAINDATE = simulation.MaintainDate;
  615. //wipItem.MaintainTime = simulation.MaintainTime;
  616. //wipItem.MaintainUser = simulation.MaintainUser;
  617. wipItem.QTY = mINNO.QTY;
  618. wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
  619. wipItem.MCARDTYPE = MCardType.MCardType_INNO;
  620. wipItem.MSEQ = i;
  621. //���� �ɼ�����
  622. wipItem.ACTIONTYPE = MaterialType.CollectMaterial.ToString();
  623. wipItem.MOSEQ = simulation.MOSEQ;
  624. dataCollectFacade.AddOnWIPItem(wipItem);
  625. i++;
  626. }
  627. }
  628. /// <summary>
  629. /// ** ��������: ���ϲɼ�������INNO��KEYPARTS����
  630. /// �������Ϻţ����������Ҷ�Ӧ��RESOURCE
  631. /// KEYPARTS�ϵļ�����ǰ̨�Ѿ�����
  632. /// �������������洦��
  633. /// ** �� ��:
  634. /// ** �� ��:
  635. /// </summary>
  636. /// <param name="actionEventArgs"></param>
  637. /// <returns></returns>
  638. public Messages Execute(ActionEventArgs actionEventArgs)
  639. {
  640. Messages messages = new Messages();
  641. Messages msgAutoGoMO = new Messages();
  642. try
  643. {
  644. // �����Զ���������
  645. //ActionGoToMO actionGoToMO = new ActionGoToMO(this.DataProvider);
  646. //msgAutoGoMO = actionGoToMO.AutoGoMO(actionEventArgs);
  647. // Added end
  648. ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
  649. //��дSIMULATION ���鹤����ID��;�̡�����
  650. messages.AddMessages(dataCollect.CheckID(actionEventArgs));
  651. if (messages.IsSuccess())
  652. {
  653. messages.AddMessages(dataCollect.Execute(actionEventArgs));
  654. if (messages.IsSuccess())
  655. {
  656. DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
  657. #region ��д������Ϣ�� ��INNO��KEYPARTS TODO
  658. if (actionEventArgs.ActionType == ActionType.DataCollectAction_CollectINNO)
  659. {
  660. InsertINNOOnWipItem(actionEventArgs, dataCollectFacade);
  661. }
  662. else
  663. {
  664. InsertKeyPartOnWipItem(actionEventArgs, dataCollectFacade);
  665. }
  666. #endregion
  667. // ���Ͽۿ���
  668. // ���� ʹ�������ļ�����������ģ���Ƿ�ʹ��
  669. if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  670. {
  671. //wfacade.CollectMaterialStock(actionEventArgs.ProductInfo.NowSimulation.RCARD, actionEventArgs.ProductInfo.NowSimulation.RCARDSEQ.ToString(), actionEventArgs.ProductInfo.NowSimulation.MOCODE);
  672. }
  673. // Added end
  674. ////���Ӱ���Դͳ�Ʋ���
  675. //#region ��д���Ա��� ����Դͳ��
  676. //ReportHelper reportCollect = new ReportHelper(this.DataProvider);
  677. //messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
  678. // , actionEventArgs.ActionType, actionEventArgs.ProductInfo));
  679. //#endregion
  680. ////
  681. }
  682. }
  683. }
  684. catch (Exception e)
  685. {
  686. messages.Add(new Message(e));
  687. }
  688. if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
  689. return messages;
  690. else
  691. {
  692. msgAutoGoMO.IgnoreError();
  693. msgAutoGoMO.AddMessages(messages);
  694. return msgAutoGoMO;
  695. }
  696. }
  697. //��չһ����ActionCheckStatus�����ķ���
  698. public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
  699. {
  700. Messages messages = new Messages();
  701. Messages msgAutoGoMO = new Messages();
  702. try
  703. {
  704. // �����Զ���������
  705. ActionGoToMO actionGoToMO = new ActionGoToMO(this.DataProvider);
  706. msgAutoGoMO = actionGoToMO.AutoGoMO(actionEventArgs, actionCheckStatus);
  707. // Added end
  708. ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
  709. //��дSIMULATION ���鹤����ID��;�̡�����
  710. messages.AddMessages(dataCollect.CheckID(actionEventArgs, actionCheckStatus));
  711. if (messages.IsSuccess())
  712. {
  713. //���ϼ��� ��INNO��KEYPARTS TODO
  714. if (actionCheckStatus.NeedUpdateSimulation == true)
  715. {
  716. messages.AddMessages(dataCollect.Execute(actionEventArgs));
  717. }
  718. else
  719. {
  720. messages.AddMessages(dataCollect.Execute(actionEventArgs, actionCheckStatus));
  721. }
  722. if (messages.IsSuccess())
  723. {
  724. DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
  725. #region ��д������Ϣ�� ��INNO��KEYPARTS
  726. if (actionEventArgs.ActionType == ActionType.DataCollectAction_CollectINNO)
  727. {
  728. if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  729. {
  730. //wfacade = ((CINNOActionEventArgs)actionEventArgs).Warehouse;
  731. }
  732. InsertINNOOnWipItem(actionEventArgs, dataCollectFacade);
  733. }
  734. else
  735. {
  736. InsertKeyPartOnWipItem(actionEventArgs, dataCollectFacade);
  737. if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  738. {
  739. //wfacade = ((CKeypartsActionEventArgs)actionEventArgs).Warehouse;
  740. }
  741. }
  742. #endregion
  743. }
  744. // ���Ͽۿ���
  745. //���� ʹ�������ļ�����������ģ���Ƿ�ʹ��
  746. if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  747. {
  748. //if (wfacade != null)
  749. // wfacade.CollectMaterialStock(actionEventArgs.ProductInfo.NowSimulation.RCARD, actionEventArgs.ProductInfo.NowSimulation.RCARDSEQ.ToString(), actionEventArgs.ProductInfo.NowSimulation.MOCODE);
  750. }
  751. // Added end
  752. //���Ӱ���Դͳ�Ʋ���
  753. #region ��д���Ա��� ����Դͳ��
  754. //������Ҫ���±���
  755. if (actionCheckStatus.NeedFillReport)
  756. {
  757. ReportHelper reportCollect = new ReportHelper(this.DataProvider);
  758. //messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
  759. // , actionEventArgs.ActionType, actionEventArgs.ProductInfo, actionCheckStatus));
  760. }
  761. //��Action�����б�
  762. actionCheckStatus.ActionList.Add(actionEventArgs);
  763. #endregion
  764. //AMOI MARK END
  765. }
  766. }
  767. catch (Exception e)
  768. {
  769. messages.Add(new Message(e));
  770. }
  771. if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
  772. return messages;
  773. else
  774. {
  775. msgAutoGoMO.IgnoreError();
  776. msgAutoGoMO.AddMessages(messages);
  777. return msgAutoGoMO;
  778. }
  779. }
  780. // Added end
  781. //��չһ����ActionCheckStatus��OPBOMDetail�����ķ���
  782. public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus, object[] OPBOMDetail)
  783. {
  784. Messages messages = new Messages();
  785. Messages msgAutoGoMO = new Messages();
  786. try
  787. {
  788. // �����Զ���������
  789. ActionGoToMO actionGoToMO = new ActionGoToMO(this.DataProvider);
  790. msgAutoGoMO = actionGoToMO.AutoGoMO(actionEventArgs, actionCheckStatus);
  791. // Added end
  792. ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
  793. //��дSIMULATION ���鹤����ID��;�̡�����
  794. messages.AddMessages(dataCollect.CheckID(actionEventArgs, actionCheckStatus));
  795. if (messages.IsSuccess())
  796. {
  797. if (actionCheckStatus.NeedUpdateSimulation == true)
  798. {
  799. messages.AddMessages(dataCollect.Execute(actionEventArgs));
  800. }
  801. else
  802. {
  803. messages.AddMessages(dataCollect.Execute(actionEventArgs, actionCheckStatus));
  804. }
  805. // BenQGuru.eMES.Material.WarehouseFacade wfacade = null;
  806. if (messages.IsSuccess())
  807. {
  808. DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
  809. #region ��д������Ϣ�� ��INNO��KEYPARTS
  810. if (actionEventArgs.ActionType == ActionType.DataCollectAction_CollectINNO)
  811. {
  812. if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  813. {
  814. //wfacade = ((CINNOActionEventArgs)actionEventArgs).Warehouse;
  815. }
  816. //messages.AddMessages(InsertLotOnWipItem(actionEventArgs, dataCollectFacade, OPBOMDetail));
  817. //if (!messages.IsSuccess())
  818. //{
  819. // return messages;
  820. //}
  821. }
  822. else
  823. {
  824. InsertKeyPartOnWipItem(actionEventArgs, dataCollectFacade);
  825. //if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  826. //{
  827. // wfacade = ((CKeypartsActionEventArgs)actionEventArgs).Warehouse;
  828. //}
  829. }
  830. #endregion
  831. }
  832. // ���Ͽۿ���
  833. // ���� ʹ�������ļ�����������ģ���Ƿ�ʹ��
  834. if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
  835. {
  836. //BenQGuru.eMES.Material.WarehouseFacade wfacade = new WarehouseFacade(this.DataProvider);
  837. //if (wfacade != null)
  838. // wfacade.CollectMaterialStock(actionEventArgs.ProductInfo.NowSimulation.RCARD, actionEventArgs.ProductInfo.NowSimulation.RCARDSEQ.ToString(), actionEventArgs.ProductInfo.NowSimulation.MOCODE);
  839. }
  840. // Added end
  841. // ���Ӱ���Դͳ�Ʋ���
  842. #region ��д���Ա��� ����Դͳ��
  843. //������Ҫ���±���
  844. if (actionCheckStatus.NeedFillReport)
  845. {
  846. ReportHelper reportCollect = new ReportHelper(this.DataProvider);
  847. //messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
  848. // , actionEventArgs.ActionType, actionEventArgs.ProductInfo, actionCheckStatus));
  849. }
  850. //��Action�����б�
  851. actionCheckStatus.ActionList.Add(actionEventArgs);
  852. #endregion
  853. }
  854. }
  855. catch (Exception e)
  856. {
  857. messages.Add(new Message(e));
  858. }
  859. if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
  860. return messages;
  861. else
  862. {
  863. msgAutoGoMO.IgnoreError();
  864. msgAutoGoMO.AddMessages(messages);
  865. return msgAutoGoMO;
  866. }
  867. }
  868. public const string MCardType_Keyparts = "0";
  869. public const string MCardType_INNO = "1";
  870. }
  871. /// <summary>
  872. /// ���: ActionItem.cs
  873. /// �� ��: ����һ�� KEYPARTS��BOM������һ�����ϣ�����KEYPARTS
  874. /// �� ��:
  875. /// </summary>
  876. public class OPBomKeypart
  877. {
  878. public ICSOPBOMDETAIL OpBomDetial;
  879. public int Count;
  880. public OPBomKeypart()
  881. {
  882. MKeyparts = new ArrayList();
  883. }
  884. public ArrayList MKeyparts;
  885. }
  886. /// <summary>
  887. /// ���: ActionItem.cs
  888. /// �� ��: ����һ��BOM�������������ϣ���������KEYPARTS���߼�
  889. /// �� ��:
  890. /// </summary>
  891. public class OPBomKeyparts
  892. {
  893. private List<ICSOPBOMDETAIL> _opBomDetials;
  894. private int _iDMergeRule;
  895. private FramDataContext _domainDataProvider;
  896. /// <summary>
  897. /// ** ��������: ���ϲɼ�
  898. /// �����������ϣ�������������
  899. /// �����ݹ�������������ʾ���ϸ���
  900. /// ** �� ��:
  901. /// ** �� ��:
  902. /// </summary
  903. //return messages;>
  904. /// <param name="opBomDetials">��Ҫ�ϵ����е���</param>
  905. /// <param name="iDMergeRule">��������</param>
  906. /// <param name="domainDataProvider"></param>
  907. public OPBomKeyparts(List<ICSOPBOMDETAIL> opBomDetials, int iDMergeRule, FramDataContext domainDataProvider)
  908. {
  909. _opBomDetials = opBomDetials;
  910. _iDMergeRule = iDMergeRule;
  911. _domainDataProvider = domainDataProvider;
  912. _bomKeyparts = new ArrayList();
  913. //��¼���е���ѡ���Ϻ�
  914. ArrayList sourceItemCodes = new ArrayList();
  915. if (opBomDetials == null)
  916. {
  917. opBomDetials = new List<ICSOPBOMDETAIL>();
  918. return;
  919. }
  920. for (int i = 0; i < opBomDetials.Count; i++)
  921. {
  922. ICSOPBOMDETAIL opBomDetial = (ICSOPBOMDETAIL)opBomDetials[i];
  923. //��ѡ����ѡ�� OPBOMItemControlType
  924. if (opBomDetial.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
  925. {
  926. if (opBomDetial.OBITEMCODE == opBomDetial.OBITEMCODE)
  927. {
  928. OPBomKeypart BomKeypart = new OPBomKeypart();
  929. BomKeypart.OpBomDetial = opBomDetial;
  930. this._count = this._count + Convert.ToInt32(opBomDetial.OBITEMQTY) * iDMergeRule;
  931. _bomKeyparts.Add(BomKeypart);
  932. sourceItemCodes.Add(opBomDetial.OBSITEMCODE);
  933. }
  934. }
  935. }
  936. for (int i = 0; i < opBomDetials.Count; i++)
  937. {
  938. ICSOPBOMDETAIL opBomDetial = (ICSOPBOMDETAIL)opBomDetials[i];
  939. //��ѡ����ѡ�� ������Щû��ά����ѡ�ϵ��ӽ���
  940. if (opBomDetial.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
  941. {
  942. if (opBomDetial.OBITEMCODE != opBomDetial.OBSITEMCODE)
  943. {
  944. if (sourceItemCodes.IndexOf(opBomDetial.OBSITEMCODE) < 0)
  945. {
  946. OPBomKeypart BomKeypart = new OPBomKeypart();
  947. BomKeypart.OpBomDetial = opBomDetial;
  948. this._count = this._count + Convert.ToInt32(opBomDetial.OBITEMQTY) * iDMergeRule;
  949. _bomKeyparts.Add(BomKeypart);
  950. sourceItemCodes.Add(opBomDetial.OBSITEMCODE);
  951. }
  952. }
  953. }
  954. }
  955. }
  956. private int _count = 0;
  957. public int Count
  958. {
  959. get
  960. {
  961. return _count;
  962. }
  963. }
  964. private ArrayList _bomKeyparts;
  965. /// <summary>
  966. /// ** ��������: ���ϲɼ� ����һ��KEYPARTS
  967. /// �����������ϣ�������������
  968. /// �����ݹ�������������ʾ���ϸ���
  969. /// ** �� ��:
  970. /// ** �� ��:
  971. /// </summary>
  972. /// <param name="keyPart"></param>
  973. public Messages AddKeyparts(string keyPart, string moCode)
  974. {
  975. return AddKeyparts(keyPart, moCode, string.Empty);
  976. }
  977. /// <summary>
  978. /// ** ��������: ���ϲɼ� ����һ��KEYPARTS
  979. /// �����������ϣ�������������
  980. /// �����ݹ�������������ʾ���ϸ���
  981. /// ** �� ��:
  982. /// ** �� ��:
  983. /// </summary>
  984. /// <param name="keyPart"></param>
  985. public Messages AddKeyparts(string keyPart, string moCode, string runningCard)
  986. {
  987. Messages messages = new Messages();
  988. //MaterialFacade material = new MaterialFacade(_domainDataProvider);
  989. //object[] MKeyparts = material.QueryMKeyPart(string.Empty, keyPart, 0, 100);
  990. //if (MKeyparts == null)
  991. // throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
  992. //if (MKeyparts.Length == 0)
  993. // throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
  994. //MKeyPart mKeyPart = null;
  995. //ArrayList ar = new ArrayList();
  996. //foreach (MKeyPart key in MKeyparts)
  997. //{
  998. // if (key.RunningCardStart.Length == keyPart.Length
  999. // && String.Compare(key.RunningCardStart, keyPart, false) <= 0
  1000. // && String.Compare(key.RunningCardEnd, keyPart, false) >= 0)
  1001. // {
  1002. // mKeyPart = key;
  1003. // ar.Add(key);
  1004. // }
  1005. //}
  1006. //if (mKeyPart == null)
  1007. //{
  1008. // throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
  1009. //}
  1010. //int n = GetbomKeypart(mKeyPart.MItemCode);
  1011. //if (n < 0)
  1012. // throw new Exception("$CS_KeyPartNotForThisOP $CS_Param_Keypart=" + keyPart + " $CS_Param_KeypartItem=" + mKeyPart.MItemCode);
  1013. //else
  1014. //{
  1015. // OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[n];
  1016. // //�����Ƿ��ظ�
  1017. // for (int i = 0; i < BomKeypart.MKeyparts.Count; i++)
  1018. // {
  1019. // if (((MKeyPart)BomKeypart.MKeyparts[i]).Keypart == keyPart)
  1020. // throw new Exception("$CS_KeyPartRepeat");
  1021. // }
  1022. // if (BomKeypart.OpBomDetial.OBITEMQTY * _iDMergeRule <= BomKeypart.MKeyparts.Count)
  1023. // {
  1024. // throw new Exception("$CS_KeyPartOutofItemBomCount "
  1025. // + " $CS_Param_KeypartItem=" + mKeyPart.MItemCode);
  1026. // }
  1027. // MaterialFacade mf = new MaterialFacade(this._domainDataProvider);
  1028. // //RunningCard���ȼ���
  1029. // bool isExist = false;
  1030. // foreach (MKeyPart key in ar)
  1031. // {
  1032. // if (key.MoCode != moCode && key.MoCode != String.Empty)
  1033. // {
  1034. // throw new Exception("$CS_KEYPART_NOT_BELONG_MO $Domain_MO=" + moCode);
  1035. // }
  1036. // if (mf.RunningCardRangeCheck(key.MItemCode.ToString().ToUpper().Trim(), keyPart, key.Sequence.ToString().Trim()))
  1037. // {
  1038. // isExist = true;
  1039. // break;
  1040. // }
  1041. // }
  1042. // if (!isExist)
  1043. // {
  1044. // throw new Exception("$CS_NoKeyPartInfo $CS_Param_Keypart=" + keyPart);
  1045. // }
  1046. // // ����KeyPart�깤״̬���Ƿ�������
  1047. // if (BomKeypart.OpBomDetial.ACTIONTYPE == (int)MaterialType.CollectMaterial)
  1048. // {
  1049. // if (FormatHelper.StringToBoolean(BomKeypart.OpBomDetial.CHECKSTATUS) == true)
  1050. // {
  1051. // Messages msg = CheckKeyPartStatus(keyPart);
  1052. // if (msg.IsSuccess() == false)
  1053. // {
  1054. // return msg;
  1055. // }
  1056. // }
  1057. // }
  1058. // else if (runningCard != string.Empty) // ����
  1059. // {
  1060. // if (CheckKeyPartUnLoadStatus(keyPart, runningCard) == false)
  1061. // {
  1062. // messages.Add(new Message(MessageType.Error, "$DropMaterial_KeyPart_Not_On_RCard"));
  1063. // return messages;
  1064. // }
  1065. // }
  1066. // // Added end
  1067. // mKeyPart.Keypart = keyPart;
  1068. // BomKeypart.MKeyparts.Add(mKeyPart);
  1069. //}
  1070. return messages;
  1071. }
  1072. /// <summary>
  1073. /// ** ��������: �����������Ż�ȡKEYPARTS
  1074. /// ** �� ��:
  1075. /// ** �� ��:
  1076. /// </summary>
  1077. /// <param name="index"></param>
  1078. /// <returns></returns>
  1079. public object GetKeypart(int index)
  1080. {
  1081. int n = index;
  1082. for (int i = 0; i < _bomKeyparts.Count; i++)
  1083. {
  1084. OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[i];
  1085. if (n >= BomKeypart.MKeyparts.Count)
  1086. n = n - BomKeypart.MKeyparts.Count;
  1087. else
  1088. return (object)BomKeypart.MKeyparts[n];
  1089. }
  1090. throw new Exception("$CS_System_KeyPartsOutofCount");
  1091. }
  1092. /// <summary>
  1093. /// ** ��������: �����ϺŻ�ȡ��Ӧ��������Ϣ
  1094. /// ** �� ��:
  1095. /// ** �� ��:
  1096. /// </summary>
  1097. /// <param name="bomItemCode"></param>
  1098. /// <returns></returns>
  1099. private int GetbomKeypart(string bomItemCode)
  1100. {
  1101. //���ҵ���Ӧ�����Ϻ�
  1102. string itemCode = string.Empty;
  1103. for (int i = 0; i < _opBomDetials.Count; i++)
  1104. {
  1105. ICSOPBOMDETAIL opBomDetail = (ICSOPBOMDETAIL)_opBomDetials[i];
  1106. if (opBomDetail.OBITEMCODE == bomItemCode || opBomDetail.OBSITEMCODE == bomItemCode)
  1107. {
  1108. //����ITEMCONTROL
  1109. if (opBomDetail.OBITEMCONTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
  1110. itemCode = opBomDetail.OBSITEMCODE;
  1111. else
  1112. throw new Exception("$CS_ItemControl_Is_NotKeyparts $CS_Param_ItemControl=" + opBomDetail.OBITEMCONTYPE);
  1113. }
  1114. }
  1115. if (itemCode == string.Empty)
  1116. return -1;
  1117. //������
  1118. for (int i = 0; i < _bomKeyparts.Count; i++)
  1119. {
  1120. OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[i];
  1121. if (BomKeypart.OpBomDetial.OBSITEMCODE == itemCode)
  1122. {
  1123. return i;
  1124. }
  1125. }
  1126. return -1;
  1127. }
  1128. /// <summary>
  1129. /// ** ��������: ��ȡ����KEYPARTS����
  1130. /// ** �� ��:
  1131. /// ** �� ��:
  1132. /// </summary>
  1133. /// <returns></returns>
  1134. public int GetbomKeypartCount()
  1135. {
  1136. int n = 0;
  1137. for (int i = 0; i < _bomKeyparts.Count; i++)
  1138. {
  1139. OPBomKeypart BomKeypart = (OPBomKeypart)_bomKeyparts[i];
  1140. n = n + BomKeypart.MKeyparts.Count;
  1141. }
  1142. return n;
  1143. }
  1144. /// <summary>
  1145. /// ����KeyPart�Ƿ��깤
  1146. /// ����KeyPart�Ƿ�����
  1147. /// </summary>
  1148. public Messages CheckKeyPartStatus(string keyPartNo)
  1149. {
  1150. return CheckKeyPartStatus(keyPartNo, string.Empty);
  1151. }
  1152. /// <summary>
  1153. /// ����KeyPart�Ƿ��깤
  1154. /// ����KeyPart�Ƿ�����
  1155. /// </summary>
  1156. public Messages CheckKeyPartStatus(string keyPartNo, string checkItemCode)
  1157. {
  1158. Messages msg = new Messages();
  1159. DataCollectFacade dcFacade = new DataCollectFacade(this._domainDataProvider);
  1160. ICSSimulationReport simulationRpt = dcFacade.GetLastSimulationReport(keyPartNo);
  1161. // ����û���ҵ�������Ϣ�������û������Ƿ񱣴�
  1162. if (simulationRpt == null)
  1163. {
  1164. //SystemSettingFacade sysFacade = new SystemSettingFacade(this._domainDataProvider);
  1165. //object obj = sysFacade.GetParameter("ITEM_CONFIRM", "DATACOLLECT_ITEM");
  1166. //bool bConfirm = false;
  1167. //if (obj != null && ((Parameter)obj).ParameterAlias == "1")
  1168. //{
  1169. // bConfirm = true;
  1170. //}
  1171. //if (bConfirm == true)
  1172. //{
  1173. // string strMsg = UserControl.MutiLanguages.ParserString("$LoadKeyPart_NoSimulation_Confirm");
  1174. // if (System.Windows.Forms.MessageBox.Show(strMsg, string.Empty, System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
  1175. // {
  1176. // msg.Add(new Message(MessageType.Error, " "));
  1177. // return msg;
  1178. // }
  1179. //}
  1180. //else
  1181. //{
  1182. // msg.Add(new Message(MessageType.Error, "$LoadKeyPart_NotComplete"));
  1183. // return msg;
  1184. //}
  1185. }
  1186. else
  1187. {
  1188. // �����Ƿ��깤
  1189. if (FormatHelper.StringToBoolean(simulationRpt.ISCOM) == false)
  1190. {
  1191. msg.Add(new Message(MessageType.Error, "$LoadKeyPart_NotComplete"));
  1192. return msg;
  1193. }
  1194. // �����Ƿ���Ʒ
  1195. if (simulationRpt.PRODUCTSTATUS != ProductStatus.GOOD)
  1196. {
  1197. msg.Add(new Message(MessageType.Error, "$LoadKeyPart_Status_NG"));
  1198. return msg;
  1199. }
  1200. // �����Ƿ�������
  1201. if (FormatHelper.StringToBoolean(simulationRpt.ISLOADEDPART) == true)
  1202. {
  1203. msg.Add(new Message(MessageType.Error, "$LoadKeyPart_KeyPart_Loaded_Already"));
  1204. return msg;
  1205. }
  1206. if (checkItemCode != null && checkItemCode != string.Empty && simulationRpt.ITEMCODE != checkItemCode)
  1207. {
  1208. msg.Add(new Message(MessageType.Error, "$Error_Inv_Product_Error"));
  1209. return msg;
  1210. }
  1211. }
  1212. return msg;
  1213. }
  1214. /// <summary>
  1215. /// ����KeyPart�Ƿ��������к��ϵ����ϲ���
  1216. /// </summary>
  1217. public bool CheckKeyPartUnLoadStatus(string keyPartNo, string runningCard)
  1218. {
  1219. string strSql = "SELECT * FROM ICSONWIPITEM WHERE MCard='" + keyPartNo + "' ORDER BY MTime DESC ";
  1220. var objs = this._domainDataProvider.ExecuteQuery<ICSONWIPITEM>(strSql).ToList();
  1221. if (objs == null || objs.Count < 1)
  1222. return false;
  1223. ICSONWIPITEM item = (ICSONWIPITEM)objs[0];
  1224. // ����KeyPart����һ�β���������
  1225. if (item.ACTIONTYPE == MaterialType.CollectMaterial.ToString())
  1226. {
  1227. // ��Ӧ�����к��ǵ�ǰ���к�
  1228. if (item.RCARD == runningCard)
  1229. {
  1230. return true;
  1231. }
  1232. else
  1233. {
  1234. // ��ѯ���ϵ����к��Dz��Ǿ�������ת��
  1235. //BenQGuru.eMES.Material.CastDownHelper castHelper = new BenQGuru.eMES.Material.CastDownHelper(this._domainDataProvider);
  1236. //ArrayList arRcard = new ArrayList();
  1237. //castHelper.GetAllRCard(ref arRcard, runningCard);
  1238. //if (arRcard.Contains(item.RCARD) == true)
  1239. //{
  1240. // return true;
  1241. //}
  1242. }
  1243. }
  1244. return false;
  1245. }
  1246. /// <summary>
  1247. /// ͨ��KeyPart�ϺŲ�ѯOPBOM Detail
  1248. /// </summary>
  1249. public OPBomKeypart GetOPBomDetail(string bomItemCode)
  1250. {
  1251. int i = this.GetbomKeypart(bomItemCode);
  1252. if (i < 0)
  1253. return null;
  1254. return (OPBomKeypart)_bomKeyparts[i];
  1255. }
  1256. // Added end
  1257. }
  1258. }