| | |
| | | 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 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> getStatusItems() { |
| | | List<SelectOption> options = new List<SelectOption>(); |
| | | options.add(new SelectOption('','--无--')); |
| | | options.add(new SelectOption('草案中','草案中')); |
| | | options.add(new SelectOption('1.受理完毕','1.受理完毕')); |
| | | options.add(new SelectOption('2.维修报价阶段','2.维修报价阶段')); |
| | | options.add(new SelectOption('3.维修阶段','3.维修阶段')); |
| | | options.add(new SelectOption('4.修理品返送阶段','4.修理品返送阶段')); |
| | | options.add(new SelectOption('5.完毕','5.完毕')); |
| | | options.add(new SelectOption('0.取消','0.取消')); |
| | | options.add(new SelectOption('0.删除','0.删除')); |
| | | options.add(new SelectOption('0.申请完毕','0.申请完毕')); |
| | | return options; |
| | | } |
| | | |
| | | public List<SelectOption> getSiteRepairItems() { |
| | | List<SelectOption> options = new List<SelectOption>(); |
| | | options.add(new SelectOption('','--无--')); |
| | | options.add(new SelectOption('RC修理','RC修理')); |
| | | options.add(new SelectOption('直送SORC修理','直送SORC修理')); |
| | | options.add(new SelectOption('直送OGZ修理','直送OGZ修理')); |
| | | options.add(new SelectOption('办事处修理','办事处修理')); |
| | | options.add(new SelectOption('现场修理','现场修理')); |
| | | return options; |
| | | } |
| | | |
| | | 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.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(RevalInfo.workLocationSelect)){ |
| | | 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() + '%\')'; |
| | | } |
| | | } else if(String.isNotBlank(HospitalName)) { |
| | | sql += ' and (HP_Name__c like \'%' + HospitalName.trim() + '%\' or Department_Name__c like \'%' + HospitalName.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() + '%\')'; |
| | | } |
| | | } else if(String.isNotBlank(HospitalName)){ |
| | | sql += ' where 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.Status1)){ |
| | | sql += ' and Status1__c = \'' + RevalInfo.Status1 + '\''; |
| | | } |
| | | 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.RepairName)){ |
| | | sql += ' and Name like \'%' + RevalInfo.RepairName + '%\''; |
| | | } |
| | | if(RepairList.size() <= 0 ){ |
| | | if(String.isNotBlank(RevalInfo.SAPRepairNo)){ |
| | | sql += ' and SAP_Service_Repair_No__c like \'%' + RevalInfo.SAPRepairNo + '%\''; |
| | | } |
| | | if(String.isNotBlank(RevalInfo.SerialNumber)){ |
| | | sql += ' and SerialNumber__c like \'%' + RevalInfo.SerialNumber + '%\''; |
| | | } |
| | | 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 day = String.valueof(RevalInfo.repair.Aware_date__c); |
| | | day = day.substring(0,10); |
| | | sql += ' and FSE_ApplyForRepair_Day__c = ' + day; |
| | | } |
| | | if(String.isNotBlank(RevalInfo.onSiteRepair)){ |
| | | sql += ' and On_site_repair__c = \'' + RevalInfo.onSiteRepair + '\''; |
| | | } |
| | | if(String.isNotBlank(RevalInfo.workLocationSelect)){ |
| | | sql += ' and work_location_select__c like \'%' + RevalInfo.workLocationSelect + '%\''; |
| | | } |
| | | sql += ' 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; |
| | | } |
| | |
| | | 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(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; |
| | | } else{ |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '多单打印最大数量为50,请选择少于50个修理!')); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '多单打印最大数量为50,请选择少于50个修理!')); |
| | | return null; |
| | | } |
| | | } else{ |
| | |
| | | public static PageReference generateAttachment(List<Repair__c> repList){ |
| | | 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]; |
| | | if(isGeneratedPDFList.size() > 0){ |
| | | delete isGeneratedPDFList; |
| | | } |
| | | for(Repair__c re : repList){ |
| | | pdfPage = new PageReference('/apex/MaintenanceCommissionPDF?id=' + re.Id); |
| | | Blob pdfBody; |
| | |
| | | } |
| | | |
| | | public class RetrievalData { |
| | | public String Status1{ get; set; } |
| | | public String RepairName{ get; set; } |
| | | public String SAPRepairNo{ get; set; } |
| | | public String HospitalName{ get; set; } |
| | | public String SerialNumber{ get; set; } |
| | | public String onSiteRepair{ get; set; } |
| | | public String workLocationSelect{ get; set; } |
| | | public Repair__c repair{ get; set; } |
| | | public RetrievalData(){ |
| | | repair = new Repair__c(); |
| | | } |
| | | } |
| | | |
| | | public class RepairData { |