高章伟
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
@isTest
public class MaintenanceContractNotOpenControllerTest {
    private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
    static testMethod void testMethod1() {
         // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        insert hospital;
        
        // 戦略科室を得る
        List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
        
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
        dep.Name = 'test dep';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
        
        // 製品を作る
        Product2 productA = new Product2( Name='テスト商品');
        insert productA;
        
        // 価格表エントリを作成する        
        PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
        entry.UnitPrice = 0;
        entry.IsActive = true;
        entry.UseStandardPrice = false;
        entry.CurrencyIsoCode = 'CNY';
        entry.Product2Id = productA.Id;
        insert entry;
        
        // 納入機器を作成する
        Asset asset = new Asset();
        asset.Name = 'テスト機器';
        asset.AccountId = dep.Id;
        asset.Department_Class__c = strategicDep[0].Id;
        asset.Hospital__c = hospital.Id;
        asset.SerialNumber = 'testserial';
        insert asset;
        
        // 维修合同を作成する
        Maintenance_Contract__c contract = new Maintenance_Contract__c();
        contract.Name = 'tect contract';
        contract.Hospital__c = hospital.Id;
        contract.Department_Class__c = strategicDep[0].Id;
        contract.Department__c = dep.Id;
        insert contract;
 
        //失但报告申请
        Lost_Report__c report= new Lost_Report__c();
        report.Maintenance_Contract__c=contract.Id;
        report.Status__c ='草案中';
        insert report;
 
        String cont=MaintenanceContractNotOpenController.SearchData('ccc','ddd','fff','aaa','bbb','xxx');
        MaintenanceContractNotOpenController ncr= new MaintenanceContractNotOpenController();
        String [] Ids = new String[]{};
        Ids.add(contract.Id);
        String slrd=MaintenanceContractNotOpenController.SearchLostReportData(Ids);
        MaintenanceContractNotOpenController.GetJTYY();
        MaintenanceContractNotOpenController.GetQX();
        // String userId=UserInfo.getUserId();
        // MaintenanceContractNotOpenController.GetUserById(userId);
        // String hospitalId=hospital.Id;
        // MaintenanceContractNotOpenController.GetAccountById(hospitalId);
        MaintenanceContractNotOpenController.SaveData(slrd,'aaa');
        // List<Lost_Report__c> lrc = [select Id,Name,Maintenance_Contract__c from Lost_Report__c limit 1];//通过Serialize方法序列化
        String lrcJson = JSON.serialize(report);
        MaintenanceContractNotOpenController.SubmitData('','');
        MaintenanceContractNotOpenController.SubmitData(lrcJson,'aa');
        MaintenanceContractNotOpenController.SubmitData(lrcJson,'');
        MaintenanceContractNotOpenController.SaveUpdateData('aa');
        MaintenanceContractNotOpenController.SaveUpdateData(slrd);
    }
}