| | |
| | | try |
| | | { |
| | | // 1. 检查条码是否为空 |
| | | if (string.IsNullOrEmpty(cBarcode)) |
| | | { |
| | | throw new Exception("请输入条码!"); |
| | | } |
| | | if (string.IsNullOrEmpty(cBarcode)) throw new Exception("请输入条码!"); |
| | | |
| | | // 2. 检查条码是否存在于 MesInvItemBarcodes 表中 |
| | | int tempNum = Db.Queryable<MesInvItemBarcodes>() |
| | | var tempNum = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(it => it.ItemBarcode == cBarcode) |
| | | .Count(); |
| | | if (tempNum == 0) |
| | | { |
| | | throw new Exception("条码不存在!"); |
| | | } |
| | | if (tempNum == 0) throw new Exception("条码不存在!"); |
| | | |
| | | // 3. 检查条码是否存在于 MesInvItemStocks 表中 |
| | | tempNum = Db.Queryable<MesInvItemStocks>() |
| | | .Where(it => it.ItemBarcode == cBarcode) |
| | | .Count(); |
| | | if (tempNum == 0) |
| | | { |
| | | throw new Exception("库存中无此条码!"); |
| | | } |
| | | if (tempNum == 0) throw new Exception("库存中无此条码!"); |
| | | |
| | | // 4. 获取 MesInvItemBarcodes 的数据 |
| | | var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(it => it.ItemBarcode == cBarcode) |
| | | .First(); |
| | | if (mesInvItemBarcodes == null) |
| | | { |
| | | throw new Exception("条码不存在!"); |
| | | } |
| | | if (mesInvItemBarcodes == null) throw new Exception("条码不存在!"); |
| | | |
| | | // 5. 检查条码数量是否为 0 |
| | | if (mesInvItemBarcodes.Quantity == 0) |
| | | { |
| | | throw new Exception("此条码数量为0!"); |
| | | } |
| | | |
| | | // 6. 检查条码状态 |
| | | if (mesInvItemBarcodes.Barcodestatus == 1 || |
| | | mesInvItemBarcodes.Hbdytm == 1) |
| | | { |
| | | throw new Exception("无效条码!"); |
| | | } |
| | | |
| | | // 7. 检查条码是否被冻结 |
| | | if (mesInvItemBarcodes.Visable == 1) |
| | | { |
| | | throw new Exception("条码冻结!"); |
| | | } |
| | | if (mesInvItemBarcodes.Visable == 1) throw new Exception("条码冻结!"); |
| | | |
| | | // 8. 检查条码是否作废 |
| | | if (mesInvItemBarcodes.Location == 2) |
| | | { |
| | | throw new Exception("条码作废!"); |
| | | } |
| | | if (mesInvItemBarcodes.Location == 2) throw new Exception("条码作废!"); |
| | | |
| | | // 9. 检查投料单是否需要此物料 |
| | | tempNum = Db.Queryable<Womdab>() |
| | |
| | | it.Dab001 == cDaa001 && it.Dab003 == |
| | | mesInvItemBarcodes.ItemId.ToString()) |
| | | .Count(); |
| | | if (tempNum == 0) |
| | | { |
| | | throw new Exception("投料单不需要此物料!"); |
| | | } |
| | | if (tempNum == 0) throw new Exception("投料单不需要此物料!"); |
| | | |
| | | string sql = |
| | | var sql = |
| | | "SELECT COUNT(1) FROM WOMDAB WHERE DAB001='" + cDaa001 + |
| | | "' AND DAB003='" + mesInvItemBarcodes.ItemId + |
| | | "' AND DAB017=(SELECT DEPOTS_CODE FROM MES_INV_ITEM_STOCKS WHERE ITEM_BARCODE='" + |
| | |
| | | |
| | | // 10. 检查发料仓库是否正确 |
| | | tempNum = Db.Ado.SqlQuerySingle<int>(sql); |
| | | if (tempNum == 0) |
| | | { |
| | | throw new Exception("发料仓库有误!"); |
| | | } |
| | | if (tempNum == 0) throw new Exception("发料仓库有误!"); |
| | | |
| | | // 11. 成功,返回结果 |
| | | return true; |
| | |
| | | |
| | | public decimal? GetBarCodesQuan(WarehouseQuery query) |
| | | { |
| | | if (!PdaProdPickItemCkBar(query.barcode, query.daa001)) |
| | | { |
| | | return null; |
| | | } |
| | | if (!PdaProdPickItemCkBar(query.barcode, query.daa001)) return null; |
| | | |
| | | var invItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(s => s.ItemBarcode == query.barcode).First(); |
| | | |
| | | if (invItemBarcodes == null) |
| | | { |
| | | throw new Exception("条码不存在!"); |
| | | } |
| | | if (invItemBarcodes == null) throw new Exception("条码不存在!"); |
| | | |
| | | return invItemBarcodes.Quantity; |
| | | } |
| | |
| | | }; |
| | | |
| | | // 检查发料数量是否合法 |
| | | if (param.CNum <= 0) |
| | | { |
| | | throw new Exception("发料数量不能小于等于0!"); |
| | | } |
| | | if (param.CNum <= 0) throw new Exception("发料数量不能小于等于0!"); |
| | | |
| | | // 检查条码是否存在 |
| | | param.CInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(it => it.ItemBarcode == param.CBarcode) |
| | | .First(); |
| | | if (param.CInvItemBarcodes == null) |
| | | { |
| | | throw new Exception("条码不存在!"); |
| | | } |
| | | if (param.CInvItemBarcodes == null) throw new Exception("条码不存在!"); |
| | | |
| | | // 检查条码是否已入库 |
| | | param.CInvItemStocks = Db.Queryable<MesInvItemStocks>() |
| | | .Where(it => it.ItemBarcode == param.CBarcode) |
| | | .First(); |
| | | if (param.CInvItemStocks == null) |
| | | { |
| | | throw new Exception("条码未入库!"); |
| | | } |
| | | if (param.CInvItemStocks == null) throw new Exception("条码未入库!"); |
| | | |
| | | // 检查工单号是否存在 |
| | | param.CWomdaa = Db.Queryable<Womdaa>() |
| | | .Where(it => it.Daa001 == param.CDaa001) |
| | | .First(); |
| | | if (param.CWomdaa == null) |
| | | { |
| | | throw new Exception("不存在此工单!"); |
| | | } |
| | | if (param.CWomdaa == null) throw new Exception("不存在此工单!"); |
| | | |
| | | // 检查发料数量是否超出条码数量 |
| | | if (param.CNum > param.CInvItemBarcodes.Quantity) |
| | | { |
| | | throw new Exception("发料数量不能大于条码数量!"); |
| | | } |
| | | |
| | | // 检查条码合法性 |
| | | if (!PdaProdPickItemCkBar(param.CBarcode, param.CDaa001)) |
| | | { |
| | | return null; |
| | | } |
| | | if (!PdaProdPickItemCkBar(param.CBarcode, param.CDaa001)) return null; |
| | | |
| | | // 计算剩余可发数量 |
| | | decimal? tempNum = CalculateRemainingQuantity(param.CDaa001, |
| | | var tempNum = CalculateRemainingQuantity(param.CDaa001, |
| | | param.CInvItemBarcodes.ItemId); |
| | | if (param.CNum > tempNum) |
| | | { |
| | | throw new Exception("发料数量不能大于对应物料的未发料数量!"); |
| | | } |
| | | if (param.CNum > tempNum) throw new Exception("发料数量不能大于对应物料的未发料数量!"); |
| | | |
| | | // 工单部门名称 |
| | | param.CDepart = Db.Queryable<SysDepartment>() |
| | |
| | | { |
| | | string cSupName = null; |
| | | if (!string.IsNullOrEmpty(param.CInvItemBarcodes.SuppNo)) |
| | | { |
| | | cSupName = db.Queryable<MesSupplier>() |
| | | .Where(it => it.SuppNo == param.CInvItemBarcodes.SuppNo) |
| | | .Select(it => it.SuppName) |
| | | .First(); |
| | | } |
| | | |
| | | int cId = |
| | | var cId = |
| | | db.Ado.GetInt( |
| | | "SELECT F_GETSEQNEXTVALUE('MES_RF_PRNBARCODE') FROM dual"); |
| | | |
| | |
| | | .Where(it => it.TaskNo == param.CDaa001 && it.Status == 0) |
| | | .Count(); |
| | | |
| | | int cOutId = 0; |
| | | var cOutId = 0; |
| | | string cOutBill; |
| | | |
| | | if (tempNum == 0) |
| | | { |
| | | string sql = |
| | | var sql = |
| | | "SELECT COUNT(1) FROM MES_INV_ITEM_OUTS WHERE TRUNC(CREATE_DATE)=TRUNC(SYSDATE);"; |
| | | int todayCount = db.Ado.SqlQuerySingle<int>(sql); |
| | | var todayCount = db.Ado.SqlQuerySingle<int>(sql); |
| | | |
| | | cOutBill = $"P{DateTime.Now:yyyyMMdd}{(todayCount + 1):D4}"; |
| | | cOutBill = $"P{DateTime.Now:yyyyMMdd}{todayCount + 1:D4}"; |
| | | |
| | | // 插入新的出库单 |
| | | db.Insertable(new MesInvItemOuts |
| | |
| | | it.ItemOutId == cOutId) |
| | | .Count(); |
| | | |
| | | decimal? cNumTemp = param.CNum; |
| | | var cNumTemp = param.CNum; |
| | | |
| | | string sql = |
| | | var sql = |
| | | "SELECT B.Id, NVL(A.YF, 0) yfl, B.DAB006 - NVL(A.YF, 0) Qty FROM WOMDAB B LEFT JOIN (SELECT SUM(QUANTITY) YF, ITEM_DABID FROM MES_INV_ITEM_OUT_ITEMS GROUP BY ITEM_DABID) A ON A.ITEM_DABID = B.ID WHERE DAB003 = '" + |
| | | param.CInvItemBarcodes.ItemId + "' AND DAB001 = '" + param.CDaa001 + |
| | | "' ORDER BY TO_NUMBER(DAB002)"; |
| | |
| | | if (cNumTemp <= item.Qty) |
| | | { |
| | | if (tempNum == 0) |
| | | { |
| | | // 插入新的发料记录 |
| | | db.Insertable(new MesInvItemOutItems |
| | | { |
| | |
| | | DepotSectionCode = |
| | | param.CInvItemStocks.DepotSectionsCode |
| | | }).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | // 更新现有发料记录的数量 |
| | | db.Updateable<MesInvItemOutItems>() |
| | | .SetColumns(it => new MesInvItemOutItems |
| | |
| | | it.ItemOutId == cOutId && |
| | | it.ItemDabid == itemDabid) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // 更新 WOMDAB 表的发料数量 |
| | | db.Updateable<Womdab>() |
| | |
| | | private string GenerateNewBarcode(string oldBarcode) |
| | | { |
| | | // 生成新的条码逻辑 |
| | | int count = Db.Queryable<MesInvItemBarcodes>() |
| | | var count = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(b => b.OldItemBarcode == oldBarcode).Count(); |
| | | return $"{oldBarcode}-{count + 1}"; |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | if (pId == null) |
| | | { |
| | | return null; |
| | | } |
| | | if (pId == null) return null; |
| | | |
| | | // 查询物料名称 |
| | | string itemName = Db.Queryable<MesItems>() |
| | | var itemName = Db.Queryable<MesItems>() |
| | | .Where(it => it.Id == pId) |
| | | .Select(it => it.ItemName) |
| | | .First(); |
| | |
| | | { |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(pId)) |
| | | { |
| | | return null; |
| | | } |
| | | if (string.IsNullOrEmpty(pId)) return null; |
| | | |
| | | // 查询单位名称是否存在 |
| | | int tempNum = Db.Queryable<MesUnit>() |
| | | var tempNum = Db.Queryable<MesUnit>() |
| | | .Where(it => it.Id.ToString() == pId) |
| | | .Count(); |
| | | |
| | | string unitName; |
| | | |
| | | if (tempNum != 0) |
| | | { |
| | | // 如果在 MES_UNIT 表中找到单位名称 |
| | | unitName = Db.Queryable<MesUnit>() |
| | | .Where(it => it.Id.ToString() == pId) |
| | | .Select(it => it.Fname) |
| | | .First(); |
| | | } |
| | | else |
| | | { |
| | | // 如果在 MES_UNIT 表中找不到,在 MES_ITEMS 表中查找相关联的单位名称 |
| | | unitName = Db.Queryable<MesItems, MesUnit>((i, u) => |
| | | new JoinQueryInfos( |
| | |
| | | .Where((i, u) => i.Id.ToString() == pId) |
| | | .Select((i, u) => u.Fname) |
| | | .First(); |
| | | } |
| | | |
| | | return unitName; |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | if (pId == null) |
| | | { |
| | | return null; |
| | | } |
| | | if (pId == null) return null; |
| | | |
| | | // 查询物料规格 |
| | | string itemModel = Db.Queryable<MesItems>() |
| | | var itemModel = Db.Queryable<MesItems>() |
| | | .Where(it => it.Id == pId) |
| | | .Select(it => it.ItemModel) |
| | | .First(); |