| | |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using MES.Service.Modes; |
| | | using MES.Service.Modes; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.entity.Base; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | |
| | | namespace NewPdaSqlServer.service.Warehouse; |
| | | |
| | |
| | | /// 获取未完成的调拨出库单号列表 |
| | | /// </summary> |
| | | /// <returns>未完成的调拨出库单号列表</returns> |
| | | public List<string> GetTransferOutNoList(WarehouseQuery query, dynamic RequestInfo) |
| | | public List<string> GetTransferOutNoList(dynamic RequestInfo) |
| | | { |
| | | var orgId = RequestInfo.OrgId; |
| | | |
| | |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据单据号获取待处理的调拨出库明细列表 |
| | |
| | | |
| | | return new |
| | | { |
| | | //tbBillList = result, |
| | | allList = blDetails, |
| | | blDetails = blDetails.Where(x => x.DSQty > 0).ToList(), |
| | | ysDetails = blDetails.Where(x => x.SQty > 0).ToList(), |
| | | Count = items.Count + ysitems.Count |
| | |
| | | |
| | | var barcodeNum = parameters[2].Value.ToString(); |
| | | var splitNum = parameters[3].Value.ToString(); |
| | | |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 一键调拨处理 |
| | | /// </summary> |
| | | /// <param name="query">包含单据号、用户名、条码和库位信息的查询参数</param> |
| | | /// <returns>处理结果</returns> |
| | | public ProductionPickDto ScanYjdb(WarehouseQuery query) |
| | | { |
| | | // 安全获取dynamic属性值,避免空引用异常 |
| | | var p_bill_no = query.billNo?.ToString() ?? string.Empty; |
| | | var p_item_barcode = query.barcode?.ToString() ?? string.Empty; |
| | | var p_kw = query.sectionCode?.ToString() ?? string.Empty; |
| | | var c_user = query.userName?.ToString() ?? string.Empty; |
| | | |
| | | // 验证单据号 |
| | | if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("请选取单据号!"); |
| | | // 验证条码 |
| | | if (string.IsNullOrEmpty(p_item_barcode)) throw new Exception("请扫描条码!"); |
| | | // 验证库位 |
| | | if (string.IsNullOrEmpty(p_kw)) throw new Exception("请选择库位!"); |
| | | // 验证用户名 |
| | | if (string.IsNullOrEmpty(c_user)) throw new Exception("用户名不能为空!"); |
| | | |
| | | // 查询出库单并验证状态 |
| | | var transferOut = Db.Queryable<MesDbck>() |
| | | .Where(x => x.FBillNo == p_bill_no && x.FApproveStatus == 1) |
| | | .First(); |
| | | if (transferOut == null) throw new Exception("未找到调拨申请单或者调拨申请单没审核"); |
| | | |
| | | // 查询条码库存信息并验证 |
| | | var stock = Db.Queryable<MesInvItemStocks>() |
| | | .Where(x => x.ItemBarcode == p_item_barcode |
| | | && x.Quantity > 0) |
| | | .First(); |
| | | if (stock == null) throw new Exception($"库存中无此条码,请核对!{p_item_barcode}"); |
| | | |
| | | // 查询物料信息 |
| | | var item = Db.Queryable<MesItems>() |
| | | .Where(x => x.Id == stock.ItemId) |
| | | .First(); |
| | | if (item == null) throw new Exception("未找到物料"); |
| | | |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | var barcode_num = 0m; |
| | | var split_num = 0m; |
| | | |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_pda_YJDB]", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 2000), |
| | | new("@outSum", SqlDbType.Int), |
| | | new("@barcode_num", SqlDbType.Decimal, 18) { Precision = 18, Scale = 10 }, |
| | | new("@split_num", SqlDbType.Decimal, 18) { Precision = 18, Scale = 10 }, |
| | | new("@c_user", c_user), |
| | | new("@p_bill_no", p_bill_no), |
| | | new("@p_item_barcode", p_item_barcode), |
| | | new("@p_kw", p_kw) |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | parameters[2].Direction = ParameterDirection.Output; |
| | | parameters[3].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | _strMsg = parameters[0].Value?.ToString() ?? ""; |
| | | _intSum = parameters[1].Value?.ToString() ?? ""; |
| | | barcode_num = parameters[2].Value != DBNull.Value ? Convert.ToDecimal(parameters[2].Value) : 0; |
| | | split_num = parameters[3].Value != DBNull.Value ? Convert.ToDecimal(parameters[3].Value) : 0; |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0 && result != 2) throw new Exception(_strMsg); |
| | | |
| | | // 返回处理结果 |
| | | var dto = new ProductionPickDto |
| | | { |
| | | itemNo = item.ItemNo, |
| | | barcodeNum = barcode_num.ToString(), |
| | | splitNum = split_num.ToString(), |
| | | barcode = p_item_barcode, |
| | | strMsg = _strMsg, |
| | | result = _intSum |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 扫描条码进行调拨入库处理 |
| | | /// </summary> |
| | |
| | | |
| | | var barcodeNum = parameters[2].Value.ToString(); |
| | | var outBillNo = parameters[3].Value.ToString(); |
| | | |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | //一键调拨拆分 |
| | | public ProductionPickDto ScanYjdbCF(WarehouseQuery query) |
| | | { |
| | | // 安全获取dynamic属性值,避免空引用异常 |
| | | var p_bill_no = query.daa001?.ToString() ?? string.Empty; |
| | | var p_item_barcode = query.barcode?.ToString() ?? string.Empty; |
| | | var p_kw = query.sectionCode?.ToString() ?? string.Empty; |
| | | var c_user = query.userName?.ToString() ?? string.Empty; |
| | | |
| | | // 验证单据号 |
| | | if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("请选取单据号!"); |
| | | // 验证条码 |
| | | if (string.IsNullOrEmpty(p_item_barcode)) throw new Exception("请扫描条码!"); |
| | | // 验证库位 |
| | | if (string.IsNullOrEmpty(p_kw)) throw new Exception("请选择库位!"); |
| | | // 验证用户名 |
| | | if (string.IsNullOrEmpty(c_user)) throw new Exception("用户名不能为空!"); |
| | | |
| | | // 查询出库单并验证状态 |
| | | var transferOut = Db.Queryable<MesDbck>() |
| | | .Where(x => x.FBillNo == p_bill_no && x.FApproveStatus == 1) |
| | | .First(); |
| | | if (transferOut == null) throw new Exception("未找到调拨申请单或者调拨申请单没审核"); |
| | | |
| | | // 查询条码库存信息并验证 |
| | | var stock = Db.Queryable<MesInvItemStocks>() |
| | | .Where(x => x.ItemBarcode == p_item_barcode |
| | | && x.Quantity > 0) |
| | | .First(); |
| | | if (stock == null) throw new Exception($"库存中无此条码,请核对!{p_item_barcode}"); |
| | | |
| | | // 查询物料信息 |
| | | var item = Db.Queryable<MesItems>() |
| | | .Where(x => x.Id == stock.ItemId) |
| | | .First(); |
| | | if (item == null) throw new Exception("未找到物料"); |
| | | |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | var _cfBar = ""; |
| | | |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_pda_YJDB_CF]", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 2000), |
| | | new("@outSum", SqlDbType.NVarChar, 300), |
| | | new("@outCfBar", SqlDbType.NVarChar, 300), |
| | | new("@c_User", c_user), |
| | | new("@p_biLL_no", p_bill_no), |
| | | new("@p_item_barcode", p_item_barcode), |
| | | new("@num", query.Num), |
| | | new("@p_kw", p_kw) |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | parameters[2].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | _strMsg = parameters[0].Value.ToString(); |
| | | _intSum = parameters[1].Value.ToString(); |
| | | _cfBar = parameters[2].Value.ToString(); |
| | | |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | daa001 = query.daa001, |
| | | barcode = query.barcode,//原条码 |
| | | cfBarcode = _cfBar//拆分后条码 |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |