| | |
| | | using Masuit.Tools.Models; |
| | | using Masuit.Tools.Models; |
| | | using Microsoft.AspNetCore.SignalR.Protocol; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | |
| | | public ItemInBaseModel SaveBarCodes(WarehouseQuery entity) |
| | | { |
| | | ItemInBaseModel res = new ItemInBaseModel(); |
| | | string connectionString = DbHelperSQL.strConn; |
| | | string connectionString = DB.DbHelperSQL.strConn; |
| | | |
| | | // 参数验证 |
| | | if (string.IsNullOrEmpty(entity.userName)) throw new ArgumentNullException(nameof(entity.userName), "用户名不允许为空"); |
| | |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_pda_inv_cgrk]", conn)) |
| | | { |
| | | try |
| | | { |
| | | //try |
| | | //{ |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | |
| | |
| | | new SqlParameter("@pi_user", SqlDbType.NVarChar, 100) { Value = entity.userName }, |
| | | new SqlParameter("@pi_barcode", SqlDbType.NVarChar, 100) { Value = entity.barcode.Trim().ToLower() }, |
| | | new SqlParameter("@pi_sectionCode", SqlDbType.NVarChar, 30) { Value = entity.sectionCode }, |
| | | new SqlParameter("@pi_remark", SqlDbType.NVarChar, 30) { Value = entity.remark }, |
| | | new SqlParameter("@pi_cgrkType", SqlDbType.NVarChar, 30) { Value = "正常入库" }, |
| | | new SqlParameter("@pi_weight", SqlDbType.Decimal) { Value = entity.weight }, |
| | | new SqlParameter("@po_outMsg", SqlDbType.NVarChar, 300) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@po_outSum", SqlDbType.NVarChar, 300) { Direction = ParameterDirection.Output } |
| | |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | // 获取输出参数 |
| | | string? outMessage = parameters[4].Value?.ToString(); |
| | | string? outSum = parameters[5].Value?.ToString(); |
| | | string? outMessage = parameters[5].Value?.ToString(); |
| | | string? outSum = parameters[6].Value?.ToString(); |
| | | |
| | | |
| | | // 检查参数是否为空,并在异常中显示实际值 |
| | |
| | | |
| | | |
| | | return res; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | |
| | | |
| | | // 记录异常日志(建议添加日志记录) |
| | | res.Message = $"操作失败: {ex.Message}"; |
| | | res.SumQuantity = -1; |
| | | return res; |
| | | } |
| | | // // 记录异常日志(建议添加日志记录) |
| | | // res.Message = $"操作失败: {ex.Message}"; |
| | | // res.SumQuantity = -1; |
| | | // return res; |
| | | //} |
| | | } |
| | | } |
| | | } |
| | |
| | | }; |
| | | } |
| | | |
| | | public dynamic WcsmBar(WarehouseQuery entity) |
| | | { |
| | | if (entity == null) throw new ArgumentNullException(nameof(entity), "参数对象不能为 null"); |
| | | |
| | | // 参数校验 |
| | | if (string.IsNullOrEmpty(entity.userName?.ToString())) |
| | | throw new ArgumentException("操作人员不允许为空", nameof(entity.userName)); |
| | | |
| | | if (string.IsNullOrEmpty(entity.barcode?.ToString())) |
| | | throw new ArgumentException("条码不允许为空", nameof(entity.barcode)); |
| | | |
| | | var _strMsg = ""; |
| | | var _status = -1; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("prc_pda_wcsm", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | // 根据存储过程设置参数 |
| | | SqlParameter[] parameters = |
| | | { |
| | | new SqlParameter("@pi_user", SqlDbType.NVarChar, 100) { Value = entity.userName }, |
| | | new SqlParameter("@pi_barcode", SqlDbType.NVarChar, 100) { Value = entity.barcode }, |
| | | new SqlParameter("@pi_sectionCode", SqlDbType.NVarChar, 100) { Value = entity.sectionCode == null ? DBNull.Value : (object)entity.sectionCode }, |
| | | new SqlParameter("@pi_IN1", SqlDbType.NVarChar, 30) { Value = DBNull.Value }, // 备用字段1 |
| | | new SqlParameter("@pi_IN2", SqlDbType.NVarChar, 30) { Value = DBNull.Value }, // 备用字段2 |
| | | new SqlParameter("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output } |
| | | }; |
| | | |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | _strMsg = parameters[5].Value?.ToString() ?? ""; |
| | | _status = Convert.ToInt32(parameters[6].Value ?? -1); |
| | | |
| | | if (_status <= 0) throw new Exception(_strMsg); |
| | | |
| | | return new |
| | | { |
| | | message = _strMsg, |
| | | status = _status, |
| | | userName = entity.userName, |
| | | barcode = entity.barcode, |
| | | sectionCode = entity.sectionCode |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"外仓扫码入库失败:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public dynamic WcsmDetail(WarehouseQuery entity) |
| | | { |
| | | if (entity == null) throw new ArgumentNullException(nameof(entity), "参数对象不能为 null"); |
| | | |
| | | // 参数校验 |
| | | if (string.IsNullOrEmpty(entity.barcode?.ToString())) |
| | | throw new ArgumentException("条码不允许为空", nameof(entity.barcode)); |
| | | |
| | | // 使用ADO.NET直接调用存储过程 |
| | | var ds = new DataSet(); |
| | | |
| | | // 假设您使用的是SQL Server,创建SqlConnection |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | conn.Open(); |
| | | |
| | | using (var cmd = new SqlCommand("prc_pda_wcsm_detailList", conn)) |
| | | { |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | |
| | | // 添加参数 |
| | | cmd.Parameters.Add(new SqlParameter("@daa001", entity.barcode)); |
| | | cmd.Parameters.Add(new SqlParameter("@pi_orgId", DBNull.Value)); |
| | | cmd.Parameters.Add(new SqlParameter("@inP1", DBNull.Value)); |
| | | cmd.Parameters.Add(new SqlParameter("@inP2", DBNull.Value)); |
| | | cmd.Parameters.Add(new SqlParameter("@inP3", DBNull.Value)); |
| | | cmd.Parameters.Add(new SqlParameter("@inP4", DBNull.Value)); |
| | | |
| | | using (var adapter = new System.Data.SqlClient.SqlDataAdapter(cmd)) |
| | | { |
| | | adapter.Fill(ds); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 验证结果集数量 |
| | | if (ds.Tables.Count < 4) |
| | | { |
| | | throw new ApplicationException($"存储过程返回的结果集数量不足,期望4个,实际{ds.Tables.Count}个"); |
| | | } |
| | | |
| | | // 转换结果(统一使用ds) |
| | | var unscannedList = Db.Utilities.DataTableToDynamic(ds.Tables[0]); |
| | | var otherUnscannedList = Db.Utilities.DataTableToDynamic(ds.Tables[1]); |
| | | var scanProgressList = Db.Utilities.DataTableToDynamic(ds.Tables[2]); |
| | | var daaInfo = Db.Utilities.DataTableToDynamic(ds.Tables[3]); |
| | | |
| | | return new |
| | | { |
| | | unscannedList, |
| | | otherUnscannedList, |
| | | scanProgressList, |
| | | daaInfo |
| | | }; |
| | | } |
| | | |
| | | public (List<MesInvItemIns> Items, int TotalCount) GetInvItemInsList( |
| | | WarehouseQuery query) |
| | | { |
| | |
| | | if (string.IsNullOrEmpty(entity.sectionCode)) throw new ArgumentNullException(nameof(entity.sectionCode), "库位编号不允许为空"); |
| | | if (string.IsNullOrEmpty(entity.returnBarcode)) throw new ArgumentNullException(nameof(entity.returnBarcode), "条码不允许为空"); |
| | | |
| | | try |
| | | { |
| | | //try |
| | | //{ |
| | | // 检查条码是否已入库 |
| | | var isInStock = Db.Queryable<MesInvItemInCDetails>() |
| | | .Where(it => it.ItemBarcode == entity.returnBarcode) |
| | |
| | | .Where(it => it.ItemBarcode.Trim().ToLower() == entity.returnBarcode.Trim().ToLower()) |
| | | .First() ?? throw new InvalidOperationException($"未找到条码 '{entity.returnBarcode}' 的匹配信息"); |
| | | |
| | | // 获取到货明细ID(假设从条码信息中可以获取到dhmxGuid) |
| | | var dhmxGuid = itemBarcode.AboutGuid; |
| | | |
| | | // 查询检验信息(对应SQL中的视图查询逻辑) |
| | | var checkParams = new List<SugarParameter> |
| | | { |
| | | new("@dHdMx", dhmxGuid), |
| | | new("@JYZT", null, true), // 输出参数:检验状态 |
| | | new("@JYJG", null, true), // 输出参数:检验结果 |
| | | new("@PDJG", null, true), // 输出参数:判定结果 |
| | | new("@ISRK", null, true), // 输出参数:是否能入库 |
| | | new("@CLYS", null, true) // 输出参数:处理意见 |
| | | }; |
| | | |
| | | // 执行查询获取检验信息 |
| | | Db.Ado.ExecuteCommand(@" |
| | | SELECT @JYZT = ISNULL(检验状态, '未知'), |
| | | @JYJG = ISNULL(检验结果, '未知'), |
| | | @PDJG = ISNULL(判定结果, '未知'), |
| | | @ISRK = ISNULL(是否能入库, 0), |
| | | @CLYS = ISNULL(处理意见, '无') |
| | | FROM v_dhmx |
| | | WHERE dhmxGuid = @dHdMx", checkParams); |
| | | |
| | | // 解析输出参数 |
| | | var jyzt = checkParams[1].Value?.ToString() ?? "未知"; |
| | | var jyjg = checkParams[2].Value?.ToString() ?? "未知"; |
| | | var pdjg = checkParams[3].Value?.ToString() ?? "未知"; |
| | | var isRk = checkParams[4].Value != DBNull.Value ? Convert.ToInt32(checkParams[4].Value) : 0; |
| | | var clys = checkParams[5].Value?.ToString() ?? "无"; |
| | | |
| | | // 检查是否查询到检验记录 |
| | | if (string.IsNullOrEmpty(jyzt) && string.IsNullOrEmpty(jyjg)) |
| | | throw new Exception($"未找到到货明细id为[{dhmxGuid}]的检验记录"); |
| | | // 检查是否允许验退(异常直接抛出) |
| | | if (isRk != 1) |
| | | throw new Exception($"该条码对应的收料单检验结果:[{jyjg}],判定结果:[{pdjg}],处理意见:[{clys}],不能进行验退操作"); |
| | | |
| | | |
| | | |
| | | |
| | | // 将查询到的条码信息赋值给返回模型 |
| | | res.itemBarcodeDetails = itemBarcode; |
| | | |
| | | |
| | | res.Message = "查询成功"; |
| | | |
| | | |
| | | return res; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 记录异常日志(建议补充具体日志记录代码) |
| | | res.Message = $"操作失败: {ex.Message}"; |
| | | res.SumQuantity = -1; |
| | | return res; |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // // 记录异常日志(建议补充具体日志记录代码) |
| | | // res.Message = $"操作失败: {ex.Message}"; |
| | | // res.SumQuantity = -1; |
| | | // return res; |
| | | //} |
| | | } |
| | | |
| | | // 验退 |
| | |
| | | if (string.IsNullOrEmpty(entity.returnBarcode)) throw new ArgumentNullException(nameof(entity.returnBarcode), "条码不允许为空"); |
| | | if (entity.returnQuantity <= 0) throw new ArgumentException("验退数量必须大于0", nameof(entity.returnQuantity)); |
| | | |
| | | try |
| | | { |
| | | //try |
| | | //{ |
| | | // 检查条码是否已入库 |
| | | var isInStock = Db.Queryable<MesInvItemInCDetails>() |
| | | .Where(it => it.ItemBarcode == entity.returnBarcode) |
| | |
| | | string intSum = ""; |
| | | string cfBar = ""; |
| | | |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | using (var conn = new SqlConnection(DB.DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_pda_bar_cf_before]", conn)) |
| | | { |
| | |
| | | string ytSum = ""; |
| | | string ytdh = ""; |
| | | |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | using (var conn = new SqlConnection(DB.DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("prc_pda_scan_CGYT", conn)) |
| | | { |
| | |
| | | string rkMsg = ""; |
| | | string rkSum = ""; |
| | | |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | using (var conn = new SqlConnection(DB.DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("prc_pda_inv_cgrk", conn)) |
| | | { |
| | |
| | | new("@pi_user", SqlDbType.NVarChar, 100) { Value = entity.userName }, |
| | | new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = entity.returnBarcode }, // 使用原始条码 |
| | | new("@pi_sectionCode", SqlDbType.NVarChar, 100) { Value = entity.sectionCode }, |
| | | new("@pi_remark", SqlDbType.NVarChar, 30) { Value = entity.remark }, |
| | | new("@pi_cgrkType", SqlDbType.NVarChar, 30) { Value = "正常入库" }, |
| | | new("@pi_weight", SqlDbType.Decimal) { Value = entity.weight }, |
| | | new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, |
| | | new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output } |
| | |
| | | cmd.Parameters.AddRange(rkParameters); |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | rkMsg = rkParameters[3].Value.ToString(); |
| | | rkSum = rkParameters[4].Value.ToString(); |
| | | rkMsg = rkParameters[5].Value.ToString(); |
| | | rkSum = rkParameters[6].Value.ToString(); |
| | | |
| | | if (rkSum == "-1") throw new Exception(rkMsg); |
| | | } |
| | |
| | | // res.SumQuantity = res.ItemBarCDetails?.Count ?? 0; |
| | | res.SumQuantity = Convert.ToDecimal(totalCDetailsQuantity); |
| | | return res; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 记录异常日志(建议补充具体日志记录代码) |
| | | res.Message = $"操作失败: {ex.Message}"; |
| | | res.SumQuantity = -1; |
| | | return res; |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // // 记录异常日志(建议补充具体日志记录代码) |
| | | // res.Message = $"操作失败: {ex.Message}"; |
| | | // res.SumQuantity = -1; |
| | | // return res; |
| | | //} |
| | | } |
| | | |
| | | } |