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.

114 lines
4.2 KiB

3 years ago
  1. using Aborlen.Model;
  2. using FrameWork.Log;
  3. using SqlSugar;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using WorkStationBase;
  10. namespace Aborlen.WorkStation
  11. {
  12. public partial class WorkStation11 : StationBase
  13. {
  14. public void PalletNum(string stationCode, object value, DateTime triggerTime)
  15. {
  16. try
  17. {
  18. PalletCode = Convert.ToInt32(value);
  19. LogHelper.WriteLog(stationCode + "到位托盘号" + PalletCode);
  20. if (PalletCode != 0)
  21. {
  22. //托盘到达,更新条码验证规则 查询产品型号
  23. //查询订单
  24. var deploydata = Deploy_Data.Query().Where(p => p.tuopan_id == PalletCode && p.process_state <4).OrderBy(p=>p.Id,OrderByType.Desc);
  25. // var aa = deploydata.First();
  26. if (deploydata.Count() > 0)
  27. {
  28. PresentOrder = ProductOrder.Query().Where(p => p.plan_id == deploydata.First().plan_id).First();
  29. //如果是不合格 也不打印条码 直接放行
  30. if ((deploydata.First().all_result == 2))
  31. {
  32. return;
  33. }
  34. else
  35. {
  36. //未经过OP120工位 默认未合格工件
  37. string _sql = $"update Deploy_Data set all_result =1 where Id={deploydata.First().Id}";
  38. SqlSugarAdo.ExecuteCommand(_sql);
  39. }
  40. }
  41. else
  42. {
  43. //无当前工件数据,默认为空托盘 不打印条码
  44. PresentOrder = ProductOrder.Query().OrderBy(p => p.id, OrderByType.Desc).First();
  45. return;
  46. }
  47. ViewInit();
  48. ProductTypeCode = Convert.ToInt32(PresentOrder.product_id);
  49. //创建条码Id
  50. ProductSerialInfoOperate(PalletCode, ProductTypeCode);
  51. //打印条码
  52. PrintOkLabel(ProductTypeCode, (int)ProductSerialId) ;
  53. //已存在,更新上线时间
  54. string sql = $" update Deploy_Data set process_state=2 where tuopan_id ='{Read(2180, triggerTime)}' and process_state<4 and plan_id='{PresentOrder.plan_id}'";
  55. SqlSugarAdo.ExecuteCommand(sql);
  56. //写入打印完成
  57. Write(1190,(byte)1);
  58. // View.ProductCode = deploydata.First().print_pid;
  59. View.PrintCode = deploydata.First().print_pid;
  60. View.ScanTime= DateTime.Now;
  61. SendMsg.SendMsgToStation(StationInfo.StationCode, "ProductCode", NgProductCode);
  62. }
  63. else
  64. {
  65. ProductCycleTime = ExecDateDiff(ArrivedTime, DateTime.Now);
  66. ArrivedTime = DateTime.Now;
  67. //托盘离开,清空界面
  68. ViewClear();
  69. //查询合格数量 更新到订单表
  70. int okcount= Deploy_Data.Query().Where(p => p.plan_id == PresentOrder.plan_id && p.all_result == 1).Count();
  71. int nOkcount = Deploy_Data.Query().Where(p => p.plan_id == PresentOrder.plan_id && p.all_result == 2).Count();
  72. SqlSugarAdo.ExecuteCommand($"update ProductOrder set ok_account ='{okcount}',nok_account ='{nOkcount}' where plan_id ={PresentOrder.plan_id}" );
  73. SendMsg.SendMsgToStation(StationInfo.StationCode, "OkNum", okcount);
  74. SendMsg.SendMsgToStation(StationInfo.StationCode, "NgProductCode", NgProductCode);
  75. SendMsg.SendMsgToStation(StationInfo.StationCode, "NgPalletCode", NgPalletCode);
  76. }
  77. }
  78. catch (Exception ex)
  79. {
  80. LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
  81. }
  82. }
  83. }
  84. }