111
沙世明
2022-11-22 928399eceec50e3d37ea08669a12789a9410a9d2
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
public without sharing class AttachmentDisplayController {
    @AuraEnabled
    public static List<testInit> getFrameNumManage(String DNId){
        System.debug('DNId'+DNId);
        List<testInit> newinitList = new List<testInit>();
        List<testInit> initList = new List<testInit>();
        List<FrameNumManage__c> FnmList =[SELECT Id, Name ,ManagementCode__c, ApplyList__c ,InspectionCard_Select__c ,InspectionCard_Select__r.ViewLink__c,InspectionCard_Select__r.DownloadLink__c, ApplyList_Select__c,ApplyList_Select__r.DownloadLink__c,ApplyList_Select__r.ViewLink__c,  Num__c , SerialNumber__c,Material__c , MaterialDepict__c from FrameNumManage__c where signInForm__c =:DNId order by ApplyList__c desc];
        set<String> FileStrSet = new set<String>();
        List<FileAddress__c> FileList = new List<FileAddress__c>();
        Map<String,String> FileStrMap = new Map<String,String>();
        // if (FnmList.size()>0) {
        //     for (FrameNumManage__c nObj : FnmList ) {
        //         FileStrSet.add(nObj.ApplyList__c);
        //     }
        //     FileList = [SELECT Id, Name, FileName__c,ViewLink__c  FROM FileAddress__c WHERE FileName__c IN: FileStrSet];
        //     if(FileList.size()>0){
        //         for (FileAddress__c file : FileList) {
        //             FileStrMap.put(file.FileName__c, file.ViewLink__c);
        //         }
        //     }
        // }
 
        Integer n = 0; // 初始化合并行数
        for (Integer i=0;i<FnmList.size() ;i++ ) {
            testInit init = new testInit();
            if (i==0) {
                init.Name = FnmList[i].ManagementCode__c;
                init.ProductName = FnmList[i].Material__c + '-' + FnmList[i].MaterialDepict__c;
                // init.code = FnmList[i].ApplyList__c;
                if (String.isNotBlank(FnmList[i].ApplyList_Select__r.DownloadLink__c)) {
                    init.code = FnmList[i].ApplyList_Select__r.DownloadLink__c;
                }else{
                    init.code = '不出证';
                } //2022-11-21 zyh add 报关单判断
                if (String.isNotBlank(FnmList[i].InspectionCard_Select__r.DownloadLink__c)) {
                    init.sj_code = FnmList[i].InspectionCard_Select__r.DownloadLink__c;
                }else{
                    init.sj_code = '不出证';
                } //2022-11-21 zyh add 商检证判断
                
                // init.code = FileStrMap.get(FnmList[i].ApplyList__c);
                init.Num = FnmList[i].Num__c;
                init.Id = FnmList[i].Id;
                init.FrameNo = FnmList[i].SerialNumber__c;
                n = n+1;
                if (i != FnmList.size()-1) {
                    // 判断第一个与第二个是否一样,不一样赋值1
                    if (FnmList[i].ApplyList__c != FnmList[i+1].ApplyList__c) {
                        init.count = n;
                    }
                }
            }else {
                // 判断与前一个编码是一致
                if (FnmList[i].ApplyList__c == FnmList[i-1].ApplyList__c) {
                    init.Name = FnmList[i].ManagementCode__c;
                    init.ProductName = FnmList[i].Material__c + '-' + FnmList[i].MaterialDepict__c;
                    // init.code = FnmList[i].ApplyList__c;
                    if (String.isNotBlank(FnmList[i].ApplyList_Select__r.DownloadLink__c)) {
                        init.code = FnmList[i].ApplyList_Select__r.DownloadLink__c;
                    }else{
                        init.code = '不出证';
                    } //2022-11-21 zyh add 报关单判断
                    if (String.isNotBlank(FnmList[i].InspectionCard_Select__r.DownloadLink__c)) {
                        init.sj_code = FnmList[i].InspectionCard_Select__r.DownloadLink__c;
                    }else{
                        init.sj_code = '不出证';
                    } //2022-11-21 zyh add 商检证判断
                    // init.code = FileStrMap.get(FnmList[i].ApplyList__c);
                    init.Num = FnmList[i].Num__c;
                    init.Id = FnmList[i].Id;
                    init.FrameNo = FnmList[i].SerialNumber__c;
                    n = n+1;
                    // 判断是不是最后一个
                    if (i != FnmList.size()-1) {
                        // 不是最后一个,判断与下一个编码一致不一致,不一致直接赋值
                        if (FnmList[i].ApplyList__c != FnmList[i+1].ApplyList__c) {
                            init.count = n;
                        }
                    }
                    // 最后一个直接赋值
                    if (i == FnmList.size()-1) {
                        init.count = n;
                    }
                }else {
                    // 下一组开始
                    n = 0;
                    init.Name = FnmList[i].ManagementCode__c;
                    init.ProductName = FnmList[i].Material__c + '-' + FnmList[i].MaterialDepict__c;
                    // init.code = FnmList[i].ApplyList__c;
                    if (String.isNotBlank(FnmList[i].ApplyList_Select__r.DownloadLink__c)) {
                        init.code = FnmList[i].ApplyList_Select__r.DownloadLink__c;
                    }else{
                        init.code = '不出证';
                    } //2022-11-21 zyh add 报关单判断
                    if (String.isNotBlank(FnmList[i].InspectionCard_Select__r.DownloadLink__c)) {
                        init.sj_code = FnmList[i].InspectionCard_Select__r.DownloadLink__c;
                    }else{
                        init.sj_code = '不出证';
                    } //2022-11-21 zyh add 商检证判断
                    // init.code = FileStrMap.get(FnmList[i].ApplyList__c);
                    init.Num = FnmList[i].Num__c;
                    init.Id = FnmList[i].Id;
                    init.FrameNo = FnmList[i].SerialNumber__c;
                    n = n+1;
                }
            }
            initList.add(init);
        }
        // 倒序显示
        for (Integer i = initList.size()-1; i>=0 ; i--) {
            testInit init = new testInit();
            init = initList[i];
            newinitList.add(init);
        }
        System.debug('newinitList'+newinitList);
        System.debug('FnmList'+FnmList);
        return newinitList;
 
    }
    // 定义内部类,自定义参数
    class testInit{
        @AuraEnabled
        public Boolean check;
        @AuraEnabled
        public String Name;
        @AuraEnabled
        public String ProductName;
        @AuraEnabled
        public String FrameNo;
        @AuraEnabled
        public String code;
        @AuraEnabled
        public String sj_code;
        @AuraEnabled
        public Decimal Num;
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public Integer count;
    }
}