如洲 陈
2025-10-27 f8c29731de73b1c05a5336b433ad92d52eb4ee97
MES.Service/service/QC/SJService.cs
@@ -423,39 +423,36 @@
    public int SJQaSubmit(string userNo, decimal id)
    {
        return SqlSugarHelper.UseTransactionWithOracle(db =>
        var db = SqlSugarHelper.GetInstance();
        // 输出参数
        var poResult = new SugarParameter("PO_RESULT", null, System.Data.DbType.Int32, System.Data.ParameterDirection.Output, 4000);
        var poText = new SugarParameter("PO_TEXT", null, System.Data.DbType.String, System.Data.ParameterDirection.Output, 4000);
        // 输入参数 + 输出参数
        var parameters = new List<SugarParameter>
        {
            var commit = 0;
            new("P_ID", id, System.Data.DbType.Decimal, System.Data.ParameterDirection.Input),
            new("P_USER", userNo ?? string.Empty, System.Data.DbType.String, System.Data.ParameterDirection.Input),
            poResult,
            poText
        };
            // 提交首检单
            var sql = "update QS_ITEM_IPI_REQ set FSUBMIT=1, FSUBMIT_BY=:userNo, FSUBMIT_DATE=SYSDATE where ID=:id";
            var parameters = new List<SugarParameter>
            {
                new(":userNo", userNo),
                new(":id", id)
            };
            commit += db.Ado.ExecuteCommand(sql, parameters);
        // 调用存储过程提交首检单
        db.Ado.ExecuteCommand(
            "BEGIN PRC_GEN_TJQ_SJ(:P_ID, :P_USER, :PO_RESULT, :PO_TEXT); END;",
            parameters.ToArray());
            // 读取首检单,取结果与计划编号
            var req = db.Queryable<QsItemIpiReq>().Single(s => s.Id == id);
            if (req != null)
            {
                // 通过 PBAID 找到 WOMDAA 获取计划编号 DAA001
                var wom = db.Queryable<Womdaa>().Single(s => s.Id == req.Pbaid);
                if (wom != null && !string.IsNullOrWhiteSpace(wom.Daa001))
                {
                    var resultText = req.IsPass == 1 ? "合格" : "不合格";
                    // 更新 WOMDAA:首检标记与结果
                    commit += db.Updateable<Womdaa>()
                        .SetColumns(w => w.Daa025 == "1")
                        .SetColumns(w => w.Daa026 == resultText)
                        .Where(w => w.Daa001 == wom.Daa001)
                        .ExecuteCommand();
                }
            }
        var code = Convert.ToInt32(poResult.Value?.ToString() ?? "0");
        var message = poText.Value?.ToString() ?? "";
        // 如果存储过程执行失败,抛出异常
        if (code != 0)
        {
            throw new Exception($"首检提交失败: {message}");
        }
            return commit;
        });
        return code;
    }
    public (int code, string message) GenUpdateSJ(decimal id, string no, string userNo)