111
啊鑫
2025-07-16 f6598be8fdb51673c0a48ddeac8bd0e622835b35
MES.Service/service/QC/SJService.cs
@@ -53,13 +53,16 @@
            .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.BillNo),
                a => a.BillNo == queryObj.BillNo)
            .WhereIF(
                (StringUtil.IsNotNullOrEmpty(queryObj.Result) && "未完成".Equals(queryObj.Result)) ||
                (queryObj.Fsubmit != null && (queryObj.Fsubmit == 0 || queryObj.Fsubmit == null)),
                a => a.Result == "未完成" || (a.Fsubmit != null && (a.Fsubmit == 0)) || a.Fsubmit == null)
                (StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                 "未完成".Equals(queryObj.Result)) ||
                (queryObj.Fsubmit != null &&
                 (queryObj.Fsubmit == 0 || queryObj.Fsubmit == null)),
                a => a.Result == "未完成" ||
                     (a.Fsubmit != null && a.Fsubmit == 0) || a.Fsubmit == null)
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                !"未完成".Equals(queryObj.Result),
                a => a.Result != "未完成" && (a.Fsubmit != null && a.Fsubmit != 0))
                a => a.Result != "未完成" && a.Fsubmit != null && a.Fsubmit != 0)
            .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.ItemCj),
                a => a.ItemCj == queryObj.ItemCj)
            .OrderBy(a => a.BillNo, OrderByType.Desc)
@@ -83,21 +86,30 @@
            .WhereIF(queryObj.Id != null, a => a.Id == queryObj.Id)
            // .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.BillNo), a => a.BillNo == queryObj.BillNo)
            .WhereIF(
                (StringUtil.IsNotNullOrEmpty(queryObj.Result) && "未完成".Equals(queryObj.Result)) ||
                (queryObj.Fsubmit != null && (queryObj.Fsubmit == 0 || queryObj.Fsubmit == null)),
                a => a.Result == "未完成" || (a.Fsubmit != null && (a.Fsubmit == 0)) || a.Fsubmit == null)
                (StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                 "未完成".Equals(queryObj.Result)) ||
                (queryObj.Fsubmit != null &&
                 (queryObj.Fsubmit == 0 || queryObj.Fsubmit == null)),
                a => a.Result == "未完成" ||
                     (a.Fsubmit != null && a.Fsubmit == 0) || a.Fsubmit == null)
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                !"未完成".Equals(queryObj.Result), a => a.Result != "未完成" && (a.Fsubmit != null && a.Fsubmit != 0))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo), (a) => a.ItemNo.Contains(queryObj.ItemNo))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemModel), (a) => a.ItemModel.Contains(queryObj.ItemModel))
            .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ), (a) => a.SongJ.Contains(queryObj.SongJ))
            .WhereIF(!string.IsNullOrEmpty(queryObj.BillNo), (a) => a.BillNo.Contains(queryObj.BillNo))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName), (a) => a.ItemName.Contains(queryObj.ItemName))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemCj), (a) => a.ItemCj.Contains(queryObj.ItemCj))
            .WhereIF(!string.IsNullOrEmpty(queryObj.daa001), (a) => a.daa001.Contains(queryObj.daa001))
                !"未完成".Equals(queryObj.Result),
                a => a.Result != "未完成" && a.Fsubmit != null && a.Fsubmit != 0)
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemNo),
                a => a.ItemNo.Contains(queryObj.ItemNo))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemModel),
                a => a.ItemModel.Contains(queryObj.ItemModel))
            .WhereIF(!string.IsNullOrEmpty(queryObj.SongJ),
                a => a.SongJ.Contains(queryObj.SongJ))
            .WhereIF(!string.IsNullOrEmpty(queryObj.BillNo),
                a => a.BillNo.Contains(queryObj.BillNo))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemName),
                a => a.ItemName.Contains(queryObj.ItemName))
            .WhereIF(!string.IsNullOrEmpty(queryObj.ItemCj),
                a => a.ItemCj.Contains(queryObj.ItemCj))
            .WhereIF(!string.IsNullOrEmpty(queryObj.daa001),
                a => a.daa001.Contains(queryObj.daa001))
            .OrderBy(a => a.BillNo, OrderByType.Desc)
            .ToPageList(queryObj.PageIndex, queryObj.Limit);
@@ -168,21 +180,23 @@
        var db = SqlSugarHelper.GetInstance();
        var count = db.Queryable<MesQa>().Where(s => s.QsType == "1"
                                                     && s.ItemId == itemId && s.Fsubmit == 1).Count();
            && s.ItemId == itemId && s.Fsubmit == 1).Count();
        if (count <= 0) return new List<QsItemIpiItem>();
        return db
            .Queryable<MesQualityStandard>()
            .Where(b => b.QsType == "1" && b.ItemId == itemId).Select(
                b => new QsItemIpiItem
            .Where(b => b.QsType == "1" && b.ItemId == itemId).Select(b =>
                new QsItemIpiItem
                {
                    ProjName = b.ProjName,
                    ItemMod = b.ItemMod,
                    InspectionMethod = b.InspectionMethod,
                    UsingInstruments = b.UsingInstruments,
                    LevelNum = SqlFunc.IsNull(
                        SqlFunc.IsNull(Convert.ToDecimal(b.LevelNum) * Convert.ToDecimal(b.InspectionLevel), 1),
                        SqlFunc.IsNull(
                            Convert.ToDecimal(b.LevelNum) *
                            Convert.ToDecimal(b.InspectionLevel), 1),
                        Convert.ToDecimal(b.InspectionLevel)),
                    MaxValue = Convert.ToDecimal(b.MaxValue),
                    StandardValue = Convert.ToDecimal(b.StandardValue),
@@ -260,21 +274,20 @@
    {
        var qsItemIpiReq = item.From;
        var qsItemIpiItems = item.Items;
        SqlSugarHelper.UseTransactionWithOracle(
            db =>
            {
                qsItemIpiReq.StatusDate = DateTime.Now;
                var pid = db.Insertable(qsItemIpiReq)
                    .ExecuteReturnIdentity();
                qsItemIpiReq.Id = pid;
        SqlSugarHelper.UseTransactionWithOracle(db =>
        {
            qsItemIpiReq.StatusDate = DateTime.Now;
            var pid = db.Insertable(qsItemIpiReq)
                .ExecuteReturnIdentity();
            qsItemIpiReq.Id = pid;
                item.gid = pid;
            item.gid = pid;
                qsItemIpiItems.ForEach(s => s.Pid = pid);
            qsItemIpiItems.ForEach(s => s.Pid = pid);
                return db.Insertable(qsItemIpiItems)
                    .ExecuteCommand();
            });
            return db.Insertable(qsItemIpiItems)
                .ExecuteCommand();
        });
        item.Items = getQSItems(qsItemIpiReq.Id, null);
        //没有上下限的检验项目自动盘点为合格
@@ -303,14 +316,13 @@
    public QsItem SaveItem(QsItem item)
    {
        var qsItemIpiItems = item.Items;
        SqlSugarHelper.UseTransactionWithOracle(
            db =>
            {
                qsItemIpiItems.ForEach(s => s.Pid = item.gid);
        SqlSugarHelper.UseTransactionWithOracle(db =>
        {
            qsItemIpiItems.ForEach(s => s.Pid = item.gid);
                return db.Insertable(qsItemIpiItems)
                    .ExecuteCommand();
            });
            return db.Insertable(qsItemIpiItems)
                .ExecuteCommand();
        });
        item.Items = getQSItems(item.gid, null);
        //没有上下限的检验项目自动盘点为合格
@@ -394,8 +406,8 @@
        if (count == passCount) result = 1;
        var useTransactionWithOracle = SqlSugarHelper.UseTransactionWithOracle(
            db =>
        var useTransactionWithOracle =
            SqlSugarHelper.UseTransactionWithOracle(db =>
            {
                var commit = 0;
                commit += db.Updateable<QsItemIpiItem>()
@@ -430,8 +442,8 @@
            //合格的检验结果等于总检验数视为合格
            if (icount == passCount) result = 1;
            useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle(
                db =>
            useTransactionWithOracle +=
                SqlSugarHelper.UseTransactionWithOracle(db =>
                {
                    return db.Updateable<QsItemIpiReq>()
                        .SetColumns(s => s.IsPass == result)
@@ -534,15 +546,18 @@
        try
        {
            // 定义输出参数
            var outputResult = new SugarParameter("o_Result", null, DbType.Int32, ParameterDirection.Output, 4000);
            var outputMessage = new SugarParameter("o_Msg", null, DbType.String, ParameterDirection.Output, 4000);
            var outputResult = new SugarParameter("o_Result", null,
                DbType.Int32, ParameterDirection.Output, 4000);
            var outputMessage = new SugarParameter("o_Msg", null, DbType.String,
                ParameterDirection.Output, 4000);
            // 定义输入参数
            var parameters = new List<SugarParameter>
            {
                new("p_Id", item.gid, DbType.Int32, ParameterDirection.Input),
                new("p_Flag", 1, DbType.Int32, ParameterDirection.Input),
                new("p_User", item.userNo, DbType.String, ParameterDirection.Input),
                new("p_User", item.userNo, DbType.String,
                    ParameterDirection.Input),
                outputResult,
                outputMessage
            };
@@ -559,17 +574,15 @@
            var messageValue = outputMessage.Value?.ToString();
            if ("1".Equals(resultValue))
            {
                // 处理失败情况,返回错误信息
                throw new Exception($"操作失败: {messageValue}");
            }
            // 当 resultValue 为 "0" 时返回成功状态
            return true;
        }
        catch (Exception ex)
        {
         // 重新抛出更友好的异常信息
            // 重新抛出更友好的异常信息
            throw new Exception($"提交质量检验数据时发生错误: {ex.Message}", ex);
        }
    }
@@ -583,7 +596,7 @@
            .GroupBy(d => new { d.Departmentname })
            .Select(d => new SysDepartment
            {
                Departmentname = d.Departmentname,
                Departmentname = d.Departmentname
                // 其他需要的字段
            })
            .OrderBy("DEPARTMENTNAME")