/** * wangweipeng 2021/08/04 * 打印点检计划报告书 筛选条件 */ public with sharing class PrintInspectupReportController { //维修合同id public String maintenanceContractId{get;set;} //是否空白单据 public String isResultShow{get;set;} //是否空白单据 下拉内容 public static List isResultShowLOption{get;set;} //根据保有设备查询合同 public String selectAssetType{get;set;} //保有设备的下拉内容 public static List selectAssetTypeOption{get;set;} //战略科室的下拉内容 public List strategyDepartment{get;set;} //科室的下拉内容 public List department{get;set;} //设备的装机地点 public List installationSite{get;set;} //是否分页 public Boolean isPaging{get;set;} static { isResultShowLOption = new List(); isResultShowLOption.add(new SelectOption('', '--无--')); isResultShowLOption.add(new SelectOption('1', '空白单据')); isResultShowLOption.add(new SelectOption('2', '合同全部')); selectAssetTypeOption = new List(); selectAssetTypeOption.add(new SelectOption('', '--无--')); selectAssetTypeOption.add(new SelectOption('1', '战略科室')); selectAssetTypeOption.add(new SelectOption('2', '科室')); selectAssetTypeOption.add(new SelectOption('3', '装机地点')); selectAssetTypeOption.add(new SelectOption('4', '机身号')); } public String produceText{get;set;} //洗消信息 public Boolean activeOn { get; set; } //点检数据 public List inspectupPlanList{get;set;} //条件参数 public String parameter{get;set;} public PrintInspectupReportController() { parameter = ''; produceText = ''; activeOn = true; //是否分页 默认为false isPaging = false; inspectupPlanList = new List(); maintenanceContractId = System.currentPageReference().getParameters().get('id'); } public PageReference init(){ getAssetType(); getInspectupPlan(); return null; } //获取修理合同上的保有设备都是那个战略科室和科室 public void getAssetType(){ String assetTypeSQl = makeTextDepSQl(); try{ List assetTypeList = Database.query(assetTypeSQl); if(assetTypeList != null && assetTypeList.size() > 0){ //临时字符串 String strategyDepartmentStr = ''; String departmentStr = ''; String installationSiteStr = ''; //战略科室存放处 strategyDepartment = new List(); department = new List(); installationSite = new List(); for(Maintenance_Contract_Asset__c mca : assetTypeList){ //所有的战略科室 if(strategyDepartmentStr.indexOf(mca.Asset__r.Strategic_department_Class_Name__c) == -1){ strategyDepartmentStr += mca.Asset__r.Strategic_department_Class_Name__c; strategyDepartment.add(new CustomData(mca.Asset__r.Department_Class__c,mca.Asset__r.Acc_Department_Class_Name__c)); } //科室 if(departmentStr.indexOf(mca.Asset__r.Account.Name) == -1){ departmentStr += mca.Asset__r.Account.Name; department.add(new CustomData(mca.Asset__r.Account.Id,mca.Asset__r.Department_Name__c)); } //装机地点 if(mca.Asset__r.Installation_Site__c != null && mca.Asset__r.Installation_Site__c != ''){ if(installationSiteStr.indexOf(mca.Asset__r.Installation_Site__c) == -1){ installationSiteStr += mca.Asset__r.Installation_Site__c; installationSite.add(new CustomData(mca.Asset__r.Installation_Site__c,mca.Asset__r.Installation_Site__c)); } } } } }catch(exception e){ //失败提示 ApexPages.addMessages(e); } } //获取所有的点检数据 public void getInspectupPlan(){ String InspectupPlanSQL = makeTextInspectupPlanSQl(); try{ inspectupPlanList = Database.query(InspectupPlanSQL); }catch(exception e){ //失败提示 ApexPages.addMessages(e); } } //查询点检报告书的pdf public String makeTextInspectupPlanSQl(){ String InspectupPlanSQL = 'SELECT ID,NAME,Execution_End_Date__c,Chack_Plan_NO__c FROM Inspectup_Plan__c WHERE Maintenance_Contract__c = \''+maintenanceContractId+'\' ' + ' order by Maintenance_Contract__c desc'; return InspectupPlanSQL; } //查询修理合同里面保有设备都是那些科室和战略科室 public String makeTextDepSQl(){ String depSQl = 'select id,name,Asset__c,Asset__r.name,Asset__r.SerialNumber,Asset__r.Strategic_department_Class_Name__c,Asset__r.Department_Class__c,Asset__r.Acc_Department_Class_Name__c,' +' Asset__r.Department_Name__c,Asset__r.Account.Id,Asset__r.Account.Name,Asset__r.Installation_Site__c ' +' from Maintenance_Contract_Asset__c ' //+' where Check_object__c = true and Maintenance_Contract__c = \''+maintenanceContractId+'\' ' +' where Maintenance_Contract__c = \''+maintenanceContractId+'\' and isdianjian__c != 0 ' +' order by Asset__r.Acc_Department_Class_Name__c,Asset__r.Account.Name'; return depSQl; } /** * 为了方便前段table获取值 */ class CustomData { //id public String parameterId { get; private set; } //name public String parameterName { get; private set; } public CustomData(String accountId,String accountName){ parameterId = accountId; parameterName = accountName; } } }