| | |
| | | public without sharing class LexSearchContractController { |
| | | private static Boolean OSHFLG; //lt 20230517 安徽两票制 add |
| | | private static Boolean OSHFLG;//lt 20230517 安徽两票制 add |
| | | |
| | | @AuraEnabled |
| | | public static Results init(String ctype) { |
| | | public static Results init(String ctype){ |
| | | Results results = new Results(); |
| | | try { |
| | | //lt 20230517 安徽两票制 add ,OSHFLG__c |
| | | User useracc = [SELECT accountid, OSHFLG__c FROM user WHERE id = :UserInfo.getUserId()]; |
| | | User useracc = [SELECT accountid,OSHFLG__c FROM user WHERE id = :UserInfo.getUserId() ]; |
| | | OSHFLG = Useracc.OSHFLG__c; //lt 20230517 安徽两票制 add; |
| | | String accountId = Useracc.accountid; |
| | | List<Account> attList = [ |
| | | SELECT |
| | | id, |
| | | Name, |
| | | State_Master__c, |
| | | State_Master__r.Name, |
| | | Sales_Section__c, |
| | | Contract_Decide_Start_Date__c, |
| | | Contract_Decide_End_Date__c |
| | | FROM Account |
| | | WHERE |
| | | ParentId = :accountId |
| | | AND Contact_Type__c LIKE :ctype |
| | | List<Account> attList = [SELECT id,Name,State_Master__c,State_Master__r.Name,Sales_Section__c, |
| | | Contract_Decide_Start_Date__c,Contract_Decide_End_Date__c |
| | | FROM Account |
| | | WHERE ParentId = :accountId |
| | | AND Contact_Type__c like :ctype |
| | | AND Contract_Decide_Start_Date__c <= :Date.Today() |
| | | AND Contract_Decide_End_Date__c >= :Date.Today() |
| | | AND Secondary_contract__c = FALSE |
| | | AND OSH_Dealer__c = :OSHFLG //lt 20230517 安徽两票制 add |
| | | ]; |
| | | AND Secondary_contract__c = false |
| | | AND OSH_Dealer__c =: OSHFLG //lt 20230517 安徽两票制 add |
| | | ]; |
| | | results.attList = attList; |
| | | results.result = 'Success'; |
| | | results.result = 'Success'; |
| | | } catch (Exception e) { |
| | | results.result = 'Fail'; |
| | | results.errorMsg = e.getLineNumber() + '---' + e.getMessage(); |
| | |
| | | } |
| | | |
| | | @AuraEnabled |
| | | public static Results searchContract(String searchName, String accountId, String ctype, Boolean OSHFLGStr) { |
| | | public static Results searchContract(String searchName, String accountId, String ctype, Boolean OSHFLGStr){ |
| | | Results results = new Results(); |
| | | OSHFLG = OSHFLGStr; |
| | | try { |
| | | results.attList = Database.query(makeSoql(searchName, Date.today(), accountId, ctype)); |
| | | results.result = 'Success'; |
| | | results.attList = Database.query(makeSoql(searchName,Date.today(),accountId,ctype)); |
| | | results.result = 'Success'; |
| | | } catch (Exception e) { |
| | | results.result = 'Fail'; |
| | | results.errorMsg = e.getLineNumber() + '---' + e.getMessage(); |
| | |
| | | return results; |
| | | } |
| | | |
| | | private static String makeSoql(String CateName, Date timetest, String accountId, String ctype) { |
| | | private static String makeSoql(String CateName,Date timetest,String accountId, String ctype){ |
| | | |
| | | String soql = 'SELECT id,Name,State_Master__c,State_Master__r.Name,Sales_Section__c,'; |
| | | soql += ' Contract_Decide_Start_Date__c,Contract_Decide_End_Date__c,OSH_Dealer__c FROM Account'; |
| | | soql += ' where ParentId = \'' + accountId + '\''; |
| | | soql += ' AND OSH_Dealer__c = ' + OSHFLG + ''; //lt 20230517 安徽两票制 add |
| | | soql += ' AND Secondary_contract__c = false'; |
| | | soql += ' where ParentId = \'' + accountId + '\'' ; |
| | | soql += ' AND OSH_Dealer__c = ' + OSHFLG + '' ; //lt 20230517 安徽两票制 add |
| | | soql += ' AND Secondary_contract__c = false' ; |
| | | soql += ' AND Contact_Type__c like \'%' + String.escapeSingleQuotes(ctype.replaceAll('%', '\\%')) + '%\''; |
| | | soql += ' AND Contract_Decide_Start_Date__c <=' + String.valueOf(timetest).substring(0, 10); |
| | | soql += ' AND Contract_Decide_End_Date__c >= ' + String.valueOf(timetest).substring(0, 10); |
| | | if (!String.isBlank(CateName)) { |
| | | if(!String.isBlank(CateName)){ |
| | | soql += ' AND Name like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\''; |
| | | } |
| | | return soql; |