From b9055688b13a23f8e445de2bc3d5d0d2b85fec30 Mon Sep 17 00:00:00 2001
From: 李彤 <litong@prec-tech.com>
Date: 星期三, 17 五月 2023 19:27:19 +0800
Subject: [PATCH] 包含超声

---
 force-app/main/default/classes/PCLLostReportController.cls |   66 +++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/force-app/main/default/classes/PCLLostReportController.cls b/force-app/main/default/classes/PCLLostReportController.cls
index f806479..3d47d08 100644
--- a/force-app/main/default/classes/PCLLostReportController.cls
+++ b/force-app/main/default/classes/PCLLostReportController.cls
@@ -20,6 +20,8 @@
 	public integer secondNum {get; set;}
 	// add tcm 20211122 end
 
+	public Decimal InclusionUltrasound {get; set;}     //20230506 lt DB202304618804  鍖呭惈瓒呭0 add
+
 
 	// 绔炰簤瀵规墜瀵圭収鍏崇郴琛紝key鏄搧鐗屽悕瀛楋紝value鏄疘D
 	public map<string,id> CompetitionMap;
@@ -97,6 +99,8 @@
 			 Lost_reason_main__c,
 			 Lost_Reason_Sub__c,Lost_By_Company__c,
 			 LostTotalAmount__c,LostType__c,
+			 TotalAmountLost__c, //20230215 lt DB202302247719
+			 InclusionUltrasound__c, //20230506 lt DB202304618804  鍖呭惈瓒呭0
 			 Report_Status__c,Sales_assistant__c,
 			 Opportunity__c, Opportunity__r.Sales_assistant_ID__c,
 			 Opportunity__r.Sales_manager_departmentID__c,
@@ -109,6 +113,9 @@
 				pageStatus = null;
 				return;
 			}
+
+			InclusionUltrasound = lostReportList[0].InclusionUltrasound__c; //20230506 lt DB202304618804  鍖呭惈瓒呭0
+
 			lostReportList[0].Sales_assistant__c =
 				lostReportList[0].Opportunity__r.Sales_assistant_ID__c;
 			lostReportList[0].Manager_sales__c =
@@ -128,6 +135,7 @@
 			list<PCLLostBrand__c> selectlostBrandList =
 			[
 				select id, LostPrice__c, Lost_By_Company__c,
+				LostPrices_ThousandY__c,  //20230215 lt DB202302247719
 				Lost_reason_main__c,Lost_Reason_Sub__c,Name,Agency__c, AgencyMannual__c,
 				// ProductCategory__c,ProductClass__c,
 				Lost_cancel_report__c,Lost_By_Company_Mannual__c,
@@ -152,7 +160,6 @@
 					system.debug('check products:'+ (templostBrand.PCLLostBrandProduct__r != null) + '|' + (templostBrand.PCLLostBrandProduct__r.size() > 0));
 					if (templostBrand.PCLLostBrandProduct__r != null && templostBrand.PCLLostBrandProduct__r.size() > 0) {
 						for( PCLLostProduct__c tempProduct: templostBrand.PCLLostBrandProduct__r) {
-
 							tempProductList.add(new PCLLostProducts(productCount,tempProduct));
 							productCount++;
 						}
@@ -165,6 +172,7 @@
 							} else {
 								newProduct.LostProductss.LostBrandName__c = templostBrand.Lost_By_Company__c;
 							}
+							system.debug('aaa4+++'+templostBrand.Lost_By_Company_Mannual__c);
 						tempProductList.add(newProduct);
 						productCount++;
 					}
@@ -203,7 +211,12 @@
 		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
 		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
 		string brandName = tempBrand.lostBrand.Lost_By_Company__c;
-		tempBrand.lostBrand.Lost_By_Company_Mannual__c = null;
+		// fy SWAG-CCC6F6 start
+		if(!'鍏朵粬'.equals(tempBrand.lostBrand.Lost_By_Company_Mannual__c)){
+			tempBrand.lostBrand.Lost_By_Company_Mannual__c = null;
+		}
+		system.debug('aaa5+++'+tempBrand.lostBrand.Lost_By_Company_Mannual__c);
+		// fy SWAG-CCC6F6 end
 		// ID compID = CompetitionMap.get(brandName);
 		for(PCLLostProducts tempLostProduct : tempBrand.LostProducts ) {
 			// test
@@ -227,19 +240,21 @@
 		for(PCLLostProducts tempLostProduct : tempBrand.LostProducts ) {
 			// test
 			// tempLostProduct.LostProductss.Competitor__c = compID;
+			system.debug('aaaa3++'+brandNameMannual);
 			if ('鍏朵粬'.equals(brandName) && brandNameMannual != null && !''.equals(brandNameMannual)) {
 				tempLostProduct.LostProductss.LostBrandName__c = brandNameMannual;
-				tempLostProduct.LostProductss.LostProduct__c = null;
-				tempLostProduct.LostProductss.LostProductMannual__c = null;
-				tempLostProduct.LostProductss.Quantity__c = null;
-				tempLostProduct.LostProductss.ProductClass__c = null;
-				tempLostProduct.LostProductss.ProductCategory__c = null;
-				tempLostProduct.bool=false;
+				// tempLostProduct.LostProductss.LostProduct__c = null;
+				// tempLostProduct.LostProductss.LostProductMannual__c = null;
+				// tempLostProduct.LostProductss.Quantity__c = null;
+				// tempLostProduct.LostProductss.ProductClass__c = null;
+				// tempLostProduct.LostProductss.ProductCategory__c = null;
+				// tempLostProduct.bool=false;
 			}
 		}
 	}
 	// 淇濆瓨
 	public PageReference save(){
+
 		if(!DataCheck()) {
 			return null;
 		}
@@ -272,11 +287,16 @@
 			dataCheck = false;
 		}
 		for(LostBrand tempLostBrand : LostReport.LostBrands ) {
+			system.debug('aaaa1++'+tempLostBrand.lostBrand.Lost_By_Company_Mannual__c);
 			if(string.isblank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
 				tempLostBrand.lostBrand.Lost_By_Company__c.addError('璇峰~鍐欏け鍗曞搧鐗岋紒');
 				dataCheck = false;
-			}
-
+			}// fy SWAG-CCC6F6 start
+			else if('鍏朵粬'.equals(tempLostBrand.lostBrand.Lost_By_Company__c)&&string.isblank(tempLostBrand.lostBrand.Lost_By_Company_Mannual__c)){
+				tempLostBrand.lostBrand.Lost_By_Company_Mannual__c.addError('璇峰~鍐欏け鍗曞搧鐗岋紙鎵嬪姩锛夛紒');
+				dataCheck = false;
+			}// fy SWAG-CCC6F6 end
+			system.debug('aaaa2++'+tempLostBrand.lostBrand.Lost_By_Company_Mannual__c);
 			if(tempLostBrand.lostBrand.LostPrice__c == null) {
 				tempLostBrand.lostBrand.LostPrice__c.addError('澶卞崟閲戦蹇呭~锛�');
 				dataCheck = false;
@@ -322,6 +342,15 @@
 				}
 				// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
 				// update tcm 20211123 end
+				// 20230418 ljh DB202304320022 start
+				String LostBrandNameS = tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'?tempLostBrand.lostBrand.Lost_By_Company__c:tempLostBrand.lostBrand.Lost_By_Company_Mannual__c;
+				String LostBrandName = temlostProduct.LostProductss.LostBrandName__c;
+				if(LostBrandNameS != LostBrandName){
+					temlostProduct.LostProductss.LostBrandName__c.addError('澶卞崟鍝佺墝鍚嶄笉涓�鑷达紝璇风‘璁�');
+					dataCheck = false;
+				}
+				// 20230418 ljh DB202304320022 end
+				
 			}
 			// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
 			if (productCount == 0 && tempLostBrand.LostProducts != null && tempLostBrand.LostProducts.size() > 0) {
@@ -361,6 +390,7 @@
 			// 璁剧疆璁板綍绫诲瀷
 			LostReport.lostReport.recordTypeID  =  LostReport.lostReport.LostType__c== '澶卞崟'?Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_Lost_report').getRecordTypeId() : Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_PartLost_report').getRecordTypeId();
 			LostReport.lostReport.LostTotalAmount__c    = 0;
+			LostReport.lostReport.TotalAmountLost__c    = 0;  //20230215 lt DB202302247719
 			LostReport.lostReport.of_lost_system_processor__c   = 0;
 			LostReport.lostReport.Lost_reason_main__c = null;
 			LostReport.lostReport.Lost_Reason_Sub__c  = null;
@@ -368,6 +398,16 @@
 			for(LostBrand tempLostBrand : LostReport.LostBrands) {
 				if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
 					LostReport.lostReport.LostTotalAmount__c += tempLostBrand.lostBrand.LostPrice__c;
+					//20230215 lt DB202302247719  start 
+					Decimal med = tempLostBrand.lostBrand.LostPrice__c/1.13/1000;
+					Decimal med1 = med.setScale(2);
+					// System.debug('---lt123涓嶅惈绋庢暟鍊�(浜哄伐)Decimal---'+med);
+					// System.debug('---lt123涓嶅惈绋庢暟鍊�(浜哄伐)Decimal涓や綅灏忔暟---'+med1);
+					LostReport.lostReport.TotalAmountLost__c += med1;
+					//LostReport.lostReport.TotalAmountLost__c += tempLostBrand.lostBrand.LostPrices_ThousandY__c;  //20230215 lt DB202302247719
+					// LostReport.lostReport.TotalAmountLost__c += tempLostBrand.lostBrand.LostPrice__c/1.13/1000;  //20230215 lt DB202302247719
+					//20230215 lt DB202302247719  en
+
 					LostReport.lostReport.Lost_reason_main__c =
 						LostReport.lostReport.Lost_reason_main__c == null
 						? tempLostBrand.lostBrand.Lost_reason_main__c
@@ -476,6 +516,7 @@
 			LostReport.lostReport = templostReport;
 			LostReport.LostBrands = tempBrands;
 			// 杩欓噷闇�瑕佸啓涓�浜涙姤閿欎俊鎭�
+			System.debug('---lt123---'+ex.getLineNumber());
 			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
 			return false;
 		}
@@ -548,7 +589,10 @@
 		system.debug('brandNo:'+brandNo);
 		LostBrand tempLostBrand = LostReport.LostBrands.get(brandNo);
 		// PCLLostProduct__c plp = new PCLLostProduct__c(Competitor__c=CompetitionMap.get(LostReport.LostBrands[brandNo].lostBrand.Lost_By_Company__c));
-		string brandName = tempLostBrand.lostBrand.Lost_By_Company__c;
+		// 20230418 ljh DB202304320022 start
+		// string brandName = tempLostBrand.lostBrand.Lost_By_Company__c;
+		string brandName = tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'?tempLostBrand.lostBrand.Lost_By_Company__c:tempLostBrand.lostBrand.Lost_By_Company_Mannual__c;		
+		// 20230418 ljh DB202304320022 end
 		PCLLostProduct__c plp = new PCLLostProduct__c();
 		plp.LostBrandName__c = brandName;
 		tempLostBrand.LostProducts.add(new PCLLostProducts(tempLostBrand.LostProducts.size(),plp));

--
Gitblit v1.9.1