| | |
| | | |
| | | //这里面写的代码不会给覆盖,如果要重新生成请删除 MesInvItemMovesManager.cs |
| | | |
| | | public int ScanInBarcode(WarehouseQuery query) |
| | | public MovesDto ScanInBarcode(WarehouseQuery query) |
| | | { |
| | | if (string.IsNullOrEmpty(query.sectionCode)) |
| | | { |
| | |
| | | int pBillTypeId = 300; |
| | | int pTransctionNo = 301; |
| | | |
| | | var depotQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) => new JoinQueryInfos( |
| | | var depotQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) => |
| | | new JoinQueryInfos( |
| | | JoinType.Inner, a.Zuid.ToString() == b.Zuid)) |
| | | .Where((a, b) => a.DepotSectionCode == query.sectionCode) |
| | | .Select((a, b) => new { b.DepotCode }) |
| | |
| | | var cDepotCode = depotQuery.DepotCode; |
| | | |
| | | // 查询调拔入库信息 |
| | | var itemMoveQuery = Db.Queryable<MesInvItemMoves, MesInvItemMovesCDetails>((a, b) => new JoinQueryInfos( |
| | | var itemMoveQuery = Db |
| | | .Queryable<MesInvItemMoves, MesInvItemMovesCDetails>((a, b) => |
| | | new JoinQueryInfos( |
| | | JoinType.Inner, a.Id == b.ItemMoveId)) |
| | | .Where((a, b) => b.ItemBarcode == query.barcode && a.BillTypeId == pBillTypeId && a.TransactionNo == pTransctionNo && |
| | | .Where((a, b) => b.ItemBarcode == query.barcode && |
| | | a.BillTypeId == pBillTypeId && |
| | | a.TransactionNo == pTransctionNo && |
| | | a.Status == 1 && SqlFunc.IsNull(b.MoveOk, 0) != 1) |
| | | .Select((a, b) => new { a.Id, a.BillNo, a.InvDepotsCode }) |
| | | .First(); |
| | | |
| | | return 0; |
| | | if (itemMoveQuery == null) |
| | | { |
| | | throw new Exception("条码未做调拔出库扫码,请核对!"); |
| | | } |
| | | |
| | | var cBillNo = itemMoveQuery.BillNo; |
| | | var iDepotCode = itemMoveQuery.InvDepotsCode; |
| | | |
| | | // 验证库区与仓库 |
| | | var depotValidationQuery = Db.Queryable<MesDepotSections, MesDepots>( |
| | | (a, b) => new JoinQueryInfos( |
| | | JoinType.Inner, a.Zuid.ToString() == b.Zuid)) |
| | | .Where((a, b) => a.DepotSectionCode == query.sectionCode && |
| | | b.DepotCode == iDepotCode) |
| | | .Select((a, b) => new { b.DepotCode }) |
| | | .First(); |
| | | |
| | | if (depotValidationQuery == null) |
| | | { |
| | | throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!"); |
| | | } |
| | | |
| | | if (iDepotCode != depotValidationQuery.DepotCode) |
| | | { |
| | | throw new Exception("实际仓库与申请调入仓库不符,请核对!"); |
| | | } |
| | | |
| | | var barcodeCount = Db.Queryable<MesInvItemMovesCDetails>() |
| | | .Where(b => |
| | | b.ItemBarcode == query.barcode && |
| | | b.ItemMoveId == itemMoveQuery.Id && b.MoveOk == 1) |
| | | .Count(); |
| | | |
| | | if (barcodeCount > 0) |
| | | { |
| | | throw new Exception("条码调拔已完成,请核对!"); |
| | | } |
| | | |
| | | var barcodeInfo = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(t => t.ItemBarcode == query.barcode) |
| | | .First(); |
| | | |
| | | if (barcodeInfo == null) |
| | | { |
| | | throw new Exception("条码不存在,请核对!"); |
| | | } |
| | | |
| | | var isAudit = UseTransaction(db => |
| | | { |
| | | // 更新业务、库存和条码数据 |
| | | db.Updateable<MesInvBusiness2>() |
| | | .SetColumns(b => new MesInvBusiness2 |
| | | { |
| | | ToInvDepotsCode = cDepotCode, |
| | | ToInvDepotSectionsCode = query.sectionCode |
| | | }) |
| | | .Where(b => |
| | | b.BillNo == cBillNo && b.BillTypeId == pBillTypeId && |
| | | b.TransactionCode == pTransctionNo.ToString() && |
| | | b.ItemBarcode == query.barcode) |
| | | .ExecuteCommand(); |
| | | |
| | | db.Updateable<MesInvItemStocks>() |
| | | .SetColumns(b => new MesInvItemStocks |
| | | { |
| | | DepotsCode = cDepotCode, |
| | | DepotSectionsCode = query.sectionCode |
| | | }) |
| | | .Where(b => b.ItemBarcode == query.barcode) |
| | | .ExecuteCommand(); |
| | | |
| | | db.Updateable<MesInvItemMovesCDetails>() |
| | | .SetColumns(b => new MesInvItemMovesCDetails |
| | | { |
| | | MoveOk = 1, |
| | | InvDepotsCode = cDepotCode, |
| | | InvDepotSectionsCode = query.sectionCode |
| | | }) |
| | | .Where(b => |
| | | b.ItemBarcode == query.barcode && |
| | | b.ItemMoveId == itemMoveQuery.Id) |
| | | .ExecuteCommand(); |
| | | |
| | | // 检查是否所有条码已扫码移库 |
| | | var totalQuantity = db.Queryable<MesInvItemOutItems>() |
| | | .Where(a => a.ItemOutId == itemMoveQuery.Id) |
| | | .Sum(a => SqlFunc.IsNull(a.Quantity, 0)); |
| | | |
| | | var scannedQuantity = db.Queryable<MesInvItemMovesCDetails>() |
| | | .Where(a => a.ItemMoveId == itemMoveQuery.Id && a.MoveOk == 1) |
| | | .Sum(a => SqlFunc.IsNull(a.Quantity, 0)); |
| | | |
| | | if (totalQuantity == scannedQuantity) |
| | | { |
| | | return 1; |
| | | } |
| | | |
| | | return 0; |
| | | }); |
| | | |
| | | MovesDto dto = new MovesDto(); |
| | | dto.InAudit = isAudit == 1; |
| | | dto.BarcodesInfo = barcodeInfo; |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | public List<MesInvItemMoves> GetBillNo(WarehouseQuery query) |
| | | { |
| | |
| | | |
| | | return results; |
| | | } |
| | | |
| | | public bool Audit(WarehouseQuery query) |
| | | { |
| | | return Db.Updateable<MesInvItemMoves>() |
| | | .SetColumns(a => new MesInvItemMoves { Ts = 1 }) |
| | | .Where(a => a.Id == query.id) |
| | | .ExecuteCommand() > 0; |
| | | } |
| | | |
| | | public MessageCenter SaveMessageCenter(WarehouseQuery query) |
| | | { |
| | | var message = MesToErpParam(query); |
| | | |
| | | var executeReturnIdentity = |
| | | Db.Insertable(message).ExecuteReturnIdentity(); |
| | | if (executeReturnIdentity > 0) |
| | | { |
| | | message.Id = executeReturnIdentity; |
| | | message.Pid = executeReturnIdentity; |
| | | return message; |
| | | } |
| | | |
| | | throw new Exception("获取数据失败"); |
| | | } |
| | | |
| | | public MessageCenter MesToErpParam(WarehouseQuery query) |
| | | { |
| | | var erpParameters = ""; |
| | | var title = ""; |
| | | var tableName = "MES_INV_ITEM_MOVES_" + query.Type; |
| | | if ("A".Equals(query.Type)) |
| | | { |
| | | erpParameters = GetErpParameters(query.billNo); |
| | | title = "调拨入库单" + query.billNo + "审核"; |
| | | } |
| | | else if ("B".Equals(query.Type)) |
| | | { |
| | | erpParameters = GetDeApprovePam(query.id); |
| | | title = "调拨入库单" + query.billNo + "反审核"; |
| | | } |
| | | |
| | | var ErpUrl = AppsettingsUtility.Settings.ProductionErpUrl; |
| | | var message = new MessageCenter |
| | | { |
| | | TableName = tableName, |
| | | Url = ErpUrl, |
| | | Status = 1, |
| | | CreateBy = query.userName, |
| | | Route = query.billNo, |
| | | Title = title, |
| | | PageName = "Allocation/Add?id=" + query.id + |
| | | "&billNo=" + query.billNo, |
| | | CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Method = "POST", |
| | | Seq = 1, |
| | | Data = erpParameters, |
| | | IsMessage = 0, |
| | | ContentType = "application/x-www-form-urlencoded" |
| | | }; |
| | | return message; |
| | | } |
| | | |
| | | private string GetErpParameters(string? billNo) |
| | | { |
| | | // var invItemIns = Db.Queryable<MesInvItemOuts>() |
| | | // .Single(x => x.ItemOutNo == billNo); |
| | | // |
| | | // //调用function函数 |
| | | // var sql = |
| | | // $"SELECT F_GENERATE_DATA_INSERTED('{billNo}') FROM DUAL;"; |
| | | // var jsonString = Db.Ado.SqlQuerySingle<string>(sql); |
| | | // |
| | | // var encodedUrl = "taskname=CGTL&mesid=" + invItemIns.Id + |
| | | // "&optype=create&datajson=" + jsonString; |
| | | // |
| | | // return encodedUrl; |
| | | return null; |
| | | } |
| | | |
| | | private string GetDeApprovePam(decimal? id) |
| | | { |
| | | // var sid = (int)id; |
| | | // var encodedUrl = "taskname=CGTL&mesid=" + sid + |
| | | // "&optype=delete&datajson={}"; |
| | | // |
| | | // return encodedUrl; |
| | | return null; |
| | | } |
| | | } |