高章伟
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
@isTest
public class NFM113RestTest {
    static testMethod void testMethodTwo() {
        //Test.startTest();
        // //新建医院
        // Account hp = new Account();
        // hp.RecordTypeId = '01210000000QemG';
        // hp.OCM_Category__c = 'L';
        // insert hp;
        // //新建战略科室
        // Account dpt = new Account();
        // dpt.RecordTypeId = '01210000000QezZ';
        // insert dt;
        // //新建科室
        // Account dpt = new Account();
        // dpt.RecordTypeId = '01210000000QfmR';
        // insert dpt;
        //医院 记录类型
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
        //科室 记录类型
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
        if (rectDpt.size() == 0) {
            return;
        }
 
        //简档
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
 
        //用户
        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 = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
 
 
        //医院
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        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 = rectDpt[0].Id);
        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(RecordTypeId = rectDpt[0].Id);
        // 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;
        //新建维修合同
        Maintenance_Contract__c test = new Maintenance_Contract__c();
        test.Name = 'Test合同';
        test.RecordTypeId='01210000000QjeF';
        test.Department__c = dpt.Id;
        test.Management_Code__c =  'BJ-RS-BJ0062233';
        test.Status__c = '询价中';
        test.Service_Contract_Staff__c = hpowner2.Id;
        insert test;
 
 
        
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
 
        String JsonMsg = '{"Monitoring":{"Tag":"MSGH","Sender":"SAP","Receiver":"SFDC","MessageType":"NFM113","MessageGroupNumber":628504,"NumberOfRecord":1,"TransmissionDateTime":202112140933},"ReceiveInfo":[{"ReceiveNo":"KXE2019120698","ItemNo":"000020","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062230","Amount":"800.00 ","ReceiveDate":20211213,"DeleteFlag":"X","DeleteDate":20211213,"Operator":"ON000547"},{"ReceiveNo":"KXE2019120698","ItemNo":"000030","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062233","Amount":"488.00 ","ReceiveDate":20211213,"DeleteFlag":"X","DeleteDate":20211213,"Operator":"ON000547"},{"ReceiveNo":"KXE2019120698","ItemNo":"000040","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062230","Amount":"500.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXE2019120698","ItemNo":"000050","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062233","Amount":"400.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXE2019120752","ItemNo":"000020","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062230","Amount":"300.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXE2019120752","ItemNo":"000030","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062230","Amount":"8000.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXE2019120752","ItemNo":"000040","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062233","Amount":"88.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXE2019120752","ItemNo":"000050","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062233","Amount":"1000.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXS2020030254","ItemNo":"000020","CompanyCode":5113,"ContractNo":"GZ-RS-SC0054464","Amount":"760.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXS2020030254","ItemNo":"000030","CompanyCode":5113,"ContractNo":"GZ-RS-SC0054464","Amount":"5000.00 ","ReceiveDate":20211213,"DeleteFlag":"X","DeleteDate":20211213,"Operator":"ON000547"},{"ReceiveNo":"KXS2020030254","ItemNo":"000040","CompanyCode":5113,"ContractNo":"GZ-RS-SC0054464","Amount":"7000.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXS2020030254","ItemNo":"000050","CompanyCode":5113,"ContractNo":"GZ-RS-SC0054464","Amount":"200000.00 ","ReceiveDate":20211213,"DeleteFlag":"","DeleteDate":"00000000","Operator":"ON000547"},{"ReceiveNo":"KXE2019120698","ItemNo":"000020","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062230","Amount":"800.00 ","ReceiveDate":20211213,"DeleteFlag":"X","DeleteDate":20211213,"Operator":"ON000547"},{"ReceiveNo":"KXE2019120698","ItemNo":"000030","CompanyCode":5112,"ContractNo":"BJ-RS-BJ0062233","Amount":"488.00 ","ReceiveDate":20211213,"DeleteFlag":"X","DeleteDate":20211213,"Operator":"ON000547"},{"ReceiveNo":"KXS2020030254","ItemNo":"000030","CompanyCode":5113,"ContractNo":"GZ-RS-SC0054464","Amount":"5000.00 ","ReceiveDate":20211213,"DeleteFlag":"X","DeleteDate":20211213,"Operator":"ON000547"}]}';
        req.requestURI = 'services/apexrest/NFM113/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
 
        NFM113Rest.execute();
 
        //Test.stopTest();
    }
}