电子药箱通讯服务端
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.

StorageSpacePortableLinkBLL.cs 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using RDH.Data.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml.Linq;
  8. namespace RDH.Data.BLL
  9. {
  10. public partial class StorageSpacePortableLinkBLL : BaseOrclBLL<StorageSpacePortableLink>
  11. {
  12. public StorageSpacePortableLinkBLL() : base()
  13. {
  14. AliasTableName = "spl";
  15. }
  16. #region Properties
  17. internal override String TABLE_NAME { get { return "STORAGE_SPACE_PORTABLE_LINK"; } }//TB_NAME
  18. internal override string ENTITY_NAME { get { return "StorageSpacePortableLink"; } }
  19. internal override String KEY_COLUMN { get { return "KEY"; } }//KEY_COLUMN
  20. #endregion
  21. #region Override Methods
  22. internal override void InitMaps()
  23. {
  24. ColumnPropMaps.Add("KEY", "Key");
  25. ColumnPropMaps.Add("STORAGE_SPACE_KEY", "StorageSpaceKey");
  26. ColumnPropMaps.Add("PORTABLE_STORAGE_KEY", "PortableStorageKey");
  27. ColumnPropMaps.Add("MAX_QUANTITY", "MaxQuantity");
  28. ColumnPropMaps.Add("ALART_QUANTITY", "AlartQuantity");
  29. ColumnPropMaps.Add("CURRENT_QUANTITY", "CurrentQuantity");
  30. ColumnPropMaps.Add("CREATE_BY", "CreateBy");
  31. ColumnPropMaps.Add("CREATE_TIME", "CreateTime");
  32. ColumnPropMaps.Add("FLAG", "Flag");
  33. ColumnPropMaps.Add("CLIENT_TIME", "ClientTime");
  34. ColumnPropMaps.Add("SERVER_TIME", "ServerTime");
  35. ColumnPropMaps.Add("EXT01", "Ext01");
  36. ColumnPropMaps.Add("EXT02", "Ext02");
  37. ColumnPropMaps.Add("EXT03", "Ext03");
  38. ColumnPropMaps.Add("EXT04", "Ext04");
  39. ColumnPropMaps.Add("EXT05", "Ext05");
  40. ColumnPropMaps.Add("EXT06", "Ext06");
  41. ColumnPropMaps.Add("EXT07", "Ext07");
  42. ColumnPropMaps.Add("EXT08", "Ext08");
  43. ColumnPropMaps.Add("EXT09", "Ext09");
  44. ColumnPropMaps.Add("EXT10", "Ext10");//COLUMN_MAPS
  45. }
  46. internal override object GetParam(StorageSpacePortableLink storagespaceitem)
  47. {
  48. return new
  49. {
  50. Key = storagespaceitem.Key,
  51. StorageSpaceKey = storagespaceitem.StorageSpaceKey,
  52. PortableStorageKey = storagespaceitem.PortableStorageKey,
  53. MaxQuantity = storagespaceitem.MaxQuantity,
  54. AlartQuantity = storagespaceitem.AlartQuantity,
  55. CurrentQuantity = storagespaceitem.CurrentQuantity,
  56. CreateBy = storagespaceitem.CreateBy,
  57. CreateTime = storagespaceitem.CreateTime,
  58. IsAllowMultiLot = storagespaceitem.IsAllowMultiLot,
  59. DeviceKey = storagespaceitem.DeviceKey,
  60. Flag = storagespaceitem.Flag,
  61. ClientTime = storagespaceitem.ClientTime,
  62. ServerTime = storagespaceitem.ServerTime,
  63. Ext01 = storagespaceitem.Ext01,
  64. Ext02 = storagespaceitem.Ext02,
  65. Ext03 = storagespaceitem.Ext03,
  66. Ext04 = storagespaceitem.Ext04,
  67. Ext05 = storagespaceitem.Ext05,
  68. Ext06 = storagespaceitem.Ext06,
  69. Ext07 = storagespaceitem.Ext07,
  70. Ext08 = storagespaceitem.Ext08,
  71. Ext09 = storagespaceitem.Ext09,
  72. Ext10 = storagespaceitem.Ext10,
  73. };
  74. }
  75. #endregion
  76. public IEnumerable<StorageSpacePortableLink> ListStorageSpacePortableLink(DispensingDevice device)
  77. {
  78. StorageSpaceBLL bllStorage = new StorageSpaceBLL();
  79. StringBuilder sqlBuilder = new StringBuilder();
  80. sqlBuilder.Append("SELECT ");
  81. foreach (KeyValuePair<String, String> pair in this.ColumnPropMaps)
  82. {
  83. sqlBuilder.AppendFormat("{0}.{1} {2},", this.TABLE_NAME, pair.Key, pair.Value);
  84. }
  85. sqlBuilder.Append("'' spiltor1,");
  86. foreach (KeyValuePair<String, String> pair in bllStorage.ColumnPropMaps)
  87. {
  88. sqlBuilder.AppendFormat("{0}.{1} {2},", bllStorage.TABLE_NAME, pair.Key, pair.Value);
  89. }
  90. sqlBuilder.Remove(sqlBuilder.Length - 1, 1);
  91. sqlBuilder.AppendFormat(" FROM {0}"
  92. + " INNER JOIN {1} ON {1}.KEY={0}.STORAGE_SPACE_KEY"
  93. + " WHERE {1}.DEVICE_KEY=:deviceKey",
  94. this.TABLE_NAME, bllStorage.TABLE_NAME);
  95. IEnumerable<StorageSpacePortableLink> list = SqlMapper.Query<
  96. StorageSpacePortableLink,
  97. StorageSpace,
  98. StorageSpacePortableLink>(ConnectionFactory.Current.GetSessionConnection(),
  99. sqlBuilder.ToString(),
  100. (link, s) =>
  101. {
  102. link.StorageSpace = s;
  103. return link;
  104. },
  105. new { deviceKey = device.Key },
  106. splitOn: "spiltor1");
  107. return list;
  108. }
  109. public StorageSpacePortableLink? GetByStorageCode(DispensingDevice? device, String code)
  110. {
  111. SqlBuilder sqlBuilder = new SqlBuilder(this);
  112. PortableStorageBLL storageSpaceBLL = new PortableStorageBLL();
  113. TableJoinInfo storageTable = new TableJoinInfo
  114. {
  115. LeftDal = this,
  116. LeftColumnName = "PORTABLE_STORAGE_KEY",
  117. RightDal = storageSpaceBLL,
  118. RightColumnName = "KEY",
  119. JoinType = TableJoinTypes.Inner,
  120. };
  121. sqlBuilder.AppendSelectionTable(storageTable);
  122. if (device != null)
  123. {
  124. sqlBuilder.AppendWherePhrases($"{storageSpaceBLL.AliasTableName}.DEVICE_KEY=:deviceKey");
  125. }
  126. sqlBuilder.AppendWherePhrases($"NVL({storageSpaceBLL.AliasTableName}.CODE,'0')=:storaceCode");
  127. return SqlMapper.Query<StorageSpacePortableLink, PortableStorage, StorageSpacePortableLink>(
  128. ConnectionFactory.Current.GetSessionConnection(),
  129. sqlBuilder.ToString(),
  130. (l, s) =>
  131. {
  132. l.PortableStorage = s;
  133. return l;
  134. },
  135. new
  136. {
  137. deviceKey = device?.Key,
  138. storaceCode = code,
  139. },
  140. splitOn: sqlBuilder.GetSpiltors())
  141. .FirstOrDefault();
  142. }
  143. }
  144. }