南骏 池
2025-05-12 c418ccde908642c73f86ff43cc999be835a1e77d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using MES.Service.Models;
using Microsoft.IdentityModel.Tokens;
using NewPdaSqlServer.DB;
using NewPdaSqlServer.Dto.service;
using NewPdaSqlServer.entity;
using NewPdaSqlServer.util;
using SqlSugar;
using static Azure.Core.HttpHeader;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
 
namespace NewPdaSqlServer.service.QC;
 
public class IpqcService : RepositoryNoEntity
{
    public (List<VIpqcSj> item, int TotalCount) getPageSj(XJPageResult queryObj)
    {
        var parsedGuid = Guid.Empty;
        if (!queryObj.id.IsNullOrEmpty())
        {
            var isValid = Guid.TryParse(queryObj.id, out parsedGuid);
            if (!isValid)
                throw new ApplicationException("GUID转换错误");
        }
 
 
        var totalCount = 0;
 
        var pageList = Db.Queryable<VIpqcSj>()
            .WhereIF(!string.IsNullOrWhiteSpace(queryObj.keyword), a =>
                a.ItemNo.Contains(queryObj.keyword) ||
                a.ItemName.Contains(queryObj.keyword) ||
                a.Daa001.Contains(queryObj.keyword) ||
                a.ReleaseNo.Contains(queryObj.keyword) ||
                a.DepartmentName.Contains(queryObj.keyword )||
                a.XtName.Contains(queryObj.keyword) 
            )
            .WhereIF(UtilityHelper.CheckGuid(parsedGuid),
                a => a.Guid == parsedGuid.ToString() )
            .Where(a => (a.FSubmit ?? 0) == 0)
            .OrderByDescending(a => a.CreateDate)
            .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
 
        return (pageList, totalCount);
    }
 
    public List<MesQaItemsDetectDetail5> GetItems(string? releaseNo,
        string? id)
    {
        var parsedGuid = Guid.Empty;
 
        if (id != null)
        {
            var isValid = Guid.TryParse(id, out parsedGuid);
            if (!isValid)
                throw new ApplicationException("GUID转换错误");
        }
 
        var Ybsl_In = Db.Queryable<MesQaItemsDetectDetail5>()
            .Where(a => a.ParentGuid == parsedGuid)
            .Count();
 
        return Db.Queryable<MesQaItemsDetectDetail5, MesQaItemsDetectDetail12>(
                (a, b) =>
                    new JoinQueryInfos(JoinType.Left, a.Guid == b.ParentGuid))
            .Where((a, b) => a.ReleaseNo == releaseNo)
            .WhereIF(UtilityHelper.CheckGuid(parsedGuid),
                (a, b) => a.Guid == parsedGuid)
            .GroupBy((a, b) => new
            {
                a.Guid,
                a.ParentGuid,
                a.ReleaseNo,
                a.FacLevel,
                a.FcheckItem,
                a.FcheckTool,
                a.FdownAllow,
                a.FcheckLevel,
                a.Fstand,
                a.FupAllow,
                a.SampleSizeNo,
                a.FspecRequ,
                a.FreQty,
                a.CheckQyt,
                a.FcheckResu,
                a.Order,
                a.Ybsl,
                a.ISRZXX,
                a.IPQCRZXX
            }).Select((a, b) => new MesQaItemsDetectDetail5
            {
                Guid = a.Guid,
                ParentGuid = a.ParentGuid,
                ReleaseNo = a.ReleaseNo,
                CheckQyt = a.CheckQyt,
                FacLevel = a.FacLevel,
                FcheckItem = a.FcheckItem,
                FcheckTool = a.FcheckTool,
                FdownAllow = a.FdownAllow,
                FcheckLevel = a.FcheckLevel,
                Fstand = a.Fstand,
                FupAllow = a.FupAllow,
                SampleSizeNo = a.SampleSizeNo,
                FspecRequ = a.FspecRequ,
                FreQty = a.FreQty,
                Factory = "1000",
                Company = "1000",
                FenterQty = SqlFunc.AggregateCount(b.Guid),
                FcheckResu = a.FcheckResu,
                Order = a.Order,
                Ybsl = a.Ybsl,
                YbslIn = Ybsl_In,
                ISRZXX = a.ISRZXX,
                IPQCRZXX = a.IPQCRZXX
            }).OrderBy(a => a.Order)
            .ToList();
    }
 
 
    public (List<VIpqcXj> item, int TotalCount) getPageXj(XJPageResult queryObj)
    {
        var parsedGuid = Guid.Empty;
        if (!queryObj.id.IsNullOrEmpty())
        {
            var isValid = Guid.TryParse(queryObj.id, out parsedGuid);
            if (!isValid)
                throw new ApplicationException("GUID转换错误");
        }
 
 
        var totalCount = 0;
 
        var pageList = Db.Queryable<VIpqcXj>()
            .WhereIF(!string.IsNullOrWhiteSpace(queryObj.keyword), a =>
                a.ItemNo.Contains(queryObj.keyword) ||
                a.ItemName.Contains(queryObj.keyword) ||
                a.Daa001.Contains(queryObj.keyword) ||
                a.ReleaseNo.Contains(queryObj.keyword) ||
                a.DepartmentName.Contains(queryObj.keyword) ||
                a.xtName.Contains(queryObj.keyword)
            )
            .WhereIF(UtilityHelper.CheckGuid(parsedGuid),
                a => a.Guid == parsedGuid.ToString())
            .Where(a => (a.FSubmit ?? 0) == 0)
            .OrderByDescending(a => a.CreateDate)
            .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
 
        return (pageList, totalCount);
    }
 
 
    //更新不合格描述
    public int updateIpqcRzxx(LLJDto dto)
    {
        if (dto == null) throw new ArgumentNullException(nameof(dto), "参数对象不能为 null");
 
        // 参数校验(根据存储过程新增参数)
        if (string.IsNullOrEmpty(dto.pid?.ToString()))
            throw new ArgumentException("项目明细id存在问题,请联系管理员!", nameof(dto.pid));
 
        var withOracle = Db.Updateable<MesQaItemsDetectDetail5>()
                .SetColumns(s => s.IPQCRZXX == dto.inRzxxValue)
                .Where(s => s.Guid.ToString() == dto.pid)
                .ExecuteCommand();
 
        return withOracle;
    }
}