using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using wms.dataservice.IDataSetvice; using wms.dto; using wms.dto.request; using wms.dto.request.hj.dto; using wms.sqlsugar; using wms.sqlsugar.model.hj; namespace wms.dataservice.DataService { public class HJDataService: IHJDataService { Repository _baseWareLocationrepository => new Repository(); Repository _billDocument => new Repository(); /// /// 二升位有出库任务的一升位有货(无任务)货位 /// /// /// public List GetLocationDept1WithDept2Stock(ApplyStockOutRequest reqEntity) { //var list = _baseWareLocationrepository.Context.Queryable((location1, location2, equipment) => new object[] { // JoinType.Inner,location1.ShelfCode == location2.ShelfCode && location1.LogicCol == location2.LogicCol && location1.LogicLayer == location2.LogicLayer && location1.ZoneId == location2.ZoneId, // JoinType.Inner,house.Id == equipment.WarehouseId && location1.Tunnel == equipment.Tunnel && equipment.EquipType == BaseDictionaryConst.EquipType_PlierCode // }) // .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) // .Where((location1, zone, house, location2, equipment) => location1.LocationType == DictionaryConst.LocationTypeStorageCode && location1.LocationState == DictionaryConst.LocationStateStockCode && (string.IsNullOrEmpty(location1.LocationLock) || location1.LocationLock == DictionaryConst.LocationLockNoneCode)) // .Where((location1, zone, house, location2, equipment) => location2.LocationType == DictionaryConst.LocationTypeStorageCode && location2.LocationState == DictionaryConst.LocationStateStockCode && location2.LocationLock == DictionaryConst.LocationLockStockOutCode) // .WhereIF(!string.IsNullOrEmpty(reqEntity.LocationType), (location1, zone, house, location2, equipment) => reqEntity.LocationType == location1.LocationType) // .WhereIF(!string.IsNullOrEmpty(reqEntity.Tunnel), (location1, zone, house, location2, equipment) => location1.Tunnel == reqEntity.Tunnel) // .WhereIF(!string.IsNullOrEmpty(reqEntity.Size), (location1, zone, house, location2, equipment) => int.Parse(location1.Size) >= int.Parse(reqEntity.Size)) // .WhereIF(reqEntity.ZoneId > 0, (location1, zone, house, location2, equipment) => zone.Id == reqEntity.ZoneId) // .WhereIF(reqEntity.WarehouseId > 0, (location1, zone, house, location2, equipment) => zone.WarehouseId == reqEntity.WarehouseId) // .WhereIF(reqEntity.LocationId > 0, (location1, zone, house, location2, equipment) => location1.Id == reqEntity.LocationId) // .WhereIF(!string.IsNullOrEmpty(reqEntity.ShelfCode), (location1, zone, house, location2, equipment) => location1.ShelfCode == reqEntity.ShelfCode) // .WhereIF(reqEntity.IsExceptErrorPlier, (location1, zone, house, location2, equipment) => equipment.EquipState != BaseDictionaryConst.PlierRuningState_ErrorCode) //.Select((location1, zone, house, location2, equipment) => location1); // return list.ToList(); return null; } public (List, int) GetPageDocumentsList(DocumentsRequest request) { int count = 0; var list = _billDocument.Context.Queryable((document, house) => new object[] { JoinType.Left, document.WarehouseId == house.Id }) .WhereIF(!string.IsNullOrEmpty(request.DocsNo), (document, house) => document.DocsNo.Contains(request.DocsNo)) .WhereIF(!string.IsNullOrEmpty(request.ReqNo), (document, house) => document.ReqNo.Contains(request.ReqNo)) .WhereIF(!string.IsNullOrEmpty(request.StateCode), (document, house) => document.StateNum == int.Parse(request.StateCode)) .WhereIF(!string.IsNullOrEmpty(request.TypeCode), (document, house) => document.TypeNum == int.Parse(request.TypeCode)) .Select((document, house) => new DocumentsResponse() { Id = document.Id, WarehouseCode = house.Code, DocNo = document.DocsNo, ReqNo = document.ReqNo, TypeCode = document.TypeNum.ToString(), StateCode = document.StateNum.ToString(), DownQty = document.DownQty, //DownErrReason = document.DownErrReason, //Remark = document.Remark, AddWho = document.AddWho, EditWho = document.EditWho, AddTime = document.AddTime, EditTime = document.EditTime }) .ToPageList(request.PageIndex, request.PageSize, ref count); //list = list.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList(); return (list.ToList(), count); } public List GetStockByEquip(string code) { var list = _baseWareLocationrepository.Context.Queryable((location, stock) => new object[] { JoinType.Inner, stock.ContGrpId == location.ContGrpID, }) .Where((location, stock) => stock.ExecState == InvState.InvEcecState_BuildUp.GetHashCode()) .WhereIF(!string.IsNullOrEmpty(code), (location, stock) => location.Code.Contains(code)) .Select((location, stock) => stock.HWBarCode).ToList(); return list; } public (List, int) GetDocumentDetailListByDocsNo(DocumentsRequest request) { int count = 0; var list = _billDocument.Context.Queryable((document, barcode, mater, container, location) => new object[] { JoinType.Inner, document.DocNo == barcode.InDocsNo, JoinType.Inner, barcode.MatId == mater.Id, JoinType.Inner, barcode.RFIDBarCode == container.RFIDBarCode, JoinType.Inner, container.ContGrpId == location.ContGrpID }) .Where((document, barcode, mater, container, location) => container.ExecState == InvState.InvEcecState_In.GetHashCode() && location.LocationState == LocationState.LocationState_Full.GetHashCode() ) .WhereIF(!string.IsNullOrEmpty(request.DocsNo), (document, barcode, mater, container, location) => document.DocNo.Contains(request.DocsNo)) .WhereIF(!string.IsNullOrEmpty(request.Rfid), (document, barcode, mater, container, location) => container.RFIDBarCode.Contains(request.Rfid)) .WhereIF(!string.IsNullOrEmpty(request.location), (document, barcode, mater, container, location) => location.Code.Contains(request.location)) .Select((document, barcode, mater, container, location) => new DocumentsdetailList() { WarehouseCode = location.WareCode, MatCode = mater.Code, MatName = mater.Name, Location = location.Code, RFIDBarCode = barcode.RFIDBarCode, HWSpec = barcode.HWSpec, IsFast = barcode.IsFast, Grade = barcode.Grade }) .ToPageList(request.PageIndex, request.PageSize, ref count); //list = list.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList(); return (list.ToList(), count); } } }