BillInvflowHistoryService.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using wms.sqlsugar.model.sx;
  8. using WMS.BZModels;
  9. using WMS.BZModels.Dto.SX.BillInvflowHistoryDtos;
  10. using WMS.BZSqlSugar;
  11. using WMS.Info;
  12. namespace WMS.BZServices.SX
  13. {
  14. public class BillInvflowHistoryService
  15. {
  16. private readonly Repository<BillInvflowHistory> _billInvflowHistoryRepository;
  17. public BillInvflowHistoryService(Repository<BillInvflowHistory> billInvflowHistoryRepository)
  18. {
  19. _billInvflowHistoryRepository = billInvflowHistoryRepository;
  20. }
  21. public PagedInfo<BillInvflowHistoryDto> GetPageList(Pagination pagination, BillInvflowHistoryQueryDto billInvflowHistoryQueryDto)
  22. {
  23. ISugarQueryable<BillInvflowHistoryDto> sugarQueryable = GetQueryable(billInvflowHistoryQueryDto);
  24. var list = sugarQueryable.ToPage(pagination);
  25. return list;
  26. }
  27. public IList<BillInvflowHistoryDto> GetList(BillInvflowHistoryQueryDto billInvflowHistoryQueryDto)
  28. {
  29. ISugarQueryable<BillInvflowHistoryDto> sugarQueryable = GetQueryable(billInvflowHistoryQueryDto);
  30. var list = sugarQueryable.ToList();
  31. return list;
  32. }
  33. private ISugarQueryable<BillInvflowHistoryDto> GetQueryable(BillInvflowHistoryQueryDto billInvflowHistoryQueryDto)
  34. {
  35. var predicate = Expressionable.Create<BillInvflowHistory, BaseWarehouse>();
  36. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.KeyWord), (billInvflowHistory, warehouse) => billInvflowHistory.RFIDBarCode.Contains(billInvflowHistoryQueryDto.KeyWord) || billInvflowHistory.ContGrpBarCode.Contains(billInvflowHistoryQueryDto.KeyWord) || billInvflowHistory.MatCode.Contains(billInvflowHistoryQueryDto.KeyWord) || billInvflowHistory.MatName.Contains(billInvflowHistoryQueryDto.KeyWord) || billInvflowHistory.InvBarCode.Contains(billInvflowHistoryQueryDto.KeyWord));
  37. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.Id), (billInvflowHistory, warehouse) => billInvflowHistory.Id.ToString().Contains(billInvflowHistoryQueryDto.Id));
  38. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.WarehouseId), (billInvflowHistory, warehouse) => billInvflowHistory.WarehouseId.ToString().Contains(billInvflowHistoryQueryDto.WarehouseId));
  39. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.ContGrpId), (billInvflowHistory, warehouse) => billInvflowHistory.ContGrpId.ToString().Contains(billInvflowHistoryQueryDto.ContGrpId));
  40. //predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.EquContGrpId), (billInvflowHistory, warehouse) => billInvflowHistory.ContGrpId.ToString().Equals(billInvflowHistoryQueryDto.EquContGrpId));
  41. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.MatCode), (billInvflowHistory, warehouse) => billInvflowHistory.MatCode.Contains(billInvflowHistoryQueryDto.MatCode));
  42. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.MatName), (billInvflowHistory, warehouse) => billInvflowHistory.MatName.Contains(billInvflowHistoryQueryDto.MatName));
  43. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.RFIDBarCode), (billInvflowHistory, warehouse) => billInvflowHistory.RFIDBarCode.Contains(billInvflowHistoryQueryDto.RFIDBarCode));
  44. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.InvBarCode), (billInvflowHistory, warehouse) => billInvflowHistory.InvBarCode.Contains(billInvflowHistoryQueryDto.InvBarCode));
  45. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.PutRow), (billInvflowHistory, warehouse) => billInvflowHistory.PutRow.Equals(billInvflowHistoryQueryDto.PutRow));
  46. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.PutCol), (billInvflowHistory, warehouse) => billInvflowHistory.PutCol.Equals(billInvflowHistoryQueryDto.PutCol));
  47. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.PutLayer), (billInvflowHistory, warehouse) => billInvflowHistory.PutLayer.Equals(billInvflowHistoryQueryDto.PutLayer));
  48. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.Grade), (billInvflowHistory, warehouse) => billInvflowHistory.Grade.Contains(billInvflowHistoryQueryDto.Grade));
  49. predicate = predicate.AndIF(billInvflowHistoryQueryDto != null && billInvflowHistoryQueryDto.OneInTimeBegin.HasValue, (billInvflowHistory, warehouse) => billInvflowHistory.OneInTime >= billInvflowHistoryQueryDto.OneInTimeBegin);
  50. predicate = predicate.AndIF(billInvflowHistoryQueryDto != null && billInvflowHistoryQueryDto.OneInTimeEnd.HasValue, (billInvflowHistory, warehouse) => billInvflowHistory.OneInTime <= billInvflowHistoryQueryDto.OneInTimeEnd);
  51. predicate = predicate.AndIF(billInvflowHistoryQueryDto != null && billInvflowHistoryQueryDto.ProductTimeBegin.HasValue, (billInvflowHistory, warehouse) => billInvflowHistory.ProductTime >= billInvflowHistoryQueryDto.ProductTimeBegin);
  52. predicate = predicate.AndIF(billInvflowHistoryQueryDto != null && billInvflowHistoryQueryDto.ProductTimeEnd.HasValue, (billInvflowHistory, warehouse) => billInvflowHistory.ProductTime <= billInvflowHistoryQueryDto.ProductTimeEnd);
  53. //predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.Tunnel), (billInvflowHistory, warehouse) => warecell.Tunnel.Equals(billInvflowHistoryQueryDto.Tunnel));
  54. //predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.Code), (billInvflowHistory, warehouse) => warecell.Code.Contains(billInvflowHistoryQueryDto.Code));
  55. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsSurplus), (billInvflowHistory, warehouse) => billInvflowHistory.IsSurplus.Equals(billInvflowHistoryQueryDto.IsSurplus));
  56. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsRework), (billInvflowHistory, warehouse) => billInvflowHistory.IsRework.Equals(billInvflowHistoryQueryDto.IsRework));
  57. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsFail), (billInvflowHistory, warehouse) => billInvflowHistory.IsFail.Equals(billInvflowHistoryQueryDto.IsFail));
  58. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsFast), (billInvflowHistory, warehouse) => billInvflowHistory.IsFast.Equals(billInvflowHistoryQueryDto.IsFast));
  59. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsBack), (billInvflowHistory, warehouse) => billInvflowHistory.IsBack.Equals(billInvflowHistoryQueryDto.IsBack));
  60. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsBlack), (billInvflowHistory, warehouse) => billInvflowHistory.IsBlack.Equals(billInvflowHistoryQueryDto.IsBlack));
  61. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsControlpanel), (billInvflowHistory, warehouse) => billInvflowHistory.IsControlpanel.Equals(billInvflowHistoryQueryDto.IsControlpanel));
  62. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsTorsChk), (billInvflowHistory, warehouse) => billInvflowHistory.IsTorsChk.Equals(billInvflowHistoryQueryDto.IsTorsChk));
  63. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsCore), (billInvflowHistory, warehouse) => billInvflowHistory.IsCore.Equals(billInvflowHistoryQueryDto.IsCore));
  64. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.WbGroupCode), (billInvflowHistory, warehouse) => billInvflowHistory.WbGroupCode.Contains(billInvflowHistoryQueryDto.WbGroupCode));
  65. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.SolderCount), (billInvflowHistory, warehouse) => billInvflowHistory.SolderCount.ToString().Contains(billInvflowHistoryQueryDto.SolderCount));
  66. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.HoldTime), (billInvflowHistory, warehouse) => billInvflowHistory.HoldTime.ToString().Contains(billInvflowHistoryQueryDto.HoldTime));
  67. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.Wind), (billInvflowHistory, warehouse) => billInvflowHistory.Wind.ToString().Contains(billInvflowHistoryQueryDto.Wind));
  68. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.TorsChkQty), (billInvflowHistory, warehouse) => billInvflowHistory.TorsChkQty.Equals(billInvflowHistoryQueryDto.TorsChkQty));
  69. //if (!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsTimeOut) && billInvflowHistoryQueryDto?.IsTimeOut == "1")
  70. //{
  71. // predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.IsTimeOut), (billInvflowHistory, warehouse) => (DateTime.Now - billInvflowHistory.ProductTime).TotalHours >= 72 && !billInvflowHistory.InDocsNo.ToLower().Contains("cha"));
  72. //}
  73. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.ExecStateCode), (billInvflowHistory, warehouse) => billInvflowHistory.ExecStateCode.Equals(billInvflowHistoryQueryDto.ExecStateCode));
  74. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.ContGrpType), (billInvflowHistory, warehouse) => billInvflowHistory.ContGrpType.Equals(billInvflowHistoryQueryDto.ContGrpType));
  75. if (!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.InvStateCode))
  76. {
  77. var enums = (InvState)Enum.ToObject(typeof(InvState), Convert.ToInt32(billInvflowHistoryQueryDto?.InvStateCode));
  78. predicate = predicate.AndIF(!string.IsNullOrEmpty(billInvflowHistoryQueryDto?.InvStateCode), (billInvflowHistory, warehouse) => billInvflowHistory.InvStateCode.Equals(enums.ToString()));
  79. }
  80. var sugarQueryable = _billInvflowHistoryRepository.Context.Queryable<BillInvflowHistory, BaseWarehouse>((billInvflowHistory, warehouse) => new object[] {
  81. JoinType.Left, billInvflowHistory.WarehouseId==warehouse.Id}).Where(predicate.ToExpression())
  82. .Select((billInvflowHistory, warehouse) => new BillInvflowHistoryDto
  83. {
  84. Id = billInvflowHistory.Id.ToString(),
  85. WarehouseId = billInvflowHistory.WarehouseId.ToString(),
  86. WarehouseName = warehouse.Name,
  87. ContGrpId = billInvflowHistory.ContGrpId.ToString(),
  88. ContGrpBarCode = billInvflowHistory.ContGrpBarCode,
  89. ContGrpType = (int)billInvflowHistory.ContGrpType,
  90. BoxBarCode = billInvflowHistory.BoxBarCode,
  91. BomDocsNo = billInvflowHistory.BomDocsNo,
  92. BomMatId = billInvflowHistory.BomMatId.ToString(),
  93. BomMatCode = billInvflowHistory.BomMatCode,
  94. BomMatName = billInvflowHistory.BomMatName,
  95. BomSetId = billInvflowHistory.BomSetId.ToString(),
  96. ExecStateCode = billInvflowHistory.ExecStateCode,
  97. InvStateCode = billInvflowHistory.InvStateCode,
  98. ExecDocsNo = billInvflowHistory.ExecDocsNo,
  99. ExecDocsRowNo = billInvflowHistory.ExecDocsRowNo,
  100. ExecDocsTypeCode = billInvflowHistory.ExecDocsTypeCode,
  101. InvInOut = (int)billInvflowHistory.InvInOut,
  102. ExecWho = billInvflowHistory.ExecWho,
  103. ExecTime = billInvflowHistory.ExecTime,
  104. PutRow = billInvflowHistory.PutRow,
  105. PutCol = billInvflowHistory.PutCol,
  106. PutLayer = billInvflowHistory.PutLayer,
  107. InvBarCode = billInvflowHistory.InvBarCode,
  108. InDocsNo = billInvflowHistory.InDocsNo,
  109. InDocsRowNo = billInvflowHistory.InDocsRowNo,
  110. SuppCode = billInvflowHistory.SuppCode,
  111. SuppName = billInvflowHistory.SuppName,
  112. CustCode = billInvflowHistory.CustCode,
  113. CustName = billInvflowHistory.CustName,
  114. MatId = billInvflowHistory.MatId.ToString(),
  115. MatCode = billInvflowHistory.MatCode,
  116. MatName = billInvflowHistory.MatName,
  117. TolWQty = billInvflowHistory.TolWQty,
  118. NetWQty = billInvflowHistory.NetWQty,
  119. TareWQty = billInvflowHistory.TareWQty,
  120. LengthQty = billInvflowHistory.LengthQty,
  121. CaQty = billInvflowHistory.CaQty,
  122. SolderQty = billInvflowHistory.SolderQty,
  123. ContUsageQty = billInvflowHistory.ContUsageQty,
  124. BatchNo = billInvflowHistory.BatchNo,
  125. ProductTime = billInvflowHistory.ProductTime,
  126. OneInTime = billInvflowHistory.OneInTime,
  127. RodBarCode = billInvflowHistory.RodBarCode,
  128. HWBarCode = billInvflowHistory.HWBarCode,
  129. RFIDBarCode = billInvflowHistory.RFIDBarCode,
  130. CLBarCode = billInvflowHistory.CLBarCode,
  131. HWTypeCode = billInvflowHistory.HWTypeCode,
  132. BoilerNo = billInvflowHistory.BoilerNo,
  133. PackNo = billInvflowHistory.PackNo,
  134. BrandNo = billInvflowHistory.BrandNo,
  135. ExecStd = billInvflowHistory.ExecStd,
  136. LicenceCode = billInvflowHistory.LicenceCode,
  137. IsSurplus = billInvflowHistory.IsSurplus,
  138. IsRework = billInvflowHistory.IsRework,
  139. IsBlack = billInvflowHistory.IsBlack,
  140. IsCore = billInvflowHistory.IsCore,
  141. IsFast = billInvflowHistory.IsFast,
  142. IsFail = billInvflowHistory.IsFail,
  143. FailReason = billInvflowHistory.FailReason,
  144. SilkTypeCode = billInvflowHistory.SilkTypeCode,
  145. Grade = billInvflowHistory.Grade,
  146. IsBack = billInvflowHistory.IsBack,
  147. BackReason = billInvflowHistory.BackReason,
  148. IsTorsChk = billInvflowHistory.IsTorsChk,
  149. TorsChkQty = billInvflowHistory.TorsChkQty,
  150. TorsChkTime = billInvflowHistory.TorsChkTime,
  151. TorsChkValue = billInvflowHistory.TorsChkValue,
  152. TorsChkMachCode = billInvflowHistory.TorsChkMachCode,
  153. ProcessDocsCode = billInvflowHistory.ProcessDocsCode,
  154. ProductMachCode = billInvflowHistory.ProductMachCode,
  155. ProductLineNo = billInvflowHistory.ProductLineNo,
  156. Wind = billInvflowHistory.Wind,
  157. AddWho = billInvflowHistory.AddWho,
  158. AddTime = billInvflowHistory.AddTime,
  159. EditWho = billInvflowHistory.EditWho,
  160. EditTime = billInvflowHistory.EditTime,
  161. Size = billInvflowHistory.Size,
  162. Memo = billInvflowHistory.Memo,
  163. PreStock = billInvflowHistory.PreStock,
  164. TorsChkChord = billInvflowHistory.TorsChkChord,
  165. TorsChkChordIsGood=billInvflowHistory.TorsChkChordIsGood,
  166. TorsChkFlatness = billInvflowHistory.TorsChkFlatness,
  167. TorsChkFlatnessIsGood=billInvflowHistory.TorsChkFlatnessIsGood,
  168. TorsChkStation=billInvflowHistory.TorsChkStation,
  169. TorsChkValueIsGood=billInvflowHistory.TorsChkValueIsGood,
  170. //Tunnel = warecell.Tunnel,
  171. //Code = warecell.Code,
  172. //CellState = warecell.IsStop,
  173. SolderCount = billInvflowHistory.SolderCount,
  174. HoldTime = billInvflowHistory.HoldTime,
  175. IsControlpanel = billInvflowHistory.IsControlpanel,
  176. WbGroupCode = billInvflowHistory.WbGroupCode,
  177. SkuCode = billInvflowHistory.SkuCode,
  178. }).MergeTable();
  179. return sugarQueryable;
  180. }
  181. }
  182. }