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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 OperationTakeItemBLL : BaseOrclSnapshotBLL<OperationTakeItem>
  11. {
  12. public OperationTakeItemBLL() : base()
  13. {
  14. AliasTableName = "oti";
  15. }
  16. internal override String TABLE_NAME { get { return "OPERATION_TAKE_ITEM"; } }//TB_NAME
  17. internal override string ENTITY_NAME { get { return "OperationTakeItem"; } }
  18. internal override String KEY_COLUMN { get { return "SNAPSHOT_KEY"; } }//KEY_COLUMN
  19. internal override string SNAPSHOT_BASE { get { return "OPERATION_TAKE_ITEM_BASE"; } }
  20. internal override void InitMaps()
  21. {
  22. ColumnPropMaps.Add("SNAPSHOT_KEY", "SnapshotKey");
  23. ColumnPropMaps.Add("KEY", "Key");
  24. ColumnPropMaps.Add("TAKE_BAG_KEY", "TakeBagKey");
  25. ColumnPropMaps.Add("ITEM_KEY", "ItemKey");
  26. ColumnPropMaps.Add("CREATE_BY", "CreateBy");
  27. ColumnPropMaps.Add("CREATE_TIME", "CreateTime");
  28. ColumnPropMaps.Add("TAKE_QUANTITY", "TakeQuantity");
  29. ColumnPropMaps.Add("RETURN_QUANTITY", "ReturnQuantity");
  30. ColumnPropMaps.Add("CHECK_QUANTITY", "CheckQuantity");
  31. ColumnPropMaps.Add("TRANSFER_QUANTITY", "TransferQuantity");
  32. ColumnPropMaps.Add("ABOLISH_QUANTITY", "AbolishQuantity");
  33. ColumnPropMaps.Add("RETURNSTORE_QUANTITY", "ReturnstoreQuantity");
  34. ColumnPropMaps.Add("IS_OUTSID", "IsOutsid");
  35. ColumnPropMaps.Add("REPLACE_BY", "ReplaceBy");
  36. ColumnPropMaps.Add("STATUS", "Status");
  37. ColumnPropMaps.Add("DEVICE_KEY", "DeviceKey");
  38. ColumnPropMaps.Add("FLAG", "Flag");
  39. ColumnPropMaps.Add("CLIENT_TIME", "ClientTime");
  40. ColumnPropMaps.Add("SERVER_TIME", "ServerTime");
  41. ColumnPropMaps.Add("EXT01", "Ext01");
  42. ColumnPropMaps.Add("EXT02", "Ext02");
  43. ColumnPropMaps.Add("EXT03", "Ext03");
  44. ColumnPropMaps.Add("EXT04", "Ext04");
  45. ColumnPropMaps.Add("EXT05", "Ext05");
  46. ColumnPropMaps.Add("EXT06", "Ext06");
  47. ColumnPropMaps.Add("EXT07", "Ext07");
  48. ColumnPropMaps.Add("EXT08", "Ext08");
  49. ColumnPropMaps.Add("EXT09", "Ext09");
  50. ColumnPropMaps.Add("EXT10", "Ext10");
  51. ColumnPropMaps.Add("DISPOSE_QUANTITY", "DisposeQuantity");
  52. ColumnPropMaps.Add("WITNESS_USER", "WitnessUser");//COLUMN_MAPS
  53. }
  54. internal override object GetParam(OperationTakeItem operationtakeitem)
  55. {
  56. return new
  57. {
  58. SnapshotKey = operationtakeitem.SnapshotKey,
  59. Key = operationtakeitem.Key,
  60. TakeBagKey = operationtakeitem.TakeBagKey,
  61. ItemKey = operationtakeitem.ItemKey,
  62. CreateBy = operationtakeitem.CreateBy,
  63. CreateTime = operationtakeitem.CreateTime,
  64. TakeQuantity = operationtakeitem.TakeQuantity,
  65. ReturnQuantity = operationtakeitem.ReturnQuantity,
  66. CheckQuantity = operationtakeitem.CheckQuantity,
  67. TransferQuantity = operationtakeitem.TransferQuantity,
  68. AbolishQuantity = operationtakeitem.AbolishQuantity,
  69. ReturnstoreQuantity = operationtakeitem.ReturnstoreQuantity,
  70. IsOutsid = operationtakeitem.IsOutsid,
  71. ReplaceBy = operationtakeitem.ReplaceBy,
  72. Status = operationtakeitem.Status,
  73. DeviceKey = operationtakeitem.DeviceKey,
  74. Flag = operationtakeitem.Flag,
  75. ClientTime = operationtakeitem.ClientTime,
  76. ServerTime = operationtakeitem.ServerTime,
  77. Ext01 = operationtakeitem.Ext01,
  78. Ext02 = operationtakeitem.Ext02,
  79. Ext03 = operationtakeitem.Ext03,
  80. Ext04 = operationtakeitem.Ext04,
  81. Ext05 = operationtakeitem.Ext05,
  82. Ext06 = operationtakeitem.Ext06,
  83. Ext07 = operationtakeitem.Ext07,
  84. Ext08 = operationtakeitem.Ext08,
  85. Ext09 = operationtakeitem.Ext09,
  86. Ext10 = operationtakeitem.Ext10,
  87. DisposeQuantity = operationtakeitem.DisposeQuantity,
  88. WitnessUser = operationtakeitem.WitnessUser, //Params
  89. };
  90. }
  91. public IEnumerable<OperationTakeItem> ListTakeItemsByTakeBag(OperationTakeItemBag bag)
  92. {
  93. SqlBuilder sqlBuilder = new SqlBuilder(this);
  94. ItemBLL itemBLL = new ItemBLL();
  95. TableJoinInfo itemTable = new TableJoinInfo
  96. {
  97. LeftDal = this,
  98. LeftColumnName = "ITEM_KEY",
  99. RightDal = itemBLL,
  100. RightColumnName = "KEY",
  101. JoinType = TableJoinTypes.Inner
  102. };
  103. sqlBuilder.AppendSelectionTable(itemTable);
  104. sqlBuilder.AppendWherePhrases($"{this.AliasTableName}.TAKE_BAG_KEY=:bagKey");
  105. IEnumerable<OperationTakeItem> rlt = SqlMapper.Query<OperationTakeItem, Item, OperationTakeItem>(
  106. ConnectionFactory.Current.GetSessionConnection(),
  107. sqlBuilder.ToString(),
  108. (oti, i) =>
  109. {
  110. oti.Item = i;
  111. return oti;
  112. },
  113. new
  114. {
  115. bagKey = bag.Key
  116. },
  117. splitOn: sqlBuilder.GetSpiltors());
  118. if (rlt != null)
  119. {
  120. return rlt.GroupBy(x => x.ItemKey)
  121. .Select(x => new OperationTakeItem
  122. {
  123. Item = x.First().Item,
  124. TakeBagKey = x.First().TakeBagKey,
  125. TakeQuantity = x.Sum(i => i.TakeQuantity.GetValueOrDefault())
  126. });
  127. }
  128. return null;
  129. }
  130. public IEnumerable<OperationTakeItem> ListTakeItemLotsByTakeBag(OperationTakeItemBag bag)
  131. {
  132. SqlBuilder sqlBuilder = new SqlBuilder(this);
  133. ItemBLL itemBLL = new ItemBLL();
  134. TableJoinInfo itemTable = new TableJoinInfo
  135. {
  136. LeftDal = this,
  137. LeftColumnName = "ITEM_KEY",
  138. RightDal = itemBLL,
  139. RightColumnName = "KEY",
  140. JoinType = TableJoinTypes.Inner
  141. };
  142. sqlBuilder.AppendSelectionTable(itemTable);
  143. ItemLotBLL itemLotBLL = new ItemLotBLL();
  144. TableJoinInfo itemLotTable = new TableJoinInfo
  145. {
  146. LeftDal = this,
  147. LeftColumnName = "EXT01",
  148. RightDal = itemLotBLL,
  149. RightColumnName = "KEY",
  150. JoinType = TableJoinTypes.Inner
  151. };
  152. sqlBuilder.AppendSelectionTable(itemLotTable);
  153. sqlBuilder.AppendWherePhrases($"{this.AliasTableName}.TAKE_BAG_KEY=:bagKey");
  154. IEnumerable<OperationTakeItem> rlt = SqlMapper.Query<OperationTakeItem, Item, ItemLot, OperationTakeItem>(
  155. ConnectionFactory.Current.GetSessionConnection(),
  156. sqlBuilder.ToString(),
  157. (oti, i, il) =>
  158. {
  159. oti.Item = i;
  160. oti.ItemLot = il;
  161. return oti;
  162. },
  163. new
  164. {
  165. bagKey = bag.Key
  166. },
  167. splitOn: sqlBuilder.GetSpiltors());
  168. return rlt;
  169. }
  170. }
  171. }