binxie
2023-06-16 da42e2995c00293af89c71fe5ba6e16cbb77e1b3
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
public without sharing class LexArriveGoodsController {
    
    //初始化
    @AuraEnabled
    public static Results init(String arrType, String eSetId) {
        Results results = new Results();
        results.isNoteStay = LexUtility.getIsNoteStay();
        try {
            ArriveGoodsController arrController = new ArriveGoodsController(eSetId, arrType);
            arrController.isLwc = true;
            arrController.init();
            results.arrGoodCon = JSON.serialize(arrController);
            results.coc = arrController.coc;
            results.saveFLGbln = arrController.saveFLGbln;
            results.returnFLGbln = arrController.ReturnFLGbln;
            results.result = 'Success';
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
 
    //搜索产品
    @AuraEnabled
    public static Results searchProduct(String barcode, String arrControllerStr) {
        Results results = new Results();
        try {
            System.debug('arrControllerStr:'+arrControllerStr);
            ArriveGoodsController arrController = (ArriveGoodsController)JSON.deserialize(arrControllerStr, ArriveGoodsController.class);
            arrController.barcode = barcode;
            arrController.returnError = null;
            arrController.warningList = new List<String>();
            arrController.errorList = new List<String>();
            arrController.SearchPro();
            results.arrGoodCon = JSON.serialize(arrController);
            if(arrController.returnError != null && arrController.returnError != ''){
                results.result = 'Fail';
                results.errorMsgList = arrController.errorList;
                results.warningMsgList = arrController.warningList;
                results.errorMsg = arrController.returnError;
            }else {
                results.coc = arrController.coc;
                results.saveFLGbln = arrController.saveFLGbln;
                results.returnFLGbln = arrController.ReturnFLGbln;
                results.detailsSummary = changeType1(arrController.detailsSummary);
                results.consumableorderdetailsRecords = changeType1(arrController.ConsumableorderdetailsRecords);
                results.showGoodsofReturnList = changeType1(arrController.ShowGoodsofReturnList);
                results.consumableInventory = changeType1(arrController.consumableInventory);
                results.consumableorderdetailsRecordserror = changeType1(arrController.ConsumableorderdetailsRecordserror);
                results.errorMsgList = arrController.errorList;
                results.warningMsgList = arrController.warningList;
                results.result = 'Success';
            }
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage() + '---' + e.getStackTraceString();
        }
        return results;
    }
 
    //到货确认
    @AuraEnabled
    public static Results arriveGoodsConfim(String arrControllerStr) {
        Results results = new Results();
        try {
            ArriveGoodsController arrController = (ArriveGoodsController)JSON.deserialize(arrControllerStr, ArriveGoodsController.class);
            arrController.returnError = null;
            arrController.warningList = new List<String>();
            arrController.errorList = new List<String>();
            Pagereference page = arrController.ArriveGoodsConfim();
            results.arrGoodCon = JSON.serialize(arrController);
            if(arrController.returnError != null && arrController.returnError != ''){
                results.result = 'Fail';
                results.errorMsgList = arrController.errorList;
                results.warningMsgList = arrController.warningList;
                results.errorMsg = arrController.returnError;
            }else {
                if(arrController.urlType == 'UnabletoEdit'){
                    results.url = '/lexarrivegsdetails?EsetId='+arrController.arriveId;
                }
                results.errorMsgList = arrController.errorList;
                results.warningMsgList = arrController.warningList;
                results.result = 'Success';
            }
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
    
    //登录返品
    @AuraEnabled
    public static Results updateGoodsOfReturn(String arrControllerStr, String showGoodsofReturnListStr) {
        Results results = new Results();
        try {
            List<ConsumableorderdetailsInfo> showGoodsofReturnList = (List<ConsumableorderdetailsInfo>)JSON.deserialize(showGoodsofReturnListStr, List<ConsumableorderdetailsInfo>.class);
            ArriveGoodsController arrController = (ArriveGoodsController)JSON.deserialize(arrControllerStr, ArriveGoodsController.class);
            arrController.ShowGoodsofReturnList = changeType2(showGoodsofReturnList);
            arrController.returnError = null;
            arrController.warningList = new List<String>();
            arrController.errorList = new List<String>();
            StaticParameter.ConsumableOrderTrigger = true; //Add by Li Jun for bypass ConsumableOrderTrigger 20230616
            Pagereference page = arrController.UpdateGoodsOfReturn();
            results.arrGoodCon = JSON.serialize(arrController);
            if(arrController.returnError != null && arrController.returnError != ''){
                results.result = 'Fail';
                results.errorMsgList = arrController.errorList;
                results.warningMsgList = arrController.warningList;
                results.errorMsg = arrController.returnError;
            }else {
                if(arrController.urlType == 'ToReturnGoodsPage'){
                    results.url = '/detail/'+arrController.return_Order_id;
                }
                if(arrController.urlType == 'ToInventoryGoodsPage'){
                    results.url = '/detail/'+arrController.inventory_Order_id;
                }
                results.errorMsgList = arrController.errorList;
                results.warningMsgList = arrController.warningList;
                results.result = 'Success';
            }
        } catch (Exception e) {
            results.result = 'Fail';
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
        }
        return results;
    }
 
    public static List<ConsumableorderdetailsInfo> changeType1(List<ArriveGoodsController.ConsumableorderdetailsInfo> conList){
        List<ConsumableorderdetailsInfo> conList1 = new List<ConsumableorderdetailsInfo>();
        if(conList != null){
            for(ArriveGoodsController.ConsumableorderdetailsInfo con : conList){
                ConsumableorderdetailsInfo con1 = new ConsumableorderdetailsInfo();
                con1.esd = con.esd;
                con1.Prod = con.Prod;
                con1.ProductName = con.ProductName;
                con1.barCodeNo = con.barCodeNo;
                con1.sterilizationlimitDate = con.sterilizationlimitDate;
                con1.serialNoorLotNo = con.serialNoorLotNo;
                con1.tracingCodeNo = con.tracingCodeNo;
                con1.ReturnReason = con.ReturnReason;
                con1.oldConsumableCount = con.oldConsumableCount;
                con1.ErrorReason = con.ErrorReason;
                con1.canEdit = con.canEdit;
                con1.intMark = con.intMark;
                con1.arriveAmount = con.arriveAmount;
                con1.arrivedCount = con.arrivedCount;
                con1.ReportProductExpirationDate = con.ReportProductExpirationDate;
                conList1.add(con1);
            }
        }
        return conList1;
    }
 
    public static List<ArriveGoodsController.ConsumableorderdetailsInfo> changeType2(List<ConsumableorderdetailsInfo> conList){
        List<ArriveGoodsController.ConsumableorderdetailsInfo> conList1 = new List<ArriveGoodsController.ConsumableorderdetailsInfo>();
        if(conList != null){
            for(ConsumableorderdetailsInfo con : conList){
                ArriveGoodsController.ConsumableorderdetailsInfo con1 = new ArriveGoodsController.ConsumableorderdetailsInfo();
                con1.esd = con.esd;
                con1.Prod = con.Prod;
                con1.ProductName = con.ProductName;
                con1.barCodeNo = con.barCodeNo;
                con1.sterilizationlimitDate = con.sterilizationlimitDate;
                con1.serialNoorLotNo = con.serialNoorLotNo;
                con1.tracingCodeNo = con.tracingCodeNo;
                con1.ReturnReason = con.ReturnReason;
                con1.oldConsumableCount = con.oldConsumableCount;
                con1.ErrorReason = con.ErrorReason;
                con1.canEdit = con.canEdit;
                con1.intMark = con.intMark;
                con1.arriveAmount = con.arriveAmount;
                con1.arrivedCount = con.arrivedCount;
                con1.ReportProductExpirationDate = con.ReportProductExpirationDate;
                conList1.add(con1);
            }
        }
        return conList1;
    }
 
    public class Results {
        @AuraEnabled
        public String result;
        @AuraEnabled
        public String errorMsg;
        @AuraEnabled
        public String url;
        @AuraEnabled
        public String arrGoodCon;
        @AuraEnabled
        public Consumable_order__c coc;
        @AuraEnabled
        public Boolean returnFLGbln;
        @AuraEnabled
        public Boolean saveFLGbln;
        @AuraEnabled
        public List<ConsumableorderdetailsInfo> detailsSummary;
        @AuraEnabled
        public List<ConsumableorderdetailsInfo> consumableorderdetailsRecords;
        @AuraEnabled
        public List<ConsumableorderdetailsInfo> showGoodsofReturnList;
        @AuraEnabled
        public List<ConsumableorderdetailsInfo> consumableInventory;
        @AuraEnabled
        public List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror;
        @AuraEnabled
        public List<String> errorMsgList;
        @AuraEnabled
        public List<String> warningMsgList;
        @AuraEnabled
        public Boolean isNoteStay;
    }
 
    public class ConsumableorderdetailsInfo implements Comparable {
        @AuraEnabled
        public Consumable_order_details2__c esd { get; set; }
        @AuraEnabled
        public Product2__c Prod { get; set; }
        @AuraEnabled
        public String ProductName { get; set; }
        @AuraEnabled
        public String barCodeNo { get; set; }
        @AuraEnabled
        public Date sterilizationlimitDate { get; set; }
        @AuraEnabled
        public String serialNoorLotNo { get; set; }
        @AuraEnabled
        public String tracingCodeNo { get; set; }
        @AuraEnabled
        public String ReturnReason { get; set; }
        @AuraEnabled
        public String oldConsumableCount { get; set; }
        @AuraEnabled
        public String ErrorReason { get; set; }
        @AuraEnabled
        public boolean canEdit { get; set; }
        @AuraEnabled
        public Integer intMark { get; set; }
        @AuraEnabled
        public Decimal arriveAmount { get; set; }
        @AuraEnabled
        public Decimal arrivedCount { get; set; }
        @AuraEnabled
        public String ReportProductExpirationDate { get; set; }
 
        public ConsumableorderdetailsInfo(){
 
        }
 
        // 排序
        public Integer compareTo(Object compareTo) {
            return null;
        }
    }
}