@isTest
private class NFM612RestTest {
    static testMethod void testMethod1() {
        
    }
    @testSetup
    static void makeTestRepair() {
        
        Oly_TriggerHandler.bypass('ContactTriggerHandler');
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        // テストデータ
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM105TestCompany';
        upsert company;
        // Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId = :company.Id and RecordTypeId = :rectSct[0].Id];
        Account section = [Select Management_Code__c, Name, Id from Account where ParentId = :company.Id and RecordTypeId = :rectSct[0].Id];

        Account depart = new Account();
        depart.RecordTypeId        = rectDpt[0].Id;
        depart.Name                = '测试科室';
        depart.AgentCode_Ext__c    = '20210909';
        depart.Department_Name__c  = 'NFM105TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        // depart.AgentCode_Ext__c  = '2820422282';
        upsert depart;
        // Contact core = new Contact(email='jplumber@salesforce.com',
        // firstname='Joe',
        // lastname='Plumber',
        // accountid=depart.id,
        // Employee_No_manual__c = '20210909');
        // insert core;

        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'NFM105Prd1';
        prd1.ProductCode            = 'NFM105Prd1';
        prd1.Repair_Product_Code__c = 'NFM105Prd1_RP';
        prd1.Name                   = 'NFM105Prd1';
        prd1.Manual_Entry__c        = false;
        prdList.add(prd1);
        Product2 prd2 = new Product2();
        prd2.ProductCode_Ext__c     = 'NFM105Prd2';
        prd2.ProductCode            = 'NFM105Prd2';
        prd2.Repair_Product_Code__c = 'NFM105Prd2_RP';
        prd2.Name                   = 'NFM105Prd2';
        prd2.Manual_Entry__c        = false;
        prdList.add(prd2);
        insert prdList;






        User user = new User(Test_staff__c = true);
        user.LastName = '_サンブリッジ';
        user.FirstName = 'う';
        user.Alias = 'う';
        user.Email = 'olympustest03@sunbridge.com';
        user.Username = 'olympustest03@sunbridge.com';
        user.CommunityNickname = 'う';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '上海市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        user.Employee_No__c = 'SFDC-02001';
        insert user;

        Contact con = new Contact();
        con.AccountId = depart.Id;
        con.LastName = '测试0001';
        insert con;


        Asset ast = new Asset();
        ast.Name                   = 'NFM105Ast1';
        ast.AccountId              = depart.Id;
        ast.Department_Class__c    = section.Id;
        ast.Hospital__c            = company.Id;
        ast.Product2Id             = prd1.Id;
        ast.SerialNumber           = 'NFM105SerialNumber';
        ast.Guarantee_period_for_products__c = Date.today();
        ast.InstallDate                      = Date.today();
        insert ast;
        // ast = [select Id, Name, Product_Serial_No__c, AccountId, Department_Class__c, Department_Class__r.Management_Code_Auto__c, Hospital__c, Product2Id, Product2.ProductCode, Product2.Repair_Product_Code__c, SerialNumber
        ast = [select Id, Name, Product_Serial_No__c, AccountId, Department_Class__c,  Hospital__c, Product2Id, Product2.ProductCode, Product2.Repair_Product_Code__c, SerialNumber
               from Asset
               where Id = :ast.Id];
        // RepairSubOrder__c rso = new RepairSubOrder__c();
        // rso.RepairApplicant__c = '2820422282';
        // insert rso;

        
        

    }
  //   @isTest static void test_method1() {
		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
  //       if (rectCo.size() == 0) {
  //           throw new ControllerUtil.myException('not found 病院 recodetype');
  //       }
  //       List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
  //       if (rectSct.size() == 0) {
  //           throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
  //       }
  //       List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
  //       if (rectDpt.size() == 0) {
  //           throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
  //       }
  //       Test.startTest();

  //       Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
  //       User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
  //       insert us;
  //       RestRequest req = new RestRequest();
  //       RestResponse res = new RestResponse();
  //       //List<Account> departList = [select Management_Code__c from Account];
  //       //System.debug('测试科室编码===='+departList);
  //       //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
  //       List < Contact > contactList = [
  //               SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
  //               FROM Contact
  //           ];
  //       List < Account > accountList =
  //           [SELECT id, Management_Code__c, ParentId, Parent.ParentId
  //               FROM Account
  //           ]; 
  //       String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"353885普外科",'+
  //                                           '"startTimeThird":null,'+
  //                                           '"startTimeSecond":null,'+
  //                                           '"startTimeFirst":"20211220161732",'+
  //                                           '"responseResultType":"问题已解决",'+
  //                                           '"responseResultsThird":null,'+
  //                                           '"responseResultsSecond":null,'+
  //                                           '"responseResultsFirst":null,'+
  //                                           '"repairSubOrderType":"医院客户发起",'+
  //                                           '"repairOrderTime":"20211220155017",'+
  //                                           '"repairOrderNo2FSEID":null,'+
  //                                           '"repairOrderNo2":"SR-20211220-00009-01",'+
  //                                           '"repairOrderNo":"SR-20211220-00009",'+
  //                                           '"repairApplyType":null,'+
  //                                           '"repairApplyPersonTel":"15612383251",'+
  //                                           '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
  //                                           '"repairApplicantName":"于梦辉",'+
  //                                           '"receiverType":"FSE",'+
  //                                           '"receiverId":"SFDC-022000",'+
  //                                           '"receiverDate":"20211220155029",'+
  //                                           '"problemPhotoName":"fefb91a183b74341bd75e77a30fab660.zip",'+
  //                                           '"problemPhotofile":"https://albsylfw.s3.cn-northwest-1.amazonaws.com.cn/20211220/16/17/47/57f632df-a699-46a3-96ff-0559df91e171.zip",'+
  //                                           '"problemDesc":"1220测试",'+
  //                                           '"plannedVisitDay":"20211220155034",'+
  //                                           '"hospitalCd":"353885",'+
  //                                           '"faultType":"送气不良送水不良,出现报警,无法开机,不能电灯,面板闪烁",'+
  //                                           '"faultDescriptionThird":null,'+
  //                                           '"faultDescriptionSecond":null,'+
  //                                           '"faultDescriptionFirst":null,'+
  //                                           '"faultDate":"20211220000000",'+
  //                                           '"equipmentCd":"",'+
  //                                           '"equipmentCategory":"内科系统",'+
  //                                           '"endTimeThird":null,'+
  //                                           '"endTimeSecond":null,'+
  //                                           '"endTimeFirst":"20211220161735",'+
  //                                           // '"departmentCd":"'+accountList[0].Management_Code__c+'",'+
  //                                           '"departmentCd":"20210909",'+
  //                                           '"cancelReportReason":null,'+
  //                                           '"cancellerType":null,'+
  //                                           '"cancellerId":null,'+
  //                                           '"cancelleRepairDate":null,'+
  //                                           '"assetType":"清洗消毒机",'+
  //                                           '"applyDate":null,'+
  //                                           '"applicantType":"FSE",'+
  //                                           '"applicantId":null,'+
  //                                           '"actualVisitTimeThird":null,'+
  //                                           '"actualVisitTimeSecond":null},'+
  //                       '"applyRepairInfo":{"responseResultDesc":"测试",'+
  //                                           '"processResult":"问题已解决",'+
  //                                           '"equipmentModel":"A20915A",'+
  //                                           '"equipmentCd":""}}]';
  //       // String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817","startTimeThird":"2021-08-15 12:00:00","startTimeSecond":"2021-08-14 12:00:00","startTimeFirst":"2021-08-13 12:00:00","responseResultType":"申请修理","responseResultsThird":"故障消除","responseResultsSecond":"故障消除","responseResultsFirst":"消除故障","repairSubOrderType":"CIC代填","repairOrderTime":"2021-08-09 12:00","repairOrderNo2FSEID":"SFDC-02000","repairOrderNo2":"1000000111001","repairOrderNo":"1000000111","repairApplyPersonTel":"13739876457","repairApplyPerson":"20210909","repairApplicantName":"武文双","receiverType":"FES","receiverId":"SFDC-02000","receiverDate":"2021-08-17","problemPhotoName":"测试1.txt","problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6","problemDesc":"摄像头不能使用","plannedVisitDay":"2021/08/17 17:21","hospitalCd":"'+hospital.Management_Code__c+'","faultType":"故障类型","faultDescriptionThird":"摄像头故障","faultDescriptionSecond":"摄像头故障","faultDescriptionFirst":"摄像头故障","faultDate":"2021-08-09","equipmentCd":"JBHOS1234","equipmentCategory":"外科","endTimeThird":"2021-08-15 15:00:00","endTimeSecond":"2021-08-14 16:00:00","endTimeFirst":"2021-08-13 15:00:00","departmentCd":"20210909","cancelReportReason":"故障已处理","cancellerType":null,"cancellerId":"SFDC-02000","cancelleRepairDate":"2021-08-17","assetType":"摄像头","applyDate":"2021-08-15 15:00:00","applicantType":"FSE","applicantId":"SFDC-02000","actualVisitTimeThird":"2021-08-15","actualVisitTimeSecond":"2021-08-14"},"applyRepairInfo":{"responseResultDesc":"无描述","processResult":"已完成","equipmentModel":"CV1893","equipmentCd":"JBGCS12223"}}]';
  //       req.requestURI = 'services/apexrest/NFM612/execute';
  //       req.httpMethod = 'POST';
  //       req.requestBody = Blob.valueof(JsonMsg);
  //       RestContext.request = req;
  //       RestContext.response= res;

  //       NFM612Rest.doPost();
  //       Test.stopTest();
  //   }
    @isTest static void test_method2() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();

        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"2021-08-15 12:00:00",'+
                                            '"startTimeSecond":"2021-08-14 12:00:00",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-022000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"22220210909",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"11SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"202109000009",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-0201100",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"摄像头",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"repairApplyType":null,'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                            '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"申请修理",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    @isTest static void test_method3() {

        Test.startTest();
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();

        String JsonMsg = '[{}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }

    @isTest static void test_method4() {

        Test.startTest();
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();

        String JsonMsg = '[{"repairOderInfo":{},"applyRepairInfo":{}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    @isTest static void test_method5() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"摄像头",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"repairApplyType":null,'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                            '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"问题已解决",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    // 走catch
    @isTest static void test_method5_1() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE1",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统1",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"摄像头1",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"repairApplyType":null,'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                            '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"问题已解决",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    @isTest static void test_method5_5() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"摄像头",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"repairApplyType":null,'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                            '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"申请修理",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    // repairApplyPerson不存在====测试
    @isTest static void test_method51() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"66666666",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"摄像头",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                        '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"已完成",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    // receiverId不存在=====测试
    @isTest static void test_method52() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-0200011111111",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"摄像头",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                        '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"已完成",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    // processResult&&&&applicantId不存在====测试
    @isTest static void test_method53() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"胃镜",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-020001111111",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                        '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"申请修理",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    // repairOrderNo2FSEID不存在====测试
    @isTest static void test_method54() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000111111",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"胃镜",'+
                                            '"applyDate":"2021-08-15 15:00:00",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                        '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"已完成",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }

    @isTest static void test_method55() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"胃镜",'+
                                            '"applyDate":"",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                        '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"申请修理",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';
        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
    @isTest static void test_method56() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        Test.startTest();

        Account hospital = [select Management_Code__c from Account where RecordTypeId = :rectCo[0].Id];
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Employee_No__c = 'SFDC-02000',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 =System.Label.ProfileId_SystemAdmin);
        insert us;
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        //List<Account> departList = [select Management_Code__c from Account];
        //System.debug('测试科室编码===='+departList);
        //Integer num = Integer.valueOf('测试科室编码===='+departList[0].Management_Code__c);
        List < Contact > contactList = [
                SELECT Id, AccountId, Account.Name, Account.ParentId, Account.Parent.ParentId, CManageCode__c, Employee_No_manual__c
                FROM Contact
            ];
        String JsonMsg = '[{"repairOderInfo":{"strategicDepartmenCd":"8089817",'+
                                            '"startTimeThird":"20210909124111",'+
                                            '"startTimeSecond":"20210909124111",'+
                                            '"startTimeFirst":"2021-08-13 12:00:00",'+
                                            '"responseResultType":"申请修理",'+
                                            '"responseResultsThird":"故障消除",'+
                                            '"responseResultsSecond":"故障消除",'+
                                            '"responseResultsFirst":"消除故障",'+
                                            '"repairSubOrderType":"CIC代填",'+
                                            '"repairOrderTime":"2021-08-09 12:00",'+
                                            '"repairOrderNo2FSEID":"SFDC-02000",'+
                                            '"repairOrderNo2":"1000000111001",'+
                                            '"repairOrderNo":"1000000111",'+
                                            '"repairApplyPersonTel":"13739876457",'+
                                            '"repairApplyPerson":"'+ contactList[0].CManageCode__c +'",'+
                                            '"repairApplicantName":"武文双",'+
                                            '"receiverType":"FSE",'+
                                            '"receiverId":"SFDC-02000",'+
                                            '"receiverDate":"2021-08-17",'+
                                            '"problemPhotoName":"测试1.txt",'+
                                            '"problemPhotofile":"ZGF0YTp0ZXh0L3BsYWluO2Jhc2U2NCxNVEl6",'+
                                            '"problemDesc":"摄像头不能使用",'+
                                            '"plannedVisitDay":"2021/08/17 17:21",'+
                                            '"hospitalCd":"'+hospital.Management_Code__c+'",'+
                                            '"faultType":"故障类型",'+
                                            '"faultDescriptionThird":"摄像头故障",'+
                                            '"faultDescriptionSecond":"摄像头故障",'+
                                            '"faultDescriptionFirst":"摄像头故障",'+
                                            '"faultDate":"2021-08-09",'+
                                            '"equipmentCd":"JBHOS1234",'+
                                            '"equipmentCategory":"外科系统",'+
                                            '"endTimeThird":"2021-08-15 15:00:00",'+
                                            '"endTimeSecond":"2021-08-14 16:00:00",'+
                                            '"endTimeFirst":"2021-08-13 15:00:00",'+
                                            '"departmentCd":"20210909",'+
                                            '"cancelReportReason":"故障已处理",'+
                                            '"cancellerType":null,'+
                                            '"cancellerId":"SFDC-02000",'+
                                            '"cancelleRepairDate":"2021-08-17",'+
                                            '"assetType":"胃镜",'+
                                            '"applyDate":"20231013112225",'+
                                            '"applicantType":"FSE",'+
                                            '"applicantId":"SFDC-02000",'+
                                            '"actualVisitTimeThird":"2021-08-15",'+
                                            '"actualVisitTimeSecond":"2021-08-14"},'+
                                  '"problem":{'+
                                            '"whatProject":"a.手术",'+
                                            '"useFailProductFinish":"是",'+
                                            '"supportingProducts":"111",'+
                                            '"reportAdverseEvents":"null",'+
                                            '"problemOccurredSelect":"null",'+
                                            '"problemOccurred":"到货验收",'+
                                            '"operationOrExaminationName":"111",'+
                                            '"isProductFaultRelated":"有可能",'+
                                            '"informationFrom":"医生",'+
                                            '"ifDeadHurt":"有",'+
                                            '"failureQInHospital":"null",'+
                                            '"delayReportReason":"null",'+
                                            '"delay15Min":"null",'+
                                            '"dateReceiptQuestions":"null",'+
                                            '"breakORFallOff":"null",'+
                                            '"afterFailureInformation":"null"'+
                                        '},'+
                              '"logistics":{'+
                                            '"senderOrgCode":null,'+
                                            '"senderName":"1231",'+
                                            '"senderMobilePhone":"1231",'+
                                            '"senderCompany":null,'+
                                            '"senderAddress":"123",'+
                                            '"returnWayType":null,'+
                                            '"recepientName":"1231",'+
                                            '"recepientMobilePhone":"2131",'+
                                            '"recepientCompany":null,'+
                                            '"recepientAddress":"",'+
                                            '"orderNumber":null,'+
                                            '"logisticsSendDate":null,'+
                                            '"isOts":1,'+
                                            '"failureReason":null'+
                                        '},'+
                        '"applyRepairInfo":{"responseResultDesc":"无描述",'+
                                            '"processResult":"申请修理",'+
                                            '"equipmentModel":"CV1893",'+
                                            '"equipmentCd":"JBGCS12223"}}]';



        req.requestURI = 'services/apexrest/NFM612/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;

        NFM612Rest.doPost();
        Test.stopTest();
    }
}