public with sharing class ConsumUploadPictureController { public Boolean done_flag {get;set;} public Boolean hasPicture {get;set;} public String line {get;set;} public Consum_Apply_Equipment_Set_Detail__c caesd {get;set;} public ConsumUploadPictureController() {} public void init() { String caesd_id = System.currentPageReference().getParameters().get('caesd_id'); line = System.currentPageReference().getParameters().get('line'); List caesdList = [ SELECT Picture1__c , Picture2__c , Consum_Apply__r.Id , Received_Confirm__c , Fixture_Model_No_F__c , ProductName__c , Degree_Of_Importance__c , RAESD_Status__c , Consumable_Guaranteen_end_F__c , Consum_Apply__r.HP_received_sign_rich__c , Follower_User__c FROM Consum_Apply_Equipment_Set_Detail__c WHERE Id = : caesd_id ]; if (caesdList.size() > 0) { caesd = caesdList[0]; } else { ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, '无效的耗材明细Id'); ApexPages.addMessage(errorMessage); } } public PageReference save() { Savepoint sp = Database.setSavepoint(); try{ List caesdList = [ SELECT Picture1__c , Picture2__c , Received_Confirm__c , Fixture_Model_No_F__c , ProductName__c , Degree_Of_Importance__c , RAESD_Status__c , Consumable_Guaranteen_end_F__c , Consum_Apply__r.HP_received_sign_rich__c , Follower_User__c FROM Consum_Apply_Equipment_Set_Detail__c WHERE Id = : caesd.Id FOR UPDATE ]; if (caesdList.size() == 1) { Consum_Apply_Equipment_Set_Detail__c newCaesd = caesdList[0]; if(newCaesd.RAESD_Status__c == Consum_ApplyUtil.CaStatusMap.get(Consum_ApplyUtil.CaesdStatus.Yi_Xiao_Hao.ordinal())) { throw new ControllerUtil.myException('耗材明细已消耗,不可以更新图片,Id=' + caesd.Id); } if (String.isNotBlank(newCaesd.Consum_Apply__r.HP_received_sign_rich__c)) { throw new ControllerUtil.myException('耗材申请已上传试用表,不可以更新' ); } newCaesd.Picture1__c = caesd.Picture1__c; newCaesd.Picture2__c = caesd.Picture2__c; FixtureUtil.withoutUpdate(new List {newCaesd}); done_flag = true; hasPicture = String.isNotBlank(newCaesd.Picture1__c)||String.isNotBlank(newCaesd.Picture2__c); return null; } else { throw new ControllerUtil.myException('耗材明细不存在,可能已被删除,Id=' + caesd.Id); } } catch (Exception e) { Database.rollback(sp); ApexPages.addMessages(e); done_flag = false; return null; } } public PageReference goback(){ PageReference pageRef = new PageReference('/apex/ConsumTrialUpdate?parid=' + caesd.Consum_Apply__r.Id); return pageRef; } }