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.

81 lines
2.7 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;
  9. using System.Threading.Tasks;
  10. using WorkStationBase;
  11. namespace Aborlen.WorkStation
  12. {
  13. public partial class WorkStation105 : StationBase
  14. {
  15. public void PalletNum(string stationCode, object value, DateTime triggerTime)
  16. {
  17. try
  18. {
  19. LogHelper.WriteLog(stationCode + "到位托盘号" + Convert.ToInt32(value));
  20. if (Convert.ToByte(value) != 0)
  21. {
  22. //托盘到达,更新条码验证规则 查询产品型号
  23. //查询订单
  24. var deploydata = Deploy_Data.Query().Where(p => p.tuopan_id == Convert.ToInt32(value) && p.process_state == 1).OrderBy(p => p.Id, SqlSugar.OrderByType.Desc);
  25. if (deploydata.Count() > 0)
  26. {
  27. PresentOrder = ProductOrder.Query().Where(p => p.plan_id == deploydata.First().plan_id).First();
  28. }
  29. else
  30. {
  31. PresentOrder = ProductOrder.Query().OrderBy(p => p.id, OrderByType.Desc).First();
  32. }
  33. ProductTypeCode = Convert.ToInt32(PresentOrder.product_id);
  34. string sql = $"update Deploy_Data set ";
  35. //string _AllResult = "0";
  36. //foreach (var qualityTag in QualityOpcTagInfos)
  37. //{
  38. // int readTime = 200;
  39. // //此处托盘到位时,工件总装结果可能未更新(增加读取速度再测试)
  40. // while (_AllResult == "0")
  41. // {
  42. // _AllResult = Read(qualityTag.TagId, triggerTime).ToString();
  43. // if (readTime == 0) break;
  44. // Thread.Sleep(50);
  45. // readTime--;
  46. // }
  47. // sql = sql + $" {qualityTag.ColName}='{ Read(qualityTag.TagId, triggerTime).ToString() }' ,";
  48. //}
  49. //sql = sql.Remove(sql.Length - 1, 1);
  50. sql = sql + $"all_time='{DateTime.Now}' where tuopan_id='{Read(2180, triggerTime)}'and process_state=1 and plan_id='{PresentOrder.plan_id}'";
  51. SqlSugarAdo.ExecuteCommand(sql);
  52. //回写保存完成
  53. Write(1120, (byte)1);
  54. }
  55. }
  56. catch (Exception ex)
  57. {
  58. LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
  59. }
  60. }
  61. }
  62. }