南骏 池
2025-03-27 cd7cb6808175f5c20a09ba85193fa48dfc14c91a
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
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;
 
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.YbslIn
            }).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,
            }).OrderBy(a => a.Order)
            .ToList();
    }
}