黄千龙
2022-04-08 01f207d979d6be17c8cdec293feab48828c0ec3e
force-app/main/default/classes/WeeklyReportCmp.cls
@@ -4,10 +4,46 @@
    @AuraEnabled public Map<String,String> fieldsMap{get;set;}
    @AuraEnabled public Map<String,List<Map<String,String>>> docmap{get;set;}
    @AuraEnabled public List<Map<String,String>> doctorList{get;set;}
    // PIPL update Yin Mingjie 21/02/2022 start
    @AuraEnabled public Map<String,String> awsurl{get;set;}
    @AuraEnabled public Map<String,String> contactawsurl{get;set;}
    // PIPL update Yin Mingjie 21/02/2022 end
    public WeeklyReportCmp() {
    }
    // PIPL update Yin Mingjie 21/02/2022 start
    @RemoteAction
    @AuraEnabled
    public static Map<String,String> getAwsurl(String sobj){
        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobj);
        Map<String,String> awsmap = new Map<String,String>();
        awsmap.put('token', piIntegration.token);
        awsmap.put('newUrl', piIntegration.newUrl);
        awsmap.put('searchUrl', piIntegration.searchUrl);
        awsmap.put('transactionURL', piIntegration.transactionURL);
        return awsmap;
    }
    @RemoteAction
    @AuraEnabled
    public static Map<String, String> saveAgencyContact(String name, String nameEncrypt, String type, String typeEncrypt, String doctorDivision1,
        String doctorDivision1Encrypt, String agencyHospitalid, String awsid) {
        Agency_Contact__c agency_contact = new Agency_Contact__c();
        agency_contact.Name = name;
        agency_contact.Name_Encrypted__c = nameEncrypt;
        agency_contact.Type__c = type;
        agency_contact.Type_Encrypted__c = typeEncrypt;
        agency_contact.Doctor_Division1__c = doctorDivision1;
        agency_contact.Doctor_Division1_Encrypted__c = doctorDivision1Encrypt;
        agency_contact.Agency_Hospital__c = agencyHospitalid;
        agency_contact.AWS_Data_Id__c = awsid;
        Map<String, String> acMap = new Map<String, String>();
        acMap = LightningUtil.insertAgencyContact(agency_contact);
        return acMap;
    }
    // PIPL update Yin Mingjie 21/02/2022 end
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> getProductList(String dc, String opdsis){
@@ -43,6 +79,9 @@
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        // PIPL update Yin Mingjie 21/02/2022 start
        space.put('awsid', '');
        // PIPL update Yin Mingjie 21/02/2022 end
        space.put('selected', 'true');
        tmp.add(space);
        
@@ -52,6 +91,9 @@
            Map<String,String> om = new Map<String,String>();
            om.put('label', var.Name);
            om.put('value', var.Id);
            // PIPL update Yin Mingjie 21/02/2022 start
            om.put('awsid', var.AWS_Data_Id__c);
            // PIPL update Yin Mingjie 21/02/2022 end
            om.put('selected', 'false');
            tmp.add(om);
        }
@@ -86,7 +128,10 @@
        //阶段 StageName__c
        this.allselectlist.put('StageName__c', WeeklyReportCmp.getPicklistValues('Agency_Opportunity__c','StageName__c'));
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
        // 支援需求 SupportNeeds__c
        // this.allselectlist.put('SupportNeeds__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','SupportNeeds__c'));
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end
        // 职位
//        this.allselectlist.put('visitor_title__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','visitor_title__c'));
@@ -109,6 +154,9 @@
        
        //System.debug('fieldsMap is ' + fieldsMap);
        //System.debug('allselectlist is ' + this.allselectlist);
        this.awsurl = getAwsurl('Agency_Contact__c');// 20220222 PI改造 by Bright
        this.contactawsurl = getAwsurl('Contact');// 20220222 PI改造 by Bright
    }
    
    
@@ -210,11 +258,17 @@
    @AuraEnabled
    public static List<Agency_Hospital_Link__c> getHospitalList(String hospital_name) {
        hospital_name = '%' + hospital_name.trim() + '%'; 
        return [select Hospital_Name_readonly__c, Id, Hospital__c from Agency_Hospital_Link__c where Hospital_Name_readonly__c like :hospital_name and Agency_Campaign_Obj__c = true];
        system.debug('hospital_name+++'+hospital_name);
        List<Agency_Hospital_Link__c> ahllist = [select Hospital_Name_readonly__c, Id, Hospital__c from Agency_Hospital_Link__c where Hospital_Name_readonly__c like :hospital_name and Agency_Campaign_Obj__c = true];
        system.debug('Agency_Campaign_Obj__c+++'+ahllist);
        return ahllist;
    }
    
    @RemoteAction
    @AuraEnabled
    // PIPL update Yin Mingjie 21/02/2022 start
    public static Map<String,Map<String,String>> getDoctorList(String hospital_id){
    /*
    public static List<Map<String,String>> getDoctorList(String hospital_id){
        List<Map<String,String>> ret = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
@@ -222,14 +276,18 @@
        space.put('value', '');
        space.put('selected', 'true');
        ret.add(space);
    */
    // PIPL update Yin Mingjie 21/02/2022 end
        // 戦略科室IDを取得して、それをもとに顧客をSELECT
        Agency_Hospital_Link__c ahl = [select Hospital__c from Agency_Hospital_Link__c where id = :hospital_id];
        // PIPL update Yin Mingjie 21/02/2022 start
        /*
        List<Agency_Contact__c> doctor_list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c 
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
        for (Agency_Contact__c row : doctor_list)
        {
            Map<String,String> tmp = new Map<String,String>();
@@ -239,8 +297,32 @@
            tmp.put('Doctor_Division1__c', row.Doctor_Division1__c);
            ret.add(tmp);
        }
        */
        List<Agency_Contact__c> doctor_list = [select id,Name,AWS_Data_Id__c,Doctor_Division1__c,Type__c,Agency_Hospital__c
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
        Map<String,Map<String,String>> ret_test = new Map<String,Map<String,String>>();
        for (Agency_Contact__c row : doctor_list)
        {
            if(row.AWS_Data_Id__c == '' || row.AWS_Data_Id__c == null){
                continue;
            }
            Map<String,String> tmp = new Map<String,String>();
            tmp.put('label', row.Name);
            tmp.put('value', row.Id);
            tmp.put('awsid', row.AWS_Data_Id__c);
            tmp.put('selected', 'false');
            tmp.put('Doctor_Division1__c', row.Doctor_Division1__c);
            ret_test.put(row.AWS_Data_Id__c, tmp);
        }
        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('Agency_Contact__c');
        Map<String, String> sre = new Map<String, String>();
        sre.put('token', piIntegration.token);
        sre.put('searchUrl', piIntegration.searchUrl);
        ret_test.put('sre', sre);
        
        return ret_test;
        // PIPL update Yin Mingjie 21/02/2022 end
        /*
        String record_type_id = LightningUtil.getRecordTypeId(department);
@@ -257,9 +339,13 @@
        }
        */
        // PIPL update Yin Mingjie 21/02/2022 start
        /*
        return ret;
        */
        // PIPL update Yin Mingjie 21/02/2022 end
    }
    /*
    @RemoteAction
    @AuraEnabled
@@ -287,7 +373,7 @@
    */
    @RemoteAction
    @AuraEnabled
    @AuraEnabled//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeedsc ,String SupportNeedsc
    public static String saveAgencyReport(String Department_Cateogy, String Purpose_Type, String Agency_Report_Header,
            String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
            String Product_Category1, String Product_Category2, String Product_Category3,
@@ -295,7 +381,7 @@
    {
        Agency_Report__c agency_report = makeAgencyReport(Department_Cateogy, Purpose_Type, Agency_Report_Header,
            Agency_Hospital, Person_In_Charge2, doctor, Submit_date,
            Product_Category1, Product_Category2, Product_Category3,
            Product_Category1, Product_Category2, Product_Category3,//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeedsc   ,SupportNeedsc
            Result, Opportunity, StageName, oppAmount, oppOCMPrice, Close_Forecasted_Date, Report_Date);
        agency_report = LightningUtil.insertAgencyReport(agency_report);
@@ -303,7 +389,7 @@
    }
    public static Agency_Report__c makeAgencyReport(String Department_Cateogy, String Purpose_Type, String Agency_Report_Header,
            String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
            String Product_Category1, String Product_Category2, String Product_Category3,
            String Product_Category1, String Product_Category2, String Product_Category3,//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c   ,String SupportNeedsc
            String Result, String Opportunity, String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date)
    {
        Agency_Report__c agency_report = new Agency_Report__c();
@@ -333,6 +419,9 @@
        if (doctor != '') { agency_report.doctor2__c = doctor; } else { agency_report.doctor2__c = null; }
        if (Department_Cateogy != '') { agency_report.Department_Cateogy__c = Department_Cateogy; }
        if (Purpose_Type != '') { agency_report.Purpose_Type__c = Purpose_Type; }
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
        // if (SupportNeedsc != '') { agency_report.SupportNeeds__c = SupportNeedsc; }
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end
        if (Agency_Report_Header != '') { agency_report.Agency_Report_Header__c = Agency_Report_Header; }
        if (Agency_Hospital != '') { agency_report.Agency_Hospital__c = Agency_Hospital; }
        //if (olympus_calendar_id != '') { agency_report.Submit_date_Calendar__c = olympus_calendar_id; }
@@ -371,12 +460,12 @@
    @AuraEnabled
    public static String editAgencyReport(String Agency_Report_Id, String Department_Cateogy, String Purpose_Type, String Agency_Report_Header,
                                        String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
                                        String Product_Category1, String Product_Category2, String Product_Category3,
                                        String Product_Category1, String Product_Category2, String Product_Category3, //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c  ,String SupportNeedsc
                                        String Result, String Opportunity, String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date)
    {
        if (String.isBlank(Agency_Report_Id)) {
            return null;
        }
        }//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c   ,SupportNeeds__c
        Agency_Report__c agency_report = [select Id, Name, Department_Cateogy__c, Purpose_Type__c, Agency_Hospital__c,
                                          Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, visitor_title__c, Opportunity__c
                                          from Agency_Report__c where id=:Agency_Report_Id];
@@ -397,11 +486,13 @@
        if (Agency_Hospital != '')  {
            LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
        }
        system.debug('Purpose_Type+++==++==='+Purpose_Type);
        // WRITE Agency Report__c
        if (doctor != '') { agency_report.doctor2__c = doctor; } else { agency_report.doctor2__c = null; }
        if (Department_Cateogy != '') { agency_report.Department_Cateogy__c = Department_Cateogy; } else { agency_report.Department_Cateogy__c = null; }
        if (Purpose_Type != '') { agency_report.Purpose_Type__c = Purpose_Type; } else { agency_report.Purpose_Type__c = null; }
         //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c
        //  if (SupportNeedsc != '') { agency_report.SupportNeeds__c = SupportNeedsc; } else { agency_report.SupportNeeds__c = null; }
        if (Agency_Hospital != '') { agency_report.Agency_Hospital__c = Agency_Hospital; } else { agency_report.Agency_Hospital__c = null; }
        if (Product_Category1 != '') { agency_report.Product_Category1__c = Product_Category1; } else { agency_report.Product_Category1__c = null; }
        if (Product_Category2 != '') { agency_report.Product_Category2__c = Product_Category2; } else { agency_report.Product_Category2__c = null; }
@@ -508,10 +599,10 @@
       System.debug('sobjectName:::'+sobjectName);
       System.debug('fields:::'+fields);
       String errorMag = '';
       // 创建周报
       try{
            if(fileData!=null){ 
                String[] fileLines = new String[]{};
                fileLines = fileData.split('\n');
@@ -546,23 +637,23 @@
                            errorMag += 'error1 第'+i+'行数据活动日不能为空';
                            errorMag += '=';
                        }
                        //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk start
                        List<String> R = new List<String>();
                        R = inputvalues[1].split('/');
                        system.debug('R202216'+R);
                        Date rDate = Date.newInstance(Integer.Valueof(R[0]),Integer.Valueof(R[1]),Integer.Valueof(R[2]));
                        system.debug('rDate202216'+rDate);
                        Date start = Date.today().addMonths(-1);
                        Date startDay = start.toStartOfWeek();
                        Date firstDayOfweek = System.today().toStartOfWeek();
                        Date endDay = firstDayOfweek.addDays(6);
                        if(rDate > endDay || rDate < startDay){
                            system.debug('rDate >= ssDate');
                            // return 'error1 第'+i+'行数据活动日不能为空';
                            errorMag += 'error1 第'+i+'行数据,导入周报仅可补报最近一月周报';
                            errorMag += '=';
                        }
                        //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk end
                         //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk start
                         List<String> R = new List<String>();
                         R = inputvalues[1].split('/');
                         system.debug('R202216'+R);
                         Date rDate = Date.newInstance(Integer.Valueof(R[0]),Integer.Valueof(R[1]),Integer.Valueof(R[2]));
                         system.debug('rDate202216'+rDate);
                         Date start = Date.today().addMonths(-1);
                         Date startDay = start.toStartOfWeek();
                         Date firstDayOfweek = System.today().toStartOfWeek();
                         Date endDay = firstDayOfweek.addDays(6);
                         if(rDate > endDay || rDate < startDay){
                             system.debug('rDate >= ssDate');
                             // return 'error1 第'+i+'行数据活动日不能为空';
                             errorMag += 'error1 第'+i+'行数据,导入周报仅可补报最近一月周报';
                             errorMag += '=';
                         }
                         //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk end
                        if(inputvalues[2] == '' || inputvalues[2] == null){
                            // return 'error1 第'+i+'行数据医院不能为空';
                            errorMag += 'error1 第'+i+'行数据医院不能为空';
@@ -595,7 +686,7 @@
                            errorMag += '=';
                        }
                        if((inputvalues[7] != '' && inputvalues[7] != null)&& inputvalues[5] == inputvalues[7]){
                            // return 'error1 第'+i+'行数据产品区分1和产品区分3的值不能重复';
                            errorMag += 'error1 第'+i+'行数据产品区分1和产品区分3的值不能重复';
@@ -634,7 +725,7 @@
                            errorMag += 'error3 第'+i+'行数据结果选项列表的值'+inputvalues[9]+'不存在';
                            errorMag += '=';
                        }
                        system.debug('inputvalues[0]=================>'+inputvalues[0]);
                       system.debug('inputvalues[0]=================>'+inputvalues[0]);
                        system.debug('inputvalues[1]=================>'+inputvalues[1]);
                        system.debug('inputvalues[2]=================>'+inputvalues[2]);
                        system.debug('inputvalues[3]=================>'+inputvalues[3]);
@@ -644,7 +735,7 @@
                        system.debug('inputvalues[7]=================>'+inputvalues[7]);
                        system.debug('inputvalues[8]=================>'+inputvalues[8]);
                        system.debug('inputvalues[9]=================>'+inputvalues[9]);
                        nameList.add(inputvalues[0]);
                        dateList.add(Date.valueOf(inputvalues[1].replace('/','-')));