HJDataService.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using wms.dataservice.IDataSetvice;
  7. using wms.dto;
  8. using wms.dto.request;
  9. using wms.dto.request.hj.dto;
  10. using wms.sqlsugar;
  11. using wms.sqlsugar.model.hj;
  12. namespace wms.dataservice.DataService
  13. {
  14. public class HJDataService: IHJDataService
  15. {
  16. Repository<hjBaseWareLocation> _baseWareLocationrepository => new Repository<hjBaseWareLocation>();
  17. Repository<hjBillDocument> _billDocument => new Repository<hjBillDocument>();
  18. /// <summary>
  19. /// 二升位有出库任务的一升位有货(无任务)货位
  20. /// </summary>
  21. /// <param name="reqEntity"></param>
  22. /// <returns></returns>
  23. public List<hjBaseWareLocation> GetLocationDept1WithDept2Stock(ApplyStockOutRequest reqEntity)
  24. {
  25. //var list = _baseWareLocationrepository.Context.Queryable<hjBaseWareLocation, hjBaseWareLocation, hjBaseEquipment>((location1, location2, equipment) => new object[] {
  26. // JoinType.Inner,location1.ShelfCode == location2.ShelfCode && location1.LogicCol == location2.LogicCol && location1.LogicLayer == location2.LogicLayer && location1.ZoneId == location2.ZoneId,
  27. // JoinType.Inner,house.Id == equipment.WarehouseId && location1.Tunnel == equipment.Tunnel && equipment.EquipType == BaseDictionaryConst.EquipType_PlierCode
  28. // })
  29. // .Where((location1, zone, house, location2, equipment) => location1.Status == 1 && location1.IsDelete == 0 && location2.Status == 1 && location2.IsDelete == 0 && zone.IsDelete == 0 && zone.Status == 1 && house.IsDelete == 0 && house.Status == 1)
  30. // .Where((location1, zone, house, location2, equipment) => location1.LocationType == DictionaryConst.LocationTypeStorageCode && location1.LocationState == DictionaryConst.LocationStateStockCode && (string.IsNullOrEmpty(location1.LocationLock) || location1.LocationLock == DictionaryConst.LocationLockNoneCode))
  31. // .Where((location1, zone, house, location2, equipment) => location2.LocationType == DictionaryConst.LocationTypeStorageCode && location2.LocationState == DictionaryConst.LocationStateStockCode && location2.LocationLock == DictionaryConst.LocationLockStockOutCode)
  32. // .WhereIF(!string.IsNullOrEmpty(reqEntity.LocationType), (location1, zone, house, location2, equipment) => reqEntity.LocationType == location1.LocationType)
  33. // .WhereIF(!string.IsNullOrEmpty(reqEntity.Tunnel), (location1, zone, house, location2, equipment) => location1.Tunnel == reqEntity.Tunnel)
  34. // .WhereIF(!string.IsNullOrEmpty(reqEntity.Size), (location1, zone, house, location2, equipment) => int.Parse(location1.Size) >= int.Parse(reqEntity.Size))
  35. // .WhereIF(reqEntity.ZoneId > 0, (location1, zone, house, location2, equipment) => zone.Id == reqEntity.ZoneId)
  36. // .WhereIF(reqEntity.WarehouseId > 0, (location1, zone, house, location2, equipment) => zone.WarehouseId == reqEntity.WarehouseId)
  37. // .WhereIF(reqEntity.LocationId > 0, (location1, zone, house, location2, equipment) => location1.Id == reqEntity.LocationId)
  38. // .WhereIF(!string.IsNullOrEmpty(reqEntity.ShelfCode), (location1, zone, house, location2, equipment) => location1.ShelfCode == reqEntity.ShelfCode)
  39. // .WhereIF(reqEntity.IsExceptErrorPlier, (location1, zone, house, location2, equipment) => equipment.EquipState != BaseDictionaryConst.PlierRuningState_ErrorCode)
  40. //.Select((location1, zone, house, location2, equipment) => location1);
  41. // return list.ToList();
  42. return null;
  43. }
  44. public (List<DocumentsResponse>, int) GetPageDocumentsList(DocumentsRequest request)
  45. {
  46. int count = 0;
  47. var list = _billDocument.Context.Queryable<BillDocsinfo, BaseWarehouse>((document, house) => new object[]
  48. {
  49. JoinType.Left, document.WarehouseId == house.Id
  50. })
  51. .WhereIF(!string.IsNullOrEmpty(request.DocsNo), (document, house) => document.DocsNo.Contains(request.DocsNo))
  52. .WhereIF(!string.IsNullOrEmpty(request.ReqNo), (document, house) => document.ReqNo.Contains(request.ReqNo))
  53. .WhereIF(!string.IsNullOrEmpty(request.StateCode), (document, house) => document.StateNum == int.Parse(request.StateCode))
  54. .WhereIF(!string.IsNullOrEmpty(request.TypeCode), (document, house) => document.TypeNum == int.Parse(request.TypeCode))
  55. .Select((document, house) => new DocumentsResponse()
  56. {
  57. Id = document.Id,
  58. WarehouseCode = house.Code,
  59. DocNo = document.DocsNo,
  60. ReqNo = document.ReqNo,
  61. TypeCode = document.TypeNum.ToString(),
  62. StateCode = document.StateNum.ToString(),
  63. DownQty = document.DownQty,
  64. //DownErrReason = document.DownErrReason,
  65. //Remark = document.Remark,
  66. AddWho = document.AddWho,
  67. EditWho = document.EditWho,
  68. AddTime = document.AddTime,
  69. EditTime = document.EditTime
  70. })
  71. .ToPageList(request.PageIndex, request.PageSize, ref count);
  72. //list = list.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList();
  73. return (list.ToList(), count);
  74. }
  75. public List<string> GetStockByEquip(string code)
  76. {
  77. var list = _baseWareLocationrepository.Context.Queryable<hjBaseWareLocation, hjBillContainer>((location, stock) => new object[]
  78. {
  79. JoinType.Inner, stock.ContGrpId == location.ContGrpID,
  80. })
  81. .Where((location, stock) => stock.ExecState == InvState.InvEcecState_BuildUp.GetHashCode())
  82. .WhereIF(!string.IsNullOrEmpty(code), (location, stock) => location.Code.Contains(code))
  83. .Select((location, stock) => stock.HWBarCode).ToList();
  84. return list;
  85. }
  86. public (List<DocumentsdetailList>, int) GetDocumentDetailListByDocsNo(DocumentsRequest request)
  87. {
  88. int count = 0;
  89. var list = _billDocument.Context.Queryable<hjBillDocument, hjBillBarcode, hjBaseMater, hjBillContainer, hjBaseWareLocation>((document, barcode, mater, container, location) => new object[]
  90. {
  91. JoinType.Inner, document.DocNo == barcode.InDocsNo,
  92. JoinType.Inner, barcode.MatId == mater.Id,
  93. JoinType.Inner, barcode.RFIDBarCode == container.RFIDBarCode,
  94. JoinType.Inner, container.ContGrpId == location.ContGrpID
  95. })
  96. .Where((document, barcode, mater, container, location) => container.ExecState == InvState.InvEcecState_In.GetHashCode() && location.LocationState == LocationState.LocationState_Full.GetHashCode()
  97. )
  98. .WhereIF(!string.IsNullOrEmpty(request.DocsNo), (document, barcode, mater, container, location) => document.DocNo.Contains(request.DocsNo))
  99. .WhereIF(!string.IsNullOrEmpty(request.Rfid), (document, barcode, mater, container, location) => container.RFIDBarCode.Contains(request.Rfid))
  100. .WhereIF(!string.IsNullOrEmpty(request.location), (document, barcode, mater, container, location) => location.Code.Contains(request.location))
  101. .Select((document, barcode, mater, container, location) => new DocumentsdetailList()
  102. {
  103. WarehouseCode = location.WareCode,
  104. MatCode = mater.Code,
  105. MatName = mater.Name,
  106. Location = location.Code,
  107. RFIDBarCode = barcode.RFIDBarCode,
  108. HWSpec = barcode.HWSpec,
  109. IsFast = barcode.IsFast,
  110. Grade = barcode.Grade
  111. })
  112. .ToPageList(request.PageIndex, request.PageSize, ref count);
  113. //list = list.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList();
  114. return (list.ToList(), count);
  115. }
  116. }
  117. }