From 666b1cff3d705a53d07cd3ee6d146a7ef7ac7754 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期一, 26 六月 2023 17:13:11 +0800
Subject: [PATCH] Merge branch 'LEX_chenjingwu_dev' of http://47.92.229.245:8089/r/lightningupdate into LEX_chenjingwu_dev
---
force-app/main/default/classes/OpportunityLightingButtonController.cls | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 254 insertions(+), 10 deletions(-)
diff --git a/force-app/main/default/classes/OpportunityLightingButtonController.cls b/force-app/main/default/classes/OpportunityLightingButtonController.cls
index f3274d0..b7d7a02 100644
--- a/force-app/main/default/classes/OpportunityLightingButtonController.cls
+++ b/force-app/main/default/classes/OpportunityLightingButtonController.cls
@@ -4,7 +4,7 @@
* @Author: chen jing wu
* @Date: 2023-04-12 11:16:07
* @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-21 17:39:35
+ * @LastEditTime: 2023-06-25 13:10:39
*/
public with sharing class OpportunityLightingButtonController {
@AuraEnabled
@@ -65,8 +65,12 @@
res.trade = opportunity.Trade__c;
res.isCorrosion = opportunity.Is_Corrosion__c;
res.ifAuthorizingLock = opportunity.If_Authorizing_Lock__c;
- String profile18 = UserInfo.getProfileId();
- res.profileId = profile18.substring(0,profile18.length() - 3);
+ res.profileId = UserInfo.getProfileId();
+ res.systemProfileId = getProfileIdByName(lexLightingButtonConstant.SYSTEM_PROFILE_NAME);
+ res.j3ProfileId = getProfileIdByName(lexLightingButtonConstant.J3_PROFILE_NAME);
+ res.s61ProfileId = getProfileIdByName(lexLightingButtonConstant.S61_PROFILE_NAME);
+ res.s62ProfileId = getProfileIdByName(lexLightingButtonConstant.S62_PROFILE_NAME);
+ res.m4ProfileId = getProfileIdByName(lexLightingButtonConstant.M4_PROFILE_NAME);
} catch (Exception e) {
System.debug('e:****' + e);
}
@@ -117,7 +121,7 @@
return res;
}
@AuraEnabled
- public static InitData initFoBeforeOPDPDFBtnButton(String recordId){
+ public static InitData initForBeforeOPDPDFBtnButton(String recordId){
InitData res = new InitData();
try {
Opportunity opportunity = [
@@ -176,8 +180,11 @@
res.bidPlannedDate = opportunity.Bid_Planned_Date__c;
res.salesAssistantName = opportunity.Sales_assistant_name__c;
res.salesAssistantID = opportunity.Sales_assistant_ID__c;
- String profileId18 = UserInfo.getProfileId();
- res.profileId = profileId18.substring(0, profileId18.length() - 3);
+ res.profileId = UserInfo.getProfileId();
+ res.systemProfileId = getProfileIdByName(lexLightingButtonConstant.SYSTEM_PROFILE_NAME);
+ res.s1ProfileId = getProfileIdByName(lexLightingButtonConstant.S1_PROFILE_NAME);
+ res.s4ProfileId = getProfileIdByName(lexLightingButtonConstant.S4_PROFILE_NAME);
+ res.recordTypeId = Schema.SObjectType.Request_tedner_doc__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_AUTHORIZATION_REQUEST).getRecordTypeId();
} catch (Exception e) {
System.debug('e:****' + e);
}
@@ -217,6 +224,7 @@
res.salesManagerDepartmentID = opportunity.Sales_manager_departmentID__c;
res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c;
res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c;
+ res.recordTypeId = Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_OPPO_CANCEL_REPORT).getRecordTypeId();
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
@@ -298,7 +306,11 @@
CurrencyIsoCode
from Opportunity where Id =: recordId
];
+ Report cnyReport = [SELECT Id FROM Report WHERE Name = :lexLightingButtonConstant.REPORT_NAME_FOR_CNY limit 1];
+ Report usdReport = [SELECT Id FROM Report WHERE Name = :lexLightingButtonConstant.REPORT_NAME_FOR_USD limit 1];
res.currencyIsoCode = opportunity.CurrencyIsoCode;
+ res.reportForCNYId = cnyReport.Id;
+ res.reportForUSDId = usdReport.Id;
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
@@ -362,6 +374,127 @@
return res;
}
@AuraEnabled
+ public static InitData initForOpporSpliteButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity oppo = [
+ select
+ Authorized_DB_No__c,
+ Estimation_Decision__c,
+ SI_Decide_ID__c,
+ Name,
+ Opportunity_No__c,
+ IsAuthorized__c
+ from Opportunity where Id =: recordId
+ ];
+ res.authorizedDBNo = oppo.Authorized_DB_No__c;
+ res.estimationDecision = oppo.Estimation_Decision__c;
+ res.siDecideID = oppo.SI_Decide_ID__c;
+ res.name = oppo.Name;
+ res.opportunityNo = oppo.Opportunity_No__c;
+ res.isAuthorized = oppo.IsAuthorized__c;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForCreateActivityButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opp = [
+ select
+ AccountId
+ from Opportunity where Id =: recordId
+ ];
+ res.accountId = opp.AccountId;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForAssignTaskButtonButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opp = [
+ select
+ AccountId,
+ Name
+ from Opportunity where Id =: recordId
+ ];
+ Account acc = [
+ select
+ Name
+ from Account where Id =:opp.AccountId
+ ];
+ res.accountId = opp.AccountId;
+ res.accountName = acc.Name;
+ res.name = opp.Name;
+ res.recordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_INQUIRY_FOLLOW_UP).getRecordTypeId();
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForChangeContractTypeButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opp = [
+ select
+ StageName,
+ Estimation_Decision__c,
+ SAP_Send_OK__c,
+ If_Authorizing_Lock__c
+ from Opportunity where Id =: recordId
+ ];
+ res.stageName = opp.StageName;
+ res.estimationDecision = opp.Estimation_Decision__c;
+ res.sapSendOK = opp.SAP_Send_OK__c;
+ res.ifAuthorizingLock = opp.If_Authorizing_Lock__c;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+
+ @AuraEnabled
+ public static InitData initForSpecilaApplyCreateButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opp = [
+ select
+ Forecast_this_month__c
+ from Opportunity where Id =: recordId
+ ];
+ res.oppForecastStatus = opp.Forecast_this_month__c;
+ res.recordTypeId = Schema.SObjectType.OpportunitySpecialApply__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_SPECIL_APPLY_CREATE).getRecordTypeId();
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForSpecilaApplyCreateAchButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Statu_Achievements__c ach = [
+ select
+ Id,
+ Monthly_forecast_shipping__c,
+ Opportunity__c
+ from Statu_Achievements__c where Id =: recordId
+ ];
+ res.oppId = ach.Opportunity__c;
+ res.oppForecastStatus = ach.Monthly_forecast_shipping__c;
+ res.recordTypeId = Schema.SObjectType.OpportunitySpecialApply__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_SPECIL_APPLY_CREATE_ACH).getRecordTypeId();
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
public static string updateForAgencyAuthorizeButton(String recordId){
try {
Opportunity opp = new Opportunity();
@@ -416,9 +549,9 @@
Opportunity opp = new Opportunity();
opp.Id = recordId;
if(flag){
- opp.Stock_apply_status__c = '濉啓瀹屾瘯';
+ opp.Stock_apply_status__c = lexLightingButtonConstant.STOCK_APPLY_STATUS_WRITE_OVER;
}else {
- opp.Stock_apply_status__c = '鑽夋涓�';
+ opp.Stock_apply_status__c = lexLightingButtonConstant.STOCK_APPLY_STATUS_DRAFT;
}
update opp;
return null;
@@ -478,7 +611,7 @@
select id,
Tender_information__r.subInfoType__c
from Tender_Opportunity_Link__c
- where (Tender_information__r.subInfoType__c = '3-1锛氬簾鏍囧叕鍛�' OR Tender_information__r.subInfoType__c ='3-2锛氭祦鏍囧叕鍛�') and Opportunity__c =: recordId
+ where (Tender_information__r.subInfoType__c =:lexLightingButtonConstant.SUB_INFO_TYPE_SCRAPPED_LABEL OR Tender_information__r.subInfoType__c =:lexLightingButtonConstant.SUB_INFO_TYPE_FLOW_LABEL OR Tender_information__r.TerminateApprovalStatus__c= :lexLightingButtonConstant.SUB_INFO_TYPE_APPROVE) and Opportunity__c =: recordId
];
} catch (Exception e) {
System.debug('e:****' + e);
@@ -493,7 +626,7 @@
quotes = [
select
id
- from QuoteIrai__c where Note__c like :opportunityId and QuoteIrai_Status__c = '鑽夋涓�'
+ from QuoteIrai__c where Note__c like :opportunityId and QuoteIrai_Status__c =:lexLightingButtonConstant.QUOTEIRAI_STATUS_DRAFT
];
} catch (Exception e) {
System.debug('e:****' + e);
@@ -546,6 +679,85 @@
System.debug('e:****' + e);
}
return fields;
+ }
+ @AuraEnabled
+ public static Object submitProcess(String opportunityId) {
+ try {
+ Approval.ProcessSubmitRequest request = new Approval.ProcessSubmitRequest();
+ request.setObjectId(opportunityId);
+ Approval.ProcessResult[] processResults = new Approval.ProcessResult[] {};
+ processResults.add(Approval.process(request));
+ return processResults[0].errors;
+ } catch (Exception e) {
+ String eMessage = e.getMessage();
+ Integer left = eMessage.indexOf(',') + 1;
+ Integer right = eMessage.length();
+ return eMessage.substring(left,right);
+ }
+ }
+ @AuraEnabled
+ public static string getUserIdByName(String userName){
+ User user = null;
+ try {
+ user = [
+ select
+ Id
+ from User where Name =: userName
+ ];
+ return user.Id;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ }
+ @AuraEnabled
+ public static string getProfileIdByName(String profileName){
+ Profile pro = null;
+ try {
+ pro = [
+ select
+ Id
+ from Profile where Name =: profileName
+ ];
+ return pro.Id;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ }
+ @AuraEnabled
+ public static String changeTrade(String oppId){
+
+ List<Quote> quoList = [select id from Quote where OpportunityId = :oppId];
+ List<OpportunityLineItem> oppLI = [select id from OpportunityLineItem where Opportunity.id = :oppId];
+
+ Opportunity opp = new Opportunity();
+ opp.id = oppId;
+ opp.Estimation_Decision__c = false;
+ opp.Estimation_Id__c = null;
+ opp.Quote_Update_Sum__c = null;
+ opp.Estimation_No__c = null;
+ opp.Estimation_Proposal_Date__c = null;
+ opp.Estimation_Name__c = null;
+ // LHJ SWAG-C9QAAJ 鍘绘帀 Start
+ // opp.Authorized_Finish_Sales__c = null;
+ // opp.Authorized_DB_No__c = null;
+ // opp.Authorized_Date__c = null;
+ // opp.Autholization_Activated_Date__c = null;
+ // opp.Bidding_Content__c = null;
+ // opp.Bid_Date__c = null;
+ // opp.Bidding_No__c = null;
+ // opp.Bidding_Project_Name__c = null;
+ // LHJ End
+
+ Savepoint sp = Database.setSavepoint();
+ try {
+ delete quoList;
+ delete oppLI;
+ update opp;
+ return '1';
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ return ex.getMessage() + ' | Line:' + ex.getLineNumber();
+ }
}
public class InitData{
@AuraEnabled
@@ -642,5 +854,37 @@
public String opportunityCategory;
@AuraEnabled
public String agency1Name;
+ @AuraEnabled
+ public String authorizedDBNo;
+ @AuraEnabled
+ public String siDecideID;
+ @AuraEnabled
+ public String opportunityNo;
+ @AuraEnabled
+ public String systemProfileId;
+ @AuraEnabled
+ public String j3ProfileId;
+ @AuraEnabled
+ public String s62ProfileId;
+ @AuraEnabled
+ public String s61ProfileId;
+ @AuraEnabled
+ public String m4ProfileId;
+ @AuraEnabled
+ public String s4ProfileId;
+ @AuraEnabled
+ public String s1ProfileId;
+ @AuraEnabled
+ public String accountName;
+ @AuraEnabled
+ public String recordTypeId;
+ @AuraEnabled
+ public String reportForCNYId;
+ @AuraEnabled
+ public String reportForUSDId;
+ @AuraEnabled
+ public String oppForecastStatus;
+ @AuraEnabled
+ public String oppId;
}
}
\ No newline at end of file
--
Gitblit v1.9.1