DeviceExtentions.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using WCS.Core.DbHelper;
  2. using WCS.Entity;
  3. using WCS.Entity.Protocol;
  4. using WCS.Entity.Protocol.Station;
  5. namespace WCS.Service
  6. {
  7. public static class DeviceExtentions
  8. {
  9. }
  10. public static class TaskExtentions
  11. {
  12. public static string AddrCurrent(this WCS_TASK source, Db db)
  13. {
  14. var q1 = db.Default.Queryable<WCS_Station520>().Where(v => v.ISLAST && v.Tasknum == source.ID).Select(v => new TemporaryModel
  15. {
  16. TYPE = 1,
  17. CODE = v.DEVICE.CODE
  18. });
  19. var q2 = db.Default.Queryable<WCS_RGV521>().Where(v => v.ISLAST && (v.TaskID_1 == source.ID || v.TaskID_2 == source.ID)).Select(v => new TemporaryModel
  20. {
  21. TYPE = 2,
  22. CODE = v.DEVICE.CODE
  23. });
  24. var q = db.Default.UnionAll(q1, q2);
  25. var res = q.OrderBy(v => v.TYPE).First();
  26. return res == null ? "" : res.CODE;
  27. }
  28. }
  29. public class TemporaryModel
  30. {
  31. public int TYPE { get; set; }
  32. public string CODE { get; set; }
  33. }
  34. }