| | |
| | | using Masuit.Tools; |
| | | using MES.Service.Modes; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using Masuit.Tools; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.entity.Base; |
| | | using NewPdaSqlServer.util; |
| | | using SqlSugar; |
| | | using SqlSugar.Extensions; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | |
| | | namespace NewPdaSqlServer.service.Warehouse; |
| | | |
| | |
| | | /// 获取生产发货通知单号列表 |
| | | /// </summary> |
| | | /// <returns>发货通知单号列表</returns> |
| | | public List<string> GetFHTZBillNo(WarehouseQuery query) |
| | | public dynamic GetFHTZBillNo(dynamic query, dynamic RequestInfo) |
| | | { |
| | | var list = Db.Queryable<SalesDeliver>() |
| | | .Where(s => (s.FApproverStatus ?? false) == true) |
| | | .Select(s => s.BillNo) |
| | | .ToList(); |
| | | return list; |
| | | var orgId = RequestInfo.OrgId; |
| | | |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | // 获取未完成的退料单号列表 |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | try |
| | | { |
| | | // 返回单号字符串列表Get_Qt_ck_List |
| | | var blDetails = Db.Ado.SqlQuery<string>( |
| | | "EXEC prc_pda_xsck_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", |
| | | parameters); |
| | | return blDetails; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据发货通知单获取对应代发货明细 prc_rf_pda_scan_zout_showbl |
| | | /// </summary> |
| | | /// <returns>发货通知单明细列表</returns> |
| | | public List<ItemDetailModel> GetMesItemFHTZetailByBillNo( |
| | | WarehouseQuery query) |
| | | public dynamic GetMesItemFHTZetailByBillNo(dynamic query, |
| | | dynamic RequestInfo) |
| | | { |
| | | if (string.IsNullOrEmpty(query.billNo)) |
| | | throw new Exception("请选单据号!"); |
| | | |
| | | // 检查发货通知单是否存在且审核 |
| | | var mesItem = Db.Queryable<SalesDeliver>() |
| | | .Where(a => a.BillNo == query.billNo && a.FApproverStatus == true) |
| | | .First(); |
| | | if (query == null) |
| | | throw new ArgumentNullException(nameof(query), "参数对象不能为null"); |
| | | |
| | | if (mesItem == null) |
| | | throw new Exception("单据号不存在或未审核!"); |
| | | if (string.IsNullOrEmpty(query.billNo?.ToString())) |
| | | throw new ArgumentException("单据号不能为空", nameof(query.billNo)); |
| | | |
| | | if (mesItem.FinishStatus == true) |
| | | throw new Exception("单据号已完结!"); |
| | | var orgId = RequestInfo.OrgId; |
| | | |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | // 获取未完成的发货通知单明细 |
| | | var blDetails = Db.Queryable<SalesDeliver, SalesDeliverDetail, SalesOrderDetail,MesItems>((a, b, c, d) => |
| | | new JoinQueryInfos(JoinType.Left, a.Id == b.Pid, |
| | | JoinType.Left, b.SalesDetailId == c.Id, |
| | | JoinType.Left, c.MaterialId == d.ItemId.ToString())) |
| | | .Where((a, b) => a.BillNo == query.billNo |
| | | && (b.FMustQty ?? 0) - (b.FRealQty ?? 0) > 0) |
| | | .Select((a, b, c, d) => new ItemDetailModel |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@billNo", query.billNo), |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | try |
| | | { |
| | | var blDetails = Db.Ado.SqlQuery<dynamic>( |
| | | "EXEC prc_pda_xsck_detailList @billNo,@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(); // 已扫物料 |
| | | return new |
| | | { |
| | | ItemNo = d.ItemNo, |
| | | ItemName = d.ItemName, |
| | | ItemModel = d.ItemModel, |
| | | FQty = b.FMustQty, |
| | | SQty = b.FRealQty, |
| | | FMaterialId = d.ItemId.ToString(), |
| | | Id = b.Id.ToString() |
| | | |
| | | }) |
| | | .ToList(); |
| | | |
| | | return blDetails; |
| | | items, ysitems |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 保留原有异常处理逻辑 |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生产工单补料扫码 |
| | | /// 生产工单补料扫码 |
| | | /// 扫描条码 prc_rf_pda_scan_zout_barcode3 |
| | | /// </summary> |
| | | /// <param name="query">查询参数</param> |
| | |
| | | /// - userName: 用户名 |
| | | /// - blNo: 发货通知单号(必填) |
| | | /// </remarks> |
| | | public ProductionPickDto XSCKScanBarcode( WarehouseQuery query) |
| | | public ProductionPickDto XSCKScanBarcode(WarehouseQuery query) |
| | | { |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | if (query.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空"); |
| | | if (query.daa001.IsNullOrEmpty()) throw new Exception("发货通知单号不允许为空"); |
| | | if (query.daa001.IsNullOrEmpty()) |
| | | throw new Exception("发货通知单号不允许为空"); |
| | | if (query.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空"); |
| | | |
| | | using (var cmd = new SqlCommand("[prc_pda_XSCK]", conn)) |
| | |
| | | |
| | | var outNoType = ""; |
| | | if (query.Type == "生产补料") |
| | | { |
| | | outNoType = "SCBL(生产补料)"; |
| | | } |
| | | else |
| | | { |
| | | outNoType = "SCCL(生产超领)"; |
| | | } |
| | | |
| | | // 开启事务处理 |
| | | var success = UseTransaction(db => |
| | |
| | | Status = 0, |
| | | DepotId = stockBarcode.DepotId, |
| | | THORGID = stockBarcode.StockOrgId, |
| | | OutType = query.Type, |
| | | OutType = query.Type |
| | | //BbillNo = query.blNo |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | |
| | | PbillNo = query.billNo, |
| | | ItemId = blDetail.Bld012, |
| | | DepotId = stockBarcode.DepotId.ToString(), |
| | | ItemDabid = womdab.Guid, |
| | | ItemDabid = womdab.Guid |
| | | // Unit = blDetail.Bld009, |
| | | // DepotId = (int)stockBarcode.DepotsId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | |
| | | executeCommand += db.Updateable<MesInvItemOutItems>() |
| | | .SetColumns(it => it.TlQty == (it.TlQty ?? 0) + query.Num) |
| | | .Where(it => |
| | | it.ItemOutId == outId && |
| | | it.ItemId == stockBarcode.ItemId && |
| | | it.DepotId == stockBarcode.DepotId.ToString()) |
| | | it.ItemOutId == outId && |
| | | it.ItemId == stockBarcode.ItemId && |
| | | it.DepotId == stockBarcode.DepotId.ToString()) |
| | | .ExecuteCommand(); |
| | | |
| | | // 插入出库条码明细 |
| | |
| | | ItemId = blDetail.Bld012, |
| | | Unit = blDetail.Bld009, |
| | | DepotId = (int)stockBarcode.DepotsId, |
| | | Dabid = womdab.Guid, |
| | | Dabid = womdab.Guid |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | |
| | | // 插入业务流水 |
| | |
| | | Dab020 = (it.Dab020 ?? 0) + query.Num, // 已发料数量 |
| | | Dab021 = (it.Dab021 ?? 0) + query.Num // 已发料数量 |
| | | }) |
| | | .Where(it => it.Guid == womdab.Guid && it.Dab003 == womdab.Dab003) |
| | | .Where(it => |
| | | it.Guid == womdab.Guid && it.Dab003 == womdab.Dab003) |
| | | .ExecuteCommand(); |
| | | |
| | | // 更新发货通知单明细已补数量 |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |