| | |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.entity.Base; |
| | | using NewPdaSqlServer.util; |
| | | using OracleInternal.Sharding; |
| | | using SqlSugar; |
| | |
| | | /// </summary> |
| | | /// <param name="query">仓库查询参数</param> |
| | | /// <returns>物料明细列表</returns> |
| | | public List<ItemDetailModel> GetMesItemDetailByBillNo( |
| | | WarehouseQuery query) |
| | | public dynamic GetMesItemDetailByBillNo(dynamic query) |
| | | { |
| | | // 关联查询物料表、物料明细表和物料基础信息表 |
| | | var mesItemTblDetails = Db |
| | | .Queryable<SalesReturnNotice, SalesReturnNoticeDetail, MesItems>( |
| | | (a, b, c) => new JoinQueryInfos( |
| | | JoinType.Left, |
| | | a.Id == b.Pid, |
| | | JoinType.Left, |
| | | b.MaterialId == c.Id.ToString()) |
| | | ).Where((a, b, c) => a.BillNo == query.billNo && a.CheckStatus == true) |
| | | .Select<ItemDetailModel>((a, b, c) => new ItemDetailModel |
| | | if (string.IsNullOrEmpty(query.billNo)) |
| | | throw new Exception("请选单据号!"); |
| | | |
| | | if (query == null) |
| | | throw new ArgumentNullException(nameof(query), "参数对象不能为null"); |
| | | |
| | | if (string.IsNullOrEmpty(query.billNo?.ToString())) |
| | | throw new ArgumentException("单据号不能为空", nameof(query.billNo)); |
| | | |
| | | // 获取未完成的销售退货明细 |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@billNo", query.billNo), |
| | | new SugarParameter("@pi_orgId",null), |
| | | 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 Get_Mes_Item_Detail_By_BillNo @billNo,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 待扫物料 |
| | | var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 已扫物料 |
| | | return new |
| | | { |
| | | ItemNo = c.ItemNo, |
| | | ItemName = c.ItemName, |
| | | ItemModel = c.ItemModel, |
| | | FQty = b.SqQty, // 申请数量 |
| | | SQty = b.YsQty, // 已扫数量 |
| | | Pid = b.Pid.ToString(), |
| | | FMaterialId = b.MaterialId, |
| | | Id = b.Id.ToString() |
| | | }).ToList(); |
| | | |
| | | // 筛选出待退数量大于已退数量的记录 |
| | | //var itemTblDetails = mesItemTblDetails |
| | | // .Where(s => (s.Tld005 ?? 0) - (s.Tld006 ?? 0) > 0).ToList(); |
| | | |
| | | return mesItemTblDetails; |
| | | items = items, |
| | | ysitems = ysitems, |
| | | Count = items.Count + ysitems.Count |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 保留原有异常处理逻辑 |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |