/**2021-08-31 mzy 设备多时,FSE分批点检如果有遗漏设备的提醒设置 */ public with sharing class InspectionRemindController { public String taId{get;set;} //点检计划Id //public List BodyId {get;set;} //存放保有设备的Id //public Map BodyMap {get;set;} //存放保有设备信息 public List BodyList {get;set;} public String getInit() { system.debug('记录Id :' +taId); if(String.IsBlank(taId)){ //return 'Id不能为空'; return ''; } //初始化变量 //BodyId = new List(); BodyList = new List(); /* //根据点检计划Id查询点检报告书 List InspectionReportList = [SELECT Id FROM Inspection_Report__c WHERE Inspectup_Plan__c = :taId]; //根据点检报告书Id查询点检明细 Set IdSet = new Set(); if(InspectionReportList.size()>0){ for(Inspection_Report__c It:InspectionReportList){ IdSet.add(It.Id); } if(IdSet.size()>0){ //查询点检明细 List InspectionItemList = [ SELECT Id,AssetId__c,AssetId__r.Id,AssetId__r.Name,AssetId__r.SerialNumber FROM Inspection_Item__c WHERE Inspection_ReportId__c = :IdSet]; //构建Body if(InspectionItemList.size()>0){ for(Inspection_Item__c iitem:InspectionItemList){ if(!BodyId.contains(iitem.AssetId__c)){ BodyId.add(iitem.AssetId__c); //BodyList.add(new AssetInfo(iitem.AssetId__c,iitem.AssetId__r.Name)); BodyList.add(new AssetInfo(iitem)); } } } } } */ Map AssetMap = new Map(); List InspectionItemList = [select Id,name,AssetId__c,AssetId__r.Product_Serial_No__c,Inspection_ReportId__c, Inspection_ReportId__r.Inspectup_Plan__c from Inspection_Item__c where Inspection_ReportId__r.Inspectup_Plan__c = :taId and AssetId__c != null]; if(InspectionItemList.size()>0){ for(Inspection_Item__c iitem:InspectionItemList){ String ProductSerialNo = iitem.AssetId__r.Product_Serial_No__c; AssetMap.put(ProductSerialNo,ProductSerialNo); } } String ContractId = ''; Inspectup_Plan__c ir0 = [SELECT Id,Maintenance_Contract__c FROM Inspectup_Plan__c WHERE id = :taId]; ContractId = ir0.Maintenance_Contract__c; List mCAList = [Select Asset__c,Asset__r.Product_Serial_No__c,Asset__r.Product2.Asset_Model_No__c from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :ContractId]; if(mCAList.size()>0){ for(Maintenance_Contract_Asset__c mca:mCAList){ String ProductSerialNo = mca.Asset__r.Product_Serial_No__c; if(!AssetMap.containsKey(ProductSerialNo)){ BodyList.add(new AssetInfo(mca)); } } } return ''; } class AssetInfo { public String ProductSerialNo { get; set; } public String AssetModelNo { get; set; } public AssetInfo(Maintenance_Contract_Asset__c mca){ ProductSerialNo = mca.Asset__r.Product_Serial_No__c; AssetModelNo = mca.Asset__r.Product2.Asset_Model_No__c; } } }