From 17ef9dd2ae1d3de83cfa769d02ebe066ffb238dd Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期二, 28 三月 2023 14:54:29 +0800
Subject: [PATCH] 上限合同补充
---
force-app/main/default/classes/RollupToMaintenanceContractBatch.cls | 980 +++++++++++++++++++++++++++---------------------------
force-app/main/default/classes/NFM105Rest.cls | 8
force-app/main/default/classes/NFM103Controller.cls | 32 +
force-app/main/default/classes/NFM104Rest.cls | 4
force-app/main/default/triggers/Repair.trigger | 4
5 files changed, 519 insertions(+), 509 deletions(-)
diff --git a/force-app/main/default/classes/NFM103Controller.cls b/force-app/main/default/classes/NFM103Controller.cls
index 88fe8e6..6d8cc69 100644
--- a/force-app/main/default/classes/NFM103Controller.cls
+++ b/force-app/main/default/classes/NFM103Controller.cls
@@ -247,11 +247,12 @@
// NFM103Controller.callout(iflog.Id, rprIds);
String uid = UserInfo.getUserId();
String BUid = System.Label.Batch_User_Id;
+ String OLYid = System.Label.OlympusSystem_ID;
System.debug('zheli');
- if (uid.substring(0,15) == BUid.substring(0,15)) {
- NFM103Controller.calloutNotfuture(iflog.Id, rprIds, null);
+ if (uid.substring(0,15) == BUid.substring(0,15) || uid.substring(0,15) == OLYid.substring(0,15)) {
+ NFM103Controller.calloutNotfuture(iflog.Id, rprIds);
}else{
- NFM103Controller.callout(iflog.Id, rprIds, null);
+ NFM103Controller.callout(iflog.Id, rprIds);
}
// 20220902 ljh XLIU-CHSD8G update end
}
@@ -265,11 +266,11 @@
* @param repairIds 閫佷俊瀵捐薄淇悊
*/
@future (callout = true)
- public static void callout(String iflog_Id, List<Id> repairIds, String flag) {
- calloutNotfuture(iflog_Id, repairIds, flag);
+ public static void callout(String iflog_Id, List<Id> repairIds) {
+ calloutNotfuture(iflog_Id, repairIds);
}
//20220902 ljh 鏂板锛堝鍒讹級鏂规硶 XLIU-CHSD8G
- public static void calloutNotfuture(String iflog_Id, List<Id> repairIds,String flag) {
+ public static void calloutNotfuture(String iflog_Id, List<Id> repairIds) {
if (repairIds == null || repairIds.size() == 0) {
return;
@@ -623,11 +624,7 @@
rprId = rpr.Id; //2022-07-14 zyh add
//鍐嶆敞鍐屽垎鏋� 闇�姹� 鏂板瀛楁 20220811 sx start
- element.Reanalysis = flag;
-
- if(flag != null){
- element.UpdateStatus = 'X';
- }
+ element.Reanalysis = null;
//鍐嶆敞鍐屽垎鏋� 闇�姹� 鏂板瀛楁 20220811 sx end
}
@@ -848,11 +845,18 @@
// 銈ㄣ儵銉笺亴鐧虹敓銇椼仧鍫村悎
System.debug(Logginglevel.ERROR, 'NFM103_' + iflog.Name + ':' + ex.getMessage());
System.debug(Logginglevel.ERROR, 'NFM103_' + iflog.Name + ':' + ex.getStackTraceString());
- logstr += ex.getMessage();
- iflog.ErrorLog__c += ex.getMessage() + '\n';
- iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
+ //NFM105瑙﹀彂103鎺ュ彛 20230303 LY start
+ // Callout from triggers are currently not supported.
+ System.debug('NFM201jiekou'+ex.getMessage());
+ if (!String.valueOf(ex.getMessage()).contains('Callout from triggers')) {
+ logstr += ex.getMessage();
+ iflog.ErrorLog__c += ex.getMessage() + '\n';
+ iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
+ }
System.debug('鏍囪0--------------------1:' + rowData.retry_cnt__c);
+
+ //NFM105瑙﹀彂103鎺ュ彛 20230303 LY end
//---Gaozw---add
if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
if (rowData.retry_cnt__c < batch_retry_max_cnt) {
diff --git a/force-app/main/default/classes/NFM104Rest.cls b/force-app/main/default/classes/NFM104Rest.cls
index 9bca254..7bdbf44 100644
--- a/force-app/main/default/classes/NFM104Rest.cls
+++ b/force-app/main/default/classes/NFM104Rest.cls
@@ -313,6 +313,10 @@
else if (di.DiscountType == '杩愯緭绱㈣禂') {
rq.Delivery_compensation__c = String.isBlank(di.DiscountAmount) ? null : Decimal.valueOf(di.DiscountAmount);
}
+ //DB202303075842 LY 2023/3/6 add
+ else if (di.DiscountType == '涓婇檺鍚堝悓'){
+ rq.LimitPrice_contract_discount_amount__c = String.isBlank(di.DiscountAmount) ? null : Decimal.valueOf(di.DiscountAmount);
+ }
//
else if (di.DiscountType == '鍏朵粬') {
rq.Other_discount__c = String.isBlank(di.DiscountAmount) ? null : Decimal.valueOf(di.DiscountAmount);
diff --git a/force-app/main/default/classes/NFM105Rest.cls b/force-app/main/default/classes/NFM105Rest.cls
index 4d41916..6fd096e 100644
--- a/force-app/main/default/classes/NFM105Rest.cls
+++ b/force-app/main/default/classes/NFM105Rest.cls
@@ -62,7 +62,10 @@
BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'NFM105', ges.RepairStatusUpdate.GeneralData);
if (String.isBlank(rowData.Log__c) == false) {
- executefuture(rowData.Id);
+ //涓婇檺鍚堝悓 LY 20230209 start
+ //executefuture(rowData.Id);
+ main(rowData.Id);
+ //涓婇檺鍚堝悓 LY 20230209 end
}
// JSON銈掓埢銇�
@@ -599,7 +602,8 @@
for (Repair__c rc : rprList) {
if (rc.Limit_Price__c) {
//B95-鎶ヤ环鍚屾剰纭銆丅99-鎶ヤ环鍚屾剰纭鍙栨秷銆丄95-鍙栨秷淇悊鍙楃悊銆丄96-鍙栨秷淇悊銆丄99-淇悊鍗曞叧闂� 鏇存柊鍚堝悓鏈熼棿淇悊閲戦
- if (rc.RepairOrderStatusCode__c =='B95' || rc.RepairOrderStatusCode__c =='B99' || rc.RepairOrderStatusCode__c =='A99' || rc.RepairOrderStatusCode__c =='A95' || rc.RepairOrderStatusCode__c =='A96'){
+ //if (rc.RepairOrderStatusCode__c =='B95' || rc.RepairOrderStatusCode__c =='B99' || rc.RepairOrderStatusCode__c =='A99' || rc.RepairOrderStatusCode__c =='A95' || rc.RepairOrderStatusCode__c =='A96'){
+ if (rc.Agreed_Date__c != null){
Maintenance_Contract__c mc = new Maintenance_Contract__c();
if (!updateMC.contains(rc.Maintenance_Contract__c)) {
mc.Id = rc.Maintenance_Contract__c;
diff --git a/force-app/main/default/classes/RollupToMaintenanceContractBatch.cls b/force-app/main/default/classes/RollupToMaintenanceContractBatch.cls
index 287b7e4..f96dfe4 100644
--- a/force-app/main/default/classes/RollupToMaintenanceContractBatch.cls
+++ b/force-app/main/default/classes/RollupToMaintenanceContractBatch.cls
@@ -1,507 +1,507 @@
// LHJ 20190712 HWAG-BDH9V5 Start
//global class RollupToMaintenanceContractBatch implements Database.Batchable<AggregateResult> {
-global class RollupToMaintenanceContractBatch implements Database.Batchable<SObject> , Database.Stateful {
-// LHJ 20190712 HWAG-BDH9V5 End
- // LHJ 20190712 HWAG-BDH9V5 Start
- global Integer totalCount = 0; // 鎬讳欢鏁�
- global Integer failedCount = 0;
- global List<String> emailMessages = new List<String>();
- public List<Id> ConId;
-
- global RollupToMaintenanceContractBatch(List<Id> conID) {
- this.ConId = conID;
- }
+ global class RollupToMaintenanceContractBatch implements Database.Batchable<SObject> , Database.Stateful {
// LHJ 20190712 HWAG-BDH9V5 End
-
- /**
- * 銈炽兂銈广偪銉炽儓
- */
- global RollupToMaintenanceContractBatch() {
- }
-
- /**
- * start銇伅銆乹uery銈掑疅琛屻�佺淮淇悎鍚屻倰妞滅储
- */
- //global Iterable<AggregateResult> start(Database.batchableContext BC){
- global Database.QueryLocator start(Database.batchableContext BC){
- //return new AggregateResultIterable();
- /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� start
- return Database.getQueryLocator(
- [select Id from User where Id = :UserInfo.getUserId()]
- );
- CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� end
- */
- // LHJ 20190712 HWAG-BDH9V5 Start
- //return Database.getQueryLocator(
- // [select Id from Maintenance_Contract__c]
- //);
-
-
- if(ConId != null && ConId.size() > 0) {
- return Database.getQueryLocator([select Id from Maintenance_Contract__c where Id in :ConId]);
- } else {
- // 20221117 ljh DB202211258553 start
- // return Database.getQueryLocator([select Id from Maintenance_Contract__c]);
- return Database.getQueryLocator([select Id from Maintenance_Contract__c where Status__c = '濂戠磩' OR (Status__c = '濂戠磩婧�浜�' and Contract_End_Date__c >= :Date.today().addMonths(-6))]);
- // 20221117 ljh DB202211258553 end
- }
-
-
- // LHJ 20190712 HWAG-BDH9V5 End
-
- // if(ConId != null && ConId.size() > 0) {
- // return Database.getQueryLocator()
- // }
- }
-
- global void execute(Database.BatchableContext BC, List<SObject> mcList) {
- // LHJ 20190712 HWAG-BDH9V5 Start
- Savepoint sp = Database.setSavepoint();
- totalCount += 1;
-
- try {
- // LHJ 20190712 HWAG-BDH9V5 End
- // 缁翠慨鍚堝悓鏇存柊
- Map<Id, Maintenance_Contract__c> updateMC = new Map<Id, Maintenance_Contract__c>();
- /******************************* HWAG-AV2C67 2018/1/17 START ******************************/
- //List<Id> mcids = new List<Id>();
-
- // 宸茬粡SAP鐨勫惊鐜眹鎬�
- List<Repair__c> sapRepairList =
- [select Repair_List_Price_formula__c,
- Repair_cost__c,
- Maintenance_Contract__c,
- Maintenance_Contract__r.Contract_Start_Date__c,
- Maintenance_Contract__r.Contract_End_Date__c,
- Failure_Occurrence_Date__c,
- Repair_Quotation_Id__r.LatestQuotationDate__c,
- Repair_Quotation_Id__c
- from Repair__c
- where Maintenance_Contract__c != null
- /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� start */
- and Maintenance_Contract__c in: mcList
- /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� end */
- and Status2__c !='00.鍒犻櫎'
- and Status2__c !='00.鍙栨秷'
- and Repair_Quotation_Id__c !=null
- and (CutPrice_Reason__c='缁翠慨鍚堝悓'
- or CutPrice_Reason__c='濂楅鎶樻墸,缁翠慨鍚堝悓'
- or CutPrice_Reason__c='钀ヤ笟瀵瑰簲,缁翠慨鍚堝悓')
- order by Maintenance_Contract__c];
-
- if (sapRepairList != null && sapRepairList.size() > 0) {
- for (Repair__c rc : sapRepairList) {
- Maintenance_Contract__c mc = new Maintenance_Contract__c();
- if (updateMC.containsKey(rc.Maintenance_Contract__c)) {
- mc = updateMC.get(rc.Maintenance_Contract__c);
- } else {
- mc.Id = rc.Maintenance_Contract__c;
- mc.Sum_repair_price__c=0.0;
- mc.Repair_Cost_Sum__c =0.0;
- }
- Date dTDate = rc.Failure_Occurrence_Date__c;
- Date dSDate = rc.Maintenance_Contract__r.Contract_Start_Date__c;
- Date dEDate = rc.Maintenance_Contract__r.Contract_End_Date__c;
-
- if (dTDate >= dSDate && dTDate <= dEDate) {
- mc.Sum_repair_price__c += rc.Repair_List_Price_formula__c == null ? 0 : rc.Repair_List_Price_formula__c;
- mc.Repair_Cost_Sum__c += rc.Repair_cost__c == null ? 0 : rc.Repair_cost__c;
- }
- updateMC.put(rc.Maintenance_Contract__c, mc);
- }
- }
-
- // 娌℃湁SAP鐨勫惊鐜眹鎬�
- List<Repair__c> noSapRepairList =
- [select Repair_List_Price_formula__c,
- Repair_cost__c,
- Maintenance_Contract__c,
- Maintenance_Contract__r.Contract_Start_Date__c,
- Maintenance_Contract__r.Contract_End_Date__c,
- Failure_Occurrence_Date__c,
- Repair_Quotation_Id__c
- from Repair__c
- where Maintenance_Contract__c != null
- /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� start */
- and Maintenance_Contract__c in: mcList
- /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� end */
- and Status2__c !='00.鍒犻櫎'
- and Status2__c !='00.鍙栨秷'
- and Repair_Quotation_Id__c=null
- order by Maintenance_Contract__c];
- if (noSapRepairList != null && noSapRepairList.size() > 0) {
- for (Repair__c rc : noSapRepairList) {
- Maintenance_Contract__c mc = new Maintenance_Contract__c();
- if (updateMC.containsKey(rc.Maintenance_Contract__c)) {
- mc = updateMC.get(rc.Maintenance_Contract__c);
- } else {
- mc.Id = rc.Maintenance_Contract__c;
- mc.Sum_repair_price__c=0.0;
- mc.Repair_Cost_Sum__c =0.0;
- }
- Date dTDate = rc.Failure_Occurrence_Date__c;
- Date dSDate = rc.Maintenance_Contract__r.Contract_Start_Date__c;
- Date dEDate = rc.Maintenance_Contract__r.Contract_End_Date__c;
-
- if (dTDate >= dSDate && dTDate <= dEDate) {
- mc.Sum_repair_price__c += rc.Repair_List_Price_formula__c == null ? 0 : rc.Repair_List_Price_formula__c;
- mc.Repair_Cost_Sum__c += rc.Repair_cost__c == null ? 0 : rc.Repair_cost__c;
- }
- updateMC.put(rc.Maintenance_Contract__c, mc);
- }
- }
-
// LHJ 20190712 HWAG-BDH9V5 Start
-
- List<Repair__c> newRepairList =
- [select Id,Usage_Ratio_Price__c,
- Repair_cost__c,
- Maintenance_Contract__c,
- Maintenance_Contract__r.Contract_Start_Date__c,
- Maintenance_Contract__r.Contract_End_Date__c,
- Failure_Occurrence_Date__c,
- Repair_Quotation_Id__c,
- EquipmentGuaranteeFlg_Asset__c,
- if_Rental_Apply__c,
- Offer_Rental_New__c,
- Usage_Ratio_Price_Guarantee__c,
- VM_Maintenance_Contract__c,
- VM_Maintenance_Contract__r.RecordType_DeveloperName__c,
- Maintenance_Contract__r.RecordType_DeveloperName__c,
- VM_Maintenance_Contract__r.startDateGurantee__c,
- VM_Maintenance_Contract__r.endDateGurantee__c
- ,Agreed_Date__c //鐢ㄦ埛鍚屾剰鏃� 涓婇檺鍚堝悓 LY 20230210 add
- ,Limit_Price__c //涓婇檺淇悊 涓婇檺鍚堝悓 LY 20230210 add
- from Repair__c
- where (Maintenance_Contract__c != null or VM_Maintenance_Contract__c != null)
- and (Maintenance_Contract__c in: mcList or VM_Maintenance_Contract__c in: mcList)
- and Status2__c !='00.鍒犻櫎'
- and Status2__c !='00.鍙栨秷'
- order by Maintenance_Contract__c
- ];
-
- if (newRepairList != null && newRepairList.size() > 0) {
-
- for (Repair__c rc : newRepairList) {
- if (rc.Maintenance_Contract__c != null) {
-
- Maintenance_Contract__c mc = new Maintenance_Contract__c();
- if (updateMC.containsKey(rc.Maintenance_Contract__c)) {
- mc = updateMC.get(rc.Maintenance_Contract__c);
- } else {
- mc.Id = rc.Maintenance_Contract__c;
- mc.Sum_repair_price_new__c=0.00;
+ global Integer totalCount = 0; // 鎬讳欢鏁�
+ global Integer failedCount = 0;
+ global List<String> emailMessages = new List<String>();
+ public List<Id> ConId;
+
+ global RollupToMaintenanceContractBatch(List<Id> conID) {
+ this.ConId = conID;
+ }
+ // LHJ 20190712 HWAG-BDH9V5 End
+
+ /**
+ * 銈炽兂銈广偪銉炽儓
+ */
+ global RollupToMaintenanceContractBatch() {
+ }
+
+ /**
+ * start銇伅銆乹uery銈掑疅琛屻�佺淮淇悎鍚屻倰妞滅储
+ */
+ //global Iterable<AggregateResult> start(Database.batchableContext BC){
+ global Database.QueryLocator start(Database.batchableContext BC){
+ //return new AggregateResultIterable();
+ /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� start
+ return Database.getQueryLocator(
+ [select Id from User where Id = :UserInfo.getUserId()]
+ );
+ CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� end
+ */
+ // LHJ 20190712 HWAG-BDH9V5 Start
+ //return Database.getQueryLocator(
+ // [select Id from Maintenance_Contract__c]
+ //);
+
+
+ if(ConId != null && ConId.size() > 0) {
+ return Database.getQueryLocator([select Id from Maintenance_Contract__c where Id in :ConId]);
+ } else {
+ // 20221117 ljh DB202211258553 start
+ // return Database.getQueryLocator([select Id from Maintenance_Contract__c]);
+ return Database.getQueryLocator([select Id from Maintenance_Contract__c where Status__c = '濂戠磩' OR (Status__c = '濂戠磩婧�浜�' and Contract_End_Date__c >= :Date.today().addMonths(-6))]);
+ // 20221117 ljh DB202211258553 end
+ }
+
+
+ // LHJ 20190712 HWAG-BDH9V5 End
+
+ // if(ConId != null && ConId.size() > 0) {
+ // return Database.getQueryLocator()
+ // }
+ }
+
+ global void execute(Database.BatchableContext BC, List<SObject> mcList) {
+ // LHJ 20190712 HWAG-BDH9V5 Start
+ Savepoint sp = Database.setSavepoint();
+ totalCount += 1;
+
+ try {
+ // LHJ 20190712 HWAG-BDH9V5 End
+ // 缁翠慨鍚堝悓鏇存柊
+ Map<Id, Maintenance_Contract__c> updateMC = new Map<Id, Maintenance_Contract__c>();
+ /******************************* HWAG-AV2C67 2018/1/17 START ******************************/
+ //List<Id> mcids = new List<Id>();
+
+ // 宸茬粡SAP鐨勫惊鐜眹鎬�
+ List<Repair__c> sapRepairList =
+ [select Repair_List_Price_formula__c,
+ Repair_cost__c,
+ Maintenance_Contract__c,
+ Maintenance_Contract__r.Contract_Start_Date__c,
+ Maintenance_Contract__r.Contract_End_Date__c,
+ Failure_Occurrence_Date__c,
+ Repair_Quotation_Id__r.LatestQuotationDate__c,
+ Repair_Quotation_Id__c
+ from Repair__c
+ where Maintenance_Contract__c != null
+ /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� start */
+ and Maintenance_Contract__c in: mcList
+ /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� end */
+ and Status2__c !='00.鍒犻櫎'
+ and Status2__c !='00.鍙栨秷'
+ and Repair_Quotation_Id__c !=null
+ and (CutPrice_Reason__c='缁翠慨鍚堝悓'
+ or CutPrice_Reason__c='濂楅鎶樻墸,缁翠慨鍚堝悓'
+ or CutPrice_Reason__c='钀ヤ笟瀵瑰簲,缁翠慨鍚堝悓')
+ order by Maintenance_Contract__c];
+
+ if (sapRepairList != null && sapRepairList.size() > 0) {
+ for (Repair__c rc : sapRepairList) {
+ Maintenance_Contract__c mc = new Maintenance_Contract__c();
+ if (updateMC.containsKey(rc.Maintenance_Contract__c)) {
+ mc = updateMC.get(rc.Maintenance_Contract__c);
+ } else {
+ mc.Id = rc.Maintenance_Contract__c;
+ mc.Sum_repair_price__c=0.0;
+ mc.Repair_Cost_Sum__c =0.0;
+ }
+ Date dTDate = rc.Failure_Occurrence_Date__c;
+ Date dSDate = rc.Maintenance_Contract__r.Contract_Start_Date__c;
+ Date dEDate = rc.Maintenance_Contract__r.Contract_End_Date__c;
+
+ if (dTDate >= dSDate && dTDate <= dEDate) {
+ mc.Sum_repair_price__c += rc.Repair_List_Price_formula__c == null ? 0 : rc.Repair_List_Price_formula__c;
+ mc.Repair_Cost_Sum__c += rc.Repair_cost__c == null ? 0 : rc.Repair_cost__c;
+ }
+ updateMC.put(rc.Maintenance_Contract__c, mc);
}
- Date dTDate = rc.Failure_Occurrence_Date__c;
- Date dSDate = rc.Maintenance_Contract__r.Contract_Start_Date__c;
- Date dEDate = rc.Maintenance_Contract__r.Contract_End_Date__c;
-
- if (mc.Sum_repair_price_new__c == null) {
- mc.Sum_repair_price_new__c = 0.00;
+ }
+
+ // 娌℃湁SAP鐨勫惊鐜眹鎬�
+ List<Repair__c> noSapRepairList =
+ [select Repair_List_Price_formula__c,
+ Repair_cost__c,
+ Maintenance_Contract__c,
+ Maintenance_Contract__r.Contract_Start_Date__c,
+ Maintenance_Contract__r.Contract_End_Date__c,
+ Failure_Occurrence_Date__c,
+ Repair_Quotation_Id__c
+ from Repair__c
+ where Maintenance_Contract__c != null
+ /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� start */
+ and Maintenance_Contract__c in: mcList
+ /* CHAN-B7J5EK 2018/12/18 鎸夌収缁翠慨鍚堝悓鍒掑垎杩涜妫�绱� end */
+ and Status2__c !='00.鍒犻櫎'
+ and Status2__c !='00.鍙栨秷'
+ and Repair_Quotation_Id__c=null
+ order by Maintenance_Contract__c];
+ if (noSapRepairList != null && noSapRepairList.size() > 0) {
+ for (Repair__c rc : noSapRepairList) {
+ Maintenance_Contract__c mc = new Maintenance_Contract__c();
+ if (updateMC.containsKey(rc.Maintenance_Contract__c)) {
+ mc = updateMC.get(rc.Maintenance_Contract__c);
+ } else {
+ mc.Id = rc.Maintenance_Contract__c;
+ mc.Sum_repair_price__c=0.0;
+ mc.Repair_Cost_Sum__c =0.0;
+ }
+ Date dTDate = rc.Failure_Occurrence_Date__c;
+ Date dSDate = rc.Maintenance_Contract__r.Contract_Start_Date__c;
+ Date dEDate = rc.Maintenance_Contract__r.Contract_End_Date__c;
+
+ if (dTDate >= dSDate && dTDate <= dEDate) {
+ mc.Sum_repair_price__c += rc.Repair_List_Price_formula__c == null ? 0 : rc.Repair_List_Price_formula__c;
+ mc.Repair_Cost_Sum__c += rc.Repair_cost__c == null ? 0 : rc.Repair_cost__c;
+ }
+ updateMC.put(rc.Maintenance_Contract__c, mc);
}
- if (dTDate >= dSDate && dTDate <= dEDate) {
- //涓婇檺鍚堝悓 LY 20230210 start
- if (rc.Limit_Price__c == true) {
- if (rc.Agreed_Date__c!=null) {//鎶ヤ环鍚屾剰鍚� 淇悊鐨勩�愯鍏ュ悎鍚屾秷璐圭巼鐨勪慨鐞嗛噾棰濄�戣鍏ュ埌缁翠慨鍚堝悓鐨勫悎鍚屾湡闂翠慨鐞嗛噾棰濄�� 涓婇檺鍚堝悓 LY add 20230210
- mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price__c == null ? 0 : rc.Usage_Ratio_Price__c;
+ }
+
+ // LHJ 20190712 HWAG-BDH9V5 Start
+
+ List<Repair__c> newRepairList =
+ [select Id,Usage_Ratio_Price__c,
+ Repair_cost__c,
+ Maintenance_Contract__c,
+ Maintenance_Contract__r.Contract_Start_Date__c,
+ Maintenance_Contract__r.Contract_End_Date__c,
+ Failure_Occurrence_Date__c,
+ Repair_Quotation_Id__c,
+ EquipmentGuaranteeFlg_Asset__c,
+ if_Rental_Apply__c,
+ Offer_Rental_New__c,
+ Usage_Ratio_Price_Guarantee__c,
+ VM_Maintenance_Contract__c,
+ VM_Maintenance_Contract__r.RecordType_DeveloperName__c,
+ Maintenance_Contract__r.RecordType_DeveloperName__c,
+ VM_Maintenance_Contract__r.startDateGurantee__c,
+ VM_Maintenance_Contract__r.endDateGurantee__c
+ ,Agreed_Date__c //鐢ㄦ埛鍚屾剰鏃� 涓婇檺鍚堝悓 LY 20230210 add
+ ,Limit_Price__c //涓婇檺淇悊 涓婇檺鍚堝悓 LY 20230210 add
+ from Repair__c
+ where (Maintenance_Contract__c != null or VM_Maintenance_Contract__c != null)
+ and (Maintenance_Contract__c in: mcList or VM_Maintenance_Contract__c in: mcList)
+ and Status2__c !='00.鍒犻櫎'
+ and Status2__c !='00.鍙栨秷'
+ order by Maintenance_Contract__c
+ ];
+
+ if (newRepairList != null && newRepairList.size() > 0) {
+
+ for (Repair__c rc : newRepairList) {
+ if (rc.Maintenance_Contract__c != null) {
+
+ Maintenance_Contract__c mc = new Maintenance_Contract__c();
+ if (updateMC.containsKey(rc.Maintenance_Contract__c)) {
+ mc = updateMC.get(rc.Maintenance_Contract__c);
+ } else {
+ mc.Id = rc.Maintenance_Contract__c;
+ mc.Sum_repair_price_new__c=0.00;
}
- }else{
- mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price__c == null ? 0 : rc.Usage_Ratio_Price__c;
+ Date dTDate = rc.Failure_Occurrence_Date__c;
+ Date dSDate = rc.Maintenance_Contract__r.Contract_Start_Date__c;
+ Date dEDate = rc.Maintenance_Contract__r.Contract_End_Date__c;
+
+ if (mc.Sum_repair_price_new__c == null) {
+ mc.Sum_repair_price_new__c = 0.00;
+ }
+ if (dTDate >= dSDate && dTDate <= dEDate) {
+ //涓婇檺鍚堝悓 LY 20230210 start
+ if (rc.Limit_Price__c == true) {
+ if (rc.Agreed_Date__c!=null) {//鎶ヤ环鍚屾剰鍚� 淇悊鐨勩�愯鍏ュ悎鍚屾秷璐圭巼鐨勪慨鐞嗛噾棰濄�戣鍏ュ埌缁翠慨鍚堝悓鐨勫悎鍚屾湡闂翠慨鐞嗛噾棰濄�� 涓婇檺鍚堝悓 LY add 20230210
+ mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price__c == null ? 0 : rc.Usage_Ratio_Price__c;
+ }
+ }else{
+ mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price__c == null ? 0 : rc.Usage_Ratio_Price__c;
+ }
+ //涓婇檺鍚堝悓 LY 20230210 end
+ }
+ System.debug('淇悊閲戦缁撴潫'+mc.Sum_repair_price_new__c);
+ updateMC.put(rc.Maintenance_Contract__c, mc);
}
- //涓婇檺鍚堝悓 LY 20230210 end
- }
- System.debug('淇悊閲戦缁撴潫'+mc.Sum_repair_price_new__c);
- updateMC.put(rc.Maintenance_Contract__c, mc);
- }
- //20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 start
- if (rc.VM_Maintenance_Contract__c != null) {
- Maintenance_Contract__c mc = new Maintenance_Contract__c();
- if (updateMC.containsKey(rc.VM_Maintenance_Contract__c)) {
- mc = updateMC.get(rc.VM_Maintenance_Contract__c);
- } else {
- mc.Id = rc.VM_Maintenance_Contract__c;
- mc.Sum_repair_price_new__c=0.00;
- }
- Date dTDate = rc.Failure_Occurrence_Date__c;
- Date dSDate = rc.VM_Maintenance_Contract__r.startDateGurantee__c;
- Date dEDate = rc.VM_Maintenance_Contract__r.endDateGurantee__c;
-
- if (mc.Sum_repair_price_new__c == null) {
- mc.Sum_repair_price_new__c = 0.00;
- }
- // gzw LJPH-BZDA84 澶氬勾淇濆悎鍚屼慨鐞嗕环鏍间笉鏍规嵁寮�濮嬬粨鏉熸棩绠� start
- // if (dTDate >= dSDate && dTDate <= dEDate) {
//20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 start
- // mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price__c == null ? 0 : rc.Usage_Ratio_Price__c;
- if ('VM_Contract'.equals(rc.VM_Maintenance_Contract__r.RecordType_DeveloperName__c)) {
- mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price_Guarantee__c == null ? 0 : rc.Usage_Ratio_Price_Guarantee__c;
+ if (rc.VM_Maintenance_Contract__c != null) {
+ Maintenance_Contract__c mc = new Maintenance_Contract__c();
+ if (updateMC.containsKey(rc.VM_Maintenance_Contract__c)) {
+ mc = updateMC.get(rc.VM_Maintenance_Contract__c);
+ } else {
+ mc.Id = rc.VM_Maintenance_Contract__c;
+ mc.Sum_repair_price_new__c=0.00;
+ }
+ Date dTDate = rc.Failure_Occurrence_Date__c;
+ Date dSDate = rc.VM_Maintenance_Contract__r.startDateGurantee__c;
+ Date dEDate = rc.VM_Maintenance_Contract__r.endDateGurantee__c;
+
+ if (mc.Sum_repair_price_new__c == null) {
+ mc.Sum_repair_price_new__c = 0.00;
+ }
+ // gzw LJPH-BZDA84 澶氬勾淇濆悎鍚屼慨鐞嗕环鏍间笉鏍规嵁寮�濮嬬粨鏉熸棩绠� start
+ // if (dTDate >= dSDate && dTDate <= dEDate) {
+ //20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 start
+ // mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price__c == null ? 0 : rc.Usage_Ratio_Price__c;
+ if ('VM_Contract'.equals(rc.VM_Maintenance_Contract__r.RecordType_DeveloperName__c)) {
+ mc.Sum_repair_price_new__c += rc.Usage_Ratio_Price_Guarantee__c == null ? 0 : rc.Usage_Ratio_Price_Guarantee__c;
+ }
+ //20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 end
+ // }
+ // // gzw LJPH-BZDA84 澶氬勾淇濆悎鍚屼慨鐞嗕环鏍间笉鏍规嵁寮�濮嬬粨鏉熸棩绠� end
+ updateMC.put(rc.VM_Maintenance_Contract__c, mc);
+ //20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 end
}
- //20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 end
- // }
- // // gzw LJPH-BZDA84 澶氬勾淇濆悎鍚屼慨鐞嗕环鏍间笉鏍规嵁寮�濮嬬粨鏉熸棩绠� end
- updateMC.put(rc.VM_Maintenance_Contract__c, mc);
- //20210106 zh LJPH-BWM5HM 澶氬勾淇濅慨銆愬悎鍚屾湡闂翠慨鐞嗛噾棰濄�戦�昏緫淇敼 end
+ }
}
+
+ // LD 20200721 澶囧搧鍑哄�熷彲瑙嗗寲绠$悊 Start
+
+
+ //鏍规嵁缁翠慨鍚堝悓ID鏌ヨ鎵�鏈夊搴旂淮淇悎鍚�
+ List<Maintenance_Contract__c> conList = [SELECT Id,Name,
+ RentalRelatedCnt__c,
+ NoRentalRelatedCnt__c,
+ RentalRelatedRepairCnt__c,
+ RentalRelatedApplyCnt__c,
+ RentalRelatedSupplyCnt__c,
+ NoRentalRelatedRepairCnt__c,
+ NoRentalRelatedApplyCnt__c,
+ NoRentalRelatedSupplyCnt__c
+ FROM Maintenance_Contract__c
+ WHERE
+ Id IN :mcList];
+
+ //鏍规嵁缁翠慨鍚堝悓ID鏌ヨ瀵瑰簲缁翠慨淇濇湁璁惧
+ List<Maintenance_Contract_Asset__c> assList =
+ [SELECT Id,
+ Asset__r.EGFlg_fromContract_asset__c
+ , Maintenance_Contract__c
+ FROM Maintenance_Contract_Asset__c
+ WHERE Maintenance_Contract__c = :mcList];
+ newRepairList = [
+ select id, EquipmentGuaranteeFlg_Asset__c,
+ if_Rental_Apply__c, Offer_Rental_New__c,Maintenance_Contract__c
+ from Repair__c
+ where Maintenance_Contract__c in: mcList
+ and Status2__c !='00.鍒犻櫎'
+ and Status2__c !='00.鍙栨秷'
+ order by Maintenance_Contract__c
+
+ ];
+
+
+ //缁翠慨鍚堝悓
+ if (conList != null && conList.size() > 0) {
+ for (Maintenance_Contract__c con : conList) {
+
+ if(updateMc.containsKey(con.Id)){
+ con = updateMc.get(con.Id);
+ }
+
+ con.RentalRelatedCnt__c = 0;
+ con.NoRentalRelatedCnt__c = 0;
+ con.RentalRelatedRepairCnt__c = 0;
+ con.RentalRelatedApplyCnt__c = 0;
+ con.RentalRelatedSupplyCnt__c = 0;
+ con.NoRentalRelatedRepairCnt__c = 0;
+ con.NoRentalRelatedApplyCnt__c = 0;
+ con.NoRentalRelatedSupplyCnt__c = 0;
+
+ if (assList != null && assList.size() > 0) {
+ for (Maintenance_Contract_Asset__c ass : assList) {
+ System.debug(ass.Maintenance_Contract__c+'====ass.CurrentContract__c');
+ System.debug(con.Id+'====con.Id');
+ if(ass.Maintenance_Contract__c == con.Id){
+ if (ass.Asset__r.EGFlg_fromContract_asset__c == true) {
+ con.RentalRelatedCnt__c = con.RentalRelatedCnt__c + 1;
+ }else{
+ con.NoRentalRelatedCnt__c = con.NoRentalRelatedCnt__c + 1;
+ }
+ updateMC.put(con.Id,con);
+ }
+ }
+ }
+
+ if (newRepairList != null && newRepairList.size() > 0) {
+ for (Repair__c repc : newRepairList) {
+ if( con.Id == repc.Maintenance_Contract__c){
+ //澶囧搧纭繚鎻愪緵閫夋涓篢rue
+ if(repc.EquipmentGuaranteeFlg_Asset__c == true){
+ con.RentalRelatedRepairCnt__c = con.RentalRelatedRepairCnt__c + 1;
+ //鏄惁鐢宠澶囧搧閫夋涓篢rue
+ if(repc.if_Rental_Apply__c == true){
+ con.RentalRelatedApplyCnt__c = con.RentalRelatedApplyCnt__c + 1;
+ }
+ //鏄惁鎻愪緵澶囧搧閫夋涓篢rue
+ if(repc.Offer_Rental_New__c == true){
+ con.RentalRelatedSupplyCnt__c = con.RentalRelatedSupplyCnt__c + 1;
+ }
+ }
+ //澶囧搧纭繚鎻愪緵瀵硅薄涓篎alse
+ if(repc.EquipmentGuaranteeFlg_Asset__c == false){
+ con.NoRentalRelatedRepairCnt__c = con.NoRentalRelatedRepairCnt__c + 1;
+ //鏄惁鐢宠澶囧搧閫夋涓篢rue
+ if(repc.if_Rental_Apply__c == true){
+ con.NoRentalRelatedApplyCnt__c = con.NoRentalRelatedApplyCnt__c + 1;
+ }
+ //鏄惁鎻愪緵澶囧搧閫夋涓篢rue
+ if(repc.Offer_Rental_New__c == true){
+ con.NoRentalRelatedSupplyCnt__c = con.NoRentalRelatedSupplyCnt__c + 1;
+ }
+ }
+ updateMC.put(con.Id,con);
+ }
+ }
+ }
+ }
+ }
+
+ // LD 20200721 澶囧搧鍑哄�熷彲瑙嗗寲绠$悊 End
+ if (updateMC.size() > 0) {
+ update updateMC.values();
+ }
+ } catch (Exception e) {
+ Database.rollback(sp);
+ emailMessages.add(e.getMessage());
+ System.debug(emailMessages);
+ failedCount += mcList.size();
+ System.debug(failedCount);
+ }
+ // LHJ 20190712 HWAG-BDH9V5 End
+
+
+
+
+ //for (SObject sobj : mcList) {
+ // Maintenance_Contract__c mc = new Maintenance_Contract__c(Id=String.valueOf(sobj.get('Maintenance_Contract__c')));
+ // initMC(mc);
+ // updateMC.put(mc.Id, mc);
+ // mcids.add(String.valueOf(sobj.get('Maintenance_Contract__c')));
+ //}
+ //绛涢�夊嚭闇�瑕佹洿鏂扮殑鏁版嵁
+ //List<Maintenance_Contract__c> NeedUpdate = new List<Maintenance_Contract__c>();
+ // 淇悊 淇悊閲戦
+ // 瑕佸垽鏂槸鍚AP
+ //宸茬粡SAP鐨勫惊鐜眹鎬�
+ //for (AggregateResult aggAst : [
+ // select SUM(Repair_List_Price_formula__c) sum_Price,
+ // SUM(Repair_cost__c) sum_PricePr,
+ // Maintenance_Contract__c,
+ // Maintenance_Contract__r.Contract_Start_Date__c,
+ // Maintenance_Contract__r.Contract_End_Date__c,
+ // Failure_Occurrence_Date__c,
+ // Repair_Quotation_Id__r.LatestQuotationDate__c,
+ // Repair_Quotation_Id__c
+ // from Repair__c
+ // where Maintenance_Contract__c != null
+ // and Status2__c !='00.鍒犻櫎'
+ // and Repair_Quotation_Id__c !=null
+ // and (CutPrice_Reason__c='缁翠慨鍚堝悓' or CutPrice_Reason__c='濂楅鎶樻墸,缁翠慨鍚堝悓'or CutPrice_Reason__c='钀ヤ笟瀵瑰簲,缁翠慨鍚堝悓')
+ // group by Maintenance_Contract__c,Maintenance_Contract__r.Contract_Start_Date__c,Maintenance_Contract__r.Contract_End_Date__c,
+ // Failure_Occurrence_Date__c,Repair_Quotation_Id__r.LatestQuotationDate__c,Repair_Quotation_Id__c
+ // ]) {
+ // Id mcid = (Id) aggAst.get('Maintenance_Contract__c');
+ // Maintenance_Contract__c mc = updateMC.get(mcid);
+ // Date dRDate = Date.valueOf(aggAst.get('LatestQuotationDate__c'));
+ // Date dTDate = Date.valueOf(aggAst.get('Failure_Occurrence_Date__c'));
+ // Date dSDate = Date.valueOf(aggAst.get('Contract_Start_Date__c'));
+ // Date dEDate = Date.valueOf(aggAst.get('Contract_End_Date__c'));
+ // id RqcID = (id) aggAst.get('Repair_Quotation_Id__c');
+ // if (dTDate >= dSDate && dTDate <= dEDate) {
+
+ // mc.Sum_repair_price__c += aggAst.get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_Price')));
+ // mc.Repair_Cost_Sum__c += aggAst.get('sum_PricePr') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_PricePr')));
+ // }
+ // }
+
+ //娌℃湁SAP鐨勫惊鐜眹鎬�
+ //for (AggregateResult aggAst : [
+ // select SUM(Repair_List_Price_formula__c) sum_Price,
+ // SUM(Repair_cost__c) sum_PricePr,
+ // Maintenance_Contract__c,
+ // Maintenance_Contract__r.Contract_Start_Date__c,
+ // Maintenance_Contract__r.Contract_End_Date__c,
+ // Failure_Occurrence_Date__c,
+ // Repair_Quotation_Id__c
+ // from Repair__c
+ // where Maintenance_Contract__c != null
+ // and Status2__c !='00.鍒犻櫎'
+ // and Repair_Quotation_Id__c=null
+ // group by Maintenance_Contract__c,Maintenance_Contract__r.Contract_Start_Date__c,Maintenance_Contract__r.Contract_End_Date__c,
+ // Failure_Occurrence_Date__c,Repair_Quotation_Id__c
+ //]) {
+ // Id mcid = (Id) aggAst.get('Maintenance_Contract__c');
+ // Maintenance_Contract__c mc = updateMC.get(mcid);
+ // Date dTDate = Date.valueOf(aggAst.get('Failure_Occurrence_Date__c'));
+ // Date dSDate = Date.valueOf(aggAst.get('Contract_Start_Date__c'));
+ // Date dEDate = Date.valueOf(aggAst.get('Contract_End_Date__c'));
+ // id RqcID = (id) aggAst.get('Repair_Quotation_Id__c');
+ // if (dTDate >= dSDate && dTDate <= dEDate) {
+
+ // mc.Sum_repair_price__c += aggAst.get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_Price')));
+ // mc.Repair_Cost_Sum__c += aggAst.get('sum_PricePr') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_PricePr')));
+ // }
+ //}
+ /******************************* HWAG-AV2C67 2018/1/17 END ******************************/
+
+
+ }
+ //and (CutPrice_Reason__c='缁翠慨鍚堝悓' or CutPrice_Reason__c='缁翠慨鍚堝悓锛屽椁愭姌鎵�'or CutPrice_Reason__c='钀ヤ笟瀵瑰簲锛岀淮淇悎鍚�')
+
+ // LHJ 20190712 HWAG-BDH9V5 Start
+ global void finish(Database.BatchableContext BC) {
+ // 浠婂洖銇倓銈嬨亾銇ㄣ仾銇勩仹銇�
+ sendFieldEmail();
+ }
+
+ private void sendFieldEmail() {
+ PretechBatchEmailUtil be = new PretechBatchEmailUtil();
+ String[] toList = new String[] {UserInfo.getUserEmail()};
+ String title = '缁翠慨鍚堝悓鏇存柊澶辫触';
+ String[] ccList = new String[] {};
+ if(System.Test.isRunningTest()){
+ be.successMail('', 1);
+ }
+ if (emailMessages.size() > 0) {
+ be.failedMail(toList, ccList, title,
+ String.join(this.emailMessages, '\n'),
+ totalCount, totalCount - failedCount, failedCount,'',false);
+ be.send();
}
}
-
- // LD 20200721 澶囧搧鍑哄�熷彲瑙嗗寲绠$悊 Start
-
-
- //鏍规嵁缁翠慨鍚堝悓ID鏌ヨ鎵�鏈夊搴旂淮淇悎鍚�
- List<Maintenance_Contract__c> conList = [SELECT Id,Name,
- RentalRelatedCnt__c,
- NoRentalRelatedCnt__c,
- RentalRelatedRepairCnt__c,
- RentalRelatedApplyCnt__c,
- RentalRelatedSupplyCnt__c,
- NoRentalRelatedRepairCnt__c,
- NoRentalRelatedApplyCnt__c,
- NoRentalRelatedSupplyCnt__c
- FROM Maintenance_Contract__c
- WHERE
- Id IN :mcList];
-
- //鏍规嵁缁翠慨鍚堝悓ID鏌ヨ瀵瑰簲缁翠慨淇濇湁璁惧
- List<Maintenance_Contract_Asset__c> assList =
- [SELECT Id,
- Asset__r.EGFlg_fromContract_asset__c
- , Maintenance_Contract__c
- FROM Maintenance_Contract_Asset__c
- WHERE Maintenance_Contract__c = :mcList];
- newRepairList = [
- select id, EquipmentGuaranteeFlg_Asset__c,
- if_Rental_Apply__c, Offer_Rental_New__c,Maintenance_Contract__c
- from Repair__c
- where Maintenance_Contract__c in: mcList
- and Status2__c !='00.鍒犻櫎'
- and Status2__c !='00.鍙栨秷'
- order by Maintenance_Contract__c
-
- ];
-
-
- //缁翠慨鍚堝悓
- if (conList != null && conList.size() > 0) {
- for (Maintenance_Contract__c con : conList) {
-
- if(updateMc.containsKey(con.Id)){
- con = updateMc.get(con.Id);
- }
-
- con.RentalRelatedCnt__c = 0;
- con.NoRentalRelatedCnt__c = 0;
- con.RentalRelatedRepairCnt__c = 0;
- con.RentalRelatedApplyCnt__c = 0;
- con.RentalRelatedSupplyCnt__c = 0;
- con.NoRentalRelatedRepairCnt__c = 0;
- con.NoRentalRelatedApplyCnt__c = 0;
- con.NoRentalRelatedSupplyCnt__c = 0;
-
- if (assList != null && assList.size() > 0) {
- for (Maintenance_Contract_Asset__c ass : assList) {
- System.debug(ass.Maintenance_Contract__c+'====ass.CurrentContract__c');
- System.debug(con.Id+'====con.Id');
- if(ass.Maintenance_Contract__c == con.Id){
- if (ass.Asset__r.EGFlg_fromContract_asset__c == true) {
- con.RentalRelatedCnt__c = con.RentalRelatedCnt__c + 1;
- }else{
- con.NoRentalRelatedCnt__c = con.NoRentalRelatedCnt__c + 1;
- }
- updateMC.put(con.Id,con);
- }
- }
- }
-
- if (newRepairList != null && newRepairList.size() > 0) {
- for (Repair__c repc : newRepairList) {
- if( con.Id == repc.Maintenance_Contract__c){
- //澶囧搧纭繚鎻愪緵閫夋涓篢rue
- if(repc.EquipmentGuaranteeFlg_Asset__c == true){
- con.RentalRelatedRepairCnt__c = con.RentalRelatedRepairCnt__c + 1;
- //鏄惁鐢宠澶囧搧閫夋涓篢rue
- if(repc.if_Rental_Apply__c == true){
- con.RentalRelatedApplyCnt__c = con.RentalRelatedApplyCnt__c + 1;
- }
- //鏄惁鎻愪緵澶囧搧閫夋涓篢rue
- if(repc.Offer_Rental_New__c == true){
- con.RentalRelatedSupplyCnt__c = con.RentalRelatedSupplyCnt__c + 1;
- }
- }
- //澶囧搧纭繚鎻愪緵瀵硅薄涓篎alse
- if(repc.EquipmentGuaranteeFlg_Asset__c == false){
- con.NoRentalRelatedRepairCnt__c = con.NoRentalRelatedRepairCnt__c + 1;
- //鏄惁鐢宠澶囧搧閫夋涓篢rue
- if(repc.if_Rental_Apply__c == true){
- con.NoRentalRelatedApplyCnt__c = con.NoRentalRelatedApplyCnt__c + 1;
- }
- //鏄惁鎻愪緵澶囧搧閫夋涓篢rue
- if(repc.Offer_Rental_New__c == true){
- con.NoRentalRelatedSupplyCnt__c = con.NoRentalRelatedSupplyCnt__c + 1;
- }
- }
- updateMC.put(con.Id,con);
- }
- }
- }
- }
- }
-
- // LD 20200721 澶囧搧鍑哄�熷彲瑙嗗寲绠$悊 End
- if (updateMC.size() > 0) {
- update updateMC.values();
- }
- } catch (Exception e) {
- Database.rollback(sp);
- emailMessages.add(e.getMessage());
- System.debug(emailMessages);
- failedCount += mcList.size();
- System.debug(failedCount);
- }
- // LHJ 20190712 HWAG-BDH9V5 End
-
-
-
-
- //for (SObject sobj : mcList) {
- // Maintenance_Contract__c mc = new Maintenance_Contract__c(Id=String.valueOf(sobj.get('Maintenance_Contract__c')));
- // initMC(mc);
- // updateMC.put(mc.Id, mc);
- // mcids.add(String.valueOf(sobj.get('Maintenance_Contract__c')));
- //}
- //绛涢�夊嚭闇�瑕佹洿鏂扮殑鏁版嵁
- //List<Maintenance_Contract__c> NeedUpdate = new List<Maintenance_Contract__c>();
- // 淇悊 淇悊閲戦
- // 瑕佸垽鏂槸鍚AP
- //宸茬粡SAP鐨勫惊鐜眹鎬�
- //for (AggregateResult aggAst : [
- // select SUM(Repair_List_Price_formula__c) sum_Price,
- // SUM(Repair_cost__c) sum_PricePr,
- // Maintenance_Contract__c,
- // Maintenance_Contract__r.Contract_Start_Date__c,
- // Maintenance_Contract__r.Contract_End_Date__c,
- // Failure_Occurrence_Date__c,
- // Repair_Quotation_Id__r.LatestQuotationDate__c,
- // Repair_Quotation_Id__c
- // from Repair__c
- // where Maintenance_Contract__c != null
- // and Status2__c !='00.鍒犻櫎'
- // and Repair_Quotation_Id__c !=null
- // and (CutPrice_Reason__c='缁翠慨鍚堝悓' or CutPrice_Reason__c='濂楅鎶樻墸,缁翠慨鍚堝悓'or CutPrice_Reason__c='钀ヤ笟瀵瑰簲,缁翠慨鍚堝悓')
- // group by Maintenance_Contract__c,Maintenance_Contract__r.Contract_Start_Date__c,Maintenance_Contract__r.Contract_End_Date__c,
- // Failure_Occurrence_Date__c,Repair_Quotation_Id__r.LatestQuotationDate__c,Repair_Quotation_Id__c
- // ]) {
- // Id mcid = (Id) aggAst.get('Maintenance_Contract__c');
- // Maintenance_Contract__c mc = updateMC.get(mcid);
- // Date dRDate = Date.valueOf(aggAst.get('LatestQuotationDate__c'));
- // Date dTDate = Date.valueOf(aggAst.get('Failure_Occurrence_Date__c'));
- // Date dSDate = Date.valueOf(aggAst.get('Contract_Start_Date__c'));
- // Date dEDate = Date.valueOf(aggAst.get('Contract_End_Date__c'));
- // id RqcID = (id) aggAst.get('Repair_Quotation_Id__c');
- // if (dTDate >= dSDate && dTDate <= dEDate) {
-
- // mc.Sum_repair_price__c += aggAst.get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_Price')));
- // mc.Repair_Cost_Sum__c += aggAst.get('sum_PricePr') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_PricePr')));
- // }
+ // LHJ 20190712 HWAG-BDH9V5 End
+ /******************************* HWAG-AV2C67 2018/1/17 START ******************************/
+ // private void initMC(Maintenance_Contract__c mc) {
+ // mc.Sum_repair_price__c = 0.0;
+ // mc.Repair_Cost_Sum__c =0.0;
// }
- //娌℃湁SAP鐨勫惊鐜眹鎬�
- //for (AggregateResult aggAst : [
- // select SUM(Repair_List_Price_formula__c) sum_Price,
- // SUM(Repair_cost__c) sum_PricePr,
- // Maintenance_Contract__c,
- // Maintenance_Contract__r.Contract_Start_Date__c,
- // Maintenance_Contract__r.Contract_End_Date__c,
- // Failure_Occurrence_Date__c,
- // Repair_Quotation_Id__c
- // from Repair__c
- // where Maintenance_Contract__c != null
- // and Status2__c !='00.鍒犻櫎'
- // and Repair_Quotation_Id__c=null
- // group by Maintenance_Contract__c,Maintenance_Contract__r.Contract_Start_Date__c,Maintenance_Contract__r.Contract_End_Date__c,
- // Failure_Occurrence_Date__c,Repair_Quotation_Id__c
- //]) {
- // Id mcid = (Id) aggAst.get('Maintenance_Contract__c');
- // Maintenance_Contract__c mc = updateMC.get(mcid);
- // Date dTDate = Date.valueOf(aggAst.get('Failure_Occurrence_Date__c'));
- // Date dSDate = Date.valueOf(aggAst.get('Contract_Start_Date__c'));
- // Date dEDate = Date.valueOf(aggAst.get('Contract_End_Date__c'));
- // id RqcID = (id) aggAst.get('Repair_Quotation_Id__c');
- // if (dTDate >= dSDate && dTDate <= dEDate) {
-
- // mc.Sum_repair_price__c += aggAst.get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_Price')));
- // mc.Repair_Cost_Sum__c += aggAst.get('sum_PricePr') == null ? 0 : Decimal.valueOf(String.valueOf(aggAst.get('sum_PricePr')));
- // }
- //}
- /******************************* HWAG-AV2C67 2018/1/17 END ******************************/
-
-
- }
- //and (CutPrice_Reason__c='缁翠慨鍚堝悓' or CutPrice_Reason__c='缁翠慨鍚堝悓锛屽椁愭姌鎵�'or CutPrice_Reason__c='钀ヤ笟瀵瑰簲锛岀淮淇悎鍚�')
+ // public class AggregateResultIterator implements Iterator<AggregateResult> {
+ // AggregateResult [] results {get;set;}
+ // // tracks which result item is returned
+ // Integer index {get; set;}
+
+ // public AggregateResultIterator() {
+ // index = 0;
+ // // Fire query here to load the results
+ // Date tdate = Date.today();
+ // Date before2day = tdate.addDays(-2);
+ // Date sdate = tdate.addDays(-30);
+ // Datetime before2dayTime = Datetime.newInstance(before2day, Time.newInstance(0, 0, 0, 0));
+ // results = [
+ // Select Maintenance_Contract__c
+ // From Repair__c
+ // Where Maintenance_Contract__c != null
+
+ // GROUP BY Maintenance_Contract__c
- // LHJ 20190712 HWAG-BDH9V5 Start
- global void finish(Database.BatchableContext BC) {
- // 浠婂洖銇倓銈嬨亾銇ㄣ仾銇勩仹銇�
- sendFieldEmail();
- }
-
- private void sendFieldEmail() {
- PretechBatchEmailUtil be = new PretechBatchEmailUtil();
- String[] toList = new String[] {UserInfo.getUserEmail()};
- String title = '缁翠慨鍚堝悓鏇存柊澶辫触';
- String[] ccList = new String[] {};
- if(System.Test.isRunningTest()){
- be.successMail('', 1);
- }
- if (emailMessages.size() > 0) {
- be.failedMail(toList, ccList, title,
- String.join(this.emailMessages, '\n'),
- totalCount, totalCount - failedCount, failedCount,'',false);
- be.send();
- }
- }
- // LHJ 20190712 HWAG-BDH9V5 End
- /******************************* HWAG-AV2C67 2018/1/17 START ******************************/
- // private void initMC(Maintenance_Contract__c mc) {
- // mc.Sum_repair_price__c = 0.0;
- // mc.Repair_Cost_Sum__c =0.0;
- // }
-
- // public class AggregateResultIterator implements Iterator<AggregateResult> {
- // AggregateResult [] results {get;set;}
- // // tracks which result item is returned
- // Integer index {get; set;}
-
- // public AggregateResultIterator() {
- // index = 0;
- // // Fire query here to load the results
- // Date tdate = Date.today();
- // Date before2day = tdate.addDays(-2);
- // Date sdate = tdate.addDays(-30);
- // Datetime before2dayTime = Datetime.newInstance(before2day, Time.newInstance(0, 0, 0, 0));
- // results = [
- // Select Maintenance_Contract__c
- // From Repair__c
- // Where Maintenance_Contract__c != null
-
- // GROUP BY Maintenance_Contract__c
-
- // ];
- // }
+ // ];
+ // }
+
+ // public boolean hasNext(){
+ // return results != null && !results.isEmpty() && index < results.size();
+ // }
+
+ // public AggregateResult next(){
+ // return results[index++];
+ // }
+ //}
- // public boolean hasNext(){
- // return results != null && !results.isEmpty() && index < results.size();
- // }
-
- // public AggregateResult next(){
- // return results[index++];
- // }
- //}
-
- //public class AggregateResultIterable implements Iterable<AggregateResult> {
- // public Iterator<AggregateResult> Iterator(){
- // return new AggregateResultIterator();
- // }
- //}
- /******************************* HWAG-AV2C67 2018/1/17 END ******************************/
-}
\ No newline at end of file
+ //public class AggregateResultIterable implements Iterable<AggregateResult> {
+ // public Iterator<AggregateResult> Iterator(){
+ // return new AggregateResultIterator();
+ // }
+ //}
+ /******************************* HWAG-AV2C67 2018/1/17 END ******************************/
+ }
\ No newline at end of file
diff --git a/force-app/main/default/triggers/Repair.trigger b/force-app/main/default/triggers/Repair.trigger
index e287d0f..99fd9e5 100644
--- a/force-app/main/default/triggers/Repair.trigger
+++ b/force-app/main/default/triggers/Repair.trigger
@@ -421,10 +421,8 @@
if (Trigger.isBefore && Trigger.isUpdate) {
for (Repair__c repair: Trigger.new) {
if (repair.Limit_Price__c ==true ){
- if (repair.Agreed_Date__c!=null &&(repair.Remaining_Amount__c-repair.Usage_Ratio_Price__c)<=0){
+ if (repair.Agreed_Date__c!=null && repair.Remaining_Amount__c >=0 &&(repair.Remaining_Amount__c-repair.Usage_Ratio_Price__c)<=0){
repair.ZFLAG_SX__c = true;
- }else{
- repair.ZFLAG_SX__c = false;
}
}
}
--
Gitblit v1.9.1