| | |
| | | if (p_section_code.IsNullOrEmpty()) throw new Exception("请扫库位条码!"); |
| | | |
| | | // 获取库位信息 |
| | | var c_depot_code = Db.Queryable<MesDepotSections, MesDepots>((a, b) => |
| | | new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid)) |
| | | .Where((a, b) => a.DepotSectionCode == p_section_code) |
| | | .Select((a, b) => b.DepotId).First(); |
| | | int? c_depot_code; |
| | | try |
| | | { |
| | | c_depot_code = Db.Queryable<MesDepotSections, MesDepots>((a, b) => |
| | | new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid)) |
| | | .Where((a, b) => a.DepotSectionCode == p_section_code) |
| | | .Select((a, b) => b.DepotId).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"库位编码 {p_section_code} 不存在,请确认!"); |
| | | } |
| | | |
| | | if (!c_depot_code.HasValue) |
| | | throw new Exception("库位编码" + p_section_code + " 不存在,请确认!"); |
| | | MesDepotSections mesDepotSections; |
| | | try |
| | | { |
| | | mesDepotSections = Db.Queryable<MesDepotSections>() |
| | | .Where(a => a.DepotSectionCode == p_section_code).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"库位编码 {p_section_code} 不存在,请确认!"); |
| | | } |
| | | |
| | | // 获取库位分区信息 |
| | | var mesDepotSections = Db.Queryable<MesDepotSections>() |
| | | .Where(a => a.DepotSectionCode == p_section_code).First(); |
| | | |
| | | if (mesDepotSections == null) |
| | | throw new Exception("库位编码" + p_section_code + " 不存在,请确认!"); |
| | | |
| | | // 获取库位基础信息 |
| | | var c_mes_depots = Db.Queryable<MesDepots>() |
| | | .Where(b => b.Guid == mesDepotSections.DepotGuid).First(); |
| | | |
| | | if (c_mes_depots == null) |
| | | throw new Exception("库位编码" + p_section_code + " 不存在,请确认!"); |
| | | MesDepots c_mes_depots; |
| | | try |
| | | { |
| | | c_mes_depots = Db.Queryable<MesDepots>() |
| | | .Where(b => b.Guid == mesDepotSections.DepotGuid).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"库位编码 {p_section_code} 对应的仓库不存在,请确认!"); |
| | | } |
| | | |
| | | // 检查条码是否已入库 |
| | | var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) => |
| | |
| | | if (c_num > 0) throw new Exception("此条码已扫入库,勿重复扫描!"); |
| | | |
| | | // 获取条码信息 |
| | | var c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(t => t.ItemBarcode == p_item_barcode).First(); |
| | | |
| | | if (c_mes_inv_item_barcodes == null) |
| | | throw new Exception("此条码不属于该退料单,请核对!"); |
| | | MesInvItemBarcodes c_mes_inv_item_barcodes; |
| | | try |
| | | { |
| | | c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(t => t.ItemBarcode == p_item_barcode).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"条码 {p_item_barcode} 不属于该退料单,请核对!"); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | // throw new Exception("此条码不是生产退料条码,不可使用生产退料模块!"); |
| | | |
| | | // 获取退料单信息 |
| | | var C_MES_ITEM_TBL = Db.Queryable<MesItemTbl>() |
| | | .Where(a => a.BillNo == c_mes_inv_item_barcodes.BillNo |
| | | && (a.Tbl013 ?? 0) == 1).First(); |
| | | |
| | | if (C_MES_ITEM_TBL == null) throw new Exception("申请单已撤回,无法扫码!"); |
| | | MesItemTbl C_MES_ITEM_TBL; |
| | | try |
| | | { |
| | | C_MES_ITEM_TBL = Db.Queryable<MesItemTbl>() |
| | | .Where(a => a.BillNo == c_mes_inv_item_barcodes.BillNo |
| | | && (a.Tbl013 ?? 0) == 1).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"申请单 {c_mes_inv_item_barcodes.BillNo} 已撤回或不存在,无法扫码!"); |
| | | } |
| | | |
| | | if (C_MES_ITEM_TBL.Tbl020 == 1) throw new Exception("扫码完成,申请单已完结!"); |
| | | |
| | | // 检查工单信息 |
| | | var wwgd = Db.Queryable<WwGd>() |
| | | .Where(a => a.Id.ToString() == C_MES_ITEM_TBL.Tbl002) |
| | | .First(); |
| | | WwGd wwgd; |
| | | try |
| | | { |
| | | wwgd = Db.Queryable<WwGd>() |
| | | .Where(a => a.Id.ToString() == C_MES_ITEM_TBL.Tbl002) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"申请单对应的工单不存在或已删除,单据号:{C_MES_ITEM_TBL.Tbl002},无法扫码!"); |
| | | } |
| | | |
| | | if (wwgd == null) throw new Exception("申请单对应的工单不存在或已删除,无法扫码!"); |
| | | |
| | | // 检查工单信息 |
| | | var WWRWD = Db.Queryable<ProductionOrder>() |
| | | .Where(a => a.OrderNo == wwgd.Daa014) |
| | | .First(); |
| | | // 检查生产订单信息 |
| | | ProductionOrder WWRWD; |
| | | try |
| | | { |
| | | WWRWD = Db.Queryable<ProductionOrder>() |
| | | .Where(a => a.OrderNo == wwgd.Daa014) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"工单 {wwgd.Daa014} 对应的生产订单不存在,请确认!"); |
| | | } |
| | | |
| | | // 获取退料单明细 |
| | | var C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>() |
| | | .Where(a => a.Tlid == c_mes_inv_item_barcodes.AboutGuid) |
| | | .First(); |
| | | |
| | | if (C_MES_ITEM_TBL_DETAIL == null) |
| | | throw new Exception("条码不属于该申请单明细,无法扫码!"); |
| | | MesItemTblDetail C_MES_ITEM_TBL_DETAIL; |
| | | try |
| | | { |
| | | C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>() |
| | | .Where(a => a.Tlid == c_mes_inv_item_barcodes.AboutGuid) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"条码 {p_item_barcode} 不属于该申请单明细,无法扫码!"); |
| | | } |
| | | |
| | | //判断货主信息 |
| | | var CABerpid = Db.Queryable<WwGdDetail>().Where(womdab => womdab.Id.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013).Select(womdab => womdab.Erpid).First(); |
| | | int? CABerpid; |
| | | try |
| | | { |
| | | CABerpid = Db.Queryable<WwGdDetail>() |
| | | .Where(womdab => womdab.Id.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013) |
| | | .Select(womdab => womdab.Erpid) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"用料清单明细不存在,明细ID:{C_MES_ITEM_TBL_DETAIL.Tld013},请联系管理员!"); |
| | | } |
| | | |
| | | var WWCAB = Db.Queryable<ProductionOrderSub>().Where(womcab => womcab.ErpId == CABerpid.Value.ToString()).First(); |
| | | if (!CABerpid.HasValue) |
| | | throw new Exception("用料清单ERP ID为空,请联系管理员!"); |
| | | |
| | | ProductionOrderSub WWCAB; |
| | | try |
| | | { |
| | | WWCAB = Db.Queryable<ProductionOrderSub>() |
| | | .Where(womcab => womcab.ErpId == CABerpid.Value.ToString()) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"生产订单子项不存在,ERP ID:{CABerpid.Value},请联系管理员!"); |
| | | } |
| | | |
| | | if ( String.IsNullOrEmpty(WWCAB.Owner)) throw new Exception("用料清单货主信息不存在,无法扫码,请联系管理员!"); |
| | | if (string.IsNullOrEmpty(WWCAB.Owner)) |
| | | throw new Exception($"用料清单货主信息不存在,生产订单子项 ERP ID:{CABerpid.Value},无法扫码,请联系管理员!"); |
| | | |
| | | //var owner_type = ""; |
| | | //if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId)) |