| | |
| | | using Masuit.Tools; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Threading.Tasks.Dataflow; |
| | | using Masuit.Tools; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.entity.Base; |
| | | using NewPdaSqlServer.util; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Threading.Tasks.Dataflow; |
| | | using DbHelperSQL = NewPdaSqlServer.DB.DbHelperSQL; |
| | | |
| | | namespace NewPdaSqlServer.service.Wom; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取库位信息 |
| | | /// </summary> |
| | | /// <param name="unity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public dynamic GetBarKwByItem(dynamic unity) |
| | | public ProductionPickDto GetItemsByDaa001(WarehouseQuery query) |
| | | { |
| | | if (unity == null) |
| | | throw new ArgumentNullException(nameof(unity), "参数对象不能为null"); |
| | | return getDaa001(query); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(unity.itemId?.ToString())) |
| | | throw new ArgumentException("物料ID不能为空", nameof(unity.itemId)); |
| | | private ProductionPickDto getDaa001(WarehouseQuery query) |
| | | { |
| | | if (string.IsNullOrEmpty(query.daa001)) throw new Exception("工单号为空"); |
| | | |
| | | try |
| | | { |
| | | var parameters = new List<SugarParameter> |
| | | var wwgd = Db.Queryable<WwGd, MesItems>((a, i) => |
| | | new JoinQueryInfos(JoinType.Left, |
| | | a.Daa003 == i.ItemId)) |
| | | .Where((a, i) => a.Daa001 == query.daa001 && (a.PcSh ?? 0) == 1) |
| | | .Select((a, i) => new |
| | | { |
| | | new SugarParameter("@itemId",unity.itemId) |
| | | }; |
| | | a.Daa001, a.RwdGuid |
| | | }).First(); |
| | | |
| | | return Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_scll_selBarMx @itemId", parameters); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"获取条码信息失败:{ex.Message}"); |
| | | } |
| | | if (wwgd?.Daa001 == null) throw new Exception("工单号不存在"); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选取列表 |
| | | /// </summary> |
| | | /// <param name="unity"></param> |
| | | /// <param name="RequestInfo"></param> |
| | | /// <returns></returns> |
| | | public dynamic GetXcslDaa(dynamic unity, dynamic RequestInfo) |
| | | { |
| | | var orgId = RequestInfo.OrgId; |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new SugarParameter("@selectKey", unity.selectKey), |
| | | new SugarParameter("@inP1", orgId), // 可选参数 |
| | | new SugarParameter("@inP2", unity.selDaaType), // 可选参数 |
| | | new SugarParameter("@inP3", null), // 可选参数 |
| | | new SugarParameter("@inP4", null), // 可选参数 |
| | | // ...其他可选参数 |
| | | }; |
| | | var result = Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_wwll_list @selectKey, @inP1, @inP2, @inP3, @inP4", parameters); |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 列表明细 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <param name="RequestInfo"></param> |
| | | /// <returns></returns> |
| | | public dynamic GetItemsByDaa001(WarehouseQuery query, dynamic RequestInfo) |
| | | { |
| | | return getDaa001(query, RequestInfo); |
| | | } |
| | | |
| | | private dynamic getDaa001(WarehouseQuery query, dynamic RequestInfo) |
| | | { |
| | | if (string.IsNullOrEmpty(query.daa001)) throw new Exception("请选工单号!"); |
| | | if (query == null) |
| | | throw new ArgumentNullException(nameof(query), "参数对象不能为null"); |
| | | if (string.IsNullOrEmpty(query.daa001?.ToString())) |
| | | throw new ArgumentException("工单号不存在", nameof(query.daa001)); |
| | | |
| | | var orgId = RequestInfo.OrgId; |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@daa001", query.daa001), |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | try |
| | | { |
| | | List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>( |
| | | "EXEC prc_pda_wwll_detailList @daa001,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 待扫物料 |
| | | var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 已扫物料 |
| | | var planNo = blDetails.FirstOrDefault()?.ErpProductionOrderNo?.ToString();// 获取工单计划号 |
| | | return new |
| | | var womdabs = Db |
| | | .Queryable<WwGd, WwGdDetail, MesItems, ProductionOrderSub>( |
| | | (a, b, c, d) => |
| | | new JoinQueryInfos( |
| | | JoinType.Left, |
| | | a.Id == b.Pid, |
| | | JoinType.Inner, |
| | | c.Id == b.Dab003, |
| | | JoinType.Inner, b.Erpid.ToString() == d.ErpId |
| | | )) |
| | | .Where((a, b, c, d) => |
| | | a.Daa001 == query.daa001 ) |
| | | .Select((a, b, c, d) => new WwGdDetail |
| | | { |
| | | daa001 = query.daa001, |
| | | PlanNo = planNo, |
| | | items = items, |
| | | ysitems = ysitems |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | Pid = b.Pid, |
| | | Dab003 = b.Dab003, |
| | | Dab006 = b.Dab006, |
| | | Dab007 = b.Dab007, |
| | | wNum = b.Dab006 - b.Dab007, // 计算字段 W_NUM |
| | | ItemName = c.ItemName, // 动态字段 ITEM_NAME |
| | | ItemNo = c.ItemNo // 动态字段 ITEM_NO |
| | | }) |
| | | .ToList(); |
| | | |
| | | var list = womdabs.Where(s => s.wNum > 0).ToList(); |
| | | |
| | | var mesInvItemOutCDetailsList = Db |
| | | .Queryable<MesInvItemOutCDetails, MesItems, MesDepots> |
| | | ((a, b, c) => |
| | | new JoinQueryInfos( |
| | | JoinType.Inner, a.ItemId == b.Id, |
| | | JoinType.Inner, c.DepotId == a.DepotId |
| | | )) |
| | | .Where((a, b, c) => a.WorkNo == query.daa001) |
| | | .Select((a, b, c) => new MesInvItemOutCDetails |
| | | { |
| | | ItemName = b.ItemName, |
| | | ItemNo = b.ItemNo, |
| | | ItemId = a.ItemId, |
| | | DepotId = a.DepotId, |
| | | WorkNo = a.WorkNo, |
| | | DepotName = c.DepotName, |
| | | Quantity = a.Quantity |
| | | }) |
| | | .ToList(); |
| | | |
| | | var womcaa = Db.Queryable<ProductionOrder>() |
| | | .Where(s => s.Guid == wwgd.RwdGuid) |
| | | .First(); |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | daa001 = wwgd.Daa001, |
| | | PlanNo = womcaa.ErpProductionOrderNo, |
| | | totals1 = womdabs, |
| | | daisao1 = list, |
| | | yisao = mesInvItemOutCDetailsList |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | #region 委外退料 |
| | |
| | | if (p_section_code.IsNullOrEmpty()) throw new Exception("请扫库位条码!"); |
| | | |
| | | // 获取库位信息 |
| | | 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} 不存在,请确认!"); |
| | | } |
| | | 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(); |
| | | |
| | | MesDepotSections mesDepotSections; |
| | | try |
| | | { |
| | | mesDepotSections = Db.Queryable<MesDepotSections>() |
| | | .Where(a => a.DepotSectionCode == p_section_code).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"库位编码 {p_section_code} 不存在,请确认!"); |
| | | } |
| | | if (!c_depot_code.HasValue) |
| | | 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 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 + " 不存在,请确认!"); |
| | | |
| | | // 检查条码是否已入库 |
| | | var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) => |
| | |
| | | if (c_num > 0) 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} 不属于该退料单,请核对!"); |
| | | } |
| | | 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("此条码不属于该退料单,请核对!"); |
| | | |
| | | |
| | | |
| | |
| | | // 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} 已撤回或不存在,无法扫码!"); |
| | | } |
| | | 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("申请单已撤回,无法扫码!"); |
| | | |
| | | if (C_MES_ITEM_TBL.Tbl020 == 1) throw new Exception("扫码完成,申请单已完结!"); |
| | | |
| | | // 检查工单信息 |
| | | 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},无法扫码!"); |
| | | } |
| | | var wwgd = Db.Queryable<WwGd>() |
| | | .Where(a => a.Id.ToString() == C_MES_ITEM_TBL.Tbl002) |
| | | .First(); |
| | | |
| | | // 检查生产订单信息 |
| | | ProductionOrder WWRWD; |
| | | try |
| | | { |
| | | WWRWD = Db.Queryable<ProductionOrder>() |
| | | .Where(a => a.OrderNo == wwgd.Daa014) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception($"工单 {wwgd.Daa014} 对应的生产订单不存在,请确认!"); |
| | | } |
| | | if (wwgd == null) throw new Exception("申请单对应的工单不存在或已删除,无法扫码!"); |
| | | |
| | | // 检查工单信息 |
| | | var WWRWD = Db.Queryable<ProductionOrder>() |
| | | .Where(a => a.OrderNo == wwgd.Daa014) |
| | | .First(); |
| | | |
| | | // 获取退料单明细 |
| | | 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 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("条码不属于该申请单明细,无法扫码!"); |
| | | |
| | | //判断货主信息 |
| | | 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 CABerpid = Db.Queryable<WwGdDetail>().Where(womdab => womdab.Id.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013).Select(womdab => womdab.Erpid).First(); |
| | | |
| | | if (!CABerpid.HasValue) |
| | | throw new Exception("用料清单ERP ID为空,请联系管理员!"); |
| | | var WWCAB = Db.Queryable<ProductionOrderSub>().Where(womcab => womcab.ErpId == CABerpid.Value.ToString()).First(); |
| | | |
| | | 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($"用料清单货主信息不存在,生产订单子项 ERP ID:{CABerpid.Value},无法扫码,请联系管理员!"); |
| | | if ( String.IsNullOrEmpty(WWCAB.Owner)) throw new Exception("用料清单货主信息不存在,无法扫码,请联系管理员!"); |
| | | |
| | | //var owner_type = ""; |
| | | //if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId)) |