From 9b197b7fac92278fb591ea8f4942c7d5687cb5ce Mon Sep 17 00:00:00 2001
From: 李金换 <lijinhuan@prec-tech.com>
Date: 星期一, 28 三月 2022 18:01:22 +0800
Subject: [PATCH] LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备0328
---
force-app/main/default/classes/NewQuoteEntrytheBatch.cls | 57 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/force-app/main/default/classes/NewQuoteEntrytheBatch.cls b/force-app/main/default/classes/NewQuoteEntrytheBatch.cls
index 9540803..fbaa418 100644
--- a/force-app/main/default/classes/NewQuoteEntrytheBatch.cls
+++ b/force-app/main/default/classes/NewQuoteEntrytheBatch.cls
@@ -8,7 +8,7 @@
global Database.QueryLocator start(Database.BatchableContext bc) {
String quoteLN = '%01';
- query='select Id,Opportunity.Department_Class__c,CreatedDate,Category4__c from Quote where Bollow_Date__c like :quoteLN and CreatedDate=TODAY';
+ query='select Id,Opportunity.Department_Class__c,CreatedDate,OpportunityId from Quote where Quote_No__c like :quoteLN and CreatedDate=TODAY';
return Database.getQueryLocator(query);
}
@@ -18,6 +18,7 @@
List<Opportunity> opplist = New List<Opportunity>();
Opportunity o=new Opportunity();
List<Opportunity> os=new List<Opportunity>();
+ System.debug('this is the point ------------------------------------------!');
//閬嶅巻姣忎竴涓姤浠峰崟
for(Quote oneQuote:qu){
o=oneQuote.opportunity;
@@ -30,30 +31,47 @@
}
// 涓�骞村墠鐨勬棩鏈�
Date createdDateYear = createdDateStr.addYears(-1);
+ System.debug('----------鍒涘缓鐨勬椂闂�-----------'+createdDateYear);
//鑾峰彇鎶ヤ环琛屼俊鎭�
- list<QuoteLineItem> qli=[select id,Product2Id from QuoteLineItem where QuoteId=:oneQuote.id];
+ list<QuoteLineItem> qli=[select id,Product2Id,Product2.Category4__c from QuoteLineItem where QuoteId=:oneQuote.id];
List<String> c4=new List<String>();
for(QuoteLineItem quit:qli){
c4.add(quit.Product2.Category4__c);
}
+ System.debug('this is the point2 ------------------------------------------!');
+ System.debug('鎶ヤ环琛岀鍥涘垎绫�'+c4);
+ System.debug('鎴樼暐绉戝'+o.Department_Class__c);
//鑾峰彇鏄庣粏
List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [select id, product__c, Bollow_Date__c, Rental_Apply__r.Hospital__c from Rental_Apply_Equipment_Set_Detail__c
- where Rental_Apply__r.Strategic_dept__c = : o.Department_Class__c and Key_product__c != null and Bollow_Date__c >= :createdDateYear
+ where Rental_Apply__r.Strategic_dept__c = : o.Department_Class__c and Bollow_Date__c >= :createdDateYear
and Category4__c In :c4 and Rental_Apply__r.demo_purpose2__c='璇曠敤锛堟棤璇环锛�'
order by Bollow_Date__c];
-
+ System.debug('raesdList'+raesdList[0]);
Map<String, Date> ProOfDate = new Map<String, Date>();
for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdList) {
ProOfDate.put(raesd.product__c, raesd.Bollow_Date__c);
}
+ System.debug('-----------proofdate---------:'+ProOfDate);
o.WhetherTrySpareParts_3m__c = false;
o.WhetherTrySpareParts_6m__c = false;
o.WhetherTrySpareParts_1y__c = false;
+
+
+
//鑾峰彇涓�娆¤浠蜂腑鐨勬瘡涓�涓墿鍝佺殑璇环
- list<OpportunityLineItem> ols=[select Id from OpportunityLineItem where OpportunityId =:o.id];
- for (OpportunityLineItem oppitem : ols) {
- if (ProOfDate.containsKey(((String)oppitem.Id__c).substring(0, 15))) {
- Date bollDate = ProOfDate.get(((String)oppitem.Id__c).substring(0, 15));
+ //list<OpportunityLineItem> ols=[select Id__c from OpportunityLineItem where OpportunityId =:o.id];
+ //System.debug('-----ols-------'+ols);
+ //for (OpportunityLineItem oppitem : ols) {
+ //if (ProOfDate.containsKey(oppitem.Id__c)) {
+
+
+
+ for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdList) {
+ System.debug('---------杩涘叆浜嗙洰鏍囧惊鐜�---------------------------------');
+ //Date bollDate = ProOfDate.get(oppitem.Id__c);
+ Date bollDate = raesd.Bollow_Date__c;
+ System.debug('---------time-------------:'+bollDate);
+ System.debug('---------time2-------------:'+createdDateStr);
if (bollDate != null && bollDate.addMonths(3) > createdDateStr) {
o.WhetherTrySpareParts_3m__c = true;
}
@@ -63,15 +81,26 @@
if (bollDate != null && bollDate.addYears(1) > createdDateStr && bollDate.addMonths(6) < createdDateStr) {
o.WhetherTrySpareParts_1y__c = true;
}
+ System.debug('o1:'+o.WhetherTrySpareParts_3m__c);
+ System.debug('o2:'+o.WhetherTrySpareParts_6m__c);
+ System.debug('o3:'+o.WhetherTrySpareParts_1y__c);
+ }
- }
+ //}
os.add(o);
- }
- if(os.size()>0){
- update os;
- }
+ //}
}
-
+ if(os.size()>0){
+ try{
+ update os;
+ System.debug('update successed');
+ }
+ catch(DmlException e){
+ System.debug('绯荤粺閿欒');
+ }
+ }else{
+ System.debug('娌℃湁鏁版嵁');
+ }
}
global void finish(Database.BatchableContext BC) {
--
Gitblit v1.9.1