buli
2023-04-26 610aaa20b10fecad29607c2f1912721ff01bb379
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
@isTest
public with sharing class SyncProvinceWIndowToSignFormTest {
    @isTest
    private static void testTestCase() {
        // Test data setup
        //新建电子签收单
        map <string, eSignForm__c> eSFMap = new  map <string, eSignForm__c>();
        eSignForm__c eSignForm = new eSignForm__c();
        eSignForm.Name = '::测试电子签收单';
        eSignForm.DNName__c = '112233';
        eSFMap.put(eSignForm.DNName__c, eSignForm);
 
        Statu_Achievements_DN__c  sad = new Statu_Achievements_DN__c();
        sad.Name = '112233';
        sad.DeliveryDate_Raw__c = '1111';
        sad.Sales_assistant_name_text__c = UserInfo.getUserId();
        sad.RC_Manager__c = UserInfo.getUserId();
        sad.EsignTestAccount__c =true;
        sad.ReturnMark__c = false;
 
        list<Statu_Achievements_DN__c> DNList = new list<Statu_Achievements_DN__c>();
        DNList.add(sad);
        
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            return;
        }
 
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'TestCompany';
        upsert company;
        Account section = new Account();
        section.RecordTypeId = rectSct[0].Id;
        section.Name         = '*';
        section.Department_Class_Label__c = '消化科';
        section.ParentId                  = company.Id;
        section.Hospital_Department_Class__c = company.Id;
        upsert section;
        Account depart = new Account();
        depart.RecordTypeId = rectDpt[0].Id;
        depart.Name         = '*';
        depart.Department_Name__c  = 'TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
 
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
               CloseDate=Date.today(),
               AccountId=depart.Id,
               Sales_Root__c = '販売店',
               Competitor__c ='A',
               Click_Close_Date__c = null,
               RecordType = rectOpp
        );
        insert opp;
 
        //注残
        Statu_Achievements__c Sac = new Statu_Achievements__c(
            name = 'zhucan_one',
            Opportunity__c = opp.id,
            DeliveryDate__c = Date.today(),
            ContractNO__c = 'ContractNO1',
            ContractAmount__c = 1000
        );
        insert Sac;
        list<eSignForm__c>  esignFormTest = DNUpsertBatch.SetupeSignForm(eSFMap, DNList);
        esignFormTest[0].Statu_Achievements__c = Sac.Id;
        insert esignFormTest;
        system.debug('Test esignForm Data:' + esignFormTest);
 
        OCM_Management_Province__c ocsmTest = new OCM_Management_Province__c();
        ocsmTest.Name = '其他';
        ocsmTest.Province__c = '北京市';      
        insert ocsmTest;
        ocsmTest.Window1__c = Userinfo.getUserId();
        update ocsmTest;
 
        // Actual test
        Test.startTest();
        //SyncProvinceWIndowToSignForm.syncProvinceWIndow(new Set<String>{'北京市'});
        //SyncProvinceWIndowToSignForm.syncProvinceWIndow(new Set<String>());
        Test.stopTest();
    
        // Asserts
    }
}