public class infrastructureProjectRelatedOpController {
|
// public static List<String> sortList = new List<String>{'询价','注残','发货','完毕','失单','取消'}; // WYL DB202312501399 2024/1/29
|
public static List<String> sortList = new List<String>{'询价','注残','发货'}; // WYL DB202312501399 2024/1/29
|
@AuraEnabled
|
//根据报价Id检索
|
public static Infrastructure_Project__c selectInfrastructureProjectById(String InfProId){
|
List<Infrastructure_Project__c> InfrastructureProject = [ SELECT Id,Name,OCSM_Hospital__c,OCSM_Hospital__r.Name
|
FROM Infrastructure_Project__c Where Id = :InfProId];
|
Infrastructure_Project__c InfProobj = new Infrastructure_Project__c();
|
if(InfrastructureProject.size()>0){
|
InfProobj = InfrastructureProject[0];
|
}
|
return InfProobj;
|
}
|
@AuraEnabled
|
//根据报价Id检索
|
public static List<Opportunity> selectoppByAccountId(String OCSMHospital ){
|
Map<String,List<Opportunity>> OppMap = new Map<String,List<Opportunity>>();
|
List<Opportunity> OppList = [ SELECT Id,Name,StageName__c,Opportunity_No__c,Opportunity_stage__c,Shipping_Date_For_Report__c from Opportunity Where Hospital__c = :OCSMHospital and Infrastructure_Project__c =null and StageName__c != '目标' order by StageName__c asc,CreatedDate desc];
|
for (Opportunity Oppobj : OppList) {
|
if(OppMap.containsKey(Oppobj.StageName__c)){
|
List<Opportunity> oldopp = OppMap.get(Oppobj.StageName__c);
|
oldopp.add(Oppobj);
|
OppMap.put(Oppobj.StageName__c,oldopp);
|
}else{
|
List<Opportunity> newopp = new List<Opportunity>();
|
newopp.add(Oppobj);
|
OppMap.put(Oppobj.StageName__c,newopp);
|
}
|
}
|
List<Opportunity> sortOppList = new List<Opportunity>();
|
for (String sortStr : sortList) {
|
if(OppMap.containsKey(sortStr)){
|
sortOppList.addAll(OppMap.get(sortStr));
|
}
|
}
|
// WYL DB202312501399 2024/1/29 start
|
Date todate = Date.today();
|
Date todate2 = todate.addMonths(-18);
|
List<Opportunity> sortOppList2 = new List<Opportunity>();
|
for (Opportunity opp : sortOppList) {
|
if (opp.StageName__c == '注残' || opp.StageName__c == '发货') {
|
if (opp.Shipping_Date_For_Report__c>=todate2 && opp.Shipping_Date_For_Report__c <= todate) {
|
sortOppList2.add(opp);
|
}
|
}else {
|
sortOppList2.add(opp);
|
}
|
|
}
|
return sortOppList2;
|
// WYL DB202312501399 2024/1/29 end
|
}
|
|
@AuraEnabled
|
public static List<Opportunity> selectoppByOpportunityNoc(String OCSMHospital,String OpportunityNoc){
|
System.debug('aa+'+OpportunityNoc);
|
Map<String,List<Opportunity>> OppMap = new Map<String,List<Opportunity>>();
|
String searchSql = 'Select Id,Name,StageName__c,Opportunity_No__c,Opportunity_stage__c,Shipping_Date_For_Report__c From Opportunity Where Infrastructure_Project__c =null and Hospital__c = \''+OCSMHospital+'\' and StageName__c != \'目标\' ';
|
String whereSql = '';
|
if(OpportunityNoc != null && OpportunityNoc != ''){
|
whereSql += 'and (Opportunity_No__c Like ' + '\'%' + OpportunityNoc + '%\' or Name Like ' + '\'%' + OpportunityNoc + '%\') ';
|
}
|
whereSql += ' order by StageName__c asc,CreatedDate desc';
|
searchSql = searchSql + whereSql;
|
System.debug('searchSql+'+searchSql);
|
List<Opportunity> OppList = Database.query(searchSql);
|
for (Opportunity Oppobj : OppList) {
|
if(OppMap.containsKey(Oppobj.StageName__c)){
|
List<Opportunity> oldopp = OppMap.get(Oppobj.StageName__c);
|
oldopp.add(Oppobj);
|
OppMap.put(Oppobj.StageName__c,oldopp);
|
}else{
|
List<Opportunity> newopp = new List<Opportunity>();
|
newopp.add(Oppobj);
|
OppMap.put(Oppobj.StageName__c,newopp);
|
}
|
}
|
List<Opportunity> sortOppList = new List<Opportunity>();
|
for (String sortStr : sortList) {
|
if(OppMap.containsKey(sortStr)){
|
sortOppList.addAll(OppMap.get(sortStr));
|
}
|
}
|
// WYL DB202312501399 2024/1/29 start
|
Date todate = Date.today();
|
Date todate2 = todate.addMonths(-18);
|
List<Opportunity> sortOppList2 = new List<Opportunity>();
|
for (Opportunity opp : sortOppList) {
|
if (opp.StageName__c == '注残' || opp.StageName__c == '发货') {
|
if (opp.Shipping_Date_For_Report__c>=todate2 && opp.Shipping_Date_For_Report__c <= todate) {
|
sortOppList2.add(opp);
|
}
|
}else {
|
sortOppList2.add(opp);
|
}
|
|
}
|
return sortOppList2;
|
// WYL DB202312501399 2024/1/29 end
|
}
|
@AuraEnabled
|
public static String saveOppInfrastructureProject(String saveValuec){
|
Savepoint sp = Database.setSavepoint();
|
try {
|
List<Opportunity> oppList = (List<Opportunity>)JSON.deserialize(saveValuec,List<Opportunity>.class);
|
StaticParameter.EscapeOppandStaTrigger = true;
|
update oppList;
|
StaticParameter.EscapeOppandStaTrigger = false;
|
return 'success';
|
} catch (Exception e) {
|
Database.rollback(sp);
|
return ''+e;
|
}
|
}
|
}
|