/**
|
* *
|
ODescription:
|
GAuthor: sun xia
|
@Date: 2023-07-11 15:31:56
|
GIastEditors: sun xia
|
@IastEditTime: 2023-07-11 15:31:56
|
|
* */
|
|
public with sharing class lexSubmitApprovalRentalApplyController {
|
@AuraEnabled
|
public static InitData init(String recordId){
|
InitData res = new InitData();
|
try {
|
List<Rental_Apply__c> raList = [SELECT Id, Request_shipping_day__c, Add_Approval_Status__c, Repair__c,
|
Demo_purpose1__c, demo_purpose2__c, Repair__r.Repair_Estimated_date_formula__c,
|
Repair__r.Agreed_Date__c, Repair__r.NewProductGuaranteeObject__c,Follow_UP_Opp__c,
|
Repair__r.Repair_Final_Inspection_Date__c, Repair__r.Repair_Shipped_Date__c,Statu_Achievements__c,
|
Repair__r.Status1__c, Repair__r.ReRepairObject_F__c, Repair__r.Number_of_EffectiveContract__c, BuchangApprovalManagerSalesSubmit__c,
|
Repair__r.Delivered_Product__r.Product2.Asset_Model_No__c, Campaign__c,Statu_Achievements_ID__c, SalesManagerSubmit__c,
|
Campaign__r.Status, Campaign__r.Rental_Apply_Flag__c, Campaign__r.IF_Approved__c, Campaign__r.Meeting_Approved_No__c, Campaign__r.Approved_Status__c,
|
QIS_number__c, QIS_number__r.next_action__c, applyUser__c, OPDPlan__r.SalesManager_Txt__c, OPDPlan__r.BuchangApprovalManagerSales_Txt__c,
|
Repair__r.Delivered_Product__r.Product2.Fixture_Model_No_T__c,Repair__r.Repair_Rank__c,Repair__r.IfCheckFixture__c,
|
Repair__r.DW_Sign_Txt__c,Repair__r.FSE_ApplyForRepair_Day__c,Repair__r.Repair_Ordered_Date__c,OPDPlan__c,
|
applyUser__r.Id, Owner.Id, Status__c,RecordTypeId,SupplementCreated__c from Rental_Apply__c WHERE Id = :recordId];
|
if(raList.size()>0){
|
Rental_Apply__c ra = raList[0];
|
res.rentalApplyId = ra.Id;
|
res.recordTypeId = ra.RecordTypeId;
|
res.addApprovalStatus = ra.Add_Approval_Status__c;
|
res.requestShippingDay = ra.Request_shipping_day__c;
|
res.repairId = ra.Repair__c;
|
res.demoPurpose1 = ra.Demo_purpose1__c;
|
res.demoPurpose2 = ra.demo_purpose2__c;
|
res.repairEstimatedDateFormula = ra.Repair__r.Repair_Estimated_date_formula__c;
|
res.agreedDate = ra.Repair__r.Agreed_Date__c;
|
res.newProductGuaranteeObject = ra.Repair__r.NewProductGuaranteeObject__c;
|
res.repairFinalInspectionDate = ra.Repair__r.Repair_Final_Inspection_Date__c;
|
res.repairShippedDate = ra.Repair__r.Repair_Shipped_Date__c;
|
res.status1 = ra.Repair__r.Status1__c;
|
res.reRepairObjectF = ra.Repair__r.ReRepairObject_F__c;
|
res.numberOfEffectiveContract = ra.Repair__r.Number_of_EffectiveContract__c;
|
res.assetModelNo = ra.Repair__r.Delivered_Product__r.Product2.Asset_Model_No__c;
|
res.campaignId = ra.Campaign__c;
|
res.campaignStatus = ra.Campaign__r.Status;
|
res.rentalApplyFlag = Integer.valueOf(ra.Campaign__r.Rental_Apply_Flag__c);
|
res.iFApproved = ra.Campaign__r.IF_Approved__c;
|
res.meetingApprovedNo = ra.Campaign__r.Meeting_Approved_No__c;
|
res.approvedStatus = ra.Campaign__r.Approved_Status__c;
|
res.qISNumber = ra.QIS_number__c;
|
res.nextAction = ra.QIS_number__r.next_action__c;
|
res.applyUserId = ra.applyUser__r.Id;
|
res.ownerId = ra.OwnerId;
|
res.rentalApplyStatus = ra.Status__c;
|
res.followUPOpp = ra.Follow_UP_Opp__c;
|
res.statuAchievements = ra.Statu_Achievements__c;
|
res.statuAchievementsId = ra.Statu_Achievements_ID__c;
|
res.deliveredProductFixtureModelNo = ra.Repair__r.Delivered_Product__r.Product2.Fixture_Model_No_T__c;
|
res.repairRank = ra.Repair__r.Repair_Rank__c;
|
res.dWSignTxt = ra.Repair__r.DW_Sign_Txt__c;
|
res.fSEApplyForRepairDay = ra.Repair__r.FSE_ApplyForRepair_Day__c;
|
res.repairOrderedDate = ra.Repair__r.Repair_Ordered_Date__c;
|
res.ifCheckFixture = ra.Repair__r.IfCheckFixture__c;
|
res.profileId = UserInfo.getProfileId();
|
res.demoRequestPastDataId = Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_PastData).getRecordTypeId();
|
res.supplementCreated = ra.SupplementCreated__c;
|
res.oPDPlanId = ra.OPDPlan__c;
|
res.oPDSalesManagerTxt = ra.OPDPlan__r.SalesManager_Txt__c;
|
res.oPDBuchangApprovalManagerSalesTxt = ra.OPDPlan__r.BuchangApprovalManagerSales_Txt__c;
|
res.salesManagerSubmit = ra.SalesManagerSubmit__c;
|
res.buchangApprovalManagerSalesSubmit = ra.BuchangApprovalManagerSalesSubmit__c;
|
|
Set<String> tempmodelSet = new Set<String>();
|
Set<String> tempstoppedSet = new Set<String>();
|
List<String> tempmodelList = new List<String>();
|
List<String> tempstoppedList = new List<String>();
|
List<Rental_Apply_Equipment_Set_Detail__c> raesd = [select Id, Fixture_Model_No_F__c, Product_Status_Flag_F__c from Rental_Apply_Equipment_Set_Detail__c where Rental_Apply__c = :recordId];
|
if(raesd.size() > 0 ){
|
for(Rental_Apply_Equipment_Set_Detail__c rae: raesd){
|
tempmodelSet.add(rae.Fixture_Model_No_F__c);
|
if(rae.Product_Status_Flag_F__c == false && (ra.demo_purpose2__c == '试用(有询价)' || ra.demo_purpose2__c == '试用(无询价)')){
|
tempstoppedSet.add(rae.Fixture_Model_No_F__c);
|
}
|
}
|
if(tempmodelSet.size()>0){
|
for(String model : tempmodelSet){
|
tempmodelList.add(model);
|
}
|
res.modelSet = tempmodelList;
|
}
|
if(tempstoppedSet.size()>0){
|
for(String stopped : tempstoppedSet){
|
tempstoppedList.add(stopped);
|
}
|
res.stoppedSet = tempstoppedList;
|
}
|
|
}
|
|
List<Rental_Apply_Equipment_Set__c> rseSet = [select Id from Rental_Apply_Equipment_Set__c where RetalFSetDetail_Cnt__c = 0 AND Rental_Apply__c = :recordId];
|
if(rseSet.size() > 0){
|
res.raesListSize = rseSet.size();
|
}
|
|
if(ra.demo_purpose2__c == '索赔QIS'){
|
List<QIS_Report__c> qisList = [select Id, nonyushohin__r.Product2.Fixture_Model_No_T__c From QIS_Report__c where Id =:ra.QIS_number__c];
|
res.qISisAgree = !res.modelSet.contains(qisList[0].nonyushohin__r.Product2.Fixture_Model_No_T__c);
|
res.qisSize = qisList.size();
|
}
|
|
String userId = UserInfo.getUserId();
|
User currentUser = [SELECT Id, JingliEquipmentManager__c, JingliEquipmentManager__r.Name, Buzhang_Equipment_Manager__c, Buzhang_Equipment_Manager__r.Name FROM User where Id = :userId];
|
if(currentUser!=null){
|
res.manageUsersJingliEquipmentManager = currentUser.JingliEquipmentManager__c;
|
res.manageUsersJingliEquipmentManagerTxt = currentUser.JingliEquipmentManager__r.Name;
|
res.manageUsersBuzhangEquipmentManager = currentUser.Buzhang_Equipment_Manager__c;
|
res.manageUsersBuzhangEquipmentManagerTxt = currentUser.Buzhang_Equipment_Manager__r.Name;
|
}
|
}
|
|
}
|
catch (Exception e) {
|
System.debug(LoggingLevel.INFO, '****e:' + e);
|
}
|
return res;
|
}
|
|
/**
|
* Id
|
* Status__c
|
SalesManagerSubmit__c
|
OPDManagerApprover__c
|
BuchangApprovalManagerSalesSubmit__c
|
OPDBuchangApprover__c
|
* */
|
|
@AuraEnabled
|
public static String updateRentalApply(String recordId, String status, String salesManagerSubmit, String oPDManagerApprover, String buchangApprovalManagerSalesSubmit, String oPDBuchangApprover){
|
Savepoint sp = Database.setSavepoint();
|
try {
|
Rental_Apply__c tempRa = new Rental_Apply__c ();
|
tempRa.Id = recordId;
|
tempRa.Status__c = status;
|
tempRa.SalesManagerSubmit__c = salesManagerSubmit;
|
tempRa.OPDManagerApprover__c = oPDManagerApprover;
|
tempRa.BuchangApprovalManagerSalesSubmit__c = buchangApprovalManagerSalesSubmit;
|
tempRa.OPDBuchangApprover__c = oPDBuchangApprover;
|
return '更新成功';
|
}catch(Exception e){
|
Database.rollback(sp);
|
return e.getMessage();
|
}
|
}
|
|
public class InitData{
|
@AuraEnabled
|
public String rentalApplyId; //备品借出申请Id
|
@AuraEnabled
|
public String recordTypeId;
|
@AuraEnabled
|
public String addApprovalStatus; //备品借出申请.追加备品审批状态
|
@AuraEnabled
|
public Date requestShippingDay; //备品借出申请.希望到货日
|
@AuraEnabled
|
public String repairId; //修理Id
|
@AuraEnabled
|
public String demoPurpose1; //备品借出申请.使用目的1
|
@AuraEnabled
|
public String demoPurpose2; //备品借出申请.使用目的2
|
@AuraEnabled
|
public String followUPOpp; //备品借出申请.跟进询价1
|
@AuraEnabled
|
public String statuAchievements; //备品借出申请.注残
|
@AuraEnabled
|
public String statuAchievementsId; //备品借出申请.注残Id
|
@AuraEnabled
|
public Date repairEstimatedDateFormula; //修理.6.报价日
|
@AuraEnabled
|
public Date agreedDate; //修理.7.用户同意日
|
@AuraEnabled
|
public String newProductGuaranteeObject; //修理.无偿区别标志
|
@AuraEnabled
|
public Date repairFinalInspectionDate; //修理.10.最终检测日
|
@AuraEnabled
|
public Date repairShippedDate; //修理.11.RC修理品返送日
|
@AuraEnabled
|
public String status1; //修理.状态1
|
@AuraEnabled
|
public Boolean reRepairObjectF; //修理.再受理对象品参考
|
@AuraEnabled
|
public String numberOfEffectiveContract; //修理.有无维修合同对象(SFDC)
|
@AuraEnabled
|
public String assetModelNo; //修理.资产.产品.产品型号(MDM)
|
@AuraEnabled
|
public String campaignId; //备品借出申请.学会
|
@AuraEnabled
|
public String campaignStatus; //学会.状态
|
@AuraEnabled
|
public Integer rentalApplyFlag; //学会.提交申请FLG
|
@AuraEnabled
|
public Boolean iFApproved; //学会.是否需要申请决裁
|
@AuraEnabled
|
public String meetingApprovedNo; //学会.会议决裁编码
|
@AuraEnabled
|
public String approvedStatus; //学会.决裁状态
|
@AuraEnabled
|
public String qISNumber; //备品借出申请.QIS
|
@AuraEnabled
|
public String nextAction; //QIS.对应方法
|
@AuraEnabled
|
public String applyUserId; //备品借出申请.操作者Id
|
@AuraEnabled
|
public String ownerId; //备品借出申请.所有人Id
|
@AuraEnabled
|
public String rentalApplyStatus; //备品借出申请.状态
|
@AuraEnabled
|
public String demoRequestPastDataId; //备品申请 过去历史转移Id
|
@AuraEnabled
|
public List<String> modelSet; //Set<明细.备品配套明细型号(Sys)>
|
@AuraEnabled
|
public List<String> stoppedSet; //Set<明细.备品配套明细型号(Sys)>
|
@AuraEnabled
|
public Boolean qISisAgree; //判断QIS是否一致
|
@AuraEnabled
|
public Integer qisSize;
|
@AuraEnabled
|
public String deliveredProductFixtureModelNo; // 送修型号
|
@AuraEnabled
|
public String repairRank; // 修理.报价等级
|
@AuraEnabled
|
public Boolean dWSignTxt;
|
@AuraEnabled
|
public Date fSEApplyForRepairDay;
|
@AuraEnabled
|
public Date repairOrderedDate;
|
@AuraEnabled
|
public Boolean ifCheckFixture;
|
@AuraEnabled
|
public String profileId;
|
@AuraEnabled
|
public Boolean supplementCreated; //补充申请创建
|
@AuraEnabled
|
public String oPDPlanId; //OPD计划
|
@AuraEnabled
|
public String oPDSalesManagerTxt; //OPD.推广CL6 经理级(文本)
|
@AuraEnabled
|
public String oPDBuchangApprovalManagerSalesTxt; //OPD.推广CL5 总监级(文本)
|
@AuraEnabled
|
public Integer raesListSize; //明细数量
|
@AuraEnabled
|
public String manageUsersJingliEquipmentManager; //OPD上的
|
@AuraEnabled
|
public String manageUsersJingliEquipmentManagerTxt; //OPD上的
|
@AuraEnabled
|
public String manageUsersBuzhangEquipmentManager; //OPD上的
|
@AuraEnabled
|
public String manageUsersBuzhangEquipmentManagerTxt; //OPD上的
|
@AuraEnabled
|
public String buchangApprovalManagerSalesSubmit; //借出申请.
|
@AuraEnabled
|
public String salesManagerSubmit; //借出申请.
|
|
}
|
|
|
}
|