From 196df4d4bf1941546d349cadbf343655578ec280 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期三, 13 九月 2023 15:05:56 +0800
Subject: [PATCH] sit期间修改

---
 force-app/main/default/classes/PCLLostReportController.cls | 1196 +++++++++++++++++++++++++++++++----------------------------
 1 files changed, 632 insertions(+), 564 deletions(-)

diff --git a/force-app/main/default/classes/PCLLostReportController.cls b/force-app/main/default/classes/PCLLostReportController.cls
index bebafa5..bfe5c1d 100644
--- a/force-app/main/default/classes/PCLLostReportController.cls
+++ b/force-app/main/default/classes/PCLLostReportController.cls
@@ -19,645 +19,713 @@
 	public integer topNum {get; set;}
 	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;
 	public PCLLostReportController(ApexPages.StandardController controller) {
-		this();
+	  this();
 	}
 	public PCLLostReportController(){
-		oppId =
-			ApexPages.currentPage().getParameters().get('oppId') == null ? ''
-			: ApexPages.currentPage().getParameters().get('oppId');
-		lostReportId =
-			ApexPages.currentPage().getParameters().get('Id') == null ? ''
-			: ApexPages.currentPage().getParameters().get('Id');
-		pageStatus =
-			ApexPages.currentPage().getParameters().get('pageStatus') == null ? ''
-			: ApexPages.currentPage().getParameters().get('pageStatus');
-		lostType =
-			ApexPages.currentPage().getParameters().get('lostType') == null ? ''
-			: ApexPages.currentPage().getParameters().get('lostType');
-		submitFlag = ApexPages.currentPage().getParameters().get('submitFlag') == null ? ''
-		    : ApexPages.currentPage().getParameters().get('submitFlag');
-
+	  oppId =
+		ApexPages.currentPage().getParameters().get('oppId') == null ? ''
+		: ApexPages.currentPage().getParameters().get('oppId');
+	  lostReportId =
+		ApexPages.currentPage().getParameters().get('Id') == null ? ''
+		: ApexPages.currentPage().getParameters().get('Id');
+	  pageStatus =
+		ApexPages.currentPage().getParameters().get('pageStatus') == null ? ''
+		: ApexPages.currentPage().getParameters().get('pageStatus');
+	  lostType =
+		ApexPages.currentPage().getParameters().get('lostType') == null ? ''
+		: ApexPages.currentPage().getParameters().get('lostType');
+	  submitFlag = ApexPages.currentPage().getParameters().get('submitFlag') == null ? ''
+		  : ApexPages.currentPage().getParameters().get('submitFlag');
+  
 	}
 	// 鍒濆鍖�
 	public void init(){
-		if(string.isblank(pageStatus)) {
-			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '椤甸潰鍑洪敊锛岃鍒锋柊鍚庨噸璇曪紒'));
-			// 杩欓噷闇�瑕佹姤閿欐病鏈変紶鍙傛暟
-			return;
+	  if(string.isblank(pageStatus)) {
+		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '椤甸潰鍑洪敊锛岃鍒锋柊鍚庨噸璇曪紒'));
+		// 杩欓噷闇�瑕佹姤閿欐病鏈変紶鍙傛暟
+		return;
+	  }
+	  else if(pageStatus.equals('Create')) {
+		if(string.isBlank(oppId)) {
+		  // 杩欓噷鎶ラ敊鍒涘缓鏃跺�欏繀椤绘湁璇环
+		  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍒涘缓澶卞崟鎶ュ憡鏃讹紝璇烽噸璇环椤甸潰鍒涘缓'));
+		  return;
 		}
-		else if(pageStatus.equals('Create')) {
-			if(string.isBlank(oppId)) {
-				// 杩欓噷鎶ラ敊鍒涘缓鏃跺�欏繀椤绘湁璇环
-				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍒涘缓澶卞崟鎶ュ憡鏃讹紝璇烽噸璇环椤甸潰鍒涘缓'));
-				return;
-			}
-			list<opportunity> opplist =
-			[select id,Name,
-			 Sales_assistant_ID__c,
-			 Sales_manager_departmentID__c,Sales_owner_buchangID__c
-			 from opportunity
-			 where id =: oppId
-			            limit 1];
-			if( opplist.size() == 0) {
-				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄦ病鏈夎浠风殑鏌ョ湅鏉冮檺锛屾棤娉曞垱寤哄け鍗曟姤鍛婏紒'));
-				pageStatus = null;
-				return;
-			}
-			Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe();
-			if( !s.isCreateable()) {
-				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄤ笉鑳藉垱寤哄け鍗�/閮ㄥ垎澶卞崟鎶ュ憡锛�'));
-				return;
-			}
-			Lost_cancel_report__c tempLostReport =
-				new Lost_cancel_report__c(LostType__c= lostType,
-				                          Opportunity__c = oppId,
-				                          Sales_assistant__c = opplist[0].Sales_assistant_ID__c,
-				                          Manager_sales__c = opplist[0].Sales_manager_departmentID__c,
-				                          Buchang_sales__c = opplist[0].Sales_owner_buchangID__c,
-				                          Submit_Day__c = date.today(),
-				                          Report_Status__c = '鑽夋');
-			LostReport = new LostReport(tempLostReport);
-			brandCount = 1;
+		list<opportunity> opplist =
+		[select id,Name,
+		 Sales_assistant_ID__c,
+		 Sales_manager_departmentID__c,Sales_owner_buchangID__c
+		 from opportunity
+		 where id =: oppId
+					limit 1];
+		if( opplist.size() == 0) {
+		  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄦ病鏈夎浠风殑鏌ョ湅鏉冮檺锛屾棤娉曞垱寤哄け鍗曟姤鍛婏紒'));
+		  pageStatus = null;
+		  return;
 		}
-		else if(pageStatus.equals('View') ||  pageStatus.equals('Edit')) {
-			system.debug('edit1');
-			if(string.isBlank(lostReportId)) {
-				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒'));
-				pageStatus = null;
-				return;
-			}
-			system.debug('edit2');
-			list<Lost_cancel_report__c> lostReportList =
-			[select id,of_lost_system_processor__c,
-			 Lost_reason_main__c,
-			 Lost_Reason_Sub__c,Lost_By_Company__c,
-			 LostTotalAmount__c,LostType__c,
-			 Report_Status__c,Sales_assistant__c,
-			 Opportunity__c, Opportunity__r.Sales_assistant_ID__c,
-			 Opportunity__r.Sales_manager_departmentID__c,
-			 Manager_sales__c,recordtypeid,recordtype.DeveloperName
-			 from Lost_cancel_report__c
-			 where id =: lostReportId limit 1];
-
-			if(lostReportList.size() == 0) {
-				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒'));
-				pageStatus = null;
-				return;
-			}
-			lostReportList[0].Sales_assistant__c =
-				lostReportList[0].Opportunity__r.Sales_assistant_ID__c;
-			lostReportList[0].Manager_sales__c =
-				lostReportList[0].Opportunity__r.Sales_manager_departmentID__c;
-			if(lostReportList[0].recordtype.DeveloperName.equals('PCL_Lost_report')) {
-				lostReportList[0].LostType__c ='澶卞崟';
-
-			}else if(lostReportList[0].recordtype.DeveloperName.equals('PCL_PartLost_report')) {
-				lostReportList[0].LostType__c ='閮ㄥ垎澶卞崟';
-			}
-			// 鏉冮檺锛屽鏋滃綋鍓嶇姸鎬佷笉鏄崏妗堜腑锛岄偅涔堥渶瑕佽烦杞埌鍙椤甸潰
-			if(!'鑽夋'.equals(lostReportList[0].Report_Status__c) && userinfo.getProfileId() != (ID) '00e10000000Y3o5AAC') {
-				pageStatus = 'View';
-			}
-			oppId = lostReportList[0].Opportunity__c;
-			system.debug('edit3');
-			list<PCLLostBrand__c> selectlostBrandList =
-			[
-				select id, LostPrice__c, Lost_By_Company__c,
-				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,
-				( select id,PCLLostBrand__c,LostProduct__c,
-				  LostProductMannual__c,            //SWAG-C6P9PX lt 20210913 add
-				  ProductCategory__c,ProductClass__c, //add tcm 20211123
-				  Quantity__c,Name, LostBrandName__c 
-				  from PCLLostBrand__c.PCLLostBrandProduct__r)
-				from PCLLostBrand__c
-				where Lost_cancel_report__c =: lostReportId
-			];
-			if(selectlostBrandList.size() == 0 ) {
-				LostReport = new LostReport(lostReportList[0]);
-				brandCount = 1;
-			}else{
-				system.debug('edit4:'+selectlostBrandList[0]);
-				brandCount = 0;
-				list<LostBrand> LostBrandList = new list<LostBrand>();
-				for(PCLLostBrand__c templostBrand : selectlostBrandList) {
-					list<PCLLostProducts> tempProductList = new list<PCLLostProducts>();
-					integer productCount = 0;
-					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++;
-						}
-					} else {
-						PCLLostProducts newProduct = new PCLLostProducts();
-						if ('鍏朵粬'.equals(templostBrand.Lost_By_Company__c) && 
-							templostBrand.Lost_By_Company_Mannual__c != null && 
-							!''.equals(templostBrand.Lost_By_Company_Mannual__c)) {
-								newProduct.LostProductss.LostBrandName__c = templostBrand.Lost_By_Company_Mannual__c;
-							} else {
-								newProduct.LostProductss.LostBrandName__c = templostBrand.Lost_By_Company__c;
-							}
-							system.debug('aaa4+++'+templostBrand.Lost_By_Company_Mannual__c);
-						tempProductList.add(newProduct);
-						productCount++;
-					}
-					LostBrandList.add( new LostBrand(brandCount,tempProductList, templostBrand));
-					brandCount++;
+		Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe();
+		if( !s.isCreateable()) {
+		  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄤ笉鑳藉垱寤哄け鍗�/閮ㄥ垎澶卞崟鎶ュ憡锛�'));
+		  return;
+		}
+		Lost_cancel_report__c tempLostReport =
+		  new Lost_cancel_report__c(LostType__c= lostType,
+									Opportunity__c = oppId,
+									Sales_assistant__c = opplist[0].Sales_assistant_ID__c,
+									Manager_sales__c = opplist[0].Sales_manager_departmentID__c,
+									Buchang_sales__c = opplist[0].Sales_owner_buchangID__c,
+									Submit_Day__c = date.today(),
+									Report_Status__c = '鑽夋');
+		LostReport = new LostReport(tempLostReport);
+		brandCount = 1;
+	  }
+	  else if(pageStatus.equals('View') ||  pageStatus.equals('Edit')) {
+		system.debug('edit1');
+		if(string.isBlank(lostReportId)) {
+		  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒'));
+		  pageStatus = null;
+		  return;
+		}
+		system.debug('edit2');
+		list<Lost_cancel_report__c> lostReportList =
+		[select id,of_lost_system_processor__c,
+		 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
+		 ModifyAfterApproval__c,Approved_Day__c,//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 add
+		 Report_Status__c,Sales_assistant__c,
+		 Opportunity__c, Opportunity__r.Sales_assistant_ID__c,
+		 Opportunity__r.Sales_manager_departmentID__c,
+		 Manager_sales__c,recordtypeid,recordtype.DeveloperName
+		 from Lost_cancel_report__c
+		 where id =: lostReportId limit 1];
+  
+		if(lostReportList.size() == 0) {
+		  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒'));
+		  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 =
+		  lostReportList[0].Opportunity__r.Sales_manager_departmentID__c;
+		if(lostReportList[0].recordtype.DeveloperName.equals('PCL_Lost_report')) {
+		  lostReportList[0].LostType__c ='澶卞崟';
+  
+		}else if(lostReportList[0].recordtype.DeveloperName.equals('PCL_PartLost_report')) {
+		  lostReportList[0].LostType__c ='閮ㄥ垎澶卞崟';
+		}
+		// 鏉冮檺锛屽鏋滃綋鍓嶇姸鎬佷笉鏄崏妗堜腑锛岄偅涔堥渶瑕佽烦杞埌鍙椤甸潰
+		// 20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 strat 鏀筰f鏉′欢
+		//鍘燂細!'鑽夋'.equals(lostReportList[0].Report_Status__c) && userinfo.getProfileId() != (ID) '00e10000000Y3o5AAC'
+		if(
+			!('鑽夋'.equals(lostReportList[0].Report_Status__c) 
+			|| userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC'
+			||('鎵瑰噯'.equals(lostReportList[0].Report_Status__c) && 
+			   System.Label.PCLReportProfileId.contains(userinfo.getProfileId()))
+			)
+		  ) {
+		// 20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 end 鏀筰f鏉′欢
+		  pageStatus = 'View';
+		}
+		oppId = lostReportList[0].Opportunity__c;
+		system.debug('edit3');
+		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,
+		  ( select id,PCLLostBrand__c,LostProduct__c,
+			LostProductMannual__c,            //SWAG-C6P9PX lt 20210913 add
+			ProductCategory__c,ProductClass__c, //add tcm 20211123
+			Quantity__c,Name, LostBrandName__c 
+			from PCLLostBrand__c.PCLLostBrandProduct__r)
+		  from PCLLostBrand__c
+		  where Lost_cancel_report__c =: lostReportId
+		];
+		if(selectlostBrandList.size() == 0 ) {
+		  LostReport = new LostReport(lostReportList[0]);
+		  brandCount = 1;
+		}else{
+		  system.debug('edit4:'+selectlostBrandList[0]);
+		  brandCount = 0;
+		  list<LostBrand> LostBrandList = new list<LostBrand>();
+		  for(PCLLostBrand__c templostBrand : selectlostBrandList) {
+			list<PCLLostProducts> tempProductList = new list<PCLLostProducts>();
+			integer productCount = 0;
+			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++;
+			  }
+			} else {
+			  PCLLostProducts newProduct = new PCLLostProducts();
+			  if ('鍏朵粬'.equals(templostBrand.Lost_By_Company__c) && 
+				templostBrand.Lost_By_Company_Mannual__c != null && 
+				!''.equals(templostBrand.Lost_By_Company_Mannual__c)) {
+				  newProduct.LostProductss.LostBrandName__c = templostBrand.Lost_By_Company_Mannual__c;
+				} else {
+				  newProduct.LostProductss.LostBrandName__c = templostBrand.Lost_By_Company__c;
 				}
-
-				LostReport = new LostReport(lostReportList[0],LostBrandList);
-				system.debug('LostReport.LostBrands:'+LostReport.LostBrands);
+				system.debug('aaa4+++'+templostBrand.Lost_By_Company_Mannual__c);
+			  tempProductList.add(newProduct);
+			  productCount++;
 			}
+			LostBrandList.add( new LostBrand(brandCount,tempProductList, templostBrand));
+			brandCount++;
+		  }
+  
+		  LostReport = new LostReport(lostReportList[0],LostBrandList);
+		  system.debug('LostReport.LostBrands:'+LostReport.LostBrands);
 		}
-		brandNo = 0;
-		// 璇诲彇绔炰簤瀵规墜鍝佺墝
-		// BrandmapSet();
-		if(string.isNotEmpty(submitFlag)) {
-			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,
-			                                           '鎻愪氦鎴愬姛锛�'));
-
-		}
+	  }
+	  brandNo = 0;
+	  // 璇诲彇绔炰簤瀵规墜鍝佺墝
+	  // BrandmapSet();
+	  if(string.isNotEmpty(submitFlag)) {
+		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,
+												   '鎻愪氦鎴愬姛锛�'));
+  
+	  }
 	}
 	// 缂栬緫 鍙湁绯荤粺绠$悊鍛樻垨鑰呰崏妗堜腑鍙互缂栬緫
 	public PageReference edit2(){
-		if( userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC' ||
-		    '鑽夋'.equals(LostReport.LostReport.Report_Status__c)
-		    ) {
-			pageStatus = 'Edit';
-			init();
-		}
-		else{
-			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�'));
-		}
-		return null;
+	  //20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 start 
+	  if( userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC' ||
+		  '鑽夋'.equals(LostReport.LostReport.Report_Status__c) ||
+		  ('鎵瑰噯'.equals(LostReport.LostReport.Report_Status__c) && 
+		   System.Label.PCLReportProfileId.contains(userinfo.getProfileId())
+		  )
+		) {
+		//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 end 
+		pageStatus = 'Edit';
+		init();
+	  }
+	  else{
+		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�'));
+	  }
+	  return null;
 	}
 	// 璁剧疆鍝佺墝
 	public void setBrand(){
-		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
-		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
-		string brandName = tempBrand.lostBrand.Lost_By_Company__c;
-		// 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
-			// tempLostProduct.LostProductss.Competitor__c = compID;
-			tempLostProduct.LostProductss.LostBrandName__c = brandName;
-			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;
-		}
+	  list<LostBrand> LostBrandlist =  LostReport.LostBrands;
+	  LostBrand tempBrand = LostBrandlist.get(setBrandNo);
+	  string brandName = tempBrand.lostBrand.Lost_By_Company__c;
+	  // 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
+		// tempLostProduct.LostProductss.Competitor__c = compID;
+		tempLostProduct.LostProductss.LostBrandName__c = brandName;
+		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 void setbrandmannual(){
-		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
-		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
-		string brandName = tempBrand.lostBrand.Lost_By_Company__c;
-		String brandNameMannual = tempBrand.lostBrand.Lost_By_Company_Mannual__c;
-		// ID compID = CompetitionMap.get(brandName);
-		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;
-			}
+	  list<LostBrand> LostBrandlist =  LostReport.LostBrands;
+	  LostBrand tempBrand = LostBrandlist.get(setBrandNo);
+	  string brandName = tempBrand.lostBrand.Lost_By_Company__c;
+	  String brandNameMannual = tempBrand.lostBrand.Lost_By_Company_Mannual__c;
+	  // ID compID = CompetitionMap.get(brandName);
+	  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;
 		}
+	  }
 	}
 	// 淇濆瓨
 	public PageReference save(){
-
-		if(!DataCheck()) {
-			return null;
-		}
-		if(!dataEntry()) {
-			return null;
-		}
-
-		brandCount = LostReport.LostBrands.size();
-		pageStatus = 'View';
-		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM, '淇濆瓨鎴愬姛锛�'));
-
+  
+	  if(!DataCheck()) {
 		return null;
+	  }
+	  if(!dataEntry()) {
+		return null;
+	  }
+  
+	  brandCount = LostReport.LostBrands.size();
+	  pageStatus = 'View';
+	  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM, '淇濆瓨鎴愬姛锛�'));
+  
+	  return null;
 	}
 	//璇诲彇骞舵瀯寤虹珵浜夊鎵嬪搧鐗�
 	// public void BrandmapSet(){
-	// 	CompetitionMap = new map<string, id>();
-	// 	list <Competition_Company__c> competitionList
-	// 	    =  [select id,name from Competition_Company__c];
-	// 	for(Competition_Company__c tempComp : competitionList ) {
-	// 		CompetitionMap.put(tempComp.name, tempComp.id);
-	// 	}
-
+	//   CompetitionMap = new map<string, id>();
+	//   list <Competition_Company__c> competitionList
+	//       =  [select id,name from Competition_Company__c];
+	//   for(Competition_Company__c tempComp : competitionList ) {
+	//     CompetitionMap.put(tempComp.name, tempComp.id);
+	//   }
+  
 	// }
 	// 鏁版嵁妫�鏌�
 	public boolean DataCheck(){
-		boolean dataCheck = true;
-		if(string.isBlank(LostReport.LostReport.LostType__c))
-		{
-			LostReport.LostReport.LostType__c.addError('蹇呴』濉啓澶卞崟绫诲瀷锛�');
+	  boolean dataCheck = true;
+	  if(string.isBlank(LostReport.LostReport.LostType__c))
+	  {
+		LostReport.LostReport.LostType__c.addError('蹇呴』濉啓澶卞崟绫诲瀷锛�');
+		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;
+		}
+		if(string.isblank(tempLostBrand.lostBrand.Lost_reason_main__c )) {
+		  tempLostBrand.lostBrand.Lost_reason_main__c.addError('澶卞崟鐞嗙敱(涓�)蹇呭~锛�');
+		  dataCheck = false;
+		}
+		if(string.isblank(tempLostBrand.lostBrand.Agency__c )) {
+		  tempLostBrand.lostBrand.Agency__c.addError('涓爣缁忛攢鍟嗗繀濉紒');
+		  dataCheck = false;
+		}
+		// 妫�鏌ユ槸鍚︽湁瓒呰繃1涓湁鏁扮殑浜у搧
+		integer productCount = 0;
+		for( PCLLostProducts temlostProduct : tempLostBrand.LostProducts) {
+		  if (temlostProduct.LostProductss.LostProduct__c != null || temlostProduct.LostProductss.LostProductMannual__c != null) {
+			System.debug('澶卞崟鍨嬪彿' + temlostProduct.LostProductss.LostProduct__c);
+			System.debug('澶卞崟鍨嬪彿鎵嬪姩' + temlostProduct.LostProductss.LostProductMannual__c);
+			productCount ++;
+		  }
+		  // update tcm 20211123 start
+		  if((temlostProduct.LostProductss.LostProduct__c!=null || temlostProduct.LostProductss.LostProductMannual__c!=null)&&(temlostProduct.LostProductss.Quantity__c==null || temlostProduct.LostProductss.Quantity__c ==0)) {
+			temlostProduct.LostProductss.Quantity__c.addError('璇峰~鍐欏け鍗曟暟閲忥紒');
 			dataCheck = false;
+		  }
+		  if((temlostProduct.LostProductss.LostProduct__c!=null || temlostProduct.LostProductss.LostProductMannual__c!=null)&&temlostProduct.LostProductss.ProductCategory__c==null) {
+			if (temlostProduct.LostProductss.ProductClass__c==null) {
+			  temlostProduct.LostProductss.ProductClass__c.addError('澶卞崟浜у搧绫诲埆蹇呭~锛�');
+			  temlostProduct.LostProductss.ProductCategory__c.addError('澶卞崟浜у搧蹇呭~锛�');
+			}else {
+			  temlostProduct.LostProductss.ProductCategory__c.addError('澶卞崟浜у搧蹇呭~锛�');
+			}
+			dataCheck = false;
+		  }
+		  // 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
+		  if ((temlostProduct.LostProductss.LostProduct__c==null && temlostProduct.LostProductss.LostProductMannual__c==null)&&(temlostProduct.LostProductss.ProductCategory__c!=null||temlostProduct.LostProductss.Quantity__c!=null)) {
+			if(tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'){
+			  temlostProduct.LostProductss.LostProduct__c.addError('澶卞崟瀵规墜鍨嬪彿鎴栧け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛夊繀濉紒');
+			} else{
+			  temlostProduct.LostProductss.LostProductMannual__c.addError('澶卞崟瀵规墜鍨嬪彿鎴栧け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛夊繀濉紒');
+			}
+			dataCheck = false;
+		  }
+		  // 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� 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
+		  
 		}
-		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;
-			}
-			if(string.isblank(tempLostBrand.lostBrand.Lost_reason_main__c )) {
-				tempLostBrand.lostBrand.Lost_reason_main__c.addError('澶卞崟鐞嗙敱(涓�)蹇呭~锛�');
-				dataCheck = false;
-			}
-			if(string.isblank(tempLostBrand.lostBrand.Agency__c )) {
-				tempLostBrand.lostBrand.Agency__c.addError('涓爣缁忛攢鍟嗗繀濉紒');
-				dataCheck = false;
-			}
-			// 妫�鏌ユ槸鍚︽湁瓒呰繃1涓湁鏁扮殑浜у搧
-			integer productCount = 0;
-			for( PCLLostProducts temlostProduct : tempLostBrand.LostProducts) {
-				if (temlostProduct.LostProductss.LostProduct__c != null || temlostProduct.LostProductss.LostProductMannual__c != null) {
-					System.debug('澶卞崟鍨嬪彿' + temlostProduct.LostProductss.LostProduct__c);
-					System.debug('澶卞崟鍨嬪彿鎵嬪姩' + temlostProduct.LostProductss.LostProductMannual__c);
-					productCount ++;
-				}
-				// update tcm 20211123 start
-				if((temlostProduct.LostProductss.LostProduct__c!=null || temlostProduct.LostProductss.LostProductMannual__c!=null)&&(temlostProduct.LostProductss.Quantity__c==null || temlostProduct.LostProductss.Quantity__c ==0)) {
-					temlostProduct.LostProductss.Quantity__c.addError('璇峰~鍐欏け鍗曟暟閲忥紒');
-					dataCheck = false;
-				}
-				if((temlostProduct.LostProductss.LostProduct__c!=null || temlostProduct.LostProductss.LostProductMannual__c!=null)&&temlostProduct.LostProductss.ProductCategory__c==null) {
-					if (temlostProduct.LostProductss.ProductClass__c==null) {
-						temlostProduct.LostProductss.ProductClass__c.addError('澶卞崟浜у搧绫诲埆蹇呭~锛�');
-						temlostProduct.LostProductss.ProductCategory__c.addError('澶卞崟浜у搧蹇呭~锛�');
-					}else {
-						temlostProduct.LostProductss.ProductCategory__c.addError('澶卞崟浜у搧蹇呭~锛�');
-					}
-					dataCheck = false;
-				}
-				// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
-				if ((temlostProduct.LostProductss.LostProduct__c==null && temlostProduct.LostProductss.LostProductMannual__c==null)&&(temlostProduct.LostProductss.ProductCategory__c!=null||temlostProduct.LostProductss.Quantity__c!=null)) {
-					if(tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'){
-						temlostProduct.LostProductss.LostProduct__c.addError('澶卞崟瀵规墜鍨嬪彿鎴栧け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛夊繀濉紒');
-					} else{
-						temlostProduct.LostProductss.LostProductMannual__c.addError('澶卞崟瀵规墜鍨嬪彿鎴栧け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛夊繀濉紒');
-					}
-					dataCheck = false;
-				}
-				// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
-				// update tcm 20211123 end
-			}
-			// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
-			if (productCount == 0 && tempLostBrand.LostProducts != null && tempLostBrand.LostProducts.size() > 0) {
-				if(tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'){
-					tempLostBrand.LostProducts[0].LostProductss.LostProduct__c.addError('鑷冲皯褰曞叆1鏉″け鍗曞鎵嬪瀷鍙蜂俊鎭紒');
-				}else{
-					tempLostBrand.LostProducts[0].LostProductss.LostProductMannual__c.addError('鑷冲皯褰曞叆1鏉″け鍗曞鎵嬪瀷鍙蜂俊鎭紒');
-				}
-				dataCheck = false;
-			}
-			// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
+		// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
+		if (productCount == 0 && tempLostBrand.LostProducts != null && tempLostBrand.LostProducts.size() > 0) {
+		  if(tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'){
+			tempLostBrand.LostProducts[0].LostProductss.LostProduct__c.addError('鑷冲皯褰曞叆1鏉″け鍗曞鎵嬪瀷鍙蜂俊鎭紒');
+		  }else{
+			tempLostBrand.LostProducts[0].LostProductss.LostProductMannual__c.addError('鑷冲皯褰曞叆1鏉″け鍗曞鎵嬪瀷鍙蜂俊鎭紒');
+		  }
+		  dataCheck = false;
 		}
-
-		return dataCheck;
+		// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
+	  }
+  
+	  return dataCheck;
 	}
 	public list<LostBrand> brandcopy(){
-		list<LostBrand> tempbrands = new list<LostBrand>();
-		for(LostBrand tempbrand: LostReport.LostBrands) {
-			LostBrand LostBrand =
-				new LostBrand(tempbrand.lineNo,tempbrand.LostProducts );
-			LostBrand.lostBrand = tempbrand.lostBrand.clone();
-			LostBrand.lostBrand.id = tempbrand.lostBrand.id;
-			tempbrands.add(LostBrand);
-		}
-		return tempbrands;
+	  list<LostBrand> tempbrands = new list<LostBrand>();
+	  for(LostBrand tempbrand: LostReport.LostBrands) {
+		LostBrand LostBrand =
+		  new LostBrand(tempbrand.lineNo,tempbrand.LostProducts );
+		LostBrand.lostBrand = tempbrand.lostBrand.clone();
+		LostBrand.lostBrand.id = tempbrand.lostBrand.id;
+		tempbrands.add(LostBrand);
+	  }
+	  return tempbrands;
 	}
 	// 鏁版嵁褰曞叆
 	public boolean dataEntry(){
-		system.debug('save---start:');
-		Savepoint sp = Database.setSavepoint();
-		Lost_cancel_report__c templostReport = LostReport.lostReport.clone();
-		templostReport.id = LostReport.lostReport.id;
-		list<LostBrand> tempBrands = brandcopy();
-		try{
-			// 寰呭畬鎴愶紝杩欓噷闇�瑕佹妸绗竴涓搧鐗岀殑淇℃伅璧嬪�煎埌杩欎釜澶卞崟鎶ュ憡涓婂幓锛岃繕鏈夐渶瑕佹妸鍚勪釜鍝佺墝閲戦姹囨�诲姞璧锋潵锛�
-			//system.debug('LostReport.LostBrands:'+LostReport.LostBrands);
-			// 璁剧疆璁板綍绫诲瀷
-			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.of_lost_system_processor__c   = 0;
-			LostReport.lostReport.Lost_reason_main__c = null;
-			LostReport.lostReport.Lost_Reason_Sub__c  = null;
-			LostReport.lostReport.Lost_By_Company__c = null;
-			for(LostBrand tempLostBrand : LostReport.LostBrands) {
-				if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
-					LostReport.lostReport.LostTotalAmount__c += tempLostBrand.lostBrand.LostPrice__c;
-					LostReport.lostReport.Lost_reason_main__c =
-						LostReport.lostReport.Lost_reason_main__c == null
-						? tempLostBrand.lostBrand.Lost_reason_main__c
-						: LostReport.lostReport.Lost_reason_main__c;
-					LostReport.lostReport.Lost_Reason_Sub__c  =
-						LostReport.lostReport.Lost_Reason_Sub__c == null
-						? tempLostBrand.lostBrand.Lost_Reason_Sub__c
-						: LostReport.lostReport.Lost_Reason_Sub__c;
-					LostReport.lostReport.Lost_By_Company__c =
-						LostReport.lostReport.Lost_By_Company__c == null
-						? tempLostBrand.lostBrand.Lost_By_Company__c
-						: LostReport.lostReport.Lost_By_Company__c;
-
-					for( PCLLostProducts tempLostProduct : tempLostBrand.LostProducts) {
-						if(tempLostProduct.LostProductss.Quantity__c !=null && tempLostProduct.LostProductss.Quantity__c >0) {
-							LostReport.lostReport.of_lost_system_processor__c   += tempLostProduct.LostProductss.Quantity__c;
-						}
-					}
-				}
-			}
-			upsert LostReport.lostReport;
-			// 闇�瑕佹彃鍏ユ洿鏂扮殑澶卞崟鍝佺墝
-			map<integer,PCLLostBrand__c> upsertLostBrandMap = new map<integer,PCLLostBrand__c>();
-			// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
-			map<integer,PCLLostBrand__c> deleteLostBrandMap = new map<integer,PCLLostBrand__c>();
-			// 闇�瑕佹彃鍏ユ洿鏂扮殑澶卞崟鍨嬪彿锛宬ey鏄搧鐗岀紪鍙�+鍨嬪彿缂栧彿锛寁alue鏄渶瑕佹洿鏂扮殑澶卞崟鍨嬪彿
-			map<string,PCLLostProduct__c> upsertLostProductMap = new map<string,PCLLostProduct__c>();
-			// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
-			list<PCLLostProduct__c> deleteLostProductList = new list<PCLLostProduct__c>();
-			for(LostBrand tempLostBrand : LostReport.LostBrands ) {
-				// 濡傛灉鏈夊け鍗曞搧鐗岋紝閭d箞灏辫鎻掑叆鏇存柊锛�
-				system.debug('tempLostBrand.lostBrand.Lost_By_Company__c:'+tempLostBrand.lostBrand.Lost_By_Company__c);
-				if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
-					upsertLostBrandMap.put(tempLostBrand.lineNo,tempLostBrand.lostBrand);
-					tempLostBrand.lostBrand.Lost_cancel_report__c = LostReport.lostReport.id;
-					tempLostBrand.lostBrand.Name = tempLostBrand.lostBrand.Lost_By_Company__c;
-					integer tempNo = 0;
-					for( PCLLostProducts tempLostProduct : tempLostBrand.LostProducts) {
-						system.debug('Name:'+ tempLostProduct.LostProductss.Name );
-						if(tempLostProduct.LostProductss.Quantity__c !=null && tempLostProduct.LostProductss.Quantity__c >0) {
-							tempLostProduct.LostProductss.Name = tempLostBrand.lostBrand.Name + tempLostProduct.LostProductss.Quantity__c;
-							upsertLostProductMap.put(tempLostBrand.lineNo +':'+ tempNo,tempLostProduct.LostProductss);
-						}else if(string.isNotBlank(tempLostProduct.LostProductss.id)) {
-							deleteLostProductList.add(tempLostProduct.LostProductss);
-						}
-						tempNo++;
-					}
-				}
-				// 濡傛灉娌℃湁鍝佺墝锛屼絾鏄湁id锛� 杩欐牱鏁版嵁闇�瑕佸垹闄�
-				else if(string.isNotBlank(tempLostBrand.lostBrand.id)) {
-					deleteLostBrandMap.put(tempLostBrand.lineNo,tempLostBrand.lostBrand);
-					// 杩欓噷鍙兘闇�瑕佷篃鍒ゆ柇涓�涓嬪け鍗曞瀷鍙锋湁娌℃湁闇�瑕佸垹鎺�
-				}
-			}
-			if(upsertLostBrandMap.size()>0) {
-				upsert upsertLostBrandMap.values();
-			}
-			for( string productNo :upsertLostProductMap.keyset()) {
-				PCLLostProduct__c tempLostProduct = upsertLostProductMap.get(productNo);
-				integer brandNo = integer.valueof(productNo.split(':')[0]);
-				tempLostProduct.PCLLostBrand__c = upsertLostBrandMap.get(brandNo).id;
-			}
-			if(upsertLostProductMap.size()>0) {
-				upsert upsertLostProductMap.values();
-			}
-			if(deleteLostBrandMap.size()>0) {
-				delete deleteLostBrandMap.values();
-				for(PCLLostBrand__c pcl: deleteLostBrandMap.values()) {
-					pcl.id = null;
-				}
-			}
-			if(deleteLostProductList.size()>0) {
-				delete deleteLostProductList;
-				for(PCLLostProduct__c pclp: deleteLostProductList) {
-					pclp.id = null;
-				}
-			}
-			if(deleteBrandIDSet.size() > 0) {
-				list<id> tempdeleteIDlist = new list<id>();
-				tempdeleteIDlist.addall(deleteBrandIDSet);
-				database.delete(tempdeleteIDlist);
-
-			}
-
-			for(integer brandNumber =0; brandNumber< LostReport.LostBrands.size(); brandNumber++) {
-
-				LostBrand tempLostBrand = LostReport.LostBrands.get(brandNumber);
-				if(tempLostBrand.lostBrand.Id == null) {
-					LostReport.LostBrands.remove(brandNumber);
-					brandNumber--;
-					continue;
-				}
-				for(integer productNumber = 0; productNumber< tempLostBrand.LostProducts.size(); productNumber++) {
-					PCLLostProducts tempLostProduct = tempLostBrand.LostProducts.get(productNumber);
-					if(tempLostProduct.LostProductss.Id == null) {
-						tempLostBrand.LostProducts.remove(productNumber);
-						productNumber--;
-						continue;
-					}
-				}
-			}
-			lostReportId = LostReport.lostReport.id;
-			system.debug('save---end:');
-		}catch (Exception ex) {
-			Database.rollback(sp);
-			LostReport.lostReport = templostReport;
-			LostReport.LostBrands = tempBrands;
-			// 杩欓噷闇�瑕佸啓涓�浜涙姤閿欎俊鎭�
-			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
-			return false;
+	  system.debug('save---start:');
+	  Savepoint sp = Database.setSavepoint();
+	  Lost_cancel_report__c templostReport = LostReport.lostReport.clone();
+	  templostReport.id = LostReport.lostReport.id;
+	  list<LostBrand> tempBrands = brandcopy();
+	  try{
+		// 寰呭畬鎴愶紝杩欓噷闇�瑕佹妸绗竴涓搧鐗岀殑淇℃伅璧嬪�煎埌杩欎釜澶卞崟鎶ュ憡涓婂幓锛岃繕鏈夐渶瑕佹妸鍚勪釜鍝佺墝閲戦姹囨�诲姞璧锋潵锛�
+		//system.debug('LostReport.LostBrands:'+LostReport.LostBrands);
+		// 璁剧疆璁板綍绫诲瀷
+		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;
+		LostReport.lostReport.Lost_By_Company__c = null;
+		//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 start
+		//鎵瑰噯鏃ヤ笉涓虹┖鏃剁粰淇敼鍚庡啀鎵瑰噯璧嬪��
+		if(LostReport.lostReport.Approved_Day__c != null){
+			LostReport.lostReport.ModifyAfterApproval__c = true;
 		}
-		return true;
+		//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 end
+		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
+			  : LostReport.lostReport.Lost_reason_main__c;
+			LostReport.lostReport.Lost_Reason_Sub__c  =
+			  LostReport.lostReport.Lost_Reason_Sub__c == null
+			  ? tempLostBrand.lostBrand.Lost_Reason_Sub__c
+			  : LostReport.lostReport.Lost_Reason_Sub__c;
+			LostReport.lostReport.Lost_By_Company__c =
+			  LostReport.lostReport.Lost_By_Company__c == null
+			  ? tempLostBrand.lostBrand.Lost_By_Company__c
+			  : LostReport.lostReport.Lost_By_Company__c;
+  
+			for( PCLLostProducts tempLostProduct : tempLostBrand.LostProducts) {
+			  if(tempLostProduct.LostProductss.Quantity__c !=null && tempLostProduct.LostProductss.Quantity__c >0) {
+				LostReport.lostReport.of_lost_system_processor__c   += tempLostProduct.LostProductss.Quantity__c;
+			  }
+			}
+		  }
+		}
+		upsert LostReport.lostReport;
+		// 闇�瑕佹彃鍏ユ洿鏂扮殑澶卞崟鍝佺墝
+		map<integer,PCLLostBrand__c> upsertLostBrandMap = new map<integer,PCLLostBrand__c>();
+		// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
+		map<integer,PCLLostBrand__c> deleteLostBrandMap = new map<integer,PCLLostBrand__c>();
+		// 闇�瑕佹彃鍏ユ洿鏂扮殑澶卞崟鍨嬪彿锛宬ey鏄搧鐗岀紪鍙�+鍨嬪彿缂栧彿锛寁alue鏄渶瑕佹洿鏂扮殑澶卞崟鍨嬪彿
+		map<string,PCLLostProduct__c> upsertLostProductMap = new map<string,PCLLostProduct__c>();
+		// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
+		list<PCLLostProduct__c> deleteLostProductList = new list<PCLLostProduct__c>();
+		for(LostBrand tempLostBrand : LostReport.LostBrands ) {
+		  // 濡傛灉鏈夊け鍗曞搧鐗岋紝閭d箞灏辫鎻掑叆鏇存柊锛�
+		  system.debug('tempLostBrand.lostBrand.Lost_By_Company__c:'+tempLostBrand.lostBrand.Lost_By_Company__c);
+		  if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
+			upsertLostBrandMap.put(tempLostBrand.lineNo,tempLostBrand.lostBrand);
+			tempLostBrand.lostBrand.Lost_cancel_report__c = LostReport.lostReport.id;
+			tempLostBrand.lostBrand.Name = tempLostBrand.lostBrand.Lost_By_Company__c;
+			integer tempNo = 0;
+			for( PCLLostProducts tempLostProduct : tempLostBrand.LostProducts) {
+			  system.debug('Name:'+ tempLostProduct.LostProductss.Name );
+			  if(tempLostProduct.LostProductss.Quantity__c !=null && tempLostProduct.LostProductss.Quantity__c >0) {
+				tempLostProduct.LostProductss.Name = tempLostBrand.lostBrand.Name + tempLostProduct.LostProductss.Quantity__c;
+				upsertLostProductMap.put(tempLostBrand.lineNo +':'+ tempNo,tempLostProduct.LostProductss);
+			  }else if(string.isNotBlank(tempLostProduct.LostProductss.id)) {
+				deleteLostProductList.add(tempLostProduct.LostProductss);
+			  }
+			  tempNo++;
+			}
+		  }
+		  // 濡傛灉娌℃湁鍝佺墝锛屼絾鏄湁id锛� 杩欐牱鏁版嵁闇�瑕佸垹闄�
+		  else if(string.isNotBlank(tempLostBrand.lostBrand.id)) {
+			deleteLostBrandMap.put(tempLostBrand.lineNo,tempLostBrand.lostBrand);
+			// 杩欓噷鍙兘闇�瑕佷篃鍒ゆ柇涓�涓嬪け鍗曞瀷鍙锋湁娌℃湁闇�瑕佸垹鎺�
+		  }
+		}
+		if(upsertLostBrandMap.size()>0) {
+		  upsert upsertLostBrandMap.values();
+		}
+		for( string productNo :upsertLostProductMap.keyset()) {
+		  PCLLostProduct__c tempLostProduct = upsertLostProductMap.get(productNo);
+		  integer brandNo = integer.valueof(productNo.split(':')[0]);
+		  tempLostProduct.PCLLostBrand__c = upsertLostBrandMap.get(brandNo).id;
+		}
+		if(upsertLostProductMap.size()>0) {
+		  upsert upsertLostProductMap.values();
+		}
+		if(deleteLostBrandMap.size()>0) {
+		  delete deleteLostBrandMap.values();
+		  for(PCLLostBrand__c pcl: deleteLostBrandMap.values()) {
+			pcl.id = null;
+		  }
+		}
+		if(deleteLostProductList.size()>0) {
+		  delete deleteLostProductList;
+		  for(PCLLostProduct__c pclp: deleteLostProductList) {
+			pclp.id = null;
+		  }
+		}
+		if(deleteBrandIDSet.size() > 0) {
+		  list<id> tempdeleteIDlist = new list<id>();
+		  tempdeleteIDlist.addall(deleteBrandIDSet);
+		  database.delete(tempdeleteIDlist);
+  
+		}
+  
+		for(integer brandNumber =0; brandNumber< LostReport.LostBrands.size(); brandNumber++) {
+  
+		  LostBrand tempLostBrand = LostReport.LostBrands.get(brandNumber);
+		  if(tempLostBrand.lostBrand.Id == null) {
+			LostReport.LostBrands.remove(brandNumber);
+			brandNumber--;
+			continue;
+		  }
+		  for(integer productNumber = 0; productNumber< tempLostBrand.LostProducts.size(); productNumber++) {
+			PCLLostProducts tempLostProduct = tempLostBrand.LostProducts.get(productNumber);
+			if(tempLostProduct.LostProductss.Id == null) {
+			  tempLostBrand.LostProducts.remove(productNumber);
+			  productNumber--;
+			  continue;
+			}
+		  }
+		}
+		lostReportId = LostReport.lostReport.id;
+		system.debug('save---end:');
+	  }catch (Exception ex) {
+		Database.rollback(sp);
+		LostReport.lostReport = templostReport;
+		LostReport.LostBrands = tempBrands;
+		// 杩欓噷闇�瑕佸啓涓�浜涙姤閿欎俊鎭�
+		System.debug('---lt123---'+ex.getLineNumber());
+		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
+		return false;
+	  }
+	  return true;
 	}
-
+  
 	// 鍙栨秷
 	public PageReference cancel(){
-		PageReference page = new PageReference('/'+oppId);
-		page.setRedirect(true);
-		return page;
+	  PageReference page = new PageReference('/'+oppId);
+	  page.setRedirect(true);
+	  return page;
 	}
 	// 鎻愪氦
 	public PageReference submit(){
-		if(!'鑽夋'.equals(LostReport.LostReport.Report_Status__c) ) {
-			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘鎻愪氦鐢宠锛�'));
-			return null;
-		}
+	  //20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣  update 
+	  //&& LostReport.LostReport.ModifyAfterApproval__c == false
+	  if(!'鑽夋'.equals(LostReport.LostReport.Report_Status__c) && LostReport.LostReport.ModifyAfterApproval__c == false) {
+		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘鎻愪氦鐢宠锛�'));
+		return null;
+	  }
 
-		Savepoint sp = Database.setSavepoint();
-		try{
-			LostReport.lostReport.Report_Status__c = '鎻愪氦';
-			update LostReport.lostReport;
-			Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
-			psr.setObjectId(lostReportId);
-			Approval.ProcessResult submitResult = Approval.process(psr);
-			PageReference page = new PageReference('/apex/PCLLostReportPage');
-			page.getParameters().put('Id', lostReportId);
-			page.getParameters().put('pageStatus', 'View');
-			page.getParameters().put('submitFlag', '1');
-
-			page.setRedirect(true);
-			return page;
-		}catch(exception ex) {
-			Database.rollback(sp);
-			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
-			return null;
-		}
+	  // 20230629 wkx DB202306242764  start
+	  //20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 add lcrlist1
+	  //DB202308068183 add (涓嶇瓑浜庡綋鍓嶅け鍗曟姤鍛婏紝鎵瑰噯鍚庡啀淇敼鐢�)
+	  list<Lost_cancel_report__c> lcrlist1=[select id,Opportunity__c from Lost_cancel_report__c where Opportunity__c=:oppid and id!=:lostReportId limit 1];
+	  list<opportunity> opplist1=[select id,cnt_lost_cancel_report__c,cnt_lost_cancel_draft__c from Opportunity where id=:oppid limit 1];
+	  if (opplist1[0].cnt_lost_cancel_report__c - opplist1[0].cnt_lost_cancel_draft__c > 0  && lcrlist1.size() > 0) {
+		  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '宸插瓨鍦� 璇环澶卞崟/鍙栨秷 鎶ュ憡锛�'));
+		  return null;
+	  }
+	  // 20230629 wkx DB202306242764  end
+  
+	  Savepoint sp = Database.setSavepoint();
+	  try{
+		LostReport.lostReport.Report_Status__c = '鎻愪氦';
+		update LostReport.lostReport;
+		//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 start 娉ㄩ噴
+		//DB202308068183 杩� 杩涚▼鐢熸垚鍣�
+		// Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+		// psr.setObjectId(lostReportId);
+		// Approval.ProcessResult submitResult = Approval.process(psr);
+		//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 end 娉ㄩ噴
+		PageReference page = new PageReference('/apex/PCLLostReportPage');
+		page.getParameters().put('Id', lostReportId);
+		page.getParameters().put('pageStatus', 'View');
+		page.getParameters().put('submitFlag', '1');
+  
+		page.setRedirect(true);
+		return page;
+	  }catch(exception ex) {
+		Database.rollback(sp);
+		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
+		return null;
+	  }
 	}
 	// 娣诲姞鍝佺墝
 	public PageReference addBrand(){
-		LostReport.LostBrands.add(new LostBrand(LostReport.LostBrands.size()));
-		brandCount = LostReport.LostBrands.size();
-		return null;
+	  LostReport.LostBrands.add(new LostBrand(LostReport.LostBrands.size()));
+	  brandCount = LostReport.LostBrands.size();
+	  return null;
 	}
 	// 鍒犻櫎鍝佺墝 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄垹闄ら偅涓搧鐗�
 	public PageReference Remove(){
-		system.debug('RemoveBrandNo:'+RemoveBrandNo);
-		list<LostBrand> tempLostBrands = new List<lostBrand>();
-		Integer i = 0;
-		for(integer j = 0; j< LostReport.LostBrands.size(); j++ ) {
-			LostBrand templostBrand  = LostReport.LostBrands.get(j);
-			if(j != RemoveBrandNo) {
-				templostBrand.lineNo = i;
-				tempLostBrands.add(templostBrand);
-				i++;
-			}else if(!string.isBlank(templostBrand.lostBrand.id)) {
-				deleteBrandIDSet.add(templostBrand.lostBrand.id);
-			}
+	  system.debug('RemoveBrandNo:'+RemoveBrandNo);
+	  list<LostBrand> tempLostBrands = new List<lostBrand>();
+	  Integer i = 0;
+	  for(integer j = 0; j< LostReport.LostBrands.size(); j++ ) {
+		LostBrand templostBrand  = LostReport.LostBrands.get(j);
+		if(j != RemoveBrandNo) {
+		  templostBrand.lineNo = i;
+		  tempLostBrands.add(templostBrand);
+		  i++;
+		}else if(!string.isBlank(templostBrand.lostBrand.id)) {
+		  deleteBrandIDSet.add(templostBrand.lostBrand.id);
 		}
-
-		LostReport.LostBrands =  tempLostBrands;
-
-		brandCount = LostReport.LostBrands.size();
-		return null;
+	  }
+  
+	  LostReport.LostBrands =  tempLostBrands;
+  
+	  brandCount = LostReport.LostBrands.size();
+	  return null;
 	}
 	// 娣诲姞鍨嬪彿锛� 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄坊鍔犲埌閭d釜鍝佺墝
 	// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� start
 	public PageReference addProduct(){
-		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;
-		PCLLostProduct__c plp = new PCLLostProduct__c();
-		plp.LostBrandName__c = brandName;
-		tempLostBrand.LostProducts.add(new PCLLostProducts(tempLostBrand.LostProducts.size(),plp));
-		tempLostBrand.ProductSize = tempLostBrand.LostProducts.size();
-		return null;
+	  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));
+	  // 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));
+	  tempLostBrand.ProductSize = tempLostBrand.LostProducts.size();
+	  return null;
 	}
 	// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� end
 	// 椤甸潰鐨勬暟鎹粨鏋�
 	public class LostReport {
-		public Lost_cancel_report__c lostReport { get; set; }
-		public list<LostBrand> LostBrands { get; set; }
-		public LostReport(){
-			lostReport = new Lost_cancel_report__c();
-			LostBrands = new list<LostBrand> {new LostBrand(0)};
-		}
-		public LostReport(Lost_cancel_report__c lostReport){
-			this.lostReport = lostReport;
-			LostBrands = new list<LostBrand> {new LostBrand(0)};
-		}
-		public LostReport(Lost_cancel_report__c lostReport,  list<LostBrand> LostBrands){
-			this.lostReport = lostReport;
-			this.LostBrands = LostBrands;
-		}
+	  public Lost_cancel_report__c lostReport { get; set; }
+	  public list<LostBrand> LostBrands { get; set; }
+	  public LostReport(){
+		lostReport = new Lost_cancel_report__c();
+		LostBrands = new list<LostBrand> {new LostBrand(0)};
+	  }
+	  public LostReport(Lost_cancel_report__c lostReport){
+		this.lostReport = lostReport;
+		LostBrands = new list<LostBrand> {new LostBrand(0)};
+	  }
+	  public LostReport(Lost_cancel_report__c lostReport,  list<LostBrand> LostBrands){
+		this.lostReport = lostReport;
+		this.LostBrands = LostBrands;
+	  }
 	}
-
+  
 	public class LostBrand {
-		public PCLLostBrand__c lostBrand { get; set; }
-		public Integer lineNo { get; set; }
-		public list<PCLLostProducts> LostProducts { get; set; }
-		public Integer ProductSize {get; set;}
-		public LostBrand( integer lineNo ){
-			lostBrand = new PCLLostBrand__c();
-			this.lineNo = lineNo;
-			LostProducts = new list<PCLLostProducts> {new PCLLostProducts()};
-			ProductSize = 1;
-			lostBrand = new PCLLostBrand__c();
-		}
-		public LostBrand( integer lineNo, list<PCLLostProducts> LostProducts ){
-			lostBrand = new PCLLostBrand__c();
-			this.lineNo = lineNo;
-			this.LostProducts = LostProducts;
-			ProductSize = LostProducts.size();
-		}
-		public LostBrand( integer lineNo, list<PCLLostProducts> LostProducts,  PCLLostBrand__c lostBrand){
-			this.lostBrand = lostBrand;
-			this.lineNo = lineNo;
-			this.LostProducts = LostProducts;
-			ProductSize = LostProducts.size();
-		}
+	  public PCLLostBrand__c lostBrand { get; set; }
+	  public Integer lineNo { get; set; }
+	  public list<PCLLostProducts> LostProducts { get; set; }
+	  public Integer ProductSize {get; set;}
+	  public LostBrand( integer lineNo ){
+		lostBrand = new PCLLostBrand__c();
+		this.lineNo = lineNo;
+		LostProducts = new list<PCLLostProducts> {new PCLLostProducts()};
+		ProductSize = 1;
+		lostBrand = new PCLLostBrand__c();
+	  }
+	  public LostBrand( integer lineNo, list<PCLLostProducts> LostProducts ){
+		lostBrand = new PCLLostBrand__c();
+		this.lineNo = lineNo;
+		this.LostProducts = LostProducts;
+		ProductSize = LostProducts.size();
+	  }
+	  public LostBrand( integer lineNo, list<PCLLostProducts> LostProducts,  PCLLostBrand__c lostBrand){
+		this.lostBrand = lostBrand;
+		this.lineNo = lineNo;
+		this.LostProducts = LostProducts;
+		ProductSize = LostProducts.size();
+	  }
 	}
 	// add tcm 20211119 start
 	public class PCLLostProducts {
-		public Integer lineNo2 { get; set; }
-		public PCLLostProduct__c LostProductss { get; set; }
-		public Boolean bool { get; set; }
-
-		public PCLLostProducts() {
-			this.lineNo2 = 0;
-			this.LostProductss=new PCLLostProduct__c();
+	  public Integer lineNo2 { get; set; }
+	  public PCLLostProduct__c LostProductss { get; set; }
+	  public Boolean bool { get; set; }
+  
+	  public PCLLostProducts() {
+		this.lineNo2 = 0;
+		this.LostProductss=new PCLLostProduct__c();
+	  }
+  
+	  public PCLLostProducts(Integer lineNo2) {
+		this.lineNo2 = lineNo2;
+		this.LostProductss=new PCLLostProduct__c();
+	  }
+  
+	  public PCLLostProducts(Integer lineNo2,PCLLostProduct__c LostProductss) {
+		this.lineNo2 = lineNo2;
+		this.LostProductss=LostProductss;
+		if (LostProductss.LostProduct__c != null) {
+		  this.bool = true;
 		}
-
-		public PCLLostProducts(Integer lineNo2) {
-			this.lineNo2 = lineNo2;
-			this.LostProductss=new PCLLostProduct__c();
-		}
-
-		public PCLLostProducts(Integer lineNo2,PCLLostProduct__c LostProductss) {
-			this.lineNo2 = lineNo2;
-			this.LostProductss=LostProductss;
-			if (LostProductss.LostProduct__c != null) {
-				this.bool = true;
-			}
-		}
+	  }
 	}
 	// add tcm 20211119 end
-
+  
 	// add tcm 20211118 start
 	public void search() {
-		if (LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c==null) {
-			LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null;
-			LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null;
-			LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false;
-
+	  if (LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c==null) {
+		LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null;
+		LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null;
+		LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false;
+  
+	  }else {
+		Product2 prd = [select Id,ProductClass__c, ProductCategory__c from Product2 where Id =:LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c];
+		if (prd.ProductCategory__c!=null) {
+		  LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=prd.ProductClass__c;
+		  LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=prd.ProductCategory__c;
+		  LostReport.LostBrands[topNum].LostProducts[secondNum].bool=true;
 		}else {
-			Product2 prd = [select Id,ProductClass__c, ProductCategory__c from Product2 where Id =:LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c];
-			if (prd.ProductCategory__c!=null) {
-				LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=prd.ProductClass__c;
-				LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=prd.ProductCategory__c;
-				LostReport.LostBrands[topNum].LostProducts[secondNum].bool=true;
-			}else {
-				LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null;
-				LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null;
-				LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false;
-
-			}
+		  LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null;
+		  LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null;
+		  LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false;
+  
 		}
+	  }
 	}
 	// add tcm 20211118 end
-}
\ No newline at end of file
+  }
\ No newline at end of file

--
Gitblit v1.9.1