高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
@isTest
private class NFM624RestTest {
    static testMethod void testMethod1(){
        BatchIF_Log__c testLog = new BatchIF_Log__c();
        testLog.CurrencyIsoCode = 'CNY';
        testLog.Type__c = 'NFM624';
        testLog.MessageGroupNumber__c = '123456789987';
        // testLog.Name = '20211207';
        testLog.ErrorLog__c = '';
        testLog.MessageGroupNumber__c = '20211207';
        testLog.RowDataFlg__c = true;
        testLog.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"354044","RelatedDepartment":"760129","RegSource":"2","PersonManagementCode":"C000132345","Name":"刘璐","Mobile":"13683268803","HospitalManagementCode2":"415","ForbiddenStatus":true,"DepartmentName":"北京大学第三医院 呼吸科 呼吸科","DepartmentManagementCode2":"416","DepartmentClass":"呼吸科","ContactId":"2552","ContactAddress":"","City":"海淀区","ApproverID":"","AgentFlag":false,"AccountName":"北京大学第三医院"}]';
        //[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,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]
        insert testLog;
        NFM624Rest.main(testLog.Id);
    }
    static testMethod void testMethod2(){
        
        //Test.startTest();
        //用户
        User hpowner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2');
        insert hpowner;
 
        User hpowner2 = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp1', Work_Location__c = '北京', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner1@sunbridge.com', Username = 'olympus_hpowner1@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = '00e10000000xnp2');
        insert hpowner2;
        
        //医院
        Account hp = new Account(RecordTypeId = '01210000000QemG', Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.Advance_Payment_Identification_Approval__c = Date.today().addyears(-1);
        insert hp;
 
        //战略科室
        Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
        
        //科室
        // Account dpt = new Account(RecordTypeId = '01210000000QfmR');
        // dpt.Name         = '*';
        // dpt.Department_Name__c  = 'TestDepart';
        // dpt.ParentId            = dc.Id;
        // dpt.Department_Class__c = dc.Id;
        // dpt.Hospital__c         = hp.Id;
        // insert dpt;
        
        //科室1
        Account dpt1 = new Account();
        dpt1.RecordTypeId = '01210000000QfmR';
        dpt1.Name         = '123';
        dpt1.Department_Name__c  = 'TestDepart1';
        dpt1.ParentId            = dc.Id;
        dpt1.Department_Class__c = dc.Id;
        dpt1.Hospital__c         = hp.Id;
        insert dpt1;
 
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
 
        String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"202107131529","Text":null,"Tag":null,"Sender":"OBPM","Receiver":"SFDC","NumberOfRecord":"2","MessageType":"NFM705","MessageGroupNumber":null},"GeData":[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"354044","RelatedDepartment":"760129","RegSource":"2","PersonManagementCode":"C000132345","Name":"刘璐","Mobile":"13683268803","HospitalManagementCode2":"415","ForbiddenStatus":true,"DepartmentName":"北京大学第三医院 呼吸科 呼吸科","DepartmentManagementCode2":"416","DepartmentClass":"呼吸科","ContactId":"2552","ContactAddress":"","City":"海淀区","ApproverID":"","AgentFlag":false,"AccountName":"北京大学第三医院"}]}';
        req.requestURI = 'services/apexrest/NFM624/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
 
        NFM624Rest.execute();
 
        //Test.stopTest();
    }
    static testMethod void testMethod3(){
        BatchIF_Log__c testLog = new BatchIF_Log__c();
        testLog.CurrencyIsoCode = 'CNY';
        testLog.Type__c = 'NFM624';
        testLog.MessageGroupNumber__c = '123456789987';
        // testLog.Name = '20211207';
        testLog.ErrorLog__c = '';
        testLog.MessageGroupNumber__c = '20211207';
        testLog.RowDataFlg__c = true;
        testLog.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"8087702","RelatedDepartment":"8087715","RegSource":"1","PersonManagementCode":"C000132192","Name":"胖达","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":false,"DepartmentName":"消化神经混合科","DepartmentManagementCode2":"1118004","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]';
        //[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,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]
        insert testLog;
        NFM624Rest.main(testLog.Id);
 
        BatchIF_Log__c testLog2 = new BatchIF_Log__c();
        testLog2.CurrencyIsoCode = 'CNY';
        testLog2.Type__c = 'NFM624';
        testLog2.MessageGroupNumber__c = '123456789987';
        // testLog.Name = '20211207';
        testLog2.ErrorLog__c = '';
        testLog2.MessageGroupNumber__c = '20211207';
        testLog2.RowDataFlg__c = true;
        testLog2.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","Name":"张三","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":false,"DepartmentName":"消化神经科","DepartmentManagementCode2":"1118001","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]';
        //[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,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]
        insert testLog2;
        NFM624Rest.main(testLog2.Id);
 
        BatchIF_Log__c testLog3 = new BatchIF_Log__c();
        testLog3.CurrencyIsoCode = 'CNY';
        testLog3.Type__c = 'NFM624';
        testLog3.MessageGroupNumber__c = '123456789987';
        // testLog.Name = '20211207';
        testLog3.ErrorLog__c = '';
        testLog3.MessageGroupNumber__c = '20211207';
        testLog3.RowDataFlg__c = true;
        testLog3.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","Name":"张三","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":false,"DepartmentName":"消化神经科","DepartmentManagementCode2":"1118001","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]';
        //[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,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]
        insert testLog3;
        NFM624Rest.main(testLog3.Id);
 
        BatchIF_Log__c testLog4 = new BatchIF_Log__c();
        testLog4.CurrencyIsoCode = 'CNY';
        testLog4.Type__c = 'NFM624';
        testLog4.MessageGroupNumber__c = '123456789987';
        // testLog.Name = '20211207';
        testLog4.ErrorLog__c = '';
        testLog4.MessageGroupNumber__c = '20211207';
        testLog4.RowDataFlg__c = true;
        testLog4.Log__c = '[{"Type":"医生","State":"北京市","ServiceUserId":"","RelatedHospital":"","RelatedDepartment":"","RegSource":"1","PersonManagementCode":"","Name":"胖达","Mobile":"17734281527","HospitalManagementCode2":"1118000","ForbiddenStatus":true,"DepartmentName":"消化神经混合科","DepartmentManagementCode2":"1118004","DepartmentClass":"消化科","ContactId":"1118002","ContactAddress":"北京市朝阳区亮马桥","City":"朝阳区","AgentFlag":false,"AccountName":"恩惠医院"}]';
        //[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,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowData_Id]
        insert testLog4;
        NFM624Rest.main(testLog4.Id);
    }
}