public class ConsumApplyCancelController {
|
|
/*--------- private ---------*/
|
private Id objId {get; set;}
|
|
/*--------- public ---------*/
|
public Consum_Apply__c ra {get; set;}
|
public String saveStatus {get; set;}
|
|
|
/**
|
* @description ConsumApplyCancelController Class的构造函数
|
* @param objId 申请书ID
|
**/
|
public ConsumApplyCancelController() {
|
this.objId = ApexPages.currentPage().getParameters().get('objId');
|
}
|
|
/**
|
* @description ConsumApplyCancelController 初始化方法
|
**/
|
public void init() {
|
try{
|
if (String.isBlank(this.objId)) {
|
throw new ControllerUtil.myException('请设置耗材借出申请的Id');
|
}
|
if (String.isNotBlank(this.objId)) {
|
List<Consum_Apply__c> ras = getRas(this.objId);
|
if (ras.size() == 0) {
|
throw new ControllerUtil.myException('没有检索出耗材申请');
|
}
|
this.ra = ras[0];
|
}
|
}
|
catch (Exception e) {
|
System.debug(e.getStackTraceString());
|
ApexPages.addMessages(e);
|
return;
|
}
|
}
|
|
/**
|
* @description 保存取消状态
|
**/
|
public void saveCancel() {
|
Savepoint sp = Database.setSavepoint();
|
try {
|
// SWAG-BFV6G4 start
|
StaticParameter.rentalApplyIsRunning = true;
|
// SWAG-BFV6G4 end
|
if (String.isBlank(this.ra.Cancel_Reason__c)) {
|
throw new ControllerUtil.myException('请输入取消理由');
|
}
|
if (String.isBlank(this.ra.Loaner_cancel_request__c)) {
|
throw new ControllerUtil.myException('备品申请取消理由备注');
|
}
|
FixtureUtil.withoutUpdate(new Consum_Apply__c[]{this.ra});
|
String statusMessage;
|
statusMessage = ConsumApplyWebService.ConsumApplyCancel(objId, false);
|
if (statusMessage != '1') {
|
throw new ControllerUtil.myException(statusMessage);
|
}
|
saveStatus = 'ok';
|
}
|
catch (Exception e) {
|
Database.rollback(sp);
|
System.debug(e.getStackTraceString());
|
ApexPages.addMessages(e);
|
saveStatus = 'ng';
|
return;
|
}
|
}
|
|
/**
|
* @description 备品借出申请取得
|
**/
|
private List<Consum_Apply__c> getRas(Id raId) {
|
return [SELECT Id
|
, Name
|
, OwnerId
|
, Status__c
|
, RA_Status__c
|
, Cancel_Reason__c
|
, Loaner_cancel_request__c
|
//, StockDown_ng_num__c
|
, Consum_Apply_Equipment_Set_Detail_Cnt__c
|
FROM Consum_Apply__c
|
WHERE Id = :raId];
|
}
|
}
|