/* * @Description: * @version: * @Author: chen jing wu * @Date: 2023-04-12 11:16:07 * @LastEditors: chen jing wu * @LastEditTime: 2023-11-05 12:04:46 */ public with sharing class OpportunityLightingButtonController { @AuraEnabled public static Map queryForEditLostButton(String recordId){ Map objs = new Map(); Report1 rep = new Report1(); try { List re = [ select id, Report_Status__c, RecordTypeId from Lost_cancel_report__c where RecordTypeId != :System.Label.Lost_cancel_record and Opportunity__c =: recordId]; rep.lostReport = re; objs.put('report',rep); Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe(); if( !s.isCreateable()) { objs.put('error',true); }else{ objs.put('error',false); } } catch (Exception e) { objs.put('error',e.getMessage()); return objs; } return objs; } public class Report1{ @AuraEnabled public List lostReport; } @AuraEnabled public static InitData initForPredictedDateChangeButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select DirectLossFLG__c, Created_Day__c from Opportunity where Id =: recordId]; res.createdDay = opportunity.Created_Day__c; res.directLossFLG = opportunity.DirectLossFLG__c; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForAgencyAuthorizeButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select Agency1_ID_18__c, StageName, SAP_Send_OK__c, Opp_order_Type__c, If_Have_170__c, If_Have_AH__c, Cnt_Lost_cancel_Draft__c, Cnt_Lost_cancel_report__c, Estimation_Id__c, DetailNum__c, Estimation_Decision__c, Sales_Root__c, AcecideCntCheck__c, IF_Submit__c , Trade__c, Is_Corrosion__c, If_Authorizing_Lock__c, AccDealerBlacklist__c, Agency1__c, Agency2__c, Hospital__c, //zzm 贸易合规2期 20231120 add start Hospital__r.TradeComplianceStatus__c, AccDealerBlacklist2__c, //zzm 贸易合规2期 20231120 add end OwnerId, Sales_assistant_name_text__c from Opportunity where Id =: recordId ]; res.AccDealerBlacklist = opportunity.AccDealerBlacklist2__c;//zzm 贸易合规2期 20240112 add res.angency1 = opportunity.Agency1__c; res.angency2 = opportunity.Agency2__c; res.accname = opportunity.Hospital__c; res.ownerids = opportunity.OwnerId; res.ddid = opportunity.Sales_assistant_name_text__c; res.agency1Id = opportunity.Agency1_ID_18__c; res.stageName = opportunity.StageName; res.sapSendOK = opportunity.SAP_Send_OK__c; res.oppOrderType = opportunity.Opp_order_Type__c; res.ifHave170 = opportunity.If_Have_170__c; res.ifHaveAH = opportunity.If_Have_AH__c; res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c; res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c; res.estimationId = opportunity.Estimation_Id__c; res.detailNum = opportunity.DetailNum__c; res.estimationDecision = opportunity.Estimation_Decision__c; res.salesRoot = opportunity.Sales_Root__c; res.acecideCntCheck = opportunity.AcecideCntCheck__c; res.ifSubmit = opportunity.IF_Submit__c; res.trade = opportunity.Trade__c; res.isCorrosion = opportunity.Is_Corrosion__c; res.ifAuthorizingLock = opportunity.If_Authorizing_Lock__c; 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); //zzm 贸易合规2期 20231120 add start res.tradeComplianceStatus = opportunity.Hospital__r.TradeComplianceStatus__c; res.proTradeComplianceStatus = getProTradeComplianceStatus(opportunity.Estimation_Id__c); //zzm 贸易合规2期 20231120 add end } catch (Exception e) { } return res; } //zzm 贸易合规2期 20231120 add start //获取询价上最新报价的产品的贸易合规状态 public static String getProTradeComplianceStatus(String eId) { List quoteLineItemList = [SELECT Id ,QuoteId ,Product2Id ,PricebookEntry.Product2.USRatio_US__c ,PricebookEntry.Product2.USRatio_US_OUT10__c ,PricebookEntry.Product2.CountryOfOrigin__c ,PricebookEntry.Product2.ProTradeComplianceStatus__c from QuoteLineItem where QuoteId= :eId]; for(QuoteLineItem qlt: quoteLineItemList) { // String flag = ControllerUtil.tradeComplianceStatusFlag(qlt.PricebookEntry.Product2.CountryOfOrigin__c,qlt.PricebookEntry.Product2.USRatio_US_OUT10__c); String flag = qlt.PricebookEntry.Product2.ProTradeComplianceStatus__c; if(flag == '0') { return '0'; } } return '1'; } //zzm 贸易合规2期 20231120 add end @AuraEnabled public static InitData initForLoseBidButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select ifOpenBid__c from Opportunity where Id =: recordId ]; res.ifOpenBid = opportunity.ifOpenBid__c; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForOLYwinBidButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select ifOpenBid__c from Opportunity where Id =: recordId ]; res.ifOpenBid = opportunity.ifOpenBid__c; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForCreateEventButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select AccountId from Opportunity where Id =: recordId]; res.accountId = opportunity.AccountId; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForBeforeOPDPDFBtnButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select AccountId from Opportunity where Id =: recordId ]; res.accountId = opportunity.AccountId; res.userId = UserInfo.getUserId(); } catch (Exception e) { } return res; } @AuraEnabled public static InitData initFoBeforeOPDPDFBtnSISButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select AccountId from Opportunity where Id =: recordId ]; res.accountId = opportunity.AccountId; res.userId = UserInfo.getUserId(); } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForRequestDBButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select StageName, SAP_Send_OK__c, Cnt_Lost_cancel_report__c, Cnt_Lost_cancel_Draft__c, Agency1__c, Agency1_ID_18__c, Name, Bid_Planned_Date__c, Sales_assistant_name__c, Sales_assistant_ID__c from Opportunity where Id =: recordId ]; res.stageName = opportunity.StageName; res.sapSendOK = opportunity.SAP_Send_OK__c; res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c; res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c; res.agency1 = opportunity.Agency1__c; res.agency1Id = opportunity.Agency1_ID_18__c; res.name = opportunity.Name; res.bidPlannedDate = opportunity.Bid_Planned_Date__c; res.salesAssistantName = opportunity.Sales_assistant_name__c; res.salesAssistantID = opportunity.Sales_assistant_ID__c; 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) { } return res; } @AuraEnabled public static InitData initForCancelReportButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select StageName, SAP_Send_OK__c, Cnt_Lost_cancel_report__c, Cnt_Lost_cancel_Draft__c, Job_category__c, Bidding_Project_Name_Bid__c, Name, Sales_assistant_name__c, Sales_assistant_ID__c, Manager_name__c, Sales_manager_departmentID__c, Sales_owner_buchang__c, Sales_owner_buchangID__c from Opportunity where Id =: recordId ]; res.stageName = opportunity.StageName; res.sapSendOK = opportunity.SAP_Send_OK__c; res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c; res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c; res.jobCategory = opportunity.Job_category__c; res.biddingProjectNameBid = opportunity.Bidding_Project_Name_Bid__c; res.name = opportunity.Name; res.salesAssistantName = opportunity.Sales_assistant_name__c; res.salesAssistantID = opportunity.Sales_assistant_ID__c; res.managerName = opportunity.Manager_name__c; 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) { } return res; } @AuraEnabled public static InitData initForLostReportButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select StageName, SAP_Send_OK__c, Cnt_Lost_cancel_Draft__c, Cnt_Lost_cancel_report__c, Name, Sales_assistant_name__c, Sales_assistant_ID__c, Manager_name__c, Sales_manager_departmentID__c, Sales_owner_buchang__c, Sales_owner_buchangID__c from Opportunity where Id =: recordId ]; res.stageName = opportunity.StageName; res.sapSendOK = opportunity.SAP_Send_OK__c; res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c; res.name = opportunity.Name; res.salesAssistantName = opportunity.Sales_assistant_name__c; res.salesAssistantID = opportunity.Sales_assistant_ID__c; res.managerName = opportunity.Manager_name__c; res.salesManagerDepartmentID = opportunity.Sales_manager_departmentID__c; res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c; res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c; res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c; Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe(); if( !s.isCreateable()) { res.isHavePower = false; }else{ res.isHavePower = true; } } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForLexQuoteEntryNewbotton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select Agency_Is_Delete__c, Account_Is_Active__c, Hospital_Is_Active__c, RecordTypeId, Estimation_Decision__c from Opportunity where Id =: recordId ]; res.agencyIsDeletec = opportunity.Agency_Is_Delete__c; res.accountIsActivec = opportunity.Account_Is_Active__c; res.hospitalIsActivec = opportunity.Hospital_Is_Active__c; res.recordTypeId = opportunity.RecordTypeId; res.estimationDecisionc = opportunity.Estimation_Decision__c; } catch (Exception e) { } return res; } @AuraEnabled public static Boolean describeSObjectCommon (String objname) { Schema.DescribeSobjectResult schemaMap = Schema.describeSObjects(new String[]{objname})[0]; return schemaMap.isCreateable(); } @AuraEnabled public static InitData initForQuotationRequestButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select Bidding_Project_Name_Bid__r.Id, Estimation_Id__c from Opportunity where Id =: recordId ]; res.biddingProjectNameBidId = opportunity.Bidding_Project_Name_Bid__r.Id; res.estimationId = opportunity.Estimation_Id__c; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForStockApplyButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select Stock_apply_status__c, Last_opportunity_file__r.Id from Opportunity where Id =: recordId ]; res.stockApplyStatus = opportunity.Stock_apply_status__c; res.lastOpportunityFileId = opportunity.Last_opportunity_file__r.Id; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForQuotationProductNewButton(String recordId){ InitData res = new InitData(); try { Opportunity opportunity = [ select CurrencyIsoCode from Opportunity where Id =: recordId ]; Report cnyReport = [SELECT Id FROM Report WHERE DeveloperName = :lexLightingButtonConstant.REPORT_DEVELOPERNAM_FOR_CNY limit 1]; Report usdReport = [SELECT Id FROM Report WHERE DeveloperName = :lexLightingButtonConstant.REPORT_DEVELOPERNAM_FOR_USD limit 1]; res.currencyIsoCode = opportunity.CurrencyIsoCode; res.reportForCNYId = cnyReport.Id; res.reportForUSDId = usdReport.Id; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForCopyWithAssetButton(String recordId){ InitData res = new InitData(); try { Opportunity oppo = [ select Name, SAP_Send_OK__c, IsAuthorized__c from Opportunity where Id =: recordId ]; res.name = oppo.Name; res.sapSendOK = oppo.SAP_Send_OK__c; res.isAuthorized = oppo.IsAuthorized__c; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForNewOpportunityAgencyButton(String recordId){ InitData res = new InitData(); try { Opportunity opp = [ select Agency1__r.Id, Agency_Opportunity__c, Trade__c, Hospital__r.Id, Name, Close_Forecasted_Date__c, Bid_Planned_Date__c, Dealer_Final_Price__c, Wholesale_Price__c, Agency1__r.Name, Opportunity_stage__c, Opportunity_Category__c from Opportunity where Id =: recordId ]; res.agency1Id = opp.Agency1__r.Id; res.agencyOpportunity = opp.Agency_Opportunity__c; res.trade = opp.Trade__c; res.hospitalId = opp.Hospital__r.Id; res.name = opp.Name; res.closeForecastedDate = opp.Close_Forecasted_Date__c; res.bidPlannedDate = opp.Bid_Planned_Date__c; res.dealerFinalPrice = opp.Dealer_Final_Price__c; res.wholesalePrice = opp.Wholesale_Price__c; res.agency1 = opp.Agency1__c; res.opportunityStage = opp.Opportunity_stage__c; res.opportunityCategory = opp.Opportunity_Category__c; res.agency1Name = opp.Agency1__r.Name; } catch (Exception e) { } 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, recordTypeId 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; res.recordTypeId = oppo.recordTypeId; } catch (Exception e) { } 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) { } 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) { } 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) { } 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) { } 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) { } return res; } @AuraEnabled public static InitData initForNewOpportunityFileButton(String recordId){ InitData res = new InitData(); try { Opportunity opp = [ select Stock_apply_status__c from Opportunity where Id =: recordId ]; res.stockApplyStatus = opp.Stock_apply_status__c; } catch (Exception e) { } return res; } @AuraEnabled public static string updateForAgencyAuthorizeButton(String recordId){ try { Opportunity opp = new Opportunity(); opp.Id = recordId; opp.If_Authorizing__c = true; opp.if_Interface_Lock__c = true; opp.IF_Submit__c = true; update opp; return null; } catch (Exception e) { return errorMessage(e); } } @AuraEnabled public static string updateForLoseBidButton(String recordId){ try { Opportunity opp = new Opportunity(); opp.Id = recordId; opp.ConfirmationofAward__c = LightingButtonConstant.OPPORTUNITY_CONFIRMATION_OF_AWARD_LOSE_BID; update opp; return null; } catch (Exception e) { return errorMessage(e); } } @AuraEnabled public static string updateForOLYwinBidButton(String recordId){ try { Opportunity opp = [select ConfirmationofAward__c,Closing_Bid_Date__c from Opportunity where Id =: recordId]; opp.ConfirmationofAward__c = LightingButtonConstant.OPPORTUNITY_CONFIRMATION_OF_AWARD_OLY_WIN_BID; if (opp.Closing_Bid_Date__c == null) { opp.Closing_Bid_Date__c = Date.today(); } update opp; return null; } catch (Exception e) { return errorMessage(e); } } @AuraEnabled public static string updateForStockApplyButton(String recordId,Boolean flag){ try { Opportunity opp = new Opportunity(); opp.Id = recordId; if(flag){ opp.Stock_apply_status__c = lexLightingButtonConstant.STOCK_APPLY_STATUS_WRITE_OVER; }else { opp.Stock_apply_status__c = lexLightingButtonConstant.STOCK_APPLY_STATUS_DRAFT; } update opp; return null; } catch (Exception e) { return errorMessage(e); } } @AuraEnabled public static List queryForPredictedDateChangeButton(String recordId){ List rac = null; try { rac = [ select id from InquiryPredictsDateChange__c where Predicted_Date_Status__c = :LightingButtonConstant.PREDICTED_DATE_STATUS and Opportunity__c =:recordId]; } catch (Exception e) { } return rac; } @AuraEnabled public static List queryForLoseBidButton(String recordId){ List tasks = null; try { String obscureName = '%' + LightingButtonConstant.TASK_NAME_BY_CONFIRMATION_OF_WINNING_BID + '%'; tasks = [ select taskStatus__c from task__c where OpportunityId__c =: recordId and name like :obscureName]; } catch (Exception e) { } return tasks; } @AuraEnabled public static List queryForOLYwinBidButton(String recordId){ List tasks = null; try { String obscureName = '%' + LightingButtonConstant.TASK_NAME_BY_CONFIRMATION_OF_WINNING_BID + '%'; tasks = [ select taskStatus__c from task__c where OpportunityId__c =: recordId and name like :obscureName]; } catch (Exception e) { } return tasks; } @AuraEnabled public static List queryForCancelReportButton(String recordId){ List links = null; try { links = [ select id, Tender_information__r.subInfoType__c from Tender_Opportunity_Link__c //lt 20240118 DB202401275115 紧急:招标项目终止状态的逻辑调整 start 修改sql条件 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 /*where Tender_information__r.subInfoType__c != :lexLightingButtonConstant.SUB_INFO_TYPE_SCRAPPED_LABEL and Tender_information__r.subInfoType__c != :lexLightingButtonConstant.SUB_INFO_TYPE_FLOW_LABEL and Tender_information__r.TerminateApprovalStatus__c != :lexLightingButtonConstant.SUB_INFO_TYPE_APPROVE and Opportunity__c =: recordId //lt 20240118 DB202401275115 紧急:招标项目终止状态的逻辑调整 end */ ]; } catch (Exception e) { } return links; } @AuraEnabled public static List queryForQuotationRequestButton(String recordId){ List quotes = null; try { String opportunityId = '%' + recordId + '%'; quotes = [ select id from QuoteIrai__c where Note__c like :opportunityId and QuoteIrai_Status__c =:lexLightingButtonConstant.QUOTEIRAI_STATUS_DRAFT ]; } catch (Exception e) { } return quotes; } @AuraEnabled public static List queryForNewOpportunityAgencyButtonToRecords(String agency1Id,String hospitalId){ List links = null; try { links = [ SELECT Id, Name FROM Agency_Hospital_Link__c WHERE Agency__c =: agency1Id AND Hospital__c =: hospitalId ]; } catch (Exception e) { } return links; } @AuraEnabled public static List queryForNewOpportunityAgencyButtonToRecTypeList(String sobjectType,String developerName,Boolean isActive){ List types = null; try { types = [ SELECT Id, Name FROM RecordType WHERE SobjectType =: sobjectType And developerName=: developerName And IsActive =: isActive ]; } catch (Exception e) { } return types; } @AuraEnabled public static List queryForNewOpportunityAgencyButtonToRecords2(String qualifiedApiName){ List fields = null; try { fields = [ select QualifiedApiName, EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName =: qualifiedApiName ]; } catch (Exception 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) { return errorMessage(e); } } @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) { if (e.getMessage().contains(',')) { System.debug(LoggingLevel.INFO, '*** e: ' + e); String exc = '' + e.getMessage(); Integer left = exc.indexOf(':') + 1; Integer right = exc.lastIndexOf(':'); String str = exc.substring(left,right); left = str.indexOf(',') + 1; String newStr = str.substring(left); return newStr; }else { return 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) { if (e.getMessage().contains(',')) { System.debug(LoggingLevel.INFO, '*** e: ' + e); String exc = '' + e.getMessage(); Integer left = exc.indexOf(':') + 1; Integer right = exc.lastIndexOf(':'); String str = exc.substring(left,right); left = str.indexOf(',') + 1; String newStr = str.substring(left); return newStr; }else { return e.getMessage(); } } } @AuraEnabled public static string queryForProfileId(){ return UserInfo.getProfileId(); } @AuraEnabled public static Boolean queryQuote(String estimationId){ Boolean bo; try { Quote qu = [select Have_Virtual__c from Quote where Id =: estimationId]; bo = qu.Have_Virtual__c; } catch (Exception e) { } return bo; } @AuraEnabled public static String initCopy(String recordId){ String s=''; try { String objectName = 'Opportunity'; // 要获取字段的对象名 Map globalDescribe = Schema.getGlobalDescribe(); Schema.SObjectType objType = globalDescribe.get(objectName); if (objType != null) { Schema.DescribeSObjectResult objDescribe = objType.getDescribe(); Map fieldMap = objDescribe.fields.getMap(); s+='SELECT '; // 现在,fieldMap中包含了对象的所有字段信息 for (String fieldName : fieldMap.keySet()) { if(!fieldName.equals('id') &&!fieldName.equals('Id') &&!fieldName.equals('Opportunity_No__c')) s+=fieldName+','; } s=s.removeEnd(','); s+=' FROM Opportunity where id=\''+recordId+'\''; system.debug('SQL:'+s); List opportunitys = Database.query(s); s=''; if(opportunitys.size()>0){ system.debug('in!'); for (String fieldName : fieldMap.keySet()) { String formaF=fieldMap.get(fieldName).getDescribe().getName(); if(opportunitys.get(0).get(fieldName)!=null&&!opportunitys.get(0).get(fieldName).equals('null')){ if(formaF.equals('Id') ||formaF.equals('OwnerId') ||formaF.equals('CreatedDate') ||formaF.equals('CreatedById') ) { continue; } Object val=opportunitys.get(0).get(fieldName); if(val instanceof Date ){ String str=String.valueOf(val); str=str.replace(' ','T'); str+='.000Z'; s+=formaF+'='+str+','; }else if (val instanceof DateTime){ String str=String.valueOf(val); str=str.replace(' ','T'); str+='.000Z'; s+=formaF+'='+str+','; }else{ s+=formaF+'='+opportunitys.get(0).get(fieldName)+','; } } } s=s.removeEnd(','); return s; } } return s; } catch (Exception e) { } return s; } public static String forma(String str){ String res=''; String stra='a'; Integer a=stra.charAt(0); String strz='z'; Integer z=strz.charAt(0); String strAa='A'; Integer bA=strAa.charAt(0); String strZz='Z'; Integer bZ=strZz.charAt(0); String strx='_'; Integer x=strx.charAt(0); List charArr = new List(); Integer change=bA-a; Integer st=(str.charAt(0)+change); charArr.add(st); for(Integer i=0;i=a&&nextC quoList = [select id from Quote where OpportunityId = :oppId]; List 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; //DB202311617653 【询价】内外贸转换,报价单清除,询价页面金额问题 start opp.Wholesale_Price__c = null; //DB202311617653 【询价】内外贸转换,报价单清除,询价页面金额问题 end // 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 errorMessage(ex); } } @AuraEnabled public static Boolean queryLostReport (String recordId){ RecordType recordType1 = [select Id from RecordType where Name = '询价取消报告']; List repList = [select Id from Lost_cancel_report__c where Opportunity__c =: recordId and RecordTypeId !=: recordType1.Id]; if(repList.size() > 0){ return true; } return false; } @AuraEnabled public static Boolean queryCancelReport (String recordId){ RecordType recordType1 = [select Id from RecordType where Name = '询价取消报告']; List repList = [select Id from Lost_cancel_report__c where Opportunity__c =: recordId and RecordTypeId =: recordType1.Id]; if(repList.size() > 0){ return true; } return false; } //生产环境bug修改 陈京武 20231105 Start @AuraEnabled public static Boolean querySubmitLostReport (String recordId){ RecordType recordType1 = [select Id from RecordType where Name = '询价取消报告']; List repList = [select Id from Lost_cancel_report__c where Opportunity__c =: recordId and RecordTypeId !=: recordType1.Id and Report_Status__c != '草案']; if(repList.size() > 0){ return true; } return false; } @AuraEnabled public static Boolean querySubmitCancelReport (String recordId){ RecordType recordType1 = [select Id from RecordType where Name = '询价取消报告']; List repList = [select Id from Lost_cancel_report__c where Opportunity__c =: recordId and RecordTypeId =: recordType1.Id and Report_Status__c != '草案']; if(repList.size() > 0){ return true; } return false; } //生产环境bug修改 陈京武 20231105 End public static string errorMessage(Exception e){ if (e.getMessage().contains(',')) { System.debug(LoggingLevel.INFO, '*** e: ' + e); String exc = '' + e.getMessage(); Integer left = exc.indexOf(':') + 1; Integer right = exc.lastIndexOf(':'); String str = exc.substring(left,right); left = str.indexOf(',') + 1; String newStr = str.substring(left); return newStr; }else { return e.getMessage(); } } public class InitData{ @AuraEnabled public Boolean directLossFLG; @AuraEnabled public Date createdDay; @AuraEnabled public String agency1Id; @AuraEnabled public String agency1; @AuraEnabled public String stageName; @AuraEnabled public Boolean sapSendOK; @AuraEnabled public String oppOrderType; @AuraEnabled public Boolean ifHave170; @AuraEnabled public Boolean ifHaveAH; @AuraEnabled public Decimal cntLostCancelDraft; @AuraEnabled public Decimal cntLostCancelReport; @AuraEnabled public String estimationId; @AuraEnabled public Decimal detailNum; @AuraEnabled public Boolean estimationDecision; @AuraEnabled public String salesRoot; @AuraEnabled public Boolean acecideCntCheck; @AuraEnabled public Boolean ifSubmit; @AuraEnabled public String trade; @AuraEnabled public Boolean isCorrosion; @AuraEnabled public Boolean ifAuthorizingLock; @AuraEnabled public String profileId; @AuraEnabled public String ifOpenBid; @AuraEnabled public String accountId; @AuraEnabled public String userId; @AuraEnabled public String name; @AuraEnabled public Date bidPlannedDate; @AuraEnabled public String salesAssistantName; @AuraEnabled public String salesAssistantID; @AuraEnabled public String jobCategory; @AuraEnabled public String biddingProjectNameBid; @AuraEnabled public String managerName; @AuraEnabled public String salesManagerDepartmentID; @AuraEnabled public String salesOwnerBuchang; @AuraEnabled public String salesOwnerBuchangID; @AuraEnabled public String biddingProjectNameBidId; @AuraEnabled public String stockApplyStatus; @AuraEnabled public String lastOpportunityFileId; @AuraEnabled public String currencyIsoCode; @AuraEnabled public Boolean isAuthorized; @AuraEnabled public String agencyOpportunity; @AuraEnabled public String hospitalId; @AuraEnabled public Date closeForecastedDate; @AuraEnabled public Decimal dealerFinalPrice; @AuraEnabled public Decimal wholesalePrice; @AuraEnabled public String opportunityStage; @AuraEnabled 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; @AuraEnabled public String AccDealerBlacklist; @AuraEnabled public String angency1; @AuraEnabled public String angency2; @AuraEnabled public String accname; @AuraEnabled public String ownerids; @AuraEnabled public String ddid; @AuraEnabled public String agencyIsDeletec; @AuraEnabled public String accountIsActivec; @AuraEnabled public String hospitalIsActivec; @AuraEnabled public Boolean estimationDecisionc; @AuraEnabled public String reportStatus; @AuraEnabled public String reportId; @AuraEnabled public Boolean isHavePower; //zzm 贸易合规2期 20231120 add start @AuraEnabled public String tradeComplianceStatus; @AuraEnabled public List latestQuoteAllPoducts; @AuraEnabled public String proTradeComplianceStatus; //zzm 贸易合规2期 20231120 add end } }