| | |
| | | BillNo = b.BillNo // 到货单号 |
| | | }) |
| | | .ToList(); |
| | | |
| | | // 移除到货单号校验,直接返回查询结果 |
| | | return materialInfo; |
| | | } |
| | |
| | | throw new Exception($"查询物料信息失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询破坏实验记录是否存在 |
| | | /// </summary> |
| | |
| | | var count = db.Queryable<MesInvPhsy>() |
| | | .Where(x => x.BillNo == billNo && x.ReleaseNo == releaseNo) |
| | | .Count(); |
| | | |
| | | |
| | | return count > 0; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | throw new Exception($"查询破坏实验记录失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取破坏实验记录详细信息 |
| | | /// </summary> |
| | |
| | | var phsyRecords = db.Queryable<MesInvPhsy>() |
| | | .Where(x => x.BillNo == billNo && x.ReleaseNo == releaseNo) |
| | | .ToList(); |
| | | |
| | | var result = new List<PhsyRecordInfoDto>(); |
| | | |
| | | |
| | | foreach (var record in phsyRecords) |
| | | { |
| | | // 尝试通过条码查询物料信息 |
| | | var materialInfo = db.Queryable<MesInvItemBarcodes>() |
| | | .LeftJoin<MesItems>((b, m) => b.ItemId == m.Id) |
| | | .Where((b, m) => b.ItemBarcode == record.ItemBarcode) |
| | | .Select((b, m) => new { |
| | | .Select((b, m) => new { |
| | | ItemNo = b.ItemNo, |
| | | ItemName = m.ItemName, |
| | | ItemModel = m.ItemModel |
| | | }) |
| | | .First(); |
| | | |
| | | var dto = new PhsyRecordInfoDto |
| | | { |
| | | ItemBarcode = record.ItemBarcode, |
| | |
| | | Cqty = record.Cqty, |
| | | CreateDate = record.CreateDate |
| | | }; |
| | | |
| | | |
| | | result.Add(dto); |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | throw new Exception($"获取破坏实验记录信息失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 调用破坏实验存储过程 |
| | | /// </summary> |
| | |
| | | var inputParam5 = new SugarParameter("P_LX", lx, DbType.Int32, ParameterDirection.Input); |
| | | var inputParam6 = new SugarParameter("ITEM_ID", itemId ?? 0, DbType.Decimal, ParameterDirection.Input); |
| | | var inputParam7 = new SugarParameter("P_RELEASE_NO", releaseNo, DbType.String, ParameterDirection.Input); |
| | | |
| | | |
| | | // 定义输出参数 |
| | | var outputResult = new SugarParameter("PO_RESULT", null, DbType.Int32, ParameterDirection.Output); |
| | | var outputMessage = new SugarParameter("PO_MSG", null, DbType.String, ParameterDirection.Output, 4000); |
| | | |
| | | // 使用SqlSugar执行存储过程 |
| | | db.Ado.ExecuteCommand("BEGIN PRC_INV_PHSYUPDATE(:P_ITEM_BARCODE, :P_YQTY, :P_CQTY, :P_BILL_NO, :P_LX, :ITEM_ID, :P_RELEASE_NO, :PO_RESULT, :PO_MSG); END;", |
| | | db.Ado.ExecuteCommand("BEGIN PRC_INV_PHSYUPDATE(:P_ITEM_BARCODE, :P_YQTY, :P_CQTY, :P_BILL_NO, :P_LX, :ITEM_ID, :P_RELEASE_NO, :PO_RESULT, :PO_MSG); END;", |
| | | inputParam1, inputParam2, inputParam3, inputParam4, inputParam5, inputParam6, inputParam7, outputResult, outputMessage); |
| | | |
| | | // 获取输出参数的值 |
| | | var result = outputResult.Value == null ? 1 : Convert.ToInt32(outputResult.Value); |
| | | var message = outputMessage.Value?.ToString() ?? ""; |
| | | |
| | | return (result, message); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | return (1, $"调用存储过程失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置堵穴信息 |
| | | /// </summary> |
| | |
| | | .Where(s => !string.IsNullOrEmpty(s)) |
| | | .Select(s => int.Parse(s)) |
| | | .ToList(); |
| | | |
| | | // 获取检验项目信息 |
| | | var item = db.Queryable<MesQaItemsDetectDetail5>() |
| | | .Where(x => x.Id == itemId && x.ReleaseNo == releaseNo) |
| | | .First(); |
| | | |
| | | if (item == null) |
| | | { |
| | | return (1, "检验项目不存在"); |
| | | } |
| | | |
| | | // 解析开穴数 |
| | | var holeCount = ParseHoleCount(item.FcheckItem); |
| | | if (holeCount == 0) |
| | | { |
| | | return (1, "该检验项目没有穴数信息"); |
| | | } |
| | | |
| | | // 验证堵穴数量不能大于等于开穴数 |
| | | if (blockedHolesList.Count >= holeCount) |
| | | { |
| | | return (1, $"堵穴数量不能大于等于开穴数({holeCount})"); |
| | | } |
| | | |
| | | // 验证堵穴号是否在有效范围内 |
| | | foreach (var hole in blockedHolesList) |
| | | { |
| | |
| | | return (1, $"堵穴号必须在1-{holeCount}之间"); |
| | | } |
| | | } |
| | | |
| | | // 计算新的检验数量 |
| | | var newCheckQyt = item.CheckQyt - (item.CheckQyt / holeCount) * blockedHolesList.Count; |
| | | |
| | | // 更新数据库 |
| | | var result = SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | |
| | | .Where(x => x.Id == itemId && x.ReleaseNo == releaseNo) |
| | | .ExecuteCommand(); |
| | | }); |
| | | |
| | | if (result > 0) |
| | | { |
| | | return (0, "堵穴设置成功"); |
| | |
| | | return (1, $"设置堵穴失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 解析检验项目名称中的穴数 |
| | | /// </summary> |
| | |
| | | { |
| | | if (string.IsNullOrEmpty(checkItemName)) |
| | | return 0; |
| | | |
| | | // 匹配格式:尺寸检查(5穴)或 尺寸检查(5穴) |
| | | var match = System.Text.RegularExpressions.Regex.Match(checkItemName, @"[((](\d+)穴[))]"); |
| | | return match.Success ? int.Parse(match.Groups[1].Value) : 0; |
| | | } |
| | | |
| | | |
| | | } |