| | |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | | using SqlSugar; |
| | | |
| | |
| | | conModels.Add(new ConditionalModel |
| | | { |
| | | FieldName = typeof(MesInvItemOutCDetails).GetProperties()[0].Name, |
| | | ConditionalType = ConditionalType.Equal, FieldValue = "1" |
| | | ConditionalType = ConditionalType.Equal, |
| | | FieldValue = "1" |
| | | }); //id=1 |
| | | var data7 = base.GetPageList(conModels, p, it => SqlFunc.GetRandom()); |
| | | |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | public MesInvItemOutCDetails GetOutList(WarehouseQuery query) |
| | | { |
| | | |
| | | |
| | | |
| | | var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(s => s.ItemBarcode == query.barcode).Count(); |
| | | |
| | | if (mesInvItemBarcodes <= 0) |
| | | { |
| | | throw new Exception("条码不存在"); |
| | | } |
| | | |
| | | var mesInvItemOutCDetails = Db.Queryable<MesInvItemOutCDetails>() |
| | | .Where(s => s.ItemBarcode == query.barcode && s.Receive == 0).Count(); |
| | | |
| | | |
| | | |
| | | if (mesInvItemOutCDetails <= 0) |
| | | { |
| | | throw new Exception("条码不符合接收条件,请检查!"); |
| | | } |
| | | |
| | | |
| | | |
| | | var entity = Db.Queryable<MesInvItemOutCDetails, MesInvItemOuts, MesItems>((a, b, c) => |
| | | new JoinQueryInfos(JoinType.Left, a.ItemOutId == b.Id, |
| | | JoinType.Left, a.ItemNo == c.ItemNo)) |
| | | .Where((a, b, c) => a.ItemBarcode == query.barcode) |
| | | .Select((a, b, c) => new MesInvItemOutCDetails |
| | | { |
| | | PbillNo = b.ItemOutNo, |
| | | WorkNo = a.WorkNo, |
| | | ItemNo = a.ItemNo, |
| | | ItemName = c.ItemName, |
| | | Quantity = a.Quantity |
| | | }).First(); |
| | | |
| | | if (entity == null) |
| | | { |
| | | throw new Exception("出库条码" + query.barcode + " 不存在,请确认!"); |
| | | } |
| | | |
| | | |
| | | return entity; |
| | | } |
| | | |
| | | |
| | | public MaterialReceipt GetFormList(WarehouseQuery query) |
| | | { |
| | | var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(s => s.ItemBarcode == query.barcode).Count(); |
| | | |
| | | if (mesInvItemBarcodes <= 0) |
| | | { |
| | | throw new Exception("条码不存在"); |
| | | } |
| | | |
| | | var mesInvItemOutCDetails = Db.Queryable<MesInvItemOutCDetails>() |
| | | .Where(s => s.ItemBarcode == query.barcode).First(); |
| | | |
| | | MaterialReceipt entity = new MaterialReceipt |
| | | { |
| | | InvItemoutCDetails = GetMesInvItemOutCDetails(mesInvItemOutCDetails.PbillNo), |
| | | ItemOuts = GetMesInvItemOuts(mesInvItemOutCDetails.PbillNo) |
| | | |
| | | }; |
| | | |
| | | return entity; |
| | | } |
| | | |
| | | |
| | | public MesInvItemOutCDetails confirmReceipt(WarehouseQuery query) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(query.barcode)) |
| | | { |
| | | throw new Exception("请扫出库条码!"); |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(query.billNo)) |
| | | { |
| | | throw new Exception("出库单据不能为空!"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | var barcodeInfo = GetBarcodeInfo(query.barcode); |
| | | |
| | | |
| | | if (barcodeInfo.Receive == 1) |
| | | { |
| | | throw new Exception("此条码已经接收,请检查!"); |
| | | } |
| | | |
| | | |
| | | UseTransaction(db => |
| | | { |
| | | |
| | | var count = db.Updateable<MesInvItemOutCDetails>() |
| | | .SetColumns(s => s.Receive == 1) |
| | | .Where(s => s.ItemBarcode == barcodeInfo.ItemBarcode).ExecuteCommand(); |
| | | |
| | | return 1; |
| | | }); |
| | | |
| | | return barcodeInfo; |
| | | } |
| | | |
| | | |
| | | |
| | | public List<MesInvItemOutCDetails> GetMesInvItemOutCDetails(string billno) |
| | | { |
| | | return Db.Queryable<MesInvItemOutCDetails>() |
| | | .Where(s => s.PbillNo == billno).ToList(); |
| | | } |
| | | |
| | | public MesInvItemOuts GetMesInvItemOuts(string billno) |
| | | { |
| | | return Db.Queryable<MesInvItemOuts>() |
| | | .Where(a => a.ItemOutNo == billno).Single(); |
| | | } |
| | | |
| | | |
| | | |
| | | private MesInvItemOutCDetails GetBarcodeInfo(string itemBarcode) |
| | | { |
| | | // Get barcode information |
| | | return Db.Queryable<MesInvItemOutCDetails>() |
| | | .First(b => b.ItemBarcode == itemBarcode); |
| | | } |
| | | |
| | | } |