华恒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.

813 lines
34 KiB

5 months ago
  1. using System;
  2. using System.Collections;
  3. using System.Reflection;
  4. using System.Runtime.Remoting;
  5. using System.Text.RegularExpressions;
  6. using System.Linq;
  7. using System.Data.Linq;
  8. using System.Xml;
  9. using System.IO;
  10. using ICSSoft.Base.Config.AppConfig;
  11. using System.Collections.Specialized;
  12. using ICSSoft.Frame.Data.Entity;
  13. using ICSSoft.Frame.DataConnect.Action;
  14. using ICSSoft.Frame.DataConnect;
  15. using ICSSoft.Frame.Helper;
  16. using ICSSoft.Frame.Data.BLL;
  17. namespace ICSSoft.Frame.DataCollect
  18. {
  19. /// <summary>
  20. /// DataCollectOnLine ��ժҪ˵����
  21. /// </summary>
  22. public class ActionOnLineHelper
  23. {
  24. private FramDataContext _domainDataProvider = null;
  25. public ActionOnLineHelper(FramDataContext domainDataProvider)
  26. {
  27. this._domainDataProvider = domainDataProvider;
  28. }
  29. public FramDataContext DataProvider
  30. {
  31. get
  32. {
  33. return _domainDataProvider;
  34. }
  35. }
  36. bool flag = true;
  37. public const int StartSeq = 1;
  38. public const string StringNull = "";
  39. public const int StartNGTimes = 0;
  40. //�õ�ID��ICSSimulation ��Ϣ
  41. public Messages GetIDInfo(string iD)
  42. {
  43. Messages messages = new Messages();
  44. try
  45. {
  46. DataCollectFacade dataCollect = new DataCollectFacade(this.DataProvider);
  47. ProductInfo product = new ProductInfo();
  48. object obj = dataCollect.GetSimulationByRCardOrTCard(iD.ToUpper());//����Ϊʲô��ID???????????
  49. if (obj == null)
  50. {
  51. product.LastSimulation = null;
  52. }
  53. else
  54. {
  55. product.LastSimulation = new ExtendSimulation((ICSSimulation)obj);
  56. //��Ʒͣ���̵�
  57. if (Convert.ToInt32(product.LastSimulation.IsHold) == (int)CycleStatus.Hold)
  58. {
  59. messages.Add(new Message(MessageType.Error, "$CS_LINE_IS_HOLD"));
  60. }
  61. }
  62. product.NowSimulation = new ICSSimulation();
  63. Message message = new Message(MessageType.Data, "", new object[] { product });
  64. messages.Add(message);
  65. }
  66. catch (Exception e)
  67. {
  68. messages.Add(new Message(e));
  69. }
  70. return messages;
  71. }
  72. public Messages GetIDInfoByMoCodeAndId(string moCode, string iD)
  73. {
  74. Messages messages = new Messages();
  75. try
  76. {
  77. DataCollectFacade dataCollect = new DataCollectFacade(this.DataProvider);
  78. ProductInfo product = new ProductInfo();
  79. object obj = dataCollect.GetSimulationByMoCodeAndRcardORTCard(moCode, iD.ToUpper());//���������������ź�ID����������
  80. if (obj == null)
  81. {
  82. product.LastSimulation = null;
  83. }
  84. else
  85. {
  86. product.LastSimulation = new ExtendSimulation((ICSSimulation)obj);
  87. //��Ʒͣ���̵�
  88. if (product.LastSimulation.IsHold == CycleStatus.Hold.ToString())
  89. {
  90. messages.Add(new Message(MessageType.Error, "$CS_LINE_IS_HOLD"));
  91. }
  92. }
  93. product.NowSimulation = new ICSSimulation();
  94. Message message = new Message(MessageType.Data, "", new object[] { product });
  95. messages.Add(message);
  96. }
  97. catch (Exception e)
  98. {
  99. messages.Add(new Message(e));
  100. }
  101. return messages;
  102. }
  103. public ProductInfo GetIDInfoBySimulation(ICSSimulation ICSSimulation)
  104. {
  105. ProductInfo product = new ProductInfo();
  106. product.LastSimulation = new ExtendSimulation(ICSSimulation);
  107. product.NowSimulation = new ICSSimulation();
  108. //��Ʒͣ���̵�
  109. if (Convert.ToInt32(product.LastSimulation.IsHold) == (int)CycleStatus.Hold)
  110. {
  111. throw new Exception("$CS_LINE_IS_HOLD");
  112. }
  113. return product;
  114. }
  115. /// <summary>
  116. /// �Ƚ�����ICSSimulation����;�����Ƿ�����һ��
  117. /// </summary>
  118. /// <param name="simulation1"></param>
  119. /// <param name="simulation2"></param>
  120. /// <returns></returns>
  121. public bool CompareSimulationCheck(ICSSimulation simulation1, ICSSimulation simulation2)
  122. {
  123. if (simulation1 == null)
  124. return false;
  125. if (simulation2 == null)
  126. return false;
  127. if ((simulation1.MOCODE == simulation2.MOCODE)
  128. && (simulation1.ROUTECODE == simulation2.ROUTECODE)
  129. && (simulation1.OPCODE == simulation2.OPCODE)
  130. && (simulation1.RESCODE == simulation2.RESCODE)
  131. && (simulation1.PRODUCTSTATUS == simulation2.PRODUCTSTATUS)
  132. && (simulation1.ACTIONLIST == simulation2.ACTIONLIST)
  133. && (simulation1.LACTION == simulation2.LACTION)
  134. && (simulation1.ISCOM == simulation2.ISCOM)
  135. )
  136. return true;
  137. return false;
  138. }
  139. public void CopyProduct(ProductInfo sourceProduct, ProductInfo toProduct)
  140. {
  141. ((ExtendSimulation)toProduct.LastSimulation).AdjustProductStatus = ((ExtendSimulation)sourceProduct.LastSimulation).AdjustProductStatus;
  142. ((ExtendSimulation)toProduct.LastSimulation).NextOPCode = ((ExtendSimulation)sourceProduct.LastSimulation).NextOPCode;
  143. ((ExtendSimulation)toProduct.LastSimulation).NextRouteCode = ((ExtendSimulation)sourceProduct.LastSimulation).NextRouteCode;
  144. }
  145. //Check Route �Ļ�����Ϣ Check ��ȷ����NewSimulation �������µ�;��
  146. public Messages CheckID(ActionEventArgs actionEventArgs)
  147. {
  148. return CheckID(actionEventArgs, null);
  149. }
  150. //Check Route �Ļ�����Ϣ Check ��ȷ����NewSimulation �������µ�;��
  151. public Messages CheckID(ActionEventArgs actionEventArgs, int orgid)//�Ƿ�������֯ID???????????????????????????
  152. {
  153. return CheckID(actionEventArgs, null, orgid);
  154. }
  155. // ��չһ����ActionCheckStatus�ķ���
  156. public Messages CheckID(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus, int orgid)
  157. {
  158. Messages messages = new Messages();
  159. try
  160. {
  161. if (actionEventArgs.ActionType != ActionType.DataCollectAction_GoMO)
  162. {
  163. if (actionEventArgs.ProductInfo.LastSimulation == null)
  164. {
  165. throw new Exception("$NoSimulationInfo");
  166. }
  167. else
  168. {
  169. DataCollectFacade dcFacade = new DataCollectFacade(this.DataProvider);
  170. messages.AddMessages(dcFacade.CheckID(actionEventArgs.RunningCard, actionEventArgs.ActionType, actionEventArgs.ResourceCode, actionEventArgs.UserCode, actionEventArgs.ProductInfo, actionCheckStatus));
  171. }
  172. }
  173. }
  174. catch (Exception e)
  175. {
  176. messages.Add(new Message(e));
  177. }
  178. return messages;
  179. }
  180. // ��չһ����ActionCheckStatus�ķ���
  181. public Messages CheckID(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
  182. {
  183. Messages messages = new Messages();
  184. try
  185. {
  186. if (actionEventArgs.ActionType != ActionType.DataCollectAction_GoMO)
  187. {
  188. if (actionEventArgs.ProductInfo.LastSimulation == null)
  189. {
  190. actionEventArgs.ProductInfo.LastSimulation = new ExtendSimulation(actionCheckStatus.ProductInfo.NowSimulation);
  191. }
  192. DataCollectFacade dcFacade = new DataCollectFacade(this.DataProvider);
  193. messages.AddMessages(dcFacade.CheckID(actionEventArgs.RunningCard, actionEventArgs.ActionType, actionEventArgs.ResourceCode, actionEventArgs.UserCode, actionEventArgs.ProductInfo, actionCheckStatus));
  194. }
  195. }
  196. catch (Exception e)
  197. {
  198. messages.Add(new Message(e));
  199. }
  200. return messages;
  201. }
  202. // Added end
  203. public Messages CollectErrorInformation(string actionType, ProductInfo product, object[] datas1,string memo)
  204. {
  205. Messages messages = new Messages();
  206. ICSTS tS = new ICSTS();
  207. ICSTSERRORCODE tsErrorCode;
  208. try
  209. {
  210. tS.CARDTYPE = CardType.CardType_Product;
  211. tS.FRMTIME = product.NowSimulation.MTIME;
  212. tS.FRMINPUTTYPE = "tssource_onwip";
  213. tS.FRMUSER = product.NowSimulation.MUSER;
  214. tS.FRMMEMO = memo;
  215. tS.RMABILLCODE = product.NowSimulation.RMABILLCODE;
  216. tS.FRMOPCODE = product.NowSimulation.OPCODE;
  217. tS.FRMRESCODE = product.NowSimulation.RESCODE;
  218. tS.FRMROUTECODE = product.NowSimulation.ROUTECODE;
  219. tS.FRMSEGCODE = product.NowSimulationReport.SEGCODE;
  220. tS.SHIFTCODE = product.NowSimulationReport.SHIFTCODE;
  221. tS.SHIFTDAY = product.NowSimulationReport.SHIFTDAY;
  222. tS.SHIFTTYPECODE = product.NowSimulationReport.SHIFTTYPECODE;
  223. tS.FRMSSCODE = product.NowSimulationReport.SSCODE;
  224. tS.TPCODE = product.NowSimulationReport.TPCODE;
  225. tS.FRMUSER = product.NowSimulation.MUSER;
  226. tS.ITEMCODE = product.NowSimulation.ITEMCODE;
  227. tS.MTIME = product.NowSimulation.MTIME;
  228. tS.MUSER = product.NowSimulation.MUSER;
  229. tS.MUSERName = product.NowSimulation.MUSERName;
  230. tS.MOCODE = product.NowSimulation.MOCODE;
  231. tS.MODELCODE = product.NowSimulation.MODELCODE;
  232. tS.RCARD = product.NowSimulation.RCARD;
  233. tS.RCARDSEQ = product.NowSimulation.RCARDSEQ;
  234. tS.SCARD = product.NowSimulation.SCARD;
  235. tS.SCARDSEQ = product.NowSimulation.SCARDSEQ;
  236. tS.FRMROUTECODE = product.LastSimulation.ROUTECODE;
  237. tS.TRANSSTATUS = "none";
  238. tS.TCARD = product.NowSimulation.TCARD;
  239. tS.TCARDSEQ = product.NowSimulation.TCARDSEQ;
  240. tS.TSID = AppConfig.GetGuid();
  241. tS.TSSTATUS = TSStatus.TSStatus_New;
  242. tS.FRMWEEK = (new ReportHelper(DataProvider)).WeekOfYear(tS.SHIFTDAY.ToString());
  243. tS.FRMMONTH = int.Parse(tS.SHIFTDAY.ToString().Substring(4, 2));
  244. tS.TSTIMES = (int)product.NowSimulation.NGTIMES;
  245. tS.MOSEQ = product.NowSimulation.MOSEQ;
  246. tS.WorkPoint = product.NowSimulation.WorkPoint;
  247. this.DataProvider.ICSTS.InsertOnSubmit(tS);
  248. if (datas1 != null)
  249. {
  250. for (int i = 0; i < datas1.Length; i++)
  251. {
  252. tsErrorCode = new ICSTSERRORCODE();
  253. tsErrorCode.ECODE = ((ICSECG2EC)datas1[i]).ECODE;
  254. tsErrorCode.ECGCODE = ((ICSECG2EC)datas1[i]).ECGCODE;
  255. tsErrorCode.ITEMCODE = tS.ITEMCODE;
  256. tsErrorCode.MTIME = tS.MTIME;
  257. tsErrorCode.MUSER = tS.MUSER;
  258. tsErrorCode.MOCODE = tS.MOCODE;
  259. tsErrorCode.MODELCODE = tS.MODELCODE;
  260. tsErrorCode.MUSERName = tS.MUSERName;
  261. tsErrorCode.WorkPoint = tS.WorkPoint;
  262. tsErrorCode.RCARD = tS.RCARD;
  263. tsErrorCode.RCARDSEQ = tS.RCARDSEQ;
  264. tsErrorCode.TSID = tS.TSID;
  265. tsErrorCode.MOSEQ = decimal.Parse( tS.MOSEQ.ToString());
  266. tsErrorCode.SHIFTDAY = (int)product.NowSimulationReport.SHIFTDAY;
  267. this.DataProvider.ICSTSERRORCODE.InsertOnSubmit(tsErrorCode);
  268. }
  269. }
  270. }
  271. catch (Exception e)
  272. {
  273. messages.Add(new Message(e));
  274. }
  275. return messages;
  276. }
  277. private bool CheckBeforeRework(ActionEventArgs actionEventArgs)
  278. {
  279. ICSBaseModel baseModelFacade = new ICSBaseModel(this.DataProvider);
  280. string opCode = string.Empty;
  281. ICSOP2RES op2Res = (ICSOP2RES)baseModelFacade.GetOperationByResource(actionEventArgs.ResourceCode);
  282. if (op2Res != null)
  283. {
  284. opCode = op2Res.OPCODE;
  285. }
  286. string lastAction = string.Empty;
  287. string[] actionList = actionEventArgs.ProductInfo.LastSimulation.ACTIONLIST.Split(';');
  288. if (actionList != null)
  289. {
  290. for (int i = 0; i < actionList.Length; i++)
  291. {
  292. if (actionList[i].Trim().Length > 0)
  293. {
  294. lastAction = actionList[i].Trim();
  295. }
  296. }
  297. }
  298. if (string.Compare(lastAction, "GOMO", true) == 0)
  299. {
  300. return true;
  301. }
  302. else
  303. {
  304. return (actionEventArgs.ProductInfo.LastSimulation.OPCODE != opCode);
  305. }
  306. }
  307. // ����ICSSimulation ����д
  308. public Messages Execute(ActionEventArgs actionEventArgs)
  309. {
  310. return Execute(actionEventArgs, null);
  311. }
  312. // ��չһ����ActionCheckStatus�����ķ���
  313. public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
  314. {
  315. return Execute(actionEventArgs, actionCheckStatus, false, true);
  316. }
  317. public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus, bool updateSimulation, bool addWip)
  318. {
  319. Messages messages = new Messages();
  320. try
  321. {
  322. DataCollectFacade dataCollect = new DataCollectFacade(this.DataProvider);
  323. DateTime dbDateTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  324. actionEventArgs.ProductInfo.WorkDateTime = dbDateTime;
  325. actionEventArgs.ProductInfo.NowSimulation.MTIME = dbDateTime;
  326. actionEventArgs.ProductInfo.NowSimulation.MUSER = actionEventArgs.UserCode;
  327. actionEventArgs.ProductInfo.NowSimulation.MUSERName = AppConfig.UserName;
  328. actionEventArgs.ProductInfo.NowSimulation.WorkPoint = AppConfig.WorkPointCode;
  329. actionEventArgs.ProductInfo.NowSimulationReport = this.FillSimulationReport(actionEventArgs.ProductInfo);
  330. // ����actionCheckStatus��Ϊ�գ�������actionCheckStatus
  331. if (actionCheckStatus != null)
  332. {
  333. actionCheckStatus.ProductInfo = actionEventArgs.ProductInfo;
  334. }
  335. // LastSimulation !=null �������� ����Ͷ�� ����
  336. if (actionEventArgs.ProductInfo.LastSimulation != null)
  337. {
  338. if ((actionEventArgs.ProductInfo.LastSimulation.RCARD != actionEventArgs.ProductInfo.NowSimulation.RCARD)
  339. || (actionEventArgs.ProductInfo.LastSimulation.MOCODE != actionEventArgs.ProductInfo.NowSimulation.MOCODE))
  340. {
  341. /* ���к�ת������ */
  342. if (actionEventArgs is SplitIDActionEventArgs
  343. && string.Compare((actionEventArgs as SplitIDActionEventArgs).IDMergeType, IDMergeType.IDMERGETYPE_IDMERGE, true) == 0)
  344. {
  345. #region �ְ�
  346. SplitIDActionEventArgs splitActionEventArgs = actionEventArgs as SplitIDActionEventArgs;
  347. if (splitActionEventArgs.UpdateSimulation)
  348. {
  349. if (splitActionEventArgs.IsSameMO)
  350. {
  351. /* ͬһŹ
  352. * LastSimulationѱתҪDelete; NowSimulationѾڣupdateICSSimulationReportͬICSSimulation*/
  353. dataCollect.DeleteSimulation(actionEventArgs.ProductInfo.LastSimulation);
  354. dataCollect.UpdateSimulation(actionEventArgs.ProductInfo.NowSimulation);
  355. dataCollect.DeleteSimulationReport(actionEventArgs.ProductInfo.LastSimulation);
  356. dataCollect.UpdateSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  357. }
  358. else
  359. {
  360. /* ڲͬĹɾԭICSSimulation
  361. * Ȼڵǰ߱ϣٻصԭĹɼͻ */
  362. dataCollect.DeleteSimulation(actionEventArgs.ProductInfo.LastSimulation);
  363. dataCollect.DeleteSimulation(actionEventArgs.ProductInfo.NowSimulation);
  364. dataCollect.AddSimulation(actionEventArgs.ProductInfo.NowSimulation);
  365. /* ɾ���Լ���������֤���Բ���ICSSimulationReport */
  366. dataCollect.DeleteSimulationReport(actionEventArgs.ProductInfo.LastSimulation);
  367. dataCollect.DeleteSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  368. dataCollect.AddSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  369. }
  370. }
  371. else
  372. {
  373. dataCollect.DeleteSimulation(actionEventArgs.ProductInfo.LastSimulation);
  374. dataCollect.AddSimulation(actionEventArgs.ProductInfo.NowSimulation);
  375. dataCollect.DeleteSimulationReport(actionEventArgs.ProductInfo.LastSimulation);
  376. dataCollect.AddSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  377. }
  378. #endregion
  379. }
  380. else
  381. {
  382. //���Ϻ����¹�����������
  383. if (actionEventArgs.ProductInfo.LastSimulation.MOCODE != actionEventArgs.ProductInfo.NowSimulation.MOCODE)
  384. {
  385. dataCollect.AddSimulation(actionEventArgs.ProductInfo.NowSimulation);
  386. dataCollect.AddSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  387. }
  388. else
  389. {
  390. dataCollect.DeleteSimulation(actionEventArgs.ProductInfo.LastSimulation);
  391. dataCollect.AddSimulation(actionEventArgs.ProductInfo.NowSimulation);
  392. dataCollect.DeleteSimulationReport(actionEventArgs.ProductInfo.LastSimulation);
  393. dataCollect.AddSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  394. }
  395. }
  396. }
  397. else
  398. {
  399. dataCollect.UpdateSimulation(actionEventArgs.ProductInfo.NowSimulation);
  400. dataCollect.UpdateSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  401. }
  402. }
  403. else
  404. {
  405. dataCollect.AddSimulation(actionEventArgs.ProductInfo.NowSimulation);
  406. dataCollect.AddSimulationReport(actionEventArgs.ProductInfo.NowSimulationReport);
  407. }
  408. //������Ҫ����Wip
  409. if (actionCheckStatus == null || actionCheckStatus.NeedUpdateSimulation == true)
  410. {
  411. if (actionEventArgs.ActionType == ActionType.DataCollectAction_OQCNG)
  412. {
  413. dataCollect.AddOnWIP(this.FillOnWip(actionEventArgs.ProductInfo, actionEventArgs));
  414. }
  415. else
  416. {
  417. dataCollect.AddOnWIP(this.FillOnWip(actionEventArgs.ProductInfo));
  418. }
  419. }
  420. else if (addWip == true)
  421. {
  422. dataCollect.AddOnWIP(this.FillOnWip(actionEventArgs.ProductInfo, actionEventArgs));
  423. }
  424. //������������
  425. //���Ӳ���tbltestdata����
  426. if (actionEventArgs.Params != null && actionEventArgs.Params.Length > 0)
  427. {
  428. int mesEntityListSerial = dataCollect.GetMESEntityListSerial(actionEventArgs.ProductInfo.NowSimulationReport);
  429. foreach (ICSTESTDATA item in actionEventArgs.Params)
  430. {
  431. item.ICSMESEntityList_serial = mesEntityListSerial.ToString();
  432. DataAcquiseBLL.Add(item, AppConfig.AppConnectString,_domainDataProvider);
  433. //ExternalInterfaceFacade externalInterfaceFacade = new ExternalInterfaceFacade(this.DataProvider);
  434. //item.Tblmesentitylist_Serial = mesEntityListSerial;
  435. //externalInterfaceFacade.AddTestData(item);
  436. }
  437. }
  438. }
  439. catch (Exception e)
  440. {
  441. messages.Add(new Message(e));
  442. }
  443. return messages;
  444. }
  445. // Added end
  446. //��дICSSimulationReport ID, ;��,ʱ��,����ģ��,�û���Ϣ ������ ProductInfo.NewSimulation
  447. public ICSSimulationReport FillSimulationReport(ProductInfo productInfo)
  448. {
  449. ICSSimulationReport simulationReport = new ICSSimulationReport();
  450. simulationReport.ID = AppConfig.GetGuid();
  451. simulationReport.ROUTECODE = productInfo.NowSimulation.ROUTECODE;
  452. simulationReport.OPCODE = productInfo.NowSimulation.OPCODE;
  453. simulationReport.CARTONCODE = productInfo.NowSimulation.CARTONCODE;
  454. simulationReport.EATTRIBUTE1 = productInfo.NowSimulation.EATTRIBUTE1;
  455. simulationReport.EATTRIBUTE2 = productInfo.NowSimulation.EATTRIBUTE2;
  456. simulationReport.IDMERGERULE = productInfo.NowSimulation.IDMERGERULE;
  457. simulationReport.ISCOM = productInfo.NowSimulation.ISCOM;
  458. simulationReport.ITEMCODE = productInfo.NowSimulation.ITEMCODE;
  459. simulationReport.LACTION = productInfo.NowSimulation.LACTION;
  460. simulationReport.LOTNO = productInfo.NowSimulation.LOTNO;
  461. simulationReport.MTIME = productInfo.NowSimulation.MTIME;
  462. simulationReport.MUSER = productInfo.NowSimulation.MUSER;
  463. simulationReport.MOCODE = productInfo.NowSimulation.MOCODE;
  464. simulationReport.MODELCODE = productInfo.NowSimulation.MODELCODE;
  465. simulationReport.NGTIMES = productInfo.NowSimulation.NGTIMES;
  466. simulationReport.PALLETCODE = productInfo.NowSimulation.PALLETCODE;
  467. simulationReport.RESCODE = productInfo.NowSimulation.RESCODE;
  468. simulationReport.RCARD = productInfo.NowSimulation.RCARD;
  469. simulationReport.RCARDSEQ = productInfo.NowSimulation.RCARDSEQ;
  470. simulationReport.PRODUCTSTATUS = productInfo.NowSimulation.PRODUCTSTATUS;
  471. simulationReport.TCARD = productInfo.NowSimulation.TCARD;
  472. simulationReport.TCARDSEQ = productInfo.NowSimulation.TCARDSEQ;
  473. simulationReport.SCARD = productInfo.NowSimulation.SCARD;
  474. simulationReport.SCARDSEQ = productInfo.NowSimulation.SCARDSEQ;
  475. //���ӳ���
  476. simulationReport.SHELFNO = productInfo.NowSimulation.SHELFNO;
  477. //Carton number
  478. simulationReport.CARTONCODE = productInfo.NowSimulation.CARTONCODE;
  479. ICSBaseModel dataModel = new ICSBaseModel(this.DataProvider);
  480. ICSRES resource = productInfo.Resource;
  481. if (resource == null)
  482. {
  483. resource = (ICSRES)dataModel.GetResource(productInfo.NowSimulation.RESCODE);
  484. }
  485. // Changed end
  486. simulationReport.SEGCODE = resource.SEGCODE;
  487. ICSTP period = productInfo.TimePeriod;
  488. if (period == null)
  489. {
  490. period = (ICSTP)dataModel.GetTimePeriod(resource.SHIFTTYPEID, FormatHelper.TOTimeInt(simulationReport.MTIME));
  491. if (period == null)
  492. {
  493. throw new Exception("$OutOfPerid");
  494. }
  495. productInfo.TimePeriod = period;
  496. }
  497. DateTime dbDateTime;
  498. dbDateTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  499. productInfo.WorkDateTime = dbDateTime;
  500. DateTime dtWorkDateTime = dbDateTime;
  501. if (period.ISOVERDATE == FormatHelper.TRUE_STRING)
  502. {
  503. if (period.TPBTIME < period.TPETIME)
  504. {
  505. simulationReport.SHIFTDAY = FormatHelper.TODateInt(dtWorkDateTime.AddDays(-1));
  506. }
  507. else if (FormatHelper.TOTimeInt(productInfo.NowSimulation.MTIME) < period.TPBTIME)
  508. {
  509. simulationReport.SHIFTDAY = FormatHelper.TODateInt(dtWorkDateTime.AddDays(-1));
  510. }
  511. else
  512. {
  513. simulationReport.SHIFTDAY = FormatHelper.TODateInt(simulationReport.MTIME);
  514. }
  515. }
  516. else
  517. {
  518. simulationReport.SHIFTDAY = FormatHelper.TODateInt(dtWorkDateTime);
  519. }
  520. simulationReport.SHIFTTYPECODE = resource.SHIFTTYPECODE;
  521. simulationReport.SHIFTCODE = this.DataProvider.ICSSHIFT.SingleOrDefault(a=>a.ID == period.SHIFTID).SHIFTCODE;
  522. simulationReport.TPCODE = period.TPCODE;
  523. simulationReport.SSCODE = resource.SSCODE;
  524. simulationReport.MOSEQ = productInfo.NowSimulation.MOSEQ;
  525. simulationReport.MTIME = dbDateTime;
  526. simulationReport.MUSER = AppConfig.UserCode;
  527. simulationReport.MUSERName = AppConfig.UserName;
  528. simulationReport.WorkPoint = AppConfig.WorkPointCode;
  529. return simulationReport;
  530. }
  531. //��дOnWip ;��,ʱ��,����ģ��,�û���Ϣ ������ ProductInfo.NewSimulation
  532. public ICSONWIP FillOnWip(ProductInfo productInfo)
  533. {
  534. return FillOnWip(productInfo, null);
  535. }
  536. public ICSONWIP FillOnWip(ProductInfo productInfo, ActionEventArgs actionEventArgs)
  537. {
  538. ICSONWIP onwip = new ICSONWIP();
  539. onwip.ID = AppConfig.GetGuid();
  540. onwip.ACTION = productInfo.NowSimulation.LACTION;
  541. onwip.ACTIONRESULT = productInfo.NowSimulation.PRODUCTSTATUS;
  542. onwip.ITEMCODE = productInfo.NowSimulation.ITEMCODE;
  543. onwip.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
  544. onwip.MUSER = productInfo.NowSimulation.MUSER;
  545. onwip.MOCODE = productInfo.NowSimulation.MOCODE;
  546. onwip.MODELCODE = productInfo.NowSimulation.MODELCODE;
  547. onwip.NGTIMES = productInfo.NowSimulation.NGTIMES;
  548. onwip.OPCODE = productInfo.NowSimulation.OPCODE;
  549. if (actionEventArgs == null)
  550. {
  551. onwip.RESCODE = productInfo.NowSimulation.RESCODE;
  552. }
  553. else
  554. {
  555. onwip.RESCODE = actionEventArgs.ResourceCode;
  556. }
  557. onwip.ROUTECODE = productInfo.NowSimulation.ROUTECODE;
  558. onwip.RCARD = productInfo.NowSimulation.RCARD;
  559. onwip.RCARDSEQ = productInfo.NowSimulation.RCARDSEQ;
  560. onwip.SEGCODE = productInfo.NowSimulationReport.SEGCODE;
  561. onwip.SHIFTDAY = productInfo.NowSimulationReport.SHIFTDAY;
  562. onwip.SHIFTTYPECODE = productInfo.NowSimulationReport.SHIFTTYPECODE;
  563. onwip.SHIFTCODE = productInfo.NowSimulationReport.SHIFTCODE;
  564. onwip.TPCODE = productInfo.NowSimulationReport.TPCODE;
  565. onwip.SCARD = productInfo.NowSimulation.SCARD;
  566. onwip.SCARDSEQ = productInfo.NowSimulation.SCARDSEQ;
  567. onwip.SSCODE = productInfo.NowSimulationReport.SSCODE;
  568. onwip.TCARD = productInfo.NowSimulation.TCARD;
  569. onwip.TCARDSEQ = productInfo.NowSimulation.TCARDSEQ;
  570. // ���ӳ���
  571. onwip.SHELFNO = productInfo.NowSimulation.SHELFNO;
  572. // RMA
  573. onwip.RMABILLCODE = productInfo.NowSimulation.RMABILLCODE;
  574. onwip.EATTRIBUTE1 = productInfo.NowSimulation.EATTRIBUTE1;
  575. onwip.Processed = "0";
  576. onwip.MOSEQ = productInfo.NowSimulation.MOSEQ;
  577. onwip.MUSER = AppConfig.UserCode;
  578. onwip.MUSERName = AppConfig.UserName;
  579. onwip.WorkPoint = AppConfig.WorkPointCode;
  580. return onwip;
  581. }
  582. public Messages Action(ActionEventArgs actionEventArgs)
  583. {
  584. Messages messages = new Messages();
  585. // ȥ�������е������������ŵ������ķ�����
  586. try
  587. {
  588. IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(actionEventArgs.ActionType);
  589. messages.AddMessages(dataCollectModule.Execute(actionEventArgs));
  590. if (messages.IsSuccess())
  591. this.DataProvider.Transaction.Commit();
  592. else
  593. this.DataProvider.Transaction.Rollback();
  594. }
  595. catch (Exception e)
  596. {
  597. this.DataProvider.Transaction.Rollback();
  598. messages.Add(new Message(e));
  599. }
  600. finally
  601. {
  602. }
  603. return messages;
  604. }
  605. public Messages ActionWithTransaction(ActionEventArgs actionEventArgs)
  606. {
  607. Messages messages = new Messages();
  608. try
  609. {
  610. IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(actionEventArgs.ActionType);
  611. messages.AddMessages(dataCollectModule.Execute(actionEventArgs));
  612. }
  613. catch (Exception e)
  614. {
  615. messages.Add(new Message(e));
  616. }
  617. return messages;
  618. }
  619. // ���������ĺ���������һ������ActionCheckStatus
  620. public Messages Action(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
  621. {
  622. Messages messages = new Messages();
  623. //ȥ�������е������������ŵ������ķ�����
  624. try
  625. {
  626. IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(actionEventArgs.ActionType);
  627. // ������IActionWithStatus���ͣ���ִ�д�ActionCheckStatus�ķ���
  628. if (dataCollectModule is IActionWithStatus)
  629. {
  630. messages.AddMessages(((IActionWithStatus)dataCollectModule).Execute(actionEventArgs, actionCheckStatus));
  631. }
  632. else
  633. {
  634. messages.AddMessages(dataCollectModule.Execute(actionEventArgs));
  635. }
  636. }
  637. catch (Exception e)
  638. {
  639. messages.Add(new Message(e));
  640. }
  641. finally
  642. {
  643. }
  644. return messages;
  645. }
  646. public Messages ActionWithTransaction(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
  647. {
  648. Messages messages = new Messages();
  649. try
  650. {
  651. IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(actionEventArgs.ActionType);
  652. // ������IActionWithStatus���ͣ���ִ�д�ActionCheckStatus�ķ���
  653. if (dataCollectModule is IActionWithStatus)
  654. {
  655. messages.AddMessages(((IActionWithStatus)dataCollectModule).Execute(actionEventArgs, actionCheckStatus));
  656. }
  657. else
  658. {
  659. messages.AddMessages(dataCollectModule.Execute(actionEventArgs));
  660. }
  661. }
  662. catch (Exception e)
  663. {
  664. messages.Add(new Message(e));
  665. }
  666. return messages;
  667. }
  668. // Added end
  669. public Messages ActionWithTransaction(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus, object[] OPBOMDetail)
  670. {
  671. Messages messages = new Messages();
  672. try
  673. {
  674. IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(actionEventArgs.ActionType);
  675. // ������IActionWithStatus���ͣ���ִ�д�ActionCheckStatus�ķ���
  676. if (dataCollectModule is IActionWithStatus)
  677. {
  678. messages.AddMessages(((IActionWithStatusNew)dataCollectModule).Execute(actionEventArgs, actionCheckStatus, OPBOMDetail));
  679. }
  680. else
  681. {
  682. messages.AddMessages(dataCollectModule.Execute(actionEventArgs));
  683. }
  684. }
  685. catch (Exception e)
  686. {
  687. messages.Add(new Message(e));
  688. }
  689. return messages;
  690. }
  691. private class GoodData
  692. {
  693. public string CKGROUP;
  694. public string CKGROUPDESC;
  695. public string CKITEMCODE;
  696. public decimal USL;
  697. public decimal LSL;
  698. public string TESTINGVALUE;
  699. public string TESTINGRESULT;
  700. }
  701. }
  702. }