| | |
| | | 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) |
| | |
| | | cmd.Parameters.AddRange(rkParameters); |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | rkMsg = rkParameters[3].Value.ToString(); |
| | | rkSum = rkParameters[4].Value.ToString(); |
| | | rkMsg = rkParameters[4].Value.ToString(); |
| | | rkSum = rkParameters[5].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; |
| | | //} |
| | | } |
| | | |
| | | } |