From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/BatchSelectRepairPageController.cls |  355 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 287 insertions(+), 68 deletions(-)

diff --git a/force-app/main/default/classes/BatchSelectRepairPageController.cls b/force-app/main/default/classes/BatchSelectRepairPageController.cls
index 408374c..6134e9e 100644
--- a/force-app/main/default/classes/BatchSelectRepairPageController.cls
+++ b/force-app/main/default/classes/BatchSelectRepairPageController.cls
@@ -1,73 +1,250 @@
 public with sharing class BatchSelectRepairPageController {
-    public List<RetrievalData> RevalInfoList { get; set; }
+    public RetrievalData RevalInfo { get; set; }
     public List<RepairData> RAInfoList { get; set; }
     public List<Repair__c> RepairList { get; set; }
     public List<String> repairIdList{ get; set; }
+    public List<SelectOption> StatusItems1 { get; private set; }
+    public List<SelectOption> StatusItems { get; private set; }
+    public List<SelectOption> SiteRepairItems { get; private set; }
+    public String pdfURL { get; private set; }
     public Integer RACount {
         get { return RAInfoList == null ? 0 : RAInfoList.size(); }
     }
 
     public BatchSelectRepairPageController() {
+        StatusItems = new List<SelectOption>();
+        StatusItems.add(new SelectOption('','--鏃�--'));
+        StatusItems.add(new SelectOption('00.鐢宠瀹屾瘯','00.鐢宠瀹屾瘯'));
+        StatusItems.add(new SelectOption('01.鍒嗗叕鍙稿彈鐞嗗畬姣�','01.鍒嗗叕鍙稿彈鐞嗗畬姣�'));
+        StatusItems.add(new SelectOption('02.RC鍙楃悊瀹屾瘯','02.RC鍙楃悊瀹屾瘯'));
+        StatusItems.add(new SelectOption('03.鎶ヤ环妫�鏌ョ粨鏉�','03.鎶ヤ环妫�鏌ョ粨鏉�'));
+        StatusItems.add(new SelectOption('04.鎶ヤ环璺熻繘涓�','04.鎶ヤ环璺熻繘涓�'));
+        StatusItems.add(new SelectOption('05.鎶ヤ环鍚屾剰瀹屽','05.鎶ヤ环鍚屾剰瀹屽'));
+        StatusItems.add(new SelectOption('06.闆朵欢榻愬','06.闆朵欢榻愬'));
+        StatusItems.add(new SelectOption('07.淇悊闁嬪','07.淇悊闁嬪'));
+        StatusItems.add(new SelectOption('08.淇悊棰勮瀹屾垚','08.淇悊棰勮瀹屾垚'));
+        StatusItems.add(new SelectOption('09.淇悊瀹屾垚','09.淇悊瀹屾垚'));
+        StatusItems.add(new SelectOption('10.鏈�缁堟鏌ュ畬鎴�','10.鏈�缁堟鏌ュ畬鎴�'));
+        StatusItems.add(new SelectOption('11.RC淇悊鍝佸凡杩旈��','11.RC淇悊鍝佸凡杩旈��'));
+        StatusItems.add(new SelectOption('12.鍙戠エ宸插彂閫�','12.鍙戠エ宸插彂閫�'));
+        StatusItems.add(new SelectOption('13.宸茶繑閫佸埌鐢ㄦ埛','13.宸茶繑閫佸埌鐢ㄦ埛'));
+        StatusItems.add(new SelectOption('14.鏀跺埌楠屾敹鍗�','14.鏀跺埌楠屾敹鍗�'));
+        StatusItems.add(new SelectOption('15.楠屾敹鍗曠鏀跺鏍搁�氳繃','15.楠屾敹鍗曠鏀跺鏍搁�氳繃'));
+        StatusItems.add(new SelectOption('16.閮ㄥ垎浠樻','16.閮ㄥ垎浠樻'));
+        StatusItems.add(new SelectOption('16.瀹屾瘯','16.瀹屾瘯'));
+        StatusItems.add(new SelectOption('17.浠樻瀹屾瘯','17.浠樻瀹屾瘯'));
+        StatusItems.add(new SelectOption('00.鍙栨秷','00.鍙栨秷'));
+        StatusItems.add(new SelectOption('00.鍒犻櫎','00.鍒犻櫎'));
+        StatusItems.add(new SelectOption('00.鍏抽棴','00.鍏抽棴'));
 
+        StatusItems1 = new List<SelectOption>();
+        StatusItems1.add(new SelectOption('','--鏃�--'));
+        StatusItems1.add(new SelectOption('0.鐢宠瀹屾瘯','0.鐢宠瀹屾瘯'));
+        StatusItems1.add(new SelectOption('2.缁翠慨鎶ヤ环闃舵','2.缁翠慨鎶ヤ环闃舵'));
+        StatusItems1.add(new SelectOption('3.缁翠慨闃舵','3.缁翠慨闃舵'));
+        StatusItems1.add(new SelectOption('4.淇悊鍝佽繑閫侀樁娈�','4.淇悊鍝佽繑閫侀樁娈�'));
+        StatusItems1.add(new SelectOption('5.瀹屾瘯','5.瀹屾瘯'));
+        StatusItems1.add(new SelectOption('0.鍒犻櫎','0.鍒犻櫎'));
+        StatusItems1.add(new SelectOption('0.鍙栨秷','0.鍙栨秷'));
+    
+        SiteRepairItems = new List<SelectOption>();
+        SiteRepairItems.add(new SelectOption('','--鏃�--'));
+        SiteRepairItems.add(new SelectOption('RC淇悊','RC淇悊'));
+        SiteRepairItems.add(new SelectOption('鐩撮�丼ORC淇悊','鐩撮�丼ORC淇悊'));
+        SiteRepairItems.add(new SelectOption('鐩撮�丱GZ淇悊','鐩撮�丱GZ淇悊'));
+        SiteRepairItems.add(new SelectOption('鍔炰簨澶勪慨鐞�','鍔炰簨澶勪慨鐞�'));
+        SiteRepairItems.add(new SelectOption('鐜板満淇悊','鐜板満淇悊'));
+
+        
+       
+      
     }
 
     public void init(){
-        RetrievalData reval = new RetrievalData();
-        RevalInfoList = new List<RetrievalData>();
-        reval.RepairName = null;
-        reval.SAPRepairNo = null;
-        reval.HospitalName = null;
-        RevalInfoList.add(reval);
+        RevalInfo = new RetrievalData();
     }
+
+    // public List<SelectOption> getworkLocationSelect() {
+    //     List<SelectOption> workLocationSelect = new List<SelectOption>();
+    //     workLocationSelect.add(new SelectOption('','--鏃�--'));
+    //     workLocationSelect.add(new SelectOption('鍖椾含鍔炰簨澶�','鍖椾含鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('澶╂触鍔炰簨澶�','澶╂触鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('娌冲寳鍔炰簨澶�','娌冲寳鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('娴庡崡鍔炰簨澶�','娴庡崡鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('闈掑矝鍔炰簨澶�','闈掑矝鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鍐呰挋鍔炰簨澶�','鍐呰挋鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('榛戦緳姹熷姙浜嬪','榛戦緳姹熷姙浜嬪'));
+    //     workLocationSelect.add(new SelectOption('鍚夋灄鍔炰簨澶�','鍚夋灄鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('娌堥槼鍔炰簨澶�','娌堥槼鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('澶ц繛鍔炰簨澶�','澶ц繛鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('闄曡タ鍔炰簨澶�','闄曡タ鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('闈掓捣鍔炰簨澶�','闈掓捣鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('瀹佸鍔炰簨澶�','瀹佸鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鐢樿們鍔炰簨澶�','鐢樿們鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鏂扮枂鍔炰簨澶�','鏂扮枂鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('灞辫タ鍔炰簨澶�','灞辫タ鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('娌冲崡鍔炰簨澶�','娌冲崡鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('涓婃捣鍔炰簨澶�','涓婃捣鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('姹熻嫃鍔炰簨澶�','姹熻嫃鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('姹熻タ鍔炰簨澶�','姹熻タ鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('娴欐睙鍔炰簨澶�','娴欐睙鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('瀹夊窘鍔炰簨澶�','瀹夊窘鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('绂忓缓鍔炰簨澶�','绂忓缓鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('骞夸笢鍔炰簨澶�','骞夸笢鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('娣卞湷鍔炰簨澶�','娣卞湷鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('婀栧寳鍔炰簨澶�','婀栧寳鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('婀栧崡鍔炰簨澶�','婀栧崡鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('浜戝崡鍔炰簨澶�','浜戝崡鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('璐靛窞鍔炰簨澶�','璐靛窞鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鍥涘窛鍔炰簨澶�','鍥涘窛鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('閲嶅簡鍔炰簨澶�','閲嶅簡鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鏉窞鍔炰簨澶�','鏉窞鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鏉窞鍏遍�氬姙浜嬪','鏉窞鍏遍�氬姙浜嬪'));
+    //     workLocationSelect.add(new SelectOption('瑗垮畨鍔炰簨澶�','瑗垮畨鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('瑗垮畨鍏遍�氬姙浜嬪','瑗垮畨鍏遍�氬姙浜嬪'));
+    //     workLocationSelect.add(new SelectOption('鍏遍�氬姙浜嬪','鍏遍�氬姙浜嬪'));
+    //     workLocationSelect.add(new SelectOption('鎴愰兘鍔炰簨澶�','鎴愰兘鍔炰簨澶�'));
+    //     workLocationSelect.add(new SelectOption('鎴愰兘鍏遍�氬姙浜嬪','鎴愰兘鍏遍�氬姙浜嬪'));
+    //     workLocationSelect.add(new SelectOption('骞垮窞鍔炰簨澶�','骞垮窞鍔炰簨澶�'));
+    //     return workLocationSelect;
+    // }
 
     public PageReference RetrievalBtn() {
         RepairList = new List<Repair__c>();
         RAInfoList = new List<RepairData>();
-        String RepairName;
-        String SAPRepairNo;
-        String HospitalName;
-        for(RetrievalData reval : RevalInfoList){
-            if(String.isNotBlank(reval.RepairName)){
-                RepairName = reval.RepairName;
-            }
-            if(String.isNotBlank(reval.SAPRepairNo)){
-                SAPRepairNo = reval.SAPRepairNo;
-            }
-            if(String.isNotBlank(reval.HospitalName)){
-                HospitalName = reval.HospitalName;
-            }
-        }
-        System.debug('RepairName1:' + RepairName);
-        if(String.isBlank(RepairName) && String.isBlank(SAPRepairNo) && String.isBlank(HospitalName)){
+        if(String.isBlank(RevalInfo.Status1) && String.isBlank(RevalInfo.Status2) && String.isBlank(RevalInfo.RepairName) && String.isBlank(RevalInfo.SAPRepairNo) 
+            && String.isBlank(RevalInfo.SerialNumber) && String.isBlank(RevalInfo.repair.Incharge_Staff__c) && String.isBlank(RevalInfo.onSiteRepair)
+            && String.isBlank(String.valueOf(RevalInfo.repair.Aware_date__c)) && String.isBlank(String.valueOf(RevalInfo.repair.Aware_date2__c)) && String.isBlank(RevalInfo.workLocationSelect)
+            && String.isBlank(RevalInfo.State_Hospital)){
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '璇疯嚦灏戞坊鍔犱竴涓绱㈡潯浠�!'));
             return null;
         }
-        String sql = 'select Id, Name, SAP_Service_Repair_No__c, HP_Name__c, Department_Name__c from Repair__c ';
-        if(String.isNotBlank(RepairName)){
-            sql += ' where Name like \'%' + RepairName.trim() + '%\'';
-            if(String.isNotBlank(SAPRepairNo)){
-                sql += ' and SAP_Service_Repair_No__c like \'%' + SAPRepairNo.trim() + '%\'';
-                if(String.isNotBlank(HospitalName)){
-                    sql += ' and (HP_Name__c like \'%' + HospitalName.trim() + '%\' or Department_Name__c like \'%' + HospitalName.trim() + '%\')';
+        String sql = 'select Id, Name, SAP_Service_Repair_No__c, Status1__c, Status2__c, Delivered_Product__c, SerialNumber__c, ';
+        sql += 'HP_Name__c, State_Hospital__c, Incharge_Staff__c, FSE_ApplyForRepair_Day__c, work_location_select__c, On_site_repair__c,';
+        sql += 'Number_of_EffectiveContract__c, NewProductGuaranteeObject__c from Repair__c where Id != null ';
+        if(String.isNotBlank(RevalInfo.Status2)){
+            sql += ' and Status2__c = \'' + RevalInfo.Status2 + '\'';
+        }
+        if(String.isNotBlank(RevalInfo.Status1)){
+            sql += ' and Status1__c = \'' + RevalInfo.Status1 + '\'';
+        }
+        if(String.isNotBlank(RevalInfo.HospitalName)){
+
+            sql += ' and HP_Name__c like \'%' + RevalInfo.HospitalName.trim() + '%\'';
+        }
+        if(String.isNotBlank(RevalInfo.RepairName)){
+            System.debug(LoggingLevel.INFO, '***RevalInfo.RepairName.contains(): ' + RevalInfo.RepairName.contains(' '));
+            String splitStr = null;
+            if(RevalInfo.RepairName.contains(' ')){
+                splitStr = ' ';
+            }else if(RevalInfo.RepairName.contains(',')){
+                splitStr = ',';
+            }
+            if(splitStr != null && RevalInfo.RepairName.contains(splitStr)){
+                sql += ' and (';
+                list <String> nameList = RevalInfo.RepairName.split(splitStr);
+                for(String name: nameList){
+                   sql += 'Name like \'%' + name + '%\' or ';
                 }
-            } else if(String.isNotBlank(HospitalName)) {
-                sql += ' and (HP_Name__c like \'%' + HospitalName.trim() + '%\' or Department_Name__c like \'%' + HospitalName.trim() + '%\')';
+                sql = sql.removeEnd('or ');
+                sql += ')';
+            }else{
+                sql += ' and Name like \'%' + RevalInfo.RepairName.trim() + '%\'';
             }
-        } else if(String.isNotBlank(SAPRepairNo)){
-            sql += ' where SAP_Service_Repair_No__c like \'%' + SAPRepairNo.trim() + '%\'';
-            if(String.isNotBlank(HospitalName)){
-                sql += ' and (HP_Name__c like \'%' + HospitalName.trim() + '%\' or Department_Name__c like \'%' + HospitalName.trim() + '%\')';
+            System.debug(LoggingLevel.INFO, '*** sql: ' + sql);
+        }
+        if(String.isNotBlank(RevalInfo.SAPRepairNo)){
+            System.debug(LoggingLevel.INFO, '***RevalInfo.SAPRepairNo.contains(): ' + RevalInfo.SAPRepairNo.contains(' '));
+            String splitStr = null;
+            if(RevalInfo.SAPRepairNo.contains(' ')){
+                splitStr = ' ';
+            }else if(RevalInfo.SAPRepairNo.contains(',')){
+                splitStr = ',';
             }
-        } else if(String.isNotBlank(HospitalName)){
-            sql += ' where HP_Name__c like \'%' + HospitalName.trim() + '%\' or Department_Name__c like \'%' + HospitalName.trim() + '%\'';
+            if(splitStr != null && RevalInfo.SAPRepairNo.contains(splitStr)){
+                sql += ' and (';
+                
+                list <String> noList = RevalInfo.SAPRepairNo.split(splitStr);
+                for(String no: noList){
+                   sql += 'SAP_Service_Repair_No__c like \'%' + no + '%\' or ';
+                }
+                sql = sql.removeEnd('or ');
+                sql += ')';
+            }else{
+                sql += ' and SAP_Service_Repair_No__c like \'%' + RevalInfo.SAPRepairNo.trim() + '%\'';
+            }
+            System.debug(LoggingLevel.INFO, '*** sql: ' + sql);
         }
-        sql += ' limit 5000';
-        RepairList = Database.query(sql);
-        if(RepairList.size() >= 5000 ){
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '妫�绱㈡暟鎹お澶�,璇风缉灏忔绱㈣寖鍥�'));
-            return null;
+        if(String.isNotBlank(RevalInfo.SerialNumber)){
+            List<String> SerialNumberList = new List<String>();
+            if(RevalInfo.SerialNumber.indexOf(',') != -1){
+                SerialNumberList = RevalInfo.SerialNumber.split(',');
+            }
+            System.debug('SerialNumberList1:' + SerialNumberList);
+            // 鏀寔妯$硦鏌ヨ澶氫釜锛屾枃鏈杈撳叆鐢ㄨ嫳鏂囧崐瑙掗�楀彿鍒嗛殧
+            if(SerialNumberList.size() > 0){
+                sql += ' and (SerialNumber__c like \'%';
+                Integer i = 0;
+                for(String SerialNumber : SerialNumberList){
+                    if(i == 0){
+                        sql += SerialNumber.trim() + '%\'';
+                    }else{
+                        sql += 'or SerialNumber__c like \'%' + SerialNumber.trim() + '%\'';
+                    }
+                    i++;
+                }
+                sql += ')';
+            } else{
+                sql += ' and SerialNumber__c like \'%' + RevalInfo.SerialNumber.trim() + '%\'';
+            }
         }
-        if(RepairList.size() <= 0 ){
+        if(String.isNotBlank(RevalInfo.repair.Incharge_Staff__c)){
+            sql += ' and Incharge_Staff__c = \'' + RevalInfo.repair.Incharge_Staff__c + '\'';
+        }
+        if(String.isNotBlank(String.valueof(RevalInfo.repair.Aware_date__c))&&String.isNotBlank(String.valueof(RevalInfo.repair.Aware_date2__c))){
+            String day = String.valueof(RevalInfo.repair.Aware_date__c);
+            String day2 = String.valueof(RevalInfo.repair.Aware_date2__c);
+            day = day.substring(0,10);
+            day2 = day2.substring(0,10);
+            sql += ' and FSE_ApplyForRepair_Day__c >= ' + day + 'and FSE_ApplyForRepair_Day__c <=' +day2;
+        }
+        if(String.isNotBlank(RevalInfo.onSiteRepair)){
+            sql += ' and On_site_repair__c = \'' + RevalInfo.onSiteRepair + '\'';
+        }
+        if(String.isNotBlank(RevalInfo.workLocationSelect)){
+            List<String> workLocationSelectList = new List<String>();
+            if(RevalInfo.workLocationSelect.indexOf(',') != -1){
+                workLocationSelectList = RevalInfo.workLocationSelect.split(',');
+            }
+            System.debug('workLocationSelectList1:' + workLocationSelectList);
+            if(workLocationSelectList.size() > 0){
+                sql += ' and (work_location_select__c like \'%';
+                Integer i = 0;
+                for(String workLocationSelect : workLocationSelectList){
+                    if(i == 0){
+                        sql += workLocationSelect.trim() + '%\'';
+                    }else{
+                        sql += 'or work_location_select__c like \'%' + workLocationSelect.trim() + '%\'';
+                    }
+                    i++;
+                }
+                sql += ')';
+            } else{
+                sql += ' and work_location_select__c like \'%' + RevalInfo.workLocationSelect.trim() + '%\'';
+            }
+        }
+        if(String.isNotBlank(RevalInfo.State_Hospital)){
+            sql += ' and State_Hospital__c like \'%' + RevalInfo.State_Hospital.trim() + '%\'';
+        }
+        sql += 'and Status1__c not in(\'0.鍒犻櫎\',\'0.鍙栨秷\') limit 200';
+        System.debug('sql1:' + sql);
+        if(String.isNotBlank(sql)){
+            RepairList = Database.query(sql);
+        }
+        if(RepairList.size() == 200){
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '妫�绱㈡暟鎹お澶�,璇风缉灏忔绱㈣寖鍥达紒'));
+        }
+        if(RepairList.size() <= 0){
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '娌℃绱㈠埌浠讳綍淇悊'));
             return null;
         }
@@ -79,35 +256,45 @@
     }
 
     public PageReference showPDF() {
+        System.debug(LoggingLevel.INFO, '*** joinshoPDF: ');
         repairIdList = new List<String>();
         RepairList = new List<Repair__c>();
         String url = '=';
-        if(RAInfoList == null){
+        System.debug('RAInfoList:' + RAInfoList);
+        if(RAInfoList == null || RAInfoList.isEmpty()){
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '璇峰厛妫�绱慨鐞�'));
             return null;
         }
         for(RepairData rd : RAInfoList) {
+            System.debug(LoggingLevel.INFO, '*** rd: ' + rd);
             if(rd.IFCheck){
                 repairIdList.add(rd.repair.Id);
                 RepairList.add(rd.repair);
             }
         }
+        System.debug(LoggingLevel.INFO, '***repairIdList : ' + repairIdList);
+        System.debug(LoggingLevel.INFO, '***RepairList : ' + RepairList);
         if(repairIdList.size() > 0){
             if(repairIdList.size() <= 50){
                 if(RepairList.size() > 0){
+                    System.debug(LoggingLevel.INFO, '*** if size>0 generateAttachment: ');
                     generateAttachment(RepairList);
                 }
                 for(String Id : repairIdList){
                     url += Id + '=';
                 }
-                System.debug('url1:'+url);
                 url = url.substring(0, url.lastIndexOf('='));
-                System.debug('url2:'+url);
-                PageReference pageRef = new PageReference('/apex/MaintenanceCommissionPDF?id' + url);
-                pageRef.setRedirect(true);
-                return pageRef;
+                // PageReference pageRef = new PageReference('/apex/MaintenanceCommissionPDF?id' + url);
+                // pageRef.setRedirect(true);
+                // return pageRef;
+                if(isSandbox()){
+                    pdfURL = 'https://ocsm--stagefull--c.visualforce.com/apex/MaintenanceCommissionPDF?id' + url;
+                } else{
+                    pdfURL = 'https://ocsm.my.salesforce.com/apex/MaintenanceCommissionPDF?id' + url;
+                }
+                return null;
             } else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '澶氬崟鎵撳嵃鏈�澶ф暟閲忎负50,璇烽�夋嫨灏戜簬50涓慨鐞�!'));
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '澶氬崟鎵撳嵃鏈�澶ф暟閲忎负50,璇烽�夋嫨灏戜簬50涓慨鐞嗭紒'));
                 return null;
             }
         } else{
@@ -118,30 +305,62 @@
 
     // 鐢熸垚pdf娣诲姞鍒板搴旂殑淇悊涓�
     public static PageReference generateAttachment(List<Repair__c> repList){
-        PageReference pdfPage;
-        List<Attachment> attachments = new List<Attachment>();
-        for(Repair__c re : repList){       
-            pdfPage = new PageReference('/apex/MaintenanceCommissionPDF?id=' + re.Id);
-            Blob pdfBody;
-            if(Test.isRunningTest()) { 
-                pdfBody = blob.valueOf('Unit.Test');
-            } else {
-                pdfBody = pdfPage.getContentAsPDF();
-            }
-            Attachment attach = new Attachment();
-            attach.Body = pdfBody;
-            attach.Name = re.name + '_' + 'MaintenanceCommission.pdf';
-            attach.ParentId = re.id;
-            attachments.add(attach);
-        }
-        insert attachments;
+        System.debug(LoggingLevel.INFO, '*** generateAttachment: ');
+        // PageReference pdfPage;
+        // List<Attachment> attachments = new List<Attachment>();
+        // List<String> attachmentNameList = new List<String>();
+        // List<Attachment> isGeneratedPDFList = new List<Attachment>();
+        // //鍒犻櫎宸插瓨鍦ㄧ殑闄勪欢锛岀敓鎴愭柊鐨勯檮浠�
+        // for(Repair__c re : repList){   
+        //     attachmentNameList.add(re.name + '_' + 'MaintenanceCommission.pdf');
+        // }
+        // isGeneratedPDFList = [select id from Attachment where name IN:attachmentNameList];
+        // System.debug(LoggingLevel.INFO, '*** isGeneratedPDFList: ' + isGeneratedPDFList);
+        // if(isGeneratedPDFList.size() > 0){
+        //     delete isGeneratedPDFList;
+        // }
+        BatchSelectRepairPDFDelete pdf = new BatchSelectRepairPDFDelete();
+        pdf.deletePDF(repList);
+        pdf.createPDF(repList);
+
+        // for(Repair__c re : repList){       
+        //     pdfPage = new PageReference('/apex/MaintenanceCommissionPDF?id=' + re.Id);
+        //     Blob pdfBody;
+        //     if(Test.isRunningTest()) { 
+        //         pdfBody = blob.valueOf('Unit.Test');
+        //     } else {
+        //         pdfBody = pdfPage.getContentAsPDF();
+        //     }
+        //     Attachment attach = new Attachment();
+        //     attach.Body = pdfBody;
+        //     attach.Name = re.name + '_' + 'MaintenanceCommission.pdf';
+        //     attach.ParentId = re.id;
+        //     attachments.add(attach);
+        // }
+        // System.debug(LoggingLevel.INFO, '*** attachments: ' + attachments);
+        // insert attachments;
         return null;
     }
 
+    // 鍒ゆ柇鏄惁鏄祴璇曠幆澧�
+    public  Boolean isSandbox() {
+        return [SELECT IsSandbox FROM Organization LIMIT 1].IsSandbox;
+    }
+
     public class RetrievalData {
+        public String Status1{ get; set; }
+        public String Status2{ get; set; }
         public String RepairName{ get; set; }
         public String SAPRepairNo{ get; set; }
+        public String SerialNumber{ get; set; }
+        public String onSiteRepair{ get; set; }
+        public String workLocationSelect{ get; set; }
+        public String State_Hospital{ get; set; }
         public String HospitalName{ get; set; }
+        public Repair__c repair{ get; set; }
+        public RetrievalData(){
+            repair = new Repair__c();
+        }
     }
 
     public class RepairData {

--
Gitblit v1.9.1