锐腾搅拌上料功能
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.

75 lines
3.3 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ICSSoft.Frame.Data.Entity;
  6. using ICSSoft.Base.Config.AppConfig;
  7. namespace ICSSoft.Frame.Data.DAL
  8. {
  9. public class ICSLOTONWIPDAL
  10. {
  11. public static void End(bool LotNoEnd, ICSLOTONWIP wip, string dsconn)
  12. {
  13. FramDataContext db = new FramDataContext(dsconn);
  14. db.Connection.Open();
  15. db.Transaction = db.Connection.BeginTransaction();
  16. try
  17. {
  18. var user = db.Sys_User.SingleOrDefault(a => a.UserCode == wip.UserCodeEnd && a.WorkPointCode == wip.WorkPoint);
  19. if (user == null)
  20. {
  21. throw new Exception("人员不存在!" + wip.UserCodeEnd);
  22. }
  23. //工序表.
  24. var lineOnwip = db.ICSLOTONWIP.SingleOrDefault(a => a.LOTNO == wip.LOTNO && a.LOTSEQ == wip.LOTSEQ && a.ROUTECODE == wip.ROUTECODE && a.OPCODE == wip.OPCODE && a.WorkPoint == wip.WorkPoint);
  25. if (lineOnwip == null)
  26. {
  27. throw new Exception("跟踪单-工序表数据获取错误,[结束工序]失败!");
  28. }
  29. lineOnwip.ACTIONRESULT = wip.ACTIONRESULT;
  30. lineOnwip.EndTime = wip.EndTime;
  31. lineOnwip.UserCodeEnd = wip.UserCodeEnd;
  32. db.SubmitChanges();
  33. //跟踪单表.保存最新一笔工序状态
  34. //(注意)并行工序:不管跟踪单表原来存的是哪道工序,状态如何,只要onwip表变更就更新跟踪单表[即 多人+并行工序时,跟踪单表中的工序及状态永远存的是操作员最新上传的数据,并不是并行工序中序号最大的那个].
  35. var lineSim = db.ICSLOTSIMULATION.SingleOrDefault(a => a.LOTNO == wip.LOTNO && a.LOTSEQ == wip.LOTSEQ && a.WorkPoint == wip.WorkPoint);
  36. lineSim.OPSEQ = wip.OPSEQ;
  37. lineSim.OPCODE = wip.OPCODE;
  38. //对于并行组,如果出现过NG,则不能再更改.除此以外可以直接赋值当前工序结果
  39. if (lineOnwip.EATTRIBUTE1 != "并行" || lineSim.OPListAttr != "并行" || lineSim.LACTION == "GOOD")
  40. {
  41. lineSim.LACTION = lineOnwip.ACTION;
  42. lineSim.PRODUCTSTATUS = lineOnwip.ACTION;
  43. lineSim.ACTIONLIST = lineOnwip.ACTION;
  44. }
  45. lineSim.CollectStatus = wip.ACTIONRESULT;
  46. lineSim.MTIME = DateTime.Now;
  47. lineSim.MUSER = user.UserCode;
  48. lineSim.MUSERName = user.UserName;
  49. if (lineSim.GOODQTY > lineOnwip.GOODQTY)
  50. {
  51. lineSim.GOODQTY = lineOnwip.GOODQTY;
  52. }
  53. if (LotNoEnd)
  54. {
  55. //结束跟踪单.变更状态,时间
  56. lineSim.ISCOM = "1";
  57. lineSim.EndTime = lineSim.MTIME;
  58. lineSim.EATTRIBUTE1 = "最后一道工序完成";//跟踪单结束原因,还有可能分批将数量分没了
  59. }
  60. db.SubmitChanges();
  61. db.Transaction.Commit();
  62. }
  63. catch (Exception ex)
  64. {
  65. db.Transaction.Rollback();
  66. throw ex;
  67. }
  68. }
  69. }
  70. }