liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
@RestResource(urlMapping = '/NFM612/*')
global with sharing class NFM612Rest {
    /* 迁移ali sushanhu 20231027
    //add to AWS 回复 start sushanhu 20220225 
    static Boolean SFStatus=true;
    static String SFMessage='';
   //add to AWS 回复 end sushanhu 20220225 
   */
    public static final String LOG_TYPE = 'NFM612';
    global class GeData {
        public RepairOderInfo repairOderInfo;
        public ApplyRepairInfo applyRepairInfo;
        public problem problem;
        public Logistics logistics;     //物流 zhj 改造新增字段 2023-02-14
        public String item0010;         //备用字段 zhj 改造新增字段 2023-02-14
        public String item0020;         //备用字段 zhj 改造新增字段 2023-02-14
        public String item0030;         //备用字段 zhj 改造新增字段 2023-02-14
        public String item0040;         //备用字段 zhj 改造新增字段 2023-02-14
        public String item0050;         //备用字段 zhj 改造新增字段 2023-02-14
    }
    //报修单信息
    public class RepairOderInfo {
        public String repairOrderNo; //报修单号
        public String repairOrderNo2; //报修单子单号
        public String hospitalCd; //报修医院编码
        public String strategicDepartmenCd; //战略科室编码
        public String departmentCd; //报修科室编码
        public String repairApplyPerson; //报修人用户编码
        public String repairApplicantName; //报修人姓名
        //public String repairApplicantNameEncrypted; //报修人姓名密文 add20220214          //zhj新方案改造 2022-12-07 
        public String repairApplyPersonTel; //报修人联系人电话
        //public String repairApplyPersonTelEncrypted;//保修人联系电话 密文 add 20220214    //zhj新方案改造 2022-12-07    
        //public String DataId;//aws 存储凭证 add 20220214  //迁移ali sushanhu 20231017
        public String repairApplyType; // 报修人岗位
        public String equipmentCategory; //设备大类
        public String assetType; //设备类型
        public String equipmentCd; //机身编码(医院)
        public String faultDate; //故障发生日
        public String repairOrderTime; //报修时间
        public String faultType; //故障类型
        public String problemDesc; //问题描述
        public String problemPhotoName; //问题照片
        public String problemPhotofile; //照片附件
        public String repairSubOrderType; //报修单类型
        public String responseResultType; //应对结果类型
        public String receiverType; //受理人类型
        public String receiverId; //受理人用户编号
        public String receiverDate; //受理日
        public String plannedVisitDay; //计划上门日
        //public String actualVisitTimeFirst;//实际上门日
        public String startTimeFirst; //开始时间
        public String endTimeFirst; //结束时间
        public String faultDescriptionFirst; //故障描述
        public String actualVisitTimeSecond; //二次上门日
        public String startTimeSecond; //二次上门开始时间
        public String endTimeSecond; //二次上门结束时间
        public String faultDescriptionSecond; //二次故障描述
        public String actualVisitTimeThird; //三次上门日
        public String startTimeThird; //三次上门开始时间
        public String endTimeThird; //三次上门结束时间
        public String faultDescriptionThird; //三次故障描述
        public String applicantType; //申请修理人类型
        public String applicantId; //申请修理人编号
        public String applyDate; //申请时间
        public String repairOrderNo2FSEID; //报修子单所属FSE的ID
        //  2022/4/6    zhangyuheng update start
        public String RepairFinishDate; //修理品处理完成日
        public String ApplicanterPhone; //处理人电话
        public String CancelDate;   //受理人取消报修日
        //  2022/4/6    zhangyuheng update end
 
        // 上线前 报修子单与修理上的相关字段都删除
        public String responseResultsFirst; //上门应对结果(暂时注掉)
        public String responseResultsSecond; //二次上门应对结果(暂时注掉)
        public String responseResultsThird; //三次上门应对结果(暂时注掉)
        public String cancellerType; //取消人类型
        public String cancellerId; //取消人用户编号
        public String cancelleRepairDate; //取消报修日
        public String cancelReportReason; //取消报修原因
 
        
 
 
 
    }
    //设备信息
    public class ApplyRepairInfo {
        public String equipmentModel; //设备型号
        public String equipmentCd; //机身编码(工程师)
        public String responseResultDesc; //应对描述
        public String processResult; //处理结果
    }
    //故障处理信息
    public class problem {
        public String dateReceiptQuestions; //投诉知悉日(Complaint Aware Date)
        public String ifDeadHurt; //是否有死亡、伤害、感染
        public String problemOccurred; //问题发生时间情况
        public String problemOccurredSelect; //问题发生时间情况 其他
        public String reportAdverseEvents; //医院有没有向政府机关报告不良事件或疑似不良事件
        public String whatProject; //做的是哪个项目
        public String operationOrExaminationName; //手术/检查名称
        public String breakORFallOff; //是否有发生断裂或脱落
        public String useFailProductFinish; //是否用该产品完成了手术/检查
        public String supportingProducts; //配套使用产品
        public String afterFailureInformation; //发现故障后,医院对患者的处理情况
        public String delay15Min; //发现故障现象后,有延误15分钟以上的手术实施的情况发生吗
        public String informationFrom; //信息是从医院的谁那里得到的
        public String failureQInHospital; //在医院,故障发生的频率是多少
        public String delayReportReason; //超时报告的理由
        public String isProductFaultRelated; //是否与这次产品故障相关
    }
    //物流
    public class logistics {
        public String isOts; //是否使用ots
        public String senderOrgCode; //送修机构代码
        public String senderCompany; //送修机构名称
        public String senderName; //送修人姓名
        public String senderMobilePhone; //送修人手机
        public String senderAddress; //送修人地址
        public String recepientCompany; //接收机构名称
        public String recepientName; //接收送修人姓名
        public String recepientMobilePhone; //接收人手机
        public String recepientAddress; //接收人地址
        public String returnWayType; //返品方式
        public String orderNumber; //送修物流单号
        public String failureReason; //下单失败原因
        public String logisticsSendDate; //送修物流发送日
 
        public String returnedProvince; //deloitte-zhj 20230920 新增字段 返品所属省
        public String returnedCity; //deloitte-zhj 20230920 新增字段 返品所属市
        public String returnedPersonName; //deloitte-zhj 20230920 新增字段 返品人姓名
        public String returnedPersonPhone; //deloitte-zhj 20230920 新增字段 返品人电话
        public String returnedAddress; //deloitte-zhj 20230920 新增字段 返品地址
        public String returnedCustomer; //deloitte-zhj 20230920 新增字段 返品客户
        public String returnedZipCode; //deloitte-zhj 20230920 新增字段 返品邮编
        // public String item0010; //备用字段1
        // public String item0020; //备用字段2
        // public String item0030; //备用字段3
        // public String item0040; //备用字段4
        // public String item0050; //备用字段5
    }
    @HttpPost
    global static void doPost() {
        // 取得接口传输内容
        String strData = RestContext.request.requestBody.toString();
        List < GeData > ges = (List < GeData > ) JSON.deserializeStrict(strData, List < GeData > .class);
        if (ges == null) {
            return;
        }
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = LOG_TYPE;
        iflog.ErrorLog__c = '';
        iflog.Log__c = 'callout start\n';
        BatchIF_Log__c rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, ges);
        insert rowData;
        if (String.isBlank(rowData.Log__c) == false) {
            executefuture(rowData.Id);
        }
        // JSONを戻す
        RestResponse res = RestContext.response;
        res.addHeader('Content-Type', 'application/json');
        res.statusCode = 200;
        //String jsonResponse = '{"status": "Success", "Message":'  + gedata + '}';
        String jsonResponse = '{"status": "Success", "Message":"成功"}';
        res.responseBody = Blob.valueOf(jsonResponse);
        /*迁移ali sushanhu 20231017
         //updata response toAWS 20220225 sushanhu start
         NFMUtil.NFMResponse result = NFMUtil.getNFMResponse();
         result.SFStatus=SFStatus;
         result.SFMessage=SFMessage;
         String jsonResponse =JSON.serialize(result);
         system.debug('result---'+jsonResponse);
         res.responseBody = blob.valueOf(jsonResponse);
         //updata response toAWS 20220225 sushanhu end
         */
        return;
    }
    @future(callout = true)
    global static void executefuture(String rowData_Id) {
        main(rowData_Id);
    }
    global static void main(String rowData_Id) {
        BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id];
        String logstr = ' start\n';
        String logerr = '';
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Type__c = LOG_TYPE;
        // iflog.MessageGroupNumber__c = rowData.MessageGroupNumber__c;
        iflog.MessageGroupNumber__c = rowData.Name;
        system.debug('zyhtest==========='+rowData.MessageGroupNumber__c+'=============='+rowData.Name);
        iflog.Log__c = logstr;
        iflog.ErrorLog__c = '';
        String rowDataStr = NFMUtil.getRowDataStr(rowData);
        List < GeData > itemMasterList = (List < GeData > ) JSON.deserialize(rowDataStr, List < GeData > .class);
        if (itemMasterList == null || itemMasterList.size() == 0) {
            return;
        }
        Savepoint sp = Database.setSavepoint();
        /*List<RepairSubOrder__c> rsoList = [SELECT Id FROM RepairSubOrder__c WHERE Name = ged.repairOderInfo.repairOrderNo2];
        if (rsoList.size() > 0) {
            
        }
*/
        try {
            List < RepairSubOrder__c > repairList = new List < RepairSubOrder__c > ();
            Map < String, GeData > gedMap = new Map < String, GeData > ();
            List < String > managementCodeList = new List < String > (); //存放科室编码
            List < String > rpersonList = new List < String > (); //存放报修人用户编码
            List < String > canIdList = new List < String > (); //存放取消人用户编号
            List < String > repairNoList = new List < String > ();  //存放报修子单号 
            for (GeData ged: itemMasterList) {
                String dataComplete = verify(ged);
                if (!String.isBlank(dataComplete)) {
                    logstr += dataComplete;
                    logerr += '报修子单No['+ged.repairOderInfo.repairOrderNo2+']\n' + logstr;    //2022-07-11   zyh   add
                    continue;
                }
                gedMap.put(ged.repairOderInfo.repairOrderNo2, ged);
 
                managementCodeList.add(ged.repairOderInfo.departmentCd);
                // 报修人用户编码
                if (String.isNotBlank(ged.repairOderInfo.repairApplyPerson)) {
                    rpersonList.add(ged.repairOderInfo.repairApplyPerson);
                }
                //申请修理人编号
                if (String.isNotBlank(ged.repairOderInfo.applicantId)) {
                    // canIdList.add(ged.repairOderInfo.applicantId);
                    rpersonList.add(ged.repairOderInfo.applicantId);
 
                }
                // 受理人用户编号(经销商用户、社内用户)
                if (String.isNotBlank(ged.repairOderInfo.receiverId)) {
                    rpersonList.add(ged.repairOderInfo.receiverId);
                    // canIdList.add(ged.repairOderInfo.receiverId);
                }
                canIdList.add(ged.repairOderInfo.repairOrderNo2FSEID);
            }
            if (gedMap.size() > 0) {
                
                // 根据科室编码获取科室、战略科室、医院
                Map < String, Account > accountMap = getAccountMap(managementCodeList);
                //存放报修人用户编码,id
                Map < String, Id > personMap = getContactMap(rpersonList);
                //存放取消人用户编码,受理人id.申请修理人编号,报修子单所属FSE的ID,id
                Map < String, User > canidMap =  getUserMap(canIdList);
 
                // 附件下载标记
                Boolean attachmentDownloadFlg = false;
                String repairOrderNo2Str = '报修子单No [ \n';
                Map<String,RepairSubOrder__c> RsoMap = new Map<String,RepairSubOrder__c>();
                for (String repairOrderNo2: gedMap.keySet()) {
                    GeData ged = gedMap.get(repairOrderNo2);
 
                    if (!accountMap.containsKey(ged.repairOderInfo.departmentCd)) {
                        logstr += ged.repairOderInfo.departmentCd + '该科室不存在,此条数据跳过!';
                        logerr += '报修子单No['+repairOrderNo2+']\n' + logstr;    //2022-07-11   zyh   add
                        continue;
                    }
                    if (String.isNotBlank(ged.repairOderInfo.repairApplyPerson) && !personMap.containsKey(ged.repairOderInfo.repairApplyPerson)) {
                        logstr += ged.repairOderInfo.repairApplyPerson + '报修人用户编码不存在,此条数据跳过';
                        logerr += '报修子单No['+repairOrderNo2+']\n' + logstr;    //2022-07-11   zyh   add
                        continue;
                    }
 
                    if (!personMap.containsKey(ged.repairOderInfo.receiverId)) {
                        logstr += ged.repairOderInfo.receiverId + '受理人用户编号不存在,此条数据跳过';
                        logerr += '报修子单No['+repairOrderNo2+']\n' + logstr;    //2022-07-11   zyh   add
                        continue;
                    }
                    
                    if ('申请修理'.equals(ged.applyRepairInfo.processResult) && !personMap.containsKey(ged.repairOderInfo.applicantId)) {
                        logstr += ged.repairOderInfo.applicantId + '申请修理人编号不存在,此条数据跳过';
                        logerr += '报修子单No['+repairOrderNo2+']\n' + logstr;    //2022-07-11   zyh   add
                        continue;
                    }
                    if (!canidMap.containsKey(ged.repairOderInfo.repairOrderNo2FSEID)) {
                        logstr += ged.repairOderInfo.repairOrderNo2FSEID + '报修子单所属FSE的ID不存在,此条数据跳过';
                        logerr += '报修子单No['+repairOrderNo2+']\n' + logstr;    //2022-07-11   zyh   add
                        continue;
                    }
                    RepairSubOrder__c repair = new RepairSubOrder__c();
                    repair.RepairOrderNo__c = ged.repairOderInfo.repairOrderNo; //报修单号
                    repair.RepairSubOrderNo__c = ged.repairOderInfo.repairOrderNo2; //报修单子单号
                    repair.Name = ged.repairOderInfo.repairOrderNo2; //报修单名称
                    Account dep = accountMap.get(ged.repairOderInfo.departmentCd);
                    repair.Hospital__c = dep.Parent.ParentId; //报修医院编码
                    repair.StrategicDepartment__c = dep.ParentId; //战略科室
                    repair.Department__c = dep.Id; //报修科室编码
                    //XLIU-CFZ3AR LY 20220705 Start
                    system.debug('12121121'+dep.Province_formula__c);
                    repair.State__c = dep.Province_formula__c; //省
                    //XLIU-CFZ3AR LY 20220705 End
 
                    repair.RepairApplicant__c = personMap.get(ged.repairOderInfo.repairApplyPerson); //报修人用户编码
                    repair.RepairApplicantName__c = ged.repairOderInfo.repairApplicantName; //报修人姓名
                    repair.RepairApplicantTel__c = ged.repairOderInfo.repairApplyPersonTel; //报修人联系电话
                    repair.RepairSubOrderPost__c = ged.repairOderInfo.repairApplyType; //报修人岗位
                    repair.EquipmentCategory__c = ged.repairOderInfo.equipmentCategory; //设备大类
                    repair.AssetType__c = ged.repairOderInfo.assetType; //设备类型
                    repair.AssetCode__c = ged.repairOderInfo.equipmentCd; //机身编码
                    repair.FaultTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.faultDate); //故障发生日
                    repair.RepairTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.repairOrderTime); //报修时间
                    repair.FaultType__c = ged.repairOderInfo.faultType; //故障类型
                    repair.ProblemDescription__c = ged.repairOderInfo.problemDesc; //问题描述
                    repair.RepairSubOrderType__c = ged.repairOderInfo.repairSubOrderType; //报修单类型
                    repair.ResponseResultType__c = ged.repairOderInfo.responseResultType; //应对结果类型
 
                    repair.ReceiverType__c = ged.repairOderInfo.receiverType; //受理人类型
 
                    // repair.ReceiverFSE__c = canidMap.get(ged.repairOderInfo.receiverId).Id; //受理人(FSE)
                    repair.Receiver__c = personMap.get(ged.repairOderInfo.receiverId); //受理人
                    repair.ReceiverTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.receiverDate); //受理日
                    repair.PlannedVisitDay__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.plannedVisitDay); //计划上门日
                    repair.StartTimeFirst__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.startTimeFirst); //开始时间
                    repair.EndTimeFirst__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.endTimeThird); //结束时间
                    repair.FaultDescriptionFirst__c = ged.repairOderInfo.faultDescriptionFirst; //故障描述
                    repair.ActualVisitTimeSecond__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.actualVisitTimeSecond); //二次上门日--->二次计划上门日
                    repair.StartTimeSecond__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.startTimeSecond); //二次上门开始时间--->二次上门日
                    repair.EndTimeSecond__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.endTimeSecond); //二次上门结束时间
                    repair.FaultDescriptionSecond__c = ged.repairOderInfo.faultDescriptionSecond; //二次故障描述
                    repair.ActualVisitTimeThird__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.actualVisitTimeThird); //三次上门日--->三次计划上门日
                    repair.StartTimeThird__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.startTimeThird); //三次上门开始时间--->三次上门日
                    repair.EndTimeThird__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.endTimeThird); //三次上门结束时间
                    repair.FaultDescriptionThird__c = ged.repairOderInfo.faultDescriptionThird; //三次故障描述
                    repair.ApplicantType__c = ged.repairOderInfo.applicantType; //申请修理人类型
                    //repair.RepairApplicantName_Encrypted__c =ged.repairOderInfo.repairApplicantNameEncrypted; //报修人姓名密文 add 20220214           //zhj 新方案改造 2022-12-09  
                    //repair.RepairApplicantTel_Encrypted__c = ged.repairOderInfo.repairApplyPersonTelEncrypted;//保修人联系电话密文 add 20220214       //zhj 新方案改造 2022-12-09
                    //repair.AWS_Data_Id__c =ged.repairOderInfo.DataId;//AWS 存储凭证 add 20220214 /*迁移ali sushanhu 20231017
                    // repair.Applicant__c = canidMap.get(ged.repairOderInfo.applicantId).Id; //申请修理人编号
                    repair.Applicanter__c = personMap.get(ged.repairOderInfo.applicantId);//申请修理人编号
                    repair.ApplicationTime__c = NFMUtil.parseStr2DateTime(ged.repairOderInfo.applyDate); //申请时间
 
                    repair.Ownerid = canidMap.get(ged.repairOderInfo.repairOrderNo2FSEID).Id; //报修子单所属FSE的ID
                    repair.AssetModel__c = ged.applyRepairInfo.equipmentModel; //设备型号
                    repair.AirframeCodeEngineer__c = ged.applyRepairInfo.equipmentCd; //机身编码(工程师)
                    repair.ResponseResultDesc__c = ged.applyRepairInfo.responseResultDesc; //应对描述--->问题描述(工程师)
                    repair.ProcessResult__c = ged.applyRepairInfo.processResult; //处理结果
 
                    //  2022/4/6    zhangyuheng update start
                    repair.RepairFinishDate__c = NFMUtil.parseDateTimeStr2Date(ged.repairOderInfo.RepairFinishDate) ;   //修理品处理完成日
                    repair.ApplicanterPhone__c = ged.repairOderInfo.ApplicanterPhone;   //处理人电话
                    repair.CancelleRepairTime__c = NFMUtil.parseDateTimeStr2Date(ged.repairOderInfo.CancelDate);    //受理人取消报修日
                    // repair.CancelleRepairTime__c = NFMUtil.parseStr2Date(ged.repairOderInfo.CancelDate);    //受理人取消报修日
                    repair.RepairCancelReason__c = ged.repairOderInfo.cancelReportReason;   //修理取消原因
                    //  2022/4/6    zhangyuheng update end
                    // 2023-02-20   zyh   add   start
                    repair.DateReceiptQuestions__c = NFMUtil.parseDateTimeStr2Date(ged.problem.dateReceiptQuestions); //投诉知悉日(Complaint Aware Date)
                    repair.IfDeadHurt__c = ged.problem.ifDeadHurt; //是否有死亡、伤害、感染
                    repair.ProblemOccurred__c = ged.problem.problemOccurred; //问题发生时间情况
                    repair.ProblemOccurredSelect__c = ged.problem.problemOccurredSelect; //问题发生时间情况 其他
                    repair.ReportAdverseEvents__c = ged.problem.reportAdverseEvents; //医院有没有向政府机关报告不良事件或疑似不良事件
                    repair.WhatProject__c = ged.problem.whatProject; //做的是哪个项目
                    repair.OperationOrExaminationName__c = ged.problem.operationOrExaminationName; //手术/检查名称
                    repair.BreakORFallOff__c = ged.problem.breakORFallOff; //是否有发生断裂或脱落
                    repair.UseFailProductFinish__c = ged.problem.useFailProductFinish; //是否用该产品完成了手术/检查
                    repair.SupportingProducts__c = ged.problem.supportingProducts; //配套使用产品
                    repair.AfterFailureInformation__c = ged.problem.afterFailureInformation; //发现故障后,医院对患者的处理情况
                    repair.Delay15Min__c = ged.problem.delay15Min; //发现故障现象后,有延误15分钟以上的手术实施的情况发生吗
                    repair.InformationFrom__c = ged.problem.informationFrom; //信息是从医院的谁那里得到的
                    repair.FailureQInHospital__c = ged.problem.failureQInHospital; //在医院,故障发生的频率是多少
                    repair.DelayReportReason__c = ged.problem.delayReportReason; //超时报告的理由
                    repair.IsProductFaultRelated__c = ged.problem.isProductFaultRelated; //是否与这次产品故障相关
                    if(String.isNotBlank(ged.logistics.isOts)){
                        repair.IsOts__c = ged.logistics.isOts; //是否使用ots
                    }
                    if(String.isNotBlank(ged.logistics.senderOrgCode)){
                        repair.SenderOrgCode__c = ged.logistics.senderOrgCode; //送修机构代码
                    }
                    if(String.isNotBlank(ged.logistics.senderOrgCode)){
                        repair.SenderCompany__c = ged.logistics.senderOrgCode; //送修机构名称
                    }
                    if(String.isNotBlank(ged.logistics.senderName)){
                        repair.SenderName__c = ged.logistics.senderName; //送修人姓 名
                    }
                    if(String.isNotBlank(ged.logistics.senderMobilePhone)){
                        repair.SenderMobilePhone__c = ged.logistics.senderMobilePhone; //送修人手机
                    }
                    if(String.isNotBlank(ged.logistics.senderAddress)){
                        repair.SenderAddress__c = ged.logistics.senderAddress; //送修人地址
                    }
                    if(String.isNotBlank(ged.logistics.recepientCompany)){
                        repair.RecepientCompany__c = ged.logistics.recepientCompany; //接收机构名称
                    }
                    if(String.isNotBlank(ged.logistics.recepientName)){
                        repair.RecepientName__c = ged.logistics.recepientName; //接收送修人姓名
                    }
                    if(String.isNotBlank(ged.logistics.recepientMobilePhone)){
                        repair.RecepientMobilePhone__c = ged.logistics.recepientMobilePhone; //接收人手机
                    }
                    if(String.isNotBlank(ged.logistics.recepientAddress)){
                        repair.RecepientAddress__c = ged.logistics.recepientAddress; //接收人地址
                    }
                    if(String.isNotBlank(ged.logistics.returnWayType)){
                        repair.ReturnWayType__c = ged.logistics.returnWayType; //返品方式
                    }
                    if(String.isNotBlank(ged.logistics.orderNumber)){
                        repair.OrderNumber__c = ged.logistics.orderNumber; //送修物流单号
                    }
                    //deloitte-zhj 20230920 PIPL 新增返品字段 start
                    if(String.isNotBlank(ged.logistics.returnedProvince)){
                        repair.ReturnedProvince__c = ged.logistics.returnedProvince; //送修物流单号
                    }
                    if(String.isNotBlank(ged.logistics.returnedCity)){
                        repair.ReturnedCity__c = ged.logistics.returnedCity; //送修物流单号
                    }
                    if(String.isNotBlank(ged.logistics.returnedPersonName)){
                        repair.ReturnedPersonName__c = ged.logistics.returnedPersonName; //送修物流单号
                    }
                    if(String.isNotBlank(ged.logistics.returnedPersonPhone)){
                        repair.ReturnedPersonPhone__c = ged.logistics.returnedPersonPhone; //送修物流单号
                    }
                    if(String.isNotBlank(ged.logistics.returnedAddress)){
                        repair.ReturnedAddress__c = ged.logistics.returnedAddress; //送修物流单号
                    }
                    if(String.isNotBlank(ged.logistics.returnedCustomer)){
                        repair.ReturnedCustomer__c = ged.logistics.returnedCustomer; //送修物流单号
                    }
                    if(String.isNotBlank(ged.logistics.returnedZipCode)){
                        repair.ReturnedZipCode__c = ged.logistics.returnedZipCode; //送修物流单号
                    }
                    //deloitte-zhj 20230920 PIPL 新增返品字段 end
                    System.debug(ged.logistics.orderNumber + '=========OTS');
                    System.debug(ged.logistics + '=========OTS1');
                    repair.FailureReason__c = ged.logistics.failureReason; //下单失败原因
                    repair.LogisticsSendDate__c = NFMUtil.parseDateTimeStr2Date(ged.logistics.logisticsSendDate); //送修物流发送日
                    repair.Item0010__c = ged.item0010; //备用字段1
                    repair.Item0020__c = ged.item0020; //备用字段2
                    repair.Item0030__c = ged.item0030; //备用字段3
                    repair.Item0040__c = ged.item0040; //备用字段4
                    repair.Item0050__c = ged.item0050; //备用字段5
                    // 2023-02-20   zyh   add   end
                    //LLIU-CG53S9 20220715 LY start
                    if ('问题已解决'.equals(ged.applyRepairInfo.processResult) ||'需做质量判定'.equals(ged.applyRepairInfo.processResult) ||'用户选择不修理'.equals(ged.applyRepairInfo.processResult)) {
                    //LLIU-CG53S9 20220715 LY end
                        // repair.Status__c = '关闭';
                        repair.Status__c = '已完成';   // 2022/4/6 zhangyuheng
                    } else {
                        repair.Status__c = '待处理';
 
                    }
                    // 附件信息
                    repair.AttachmentLink__c = ged.repairOderInfo.problemPhotofile;
                    String attachmentName = ged.repairOderInfo.problemPhotoName;
                    
                    if (ged.repairOderInfo != null && String.isNotBlank(ged.repairOderInfo.problemPhotofile)) {
                        repair.AttachmentDownload__c = true;
                        attachmentDownloadFlg = true;
                        if (String.isBlank(attachmentName) || (String.isNotBlank(attachmentName) && !attachmentName.contains('.zip'))){
                            attachmentName = '附件.zip';
                        } 
                        
                    }
                    repair.AttachmentName__c = attachmentName;
                    repairOrderNo2Str += repairOrderNo2 + '\n';
                    repairList.add(repair);
                    repairNoList.add(ged.repairOderInfo.repairOrderNo2);
                    RsoMap.put(ged.repairOderInfo.repairOrderNo2,repair);
                }
                //  2022/4/6    zhangyuheng update start
                List<RepairSubOrder__c> upList = new List<RepairSubOrder__c>();
                List<RepairSubOrder__c> repairSOList1 = [SELECT Id,RepairSubOrderNo__c,DateReceiptQuestions__c,
                                                                IfDeadHurt__c,
                                                                ProblemOccurred__c,
                                                                ProblemOccurredSelect__c,
                                                                ReportAdverseEvents__c,
                                                                WhatProject__c,
                                                                OperationOrExaminationName__c,
                                                                BreakORFallOff__c,
                                                                UseFailProductFinish__c,
                                                                SupportingProducts__c,
                                                                AfterFailureInformation__c,
                                                                Delay15Min__c,
                                                                InformationFrom__c,
                                                                FailureQInHospital__c,
                                                                DelayReportReason__c,
                                                                IsProductFaultRelated__c,
                                                                // 2023-04-25   zyh   add   小程序新加放开   start
                                                                SenderMobilePhone__c,
                                                                SenderName__c,
                                                                SenderAddress__c,
                                                                RecepientCompany__c,
                                                                ReturnWayType__c,
                                                                LogisticsSendDate__c
                                                                // 2023-04-25   zyh   add   小程序新加放开   end
                                                                ,Status__c
                                                                 FROM RepairSubOrder__c WHERE RepairSubOrderNo__c in: repairNoList];
                if (repairSOList1.size() > 0) {
                    for(RepairSubOrder__c rso: repairSOList1){
                        if(RsoMap.containsKey(rso.RepairSubOrderNo__c)){
                            RepairSubOrder__c temp = new RepairSubOrder__c();
                            temp = RsoMap.get(rso.RepairSubOrderNo__c);
                            temp.Id = rso .Id;
                            if(rso.Status__c != '已完成' || rso.Status__c != '待处理'){
                                temp.Status__c = rso.Status__c;
                            }
                            upList.add(temp);
                        }
                    }
                    logstr += repairOrderNo2Str + ']-已存在';
                    update upList;
                    System.debug(repairSOList1[0].Id + '===' + repairSOList1[0].DateReceiptQuestions__c);
                    logstr += repairOrderNo2Str + '更新完成, 更新总数为:' + repairSOList1.size() + '\n' + repairSOList1;
                }
                // if (repairList.size() > 0) {==== 2022/4/6 zhangyuheng注释掉
                else {
                //  2022/4/6    zhangyuheng update end
                    insert repairList;
                    repairOrderNo2Str += ' ]\n';
                    logstr += repairOrderNo2Str + '新增完成, 新增总数数为:' + repairList.size() + '\n';
                    if (attachmentDownloadFlg) {
                        NFM609Schedule.assignOneMinute('RepairSubOrder__c');    
                    }
                    
                }
            }
            logstr += 'End\n';
            rowData.retry_cnt__c = 0;
        } catch (Exception ex) {
            Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
            // エラーが発生した場合
            Database.rollback(sp);
            logstr += '\n' + ex.getMessage();
            iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
            if (!Test.isRunningTest()) {
                rowData = NFMUtil.LogAutoSend(rowData, ex, null);
            }
        }
        rowData.MessageGroupNumber__c = rowData.Name;
        update rowData;
        iflog.Log__c = logstr;
        iflog.ErrorLog__c = logerr;//2022-07-11   zyh   add
        insert iflog;
    }
    /**
     * [getAccountMap description] 根据科室编码查找科室,与科室对应的战略科室和医院
     * @param  managementCodeList [可数的管理编码]
     * @return                    [科室信息]
     */
    private static Map < String, Account > getAccountMap(List < String > managementCodeList) {
        List < Account > accountList =
            [SELECT id, Management_Code__c, ParentId, Parent.ParentId
                //XLIU-CFZ3AR LY 20220705 Start
                ,Province_formula__c
                //XLIU-CFZ3AR LY 20220705 End
                FROM Account
                WHERE Management_Code__c
                IN: managementCodeList
            ];
 
        Map < String, Account > hosMap = new Map < String, Account > ();
        for (Account ac: accountList) {
            hosMap.put(ac.Management_Code__c, ac);
        }
        return hosMap;
    }
    /**
     * [获取系统里的联系人]
     * @param  rpersonList [报修人/申请人/受理人的管理人员编号或对应用户的员工编码]
     * @return             [联系人信息]
     */
    private static Map < String, Id > getContactMap(List < String > rpersonList) {
        List < Contact > couList = [
                        SELECT id, CManageCode__c,Employee_No_manual__c 
                        FROM Contact 
                        WHERE CManageCode__c IN: rpersonList OR Employee_No_manual__c IN:rpersonList];
        Map < String, Id > contactMap = new Map < String, Id > ();        
        for (Contact con: couList) {
            contactMap.put(con.CManageCode__c, con.Id);
            if (String.isNotBlank(con.Employee_No_manual__c)) {
                contactMap.put(con.Employee_No_manual__c, con.Id);
            }
        }
        return contactMap;
    }
    /**
     * [获取系统里的用户]
     * @param  canIdList [description]
     * @return           [description]
     */
    private static Map < String, User > getUserMap(List < String > canIdList) {
        List < User > userList =
            [SELECT id, Employee_No__c, Contact.CManageCode__c,IsActive,Contact.Employee_No_manual__c
                FROM User
                WHERE Employee_No__c IN: canIdList OR Contact.CManageCode__c IN: canIdList OR Contact.Employee_No_manual__c IN:canIdList
            ];
        Map < String, User > result = new Map < String, User > ();
        for (User u: userList) {
            if (String.isNotBlank(u.Contact.CManageCode__c)) {
                result.put(u.Contact.CManageCode__c, u);
            }
            if (String.isNotBlank(u.Contact.Employee_No_manual__c)) {
                result.put(u.Contact.Employee_No_manual__c, u);
            }
            result.put(u.Employee_No__c, u);
        }
 
        return result;
    }
 
    private static String verify(GeData ged) {
        String result = '';
        String repairOrderNo2 = '';
        if (ged.repairOderInfo == null) {
            result += ' DataError: repairOderInfo is null!\n';
        } else {
            if (ged.repairOderInfo.repairOrderNo == null) {
                result += ' DataError: 报修单 [ repairOrderNo ] is null!\n';
            }
            if (ged.repairOderInfo.repairOrderNo2 == null) {
                result += ' DataError: 报修子单 [ repairOrderNo2 ] is null!\n';
            } else {
                repairOrderNo2 = '报修子单 [ ' + ged.repairOderInfo.repairOrderNo2 + ' ]\n';
            }
            if (ged.repairOderInfo.departmentCd == null) {
                result += ' DataError: 报修科室编码 [ departmentCd ] is null!\n';
            }
 
            if (ged.repairOderInfo.faultDate == null) {
                result += ' DataError: 故障发生日 [ faultDate ] is null!\n';
            }
            if (ged.repairOderInfo.repairOrderTime == null) {
                result += ' DataError: 报修时间 [ repairOrderTime ] is null!\n';
            }
            /*if (ged.repairOderInfo.faultType == null) {
                result += ' DataError: 故障类型 [ faultType ] is null!\n';
            }*/ // 2023-3-20   zyh   add   小程序注释
            if (ged.repairOderInfo.repairSubOrderType == null) {
                result += ' DataError: 报修单类型 [ repairSubOrderType ] is null!\n';
            }
 
            if (String.isBlank(ged.repairOderInfo.receiverType)) {
                result += ' DataError: 受理人类型 [ receiverType ] is null!\n';
            }
            if (String.isBlank(ged.repairOderInfo.receiverId)) {
                result += ' DataError: 受理人用户编号 [ receiverId ] is null!\n';
            }
            if (String.isBlank(ged.repairOderInfo.receiverDate)) {
                result += ' DataError: 受理日 [ receiverDate ] is null!\n';
            }
            if (ged.repairOderInfo.repairOrderNo2FSEID == null) {
                result += ' DataError: 报修子单所属FSE的ID [ repairOrderNo2FSEID ] is null!\n';
            }
        }
        if (ged.applyRepairInfo == null) {
            result += ' DataError: applyRepairInfo is null!\n';
        } else {
            if (String.isBlank(ged.applyRepairInfo.equipmentModel)) {
                result += ' DataError: 设备型号 [ equipmentModel ] is null!\n';
            }
 
            if (String.isBlank(ged.applyRepairInfo.processResult)) {
                result += ' DataError: 处理结果 [ processResult ] is null!\n';
            } else {
                if ('申请修理'.equals(ged.applyRepairInfo.processResult)) {
                    if (String.isBlank(ged.repairOderInfo.applicantId)) {
                        result += ' DataError: 申请修理人编号 [ applicantId ] is null!\n';
                    }
                    if (String.isBlank(ged.repairOderInfo.applyDate)) {
                        result += ' DataError: 申请时间 [ applyDate ] is null!\n';
                    }
                }
            }
        }
 
        if (String.isNotBlank(repairOrderNo2) && String.isNotBlank(result)) {
            result = repairOrderNo2 + result;
        }
        return result;
    }
 
            
}