| | |
| | | public ProductionPickToMes toMes { get; set; } |
| | | public bool his_isComplete { get; set; } |
| | | public bool isManual { get; set; } |
| | | public decimal cutQty { get; set; } |
| | | public double cutQty { get; set; } |
| | | |
| | | #endregion Propertys & Variables |
| | | |
| | |
| | | var action = new ApiAction<ProdReqOutput>(); |
| | | try |
| | | { |
| | | req = await Biz.Db.Queryable<BIZ_WMS_TRANSFER>().Where(x => x.BILLCODE == input.ReqNo).Includes(q => q.DtlsWithGhost, d => d.ItemInfo).IncludesAllFirstLayer().FirstAsync(); |
| | | req = await Biz.Db.Queryable<BIZ_WMS_TRANSFER>().Where(x => x.ORDER_NO == input.ReqNo).Includes(q => q.Details, d => d.ItemInfo).IncludesAllFirstLayer().FirstAsync(); |
| | | //验证明细是否正确 |
| | | if (!req.Dtls.Any()) |
| | | if (!req.Details.Any()) |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = new("WMS.ProdMReq.SelectOrder.DtlsException", input.ReqNo); |
| | |
| | | } |
| | | |
| | | //如果是手工创建的调拨单 |
| | | isManual = req.STATUS == BIZ_WMS_TRANSFER.STATUSs.MANUAL.GetValue(); |
| | | isManual = req.STATUS == BIZ_WMS_TRANSFER.STATUSs.Imported.GetValue(); |
| | | |
| | | Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.BILLCODE).ExecuteCommand(); |
| | | Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => q.TRANS_CODE == req.ORDER_NO).ExecuteCommand(); |
| | | //如果上一次推荐有数据,则先灭掉亮的灯 |
| | | if (Suggests.Any()) |
| | | { |
| | |
| | | |
| | | var begin = DateTime.Now; |
| | | var ElapsedTime = 0.0; |
| | | var sumDtls = req.Dtls.Where(q => q.LINESTATUS != BIZ_WMS_TRANSFER.STATUSs.COMPLETE.GetValue()) |
| | | .GroupBy(x => new { x.ITEM_CODE }).Select(x => new { ItemCode = x.Key.ITEM_CODE.ToString(), WarehouseCode = x.Max(t => t.OUTWAREHOUSECODE), actQty = x.Sum(t => t.PRQTY - t.OUTQTY), lockObj = new object() }); |
| | | var sumDtls = req.Details.Where(q => q.STATUS != BIZ_WMS_TRANSFER.STATUSs.Finished.GetValue()) |
| | | .GroupBy(x => new { x.ITEM_CODE }).Select(x => new { ItemCode = x.Key.ITEM_CODE.ToString(), WarehouseCode = x.Max(t => t.OUT_WH_CODE), actQty = x.Sum(t => t.QTY_REQ - t.QTY_OUT), lockObj = new object() }); |
| | | var dic = sumDtls.ToDictionary(k => k, v => new Result<List<SuggestItem>>()); |
| | | foreach (var item in dic) |
| | | { |
| | |
| | | { |
| | | lock (item.Key.lockObj) |
| | | { |
| | | dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.BILLCODE, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty); |
| | | dic[item.Key] = WMS_ITEM_Biz.WmsItem.Suggest(req.ORDER_NO, item.Key.ItemCode, item.Key.WarehouseCode, null, null, null, input.AuthOption, item.Key.actQty); |
| | | } |
| | | }); |
| | | } |
| | |
| | | var actQty = sumDtls.ToList().Where(x => x.ItemCode.Trim() == inv.Item.ITEM_CODE.Trim()).Select(x => x.actQty).FirstOrDefault(); |
| | | if (actQty > 0) |
| | | { |
| | | inv.poolItem = inv.Item.GetPoolItem(input.AuthOption.OrgCode, nameof(req), req.BILLCODE, null, actQty, false); |
| | | inv.poolItem = inv.Item.GetPoolItem(input.AuthOption.OrgCode, nameof(req), req.ORDER_NO, null, actQty, false); |
| | | } |
| | | else |
| | | { |
| | |
| | | await Share.Shelf.LightMulti(TransID, light.Color, locs); |
| | | action.Data = new ProdReqOutput() |
| | | { |
| | | ReqNo = req.BILLCODE, |
| | | ReqNo = req.ORDER_NO, |
| | | ReqType = light.ReqType.GetValue() |
| | | }; |
| | | action.LocaleMsg = Biz.L("亮灯成功,亮灯颜色[{0}]", light.Color.GetDesc()); |
| | |
| | | var action = new ApiAction(); |
| | | try |
| | | { |
| | | var dtls = req.Dtls.GroupBy(x => new { x.BILLLINE, x.ITEM_CODE, x.ItemInfo.ITEM_NAME }).Select(x => new ProdReqDtl() { BillLine = x.Key.BILLLINE.ToInt32(), ItemCode = x.Key.ITEM_CODE, ItemName = x.Key.ITEM_NAME, Status = "", Items = new List<ProdReqDtlItems>() }).ToList(); |
| | | var dtls = req.Details.GroupBy(x => new { x.ORDER_LINE, x.ITEM_CODE, x.ItemInfo.ITEM_NAME }).Select(x => new ProdReqDtl() { BillLine = x.Key.ORDER_LINE.ToInt32(), ItemCode = x.Key.ITEM_CODE, ItemName = x.Key.ITEM_NAME, Status = "", Items = new List<ProdReqDtlItems>() }).ToList(); |
| | | foreach (var d in dtls) |
| | | { |
| | | d.Items = Suggests.Where(x => x.Item.ITEM_CODE == d.ItemCode).Select(x => new ProdReqDtlItems { WHCode = x.Warehouse.WH_CODE, LocationCode = x.Location.LOCATION_CODE, SN = x.Item.SN, QTY = x.Item.QTY }).ToList(); |
| | | d.Status = $"{(double)req.Dtls.Where(x => x.ITEM_CODE == d.ItemCode).Sum(x => x.OUTQTY)} / {(double)req.Dtls.Where(x => x.ITEM_CODE == d.ItemCode).Sum(x => x.PRQTY)} {Suggests.FirstOrDefault()?.Item?.UNIT} (还需{d.Items.Count}个)"; |
| | | d.Status = $"{(double)req.Details.Where(x => x.ITEM_CODE == d.ItemCode).Sum(x => x.QTY_OUT)} / {(double)req.Details.Where(x => x.ITEM_CODE == d.ItemCode).Sum(x => x.QTY_REQ)} {Suggests.FirstOrDefault()?.Item?.UNIT} (还需{d.Items.Count}个)"; |
| | | } |
| | | action.Data = itemcode.IsNullOrEmpty() ? dtls.OrderBy(q => q.BillLine) : dtls.Where(x => x.ItemCode == itemcode).FirstOrDefault()?.Items.OrderBy(q => q.SN); |
| | | } |
| | |
| | | var action = new ApiAction(); |
| | | try |
| | | { |
| | | action.Data = $"物料{itemcode}:已下架[{(double)req.Dtls.Where(x => x.ITEM_CODE == itemcode).Sum(x => x.OUTQTY)}],共{(double)req.Dtls.Where(x => x.ITEM_CODE == itemcode).Sum(x => x.PRQTY)} {Suggests.FirstOrDefault()?.Item?.UNIT}"; |
| | | action.Data = $"物料{itemcode}:已下架[{(double)req.Details.Where(x => x.ITEM_CODE == itemcode).Sum(x => x.QTY_OUT)}],共{(double)req.Details.Where(x => x.ITEM_CODE == itemcode).Sum(x => x.QTY_REQ)} {Suggests.FirstOrDefault()?.Item?.UNIT}"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | |
| | | //仓库卡控 |
| | | if (!req.Dtls.Any(q => q.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE && q.OUTWAREHOUSECODE == CurInv.Warehouse.WH_CODE)) |
| | | if (!req.Details.Any(q => q.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE && q.OUT_WH_CODE == CurInv.Warehouse.WH_CODE)) |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = Biz.L($"条码[{CurInv.Barcode.SN}]的料号或者仓库跟单据[{req.BILLCODE}]上的不一致"); |
| | | action.LocaleMsg = Biz.L($"条码[{CurInv.Barcode.SN}]的料号或者仓库跟单据[{req.ORDER_NO}]上的不一致"); |
| | | return action; |
| | | } |
| | | |
| | |
| | | |
| | | //2.是否超发 |
| | | isExceed = false; |
| | | req = await Biz.Db.Queryable<BIZ_WMS_TRANSFER>().Where(x => x.BILLCODE == req.BILLCODE).Includes(q => q.DtlsWithGhost, d => d.ItemInfo).IncludesAllFirstLayer().FirstAsync(); |
| | | dtls = req.Dtls.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).ToList(); |
| | | req = await Biz.Db.Queryable<BIZ_WMS_TRANSFER>().Where(x => x.ORDER_NO == req.ORDER_NO).Includes(q => q.Details, d => d.ItemInfo).IncludesAllFirstLayer().FirstAsync(); |
| | | dtls = req.Details.Where(x => x.ITEM_CODE == CurInv.ItemInfo.ITEM_CODE).ToList(); |
| | | if (dtls.IsNullOrEmpty()) |
| | | { |
| | | action.IsSuccessed = false; |
| | |
| | | } |
| | | |
| | | //如果状态完成 |
| | | if (dtls.Where(x => x.LINESTATUS == BIZ_WMS_TRANSFER.STATUSs.COMPLETE.GetValue()).Count() == dtls.Count) |
| | | if (dtls.Where(x => x.STATUS == BIZ_WMS_TRANSFER.STATUSs.Finished.GetValue()).Count() == dtls.Count) |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = Biz.L("料已经发完"); |
| | | return action; |
| | | } |
| | | var actQty = dtls.Sum(x => x.OUTQTY > x.PRQTY ? 0 : x.PRQTY - x.OUTQTY); |
| | | var actQty = dtls.Sum(x => x.QTY_OUT > x.QTY_REQ ? 0 : x.QTY_REQ - x.QTY_OUT); |
| | | cutQty = 0; |
| | | if (actQty < CurInv.CurPkg.QTY) |
| | | { |
| | |
| | | |
| | | //3.是否截料,不允许超发的物料,所有的单别都需要做拆包处理,自动调用拆包,允许超发的物料,单别5408或者5409的要拆包 |
| | | isCutting = false; |
| | | decimal curQty = CurInv.CurPkg.QTY; |
| | | double curQty = CurInv.CurPkg.QTY; |
| | | foreach (var d in dtls) |
| | | { |
| | | var actPrQty = d.PRQTY - d.OUTQTY; |
| | | var actPrQty = d.QTY_REQ - d.QTY_OUT; |
| | | if (actPrQty > 0 && curQty > 0) |
| | | { |
| | | if (actPrQty >= curQty) |
| | | { |
| | | d.OUTQTY += curQty; |
| | | d.QTY_OUT += curQty; |
| | | curQty = 0; |
| | | } |
| | | else |
| | | { |
| | | d.OUTQTY = d.PRQTY; |
| | | d.QTY_OUT = d.QTY_REQ; |
| | | curQty -= actPrQty; |
| | | } |
| | | d.LINESTATUS = d.OUTQTY >= d.PRQTY ? BIZ_WMS_TRANSFER.STATUSs.COMPLETE.GetValue() : BIZ_WMS_TRANSFER.STATUSs.WORKING.GetValue(); |
| | | d.STATUS = d.QTY_OUT >= d.QTY_REQ ? BIZ_WMS_TRANSFER.STATUSs.Finished.GetValue() : BIZ_WMS_TRANSFER.STATUSs.Storing.GetValue(); |
| | | //d.OUTWAREHOUSECODE = CurInv.Warehouse.WH_CODE; |
| | | } |
| | | } |
| | | if (isExceed) |
| | | { |
| | | if (CurInv.ItemInfo.DLVY_TYPE == BAS_ITEM.DLVY_TYPEs.ByDemand.GetValue() || req.BILLCODE.Substring(2, 4) == "5408" || req.BILLCODE.Substring(2, 4) == "5409") |
| | | if (CurInv.ItemInfo.DLVY_TYPE == BAS_ITEM.DLVY_TYPEs.ByDemand.GetValue() || req.ORDER_NO.Substring(2, 4) == "5408" || req.ORDER_NO.Substring(2, 4) == "5409") |
| | | { |
| | | isCutting = true; |
| | | isExceed = false; |
| | |
| | | else |
| | | { |
| | | //最大数量明细行用于调拨,该行发料数量加上应截料数量 |
| | | var tfdtl = dtls.OrderBy(q => q.BILLLINE.ToDecimal()).Last(); |
| | | tfdtl.OUTQTY += cutQty; |
| | | var tfdtl = dtls.OrderBy(q => q.ORDER_LINE.ToDecimal()).Last(); |
| | | tfdtl.QTY_OUT += cutQty; |
| | | } |
| | | } |
| | | |
| | |
| | | CutQty = CurInv.CurPkg.QTY - cutQty, |
| | | isCutting = isCutting, |
| | | isExceed = isExceed, |
| | | ReqNo = req.BILLCODE, |
| | | ReqNo = req.ORDER_NO, |
| | | regionCode = CurInv.Region.REGION_CODE, |
| | | locationCode = CurInv.Location?.LOCATION_CODE, |
| | | }; |
| | |
| | | SN = CurInv.CurPkg.SN, |
| | | ITEM_CODE = CurInv.ItemInfo.ITEM_CODE, |
| | | QTY = CurInv.CurPkg.QTY, |
| | | META_SN = CurInv.Barcode.MetaSn, |
| | | BILLCODE = req.BILLCODE, |
| | | BILLDATE = req.BILLDATE, |
| | | ORDER_NO = req.ORDER_NO, |
| | | //BILLLINE = tfdtl.BILLLINE |
| | | }; |
| | | |
| | | //4.更新业务单据,BIZ_WMS_TRANSFER、BIZ_WMS_TRANSFER_DTL、BIZ_WMS_TRANSFER_SN 判断明细行状态是否完成 |
| | | var isComplete = !req.Dtls.Any(x => x.LINESTATUS != BIZ_WMS_TRANSFER.STATUSs.COMPLETE.GetValue() && x.LINESTATUS != BIZ_WMS_TRANSFER.STATUSs.MANUALCOMPLETE.GetValue() && x.PRQTY > 0); |
| | | var isComplete = !req.Details.Any(x => x.STATUS != BIZ_WMS_TRANSFER.STATUSs.Finished.GetValue() && x.STATUS != BIZ_WMS_TRANSFER.STATUSs.Picked.GetValue() && x.QTY_REQ > 0); |
| | | his_isComplete = isComplete; |
| | | if (isComplete) |
| | | { |
| | | //detail全部完成了 |
| | | req.STATUS = isManual ? BIZ_WMS_TRANSFER.STATUSs.MANUALCOMPLETE.GetValue() : BIZ_WMS_TRANSFER.STATUSs.COMPLETE.GetValue(); |
| | | req.STATUS = isManual ? BIZ_WMS_TRANSFER.STATUSs.Picked.GetValue() : BIZ_WMS_TRANSFER.STATUSs.Finished.GetValue(); |
| | | } |
| | | else |
| | | { |
| | | req.STATUS = BIZ_WMS_TRANSFER.STATUSs.WORKING.GetValue(); |
| | | req.STATUS = BIZ_WMS_TRANSFER.STATUSs.Storing.GetValue(); |
| | | } |
| | | //如果是Agv |
| | | if (CurReqType == ReqType.IsAgv) |
| | | { |
| | | req.STATUS = isManual ? BIZ_WMS_TRANSFER.STATUSs.MANUALCOMPLETE.GetValue() : BIZ_WMS_TRANSFER.STATUSs.COMPLETE.GetValue(); |
| | | req.STATUS = isManual ? BIZ_WMS_TRANSFER.STATUSs.Picked.GetValue() : BIZ_WMS_TRANSFER.STATUSs.Finished.GetValue(); |
| | | } |
| | | |
| | | //5.出库下架 |
| | | foreach (var item in CurInv.Items) |
| | | { |
| | | item.TRANS_CODE = nameof(BIZ_WMS_TRANSFER); |
| | | item.TRANS_NO = req.BILLCODE; |
| | | item.TRANS_LINE = string.Join(",", dtls.Select(x => x.BILLLINE)); |
| | | item.TRANS_NO = req.ORDER_NO; |
| | | item.TRANS_LINE = string.Join(",", dtls.Select(x => x.ORDER_LINE)); |
| | | item.SOURCE_CODE = "WORK_ORDER"; |
| | | item.SOURCE_ORDER = dtls.First().SOURCECODE; |
| | | item.SOURCE_ORDER = dtls.First().SOURCE_ORDER; |
| | | } |
| | | Result<TakeDownInfo> downResult = WMS_ITEM_Biz.WmsItem.TakeDown(CurInv, input.AuthOption, WMS_ITEM.STATUSs.Sended, !isCutting); |
| | | if (!downResult.IsSuccessed) |
| | |
| | | |
| | | //6. 对接MES、Agv |
| | | |
| | | action.LocaleMsg = Biz.L($"调拨出库完成,单号[{req.BILLCODE}],条码[{CurInv.SN}],状态[{req.STATUS.GetEnumDesc<BIZ_WMS_TRANSFER.STATUSs>()}]"); |
| | | action.LocaleMsg = Biz.L($"调拨出库完成,单号[{req.ORDER_NO}],条码[{CurInv.SN}],状态[{req.STATUS.GetEnumDesc<BIZ_WMS_TRANSFER.STATUSs>()}]"); |
| | | action.Data = new ProdReqOutput() |
| | | { |
| | | SN = CurInv.SN, |
| | |
| | | CutQty = CurInv.CurPkg.QTY - cutQty, |
| | | isCutting = isCutting, |
| | | isExceed = isExceed, |
| | | ReqNo = req.BILLCODE, |
| | | ReqNo = req.ORDER_NO, |
| | | regionCode = CurInv.Region.REGION_CODE, |
| | | locationCode = CurInv.Location?.LOCATION_CODE, |
| | | }; |
| | |
| | | { |
| | | //needSaveHistoryLog = true; |
| | | CloseLight(LocationHis).Wait(); |
| | | if (!(req?.BILLCODE ?? "").IsNullOrEmpty()) |
| | | if (!(req?.ORDER_NO ?? "").IsNullOrEmpty()) |
| | | { |
| | | Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(x => x.TRANS_NO == req.BILLCODE).ExecuteCommand(); |
| | | Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(x => x.TRANS_NO == req.ORDER_NO).ExecuteCommand(); |
| | | } |
| | | Biz.Db.Deleteable<WMS_ITEM_POOL>().Where(q => CurPoolList.Select(q => q.SN).Contains(q.SN)).ExecuteCommand(); |
| | | //保存操作日志 |