From a48ed9f335db52a433a2b343ff9636a28ee8a97f Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期四, 10 三月 2022 18:53:59 +0800
Subject: [PATCH] New xml file for PIPL20220310

---
 force-app/main/default/classes/SelectAssetEstimateVMController.cls | 7091 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 3,546 insertions(+), 3,545 deletions(-)

diff --git a/force-app/main/default/classes/SelectAssetEstimateVMController.cls b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
index 80df5a3..acfcd99 100644
--- a/force-app/main/default/classes/SelectAssetEstimateVMController.cls
+++ b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
@@ -1,3546 +1,3547 @@
+/*gzw 浼樺寲Maximum view state size limit 杩藉姞 Transient */
 global class SelectAssetEstimateVMController {
-	//test
-	private String targetHospitalId = null;                                    // 浠婂緦绯诲垪鐥呴櫌鐢�
-	private String targetMaintenanceContractId = null;
-	public String typeresult {get; set;}
-	
-	public String targetEstimateId { get; private set; }
-	public Boolean changedAfterPrint {get; set;}                               // true 銇牬鍚堛�佺敾闈€伀 confirm 銉°儍銈汇兗銈搞亴琛ㄧず銇椼伨銇欍�俼uoId銈掓柊銇椼亜insert銆傚垽瀹氥伅js銇仸瀹熸柦
-	public Decimal lastFriYearsPriceSum {get; set;}
-	public Decimal lastSecYearsPriceSum {get; set;}
-	Public String alertString {get; set;}
-	Public String alertString2 {get; set;}
-	Public String alertString3 {get; set;}
-	public Boolean printAsset { get; private set; }
-	public Boolean printContract { get; private set; }
-	public Boolean printTripartite { get; private set; }
-	public Boolean printAgent { get; private set; }
-	public boolean inDicideFlag {get; set;}                         //浣滀负琛ュ厖锛屽搴旀姤浠峰喅瀹氫箣鍚庯紝鍗存湭鑳借鍚堝悓璧锋鏃ユ湡浼犻�掔粰鍚堝悓鐨勯棶棰�
-	public String isPaymentSet {get; set;}
-	//public String PaymentSet {get;set;}
-	// 寮曟暟銇偟銉笺儞銈瑰绱勩伄鎯呭牨銈掓牸绱嶃仚銈嬨��
-	public Maintenance_Contract__c contract { get; private set; }
-	public Maintenance_Contract_Estimate__c estimate { get; set; }
-	// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
-	public Asset ass { get; set; }
-	// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
-	// 鐥呴櫌閰嶄笅銇磵鍏ユ鍣ㄣ伄鎯呭牨銈掓牸绱嶃仚銈嬨��
-	private List<Asset> assetRecords;                                               // TODO 绯诲垪鐥呴櫌銇牬鍚堛�併亾銇厤鍒椼伅鍥哄畾銇с亶銇亜銇с仚銆�
-	public List<AssetInfo> checkedAssets { get; set; }
-	private List<AssetInfo> unCheckedAssets = new List<AssetInfo>();
-	
-	//public List<List<AssetInfo>> checkedAssetsView { get; set; }
-	public List<List<AssetInfo> > unCheckedAssetsView { get; set; }
-	
-	// 鍒嗛〉鐢�
-	public Integer currPage { get; set; }                         // 褰撳墠椤�
-	public Integer totalPage { get; set; }                         // 鎬婚〉鏁�
-	public Integer selctRecordNum { get { return Integer.valueOf(selRecordOption); } }                         // 閫夋嫨鐨勬瘡椤佃褰曟暟
-	public Integer totalRecords { get; set; }                          // 鎬昏褰曟暟
-	public String selRecordOption { get; set; }
-	public static List<SelectOption> recordNum { get; private set; }                         // 閫夋嫨姣忛〉璁板綍鏁癓ist
-	
-	//HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
-	public Boolean IS_Clone_After_Decide { get; set; }
-	//HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
-	//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-	public List<String> TopProductModel =new List<String>();
-	//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-	static {
-		recordNum = new List<SelectOption>();
-		recordNum.add(new SelectOption('10', '10'));
-		recordNum.add(new SelectOption('20', '20'));
-		recordNum.add(new SelectOption('50', '50'));
-		recordNum.add(new SelectOption('100', '100'));
-		recordNum.add(new SelectOption('200', '200'));
-	}
-	private List<String> checkIdList = new List<String> ();                         // 鍚堝悓瀵硅薄璁惧鐨勮澶嘔D
-	
-	//-------HWAG-B4R3SS----------------update----------------------------
-	public Boolean activeOn { get; set; }
-	public String sortKey { get; set; }
-	public Boolean sortOrderAsc { get; private set; }
-	private String[] columus = new String[] {'Asset_situation__c', 'Name', 'SerialNumber', 'CurrentContract__r.Management_Code__c', 'Department_Name__c', 'Status', 'Installation_Site__c', 'Room_Number__c', 'InstallDate', 'Asset_Owner__c', 'Accumulation_Repair_Amount__c', 'AssetMark__c'};
-	private Boolean isSoft;
-	// 鏄剧ず鏁版嵁鏉℃暟闄愬埗
-	private static Integer SELECT_LIMIT = 200;
-	public List<AssetInfo> unCheckedInfoList { get; set; }
-	private String text1ForSort = null;
-	private String cond1ForSort = null;
-	private String val1ForSort = null;
-	/*****************select option******************/
-	public static List<SelectOption> textOpts { get; private set; }
-	public Decimal countorder { get; set; }
-	public List<String> assetSerialNumberList = new List<String>();
-	// 鏂拌 鎴栬�� copy
-	private Boolean newIns = false;
-	//add   wangweipeng     2021/12/06     start
-	public String checkDealerId{get;set;}
-	//add   wangweipeng     2021/12/06     end
-	
-	static {
-		textOpts = new List<SelectOption>();
-		//LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
-		// textOpts.add(new SelectOption('','-鏃�-'));
-		//LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-		/* 鍦ㄦ煡璇㈣鍙ヤ腑 鏂板浜� AssetMark__c 鐨勫瓧娈� */
-		// textOpts.add(new SelectOption('S:Asset_situation__c'  , Schema.SObjectType.Asset.fields.Asset_situation__c.label));
-		// 娣诲姞鏂版潯浠� -- 鑰楁潗/涓绘満
-		textOpts.add(new SelectOption('S:AssetMark__c', '涓绘満/鑰楁潗'));
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-		textOpts.add(new SelectOption('S:Name', Schema.SObjectType.Asset.fields.Name.label));
-		textOpts.add(new SelectOption('S:SerialNumber', Schema.SObjectType.Asset.fields.SerialNumber.label));
-		textOpts.add(new SelectOption('S:CurrentContract__r.Management_Code__c', Schema.SObjectType.Asset.fields.CurrentContract__c.label));
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-		// textOpts.add(new SelectOption('S:Status'              , Schema.SObjectType.Asset.fields.Status.label));
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-		textOpts.add(new SelectOption('S:Installation_Site__c', Schema.SObjectType.Asset.fields.Installation_Site__c.label));
-		textOpts.add(new SelectOption('S:Department_Name__c', Schema.SObjectType.Asset.fields.Department_Name__c.label));
-	}
-	public static List<SelectOption> equalOpts { get; private set; }
-	static {
-		equalOpts = new List<SelectOption>();
-		equalOpts.add(new SelectOption('equals', '绛変簬'));
-		equalOpts.add(new SelectOption('contains', '鍖呭惈'));
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-		//鏂板姞鍖归厤绗� 涓嶇瓑浜�
-		equalOpts.add(new SelectOption('notequals', '涓嶇瓑浜�'));
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-	}
-	public String text1 { get; set; }                         // 瀵硅薄
-	public String cond1 { get; set; }                         // 鏉′欢
-	public String val1 { get; set; }                          // 鍊�
-	//LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
-	public String contr {get; set; }                         //鍒ゆ柇鏄惁init
-	//LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
-	
-	// 妫�绱㈡寜閽�
-	public PageReference searchBtn() {
-		countorder = 1;
-		//楠岃瘉
-		assetSerialNumberList.clear();
-		getAssetSerialNumber();
-		totalRecords = 0;
-		List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
-		for (Asset ast : assetconfimList) {
-			totalRecords++;
-		}
-	
-	
-		// 鑾峰彇assets
-		List<Asset> assetList = getAsset(text1, cond1, val1);
-	
-		// 浣滄垚鏄庣粏琛�
-		getSortedUnCheckedInfoList(assetList);
-		// 鎺掑簭鐢ㄦ绱㈡潯浠堕��閬�
-		text1ForSort = text1;
-		cond1ForSort = cond1;
-		val1ForSort = val1;
-		currPage = 1;
-	
-	
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		return null;
-	}
-	
-	// 鍙栧凡閫夋嫨璧勪骇鐨勬満韬紪鐮�
-	public void getAssetSerialNumber() {
-		//LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
-		contr = '2';
-		//LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
-		assetSerialNumberList = new List<String>();
-		assetSerialNumberList.clear();
-		for (AssetInfo ai : this.checkedAssets) {
-			system.debug('checkedAssets1111111' + this.checkedAssets);
-			//system.debug('ai.ah.SerialNumber__c' + ai.ah.SerialNumber__c);
-			if (String.isNotEmpty(ai.rec.SerialNumber)) {
-				assetSerialNumberList.add(ai.rec.SerialNumber);
-			}
-		}
-	}
-	
-	//
-	private void getSortedUnCheckedInfoList(List<Asset> assetList) {
-		Boolean overLimit = false;
-		Map<Id, AssetInfo> markUpUnCheckMap = new Map<Id, AssetInfo>();
-		for (AssetInfo unCheckinfo : unCheckedAssets) {
-	
-			// 鎵撳嬀锛岃涓轰紭鍏堟樉绀烘槑缁�
-			if (unCheckinfo.rec_checkBox_c == true) {
-				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'unCheckinfo.rec_checkBox_c' + unCheckinfo.rec_checkBox_c));
-				markUpUnCheckMap.put(unCheckinfo.rec.Id, unCheckinfo);
-			}
-		}
-		unCheckedAssets.clear();
-		// 浼樺厛鏄剧ず鏄庣粏鏀惧湪鏈�鍓嶉潰
-		unCheckedInfoList = new List<AssetInfo>();
-		for (AssetInfo asInfo : markUpUnCheckMap.values()) {
-			unCheckedAssets.add(asInfo);
-		}
-		SELECT_LIMIT = selctRecordNum;
-		Integer selectCnt = unCheckedAssets.size();
-		for (Asset asset : assetList) {
-			// 201銈掕秴銇堛仧鍫村悎鍓�200銇伩銈掑嚭銇�
-			if (unCheckedAssets.size() >= SELECT_LIMIT) { overLimit = true; break; }
-			if (markUpUnCheckMap.containsKey(asset.Id) == false) {
-				//unCheckedInfoList.add(unCheckMap.get(asset.Id));
-				unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), asset));
-			}
-		}
-	}
-	
-	//妫�绱㈤獙璇�
-	private List<Asset> getAssetconfim(String txt, String con, String val) {
-		String soql = this.makeSoqlconfim();
-		soql += makeTextSql(txt, con, val);
-		system.debug('makeTextSql_soql' + soql);
-		if (isSoft) {
-			soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
-		} else {
-			soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
-		}
-		system.debug('====getAssetconfim:' + soql);
-		return Database.query(soql);
-	}
-	
-	private List<Asset> getAsset(String txt, String con, String val) {
-		String soql = this.makeSoqlconfim();
-		soql += makeTextSql(txt, con, val);
-	
-		if (isSoft) {
-			soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
-		} else {
-			soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
-		}
-		soql += ' limit ' + System.Label.Asset_Maxcount;
-		soql += ' OFFSET ' + (countorder - 1) * Integer.valueOf(System.Label.Asset_Maxcount);
-		return Database.query(soql);
-	}
-	
-	public Integer soqlNos() {
-		List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
-		totalRecords = assetconfimList.size();
-		//totalPage = (totalRecords/selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		return totalRecords;
-	}
-	
-	private String makeSoqlconfim() {
-		String sqlTail = '(\'';
-		system.debug('assetSerialNumberList.size()' + assetSerialNumberList.size());
-		for (Integer i = 0; i < assetSerialNumberList.size(); i++) {
-			if (i < assetSerialNumberList.size() - 1) {
-				sqlTail += assetSerialNumberList[i] + '\',\'';
-			} else {
-				sqlTail += assetSerialNumberList[i] + '\')';
-			}
-		}
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-		//tcm 娣诲姞 Management_Code__c  20211201 start
-		String soql = 'SELECT Id, Name,OwnershipMachine_No__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
-					  + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
-					  + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
-					  + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
-					  + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
-					  + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
-					  + 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
-					  + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,AssetMark__c,NoPartRiskDate_F__c,NoPartRiskDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' ';
-		//HWAG-BDJ43R ---XHL---20190729---
-		//soql +=  ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-		// soql +=  ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
-		//JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-		//HWAG-BDJ43R ---XHL---20190729---
-		if (assetSerialNumberList.size() > 0) {
-			soql += ' AND SerialNumber not in ' + sqlTail;
-		}
-		return soql;
-	}
-	
-	// 鎷兼帴妫�绱㈡潯浠秙ql鏂�
-	private String makeTextSql(String txt1, String con, String val) {
-		String soql = '';
-		if (String.isBlank(con)) {
-			con = 'equals';
-		}
-		// contains銇牬鍚堛�佹棩鍫辩敾闈€伄鐥呴櫌妞滅储銈掔湡浼笺仐銆乻pace銇у垎銇戙仸銆乤nd妞滅储
-		// equals銇牬鍚堛�丼F妯欐簴銇绱€倰鐪熶技銇椼�併��,銆嶃仹鍒嗐亼銇︺�乷r妞滅储
-		if (!String.isBlank(txt1)) {
-			if ((con == 'contains' || con == 'notcontains') && val.contains(' ')) {
-				String[] vals = val.split(' ');
-	
-				String cSql = '';
-				if (vals.size() > 0) {
-					String txt = txt1.substring(2);
-					soql += ' and ( ';
-					for (String v : vals) {
-						if (String.isNotBlank(v)) {
-							if (con == 'contains') {
-								soql += txt + ' like \'%' + v + '%\' or ';
-							} else {
-								soql += txt + ' not like \'%' + v + '%\' and ';
-							}
-						}
-	
-	
-					}
-					soql = soql.substring(0, soql.length() - 4);
-					soql += ')';
-				}
-				system.debug('containssoql:     ' + soql);
-			} else if ((con == 'equals' || con == 'notequals') && val.contains(',')) {
-				String[] vals = val.split(',');
-				if (vals.size() > 0) {
-					String txt = txt1.substring(2);                 // S:Name 銆佹渶鍒濄伄锛掓枃瀛椼亴銈裤偆銉椼仹銇�
-					soql += ' and ( ';
-					for (String v : vals) {
-						if (con == 'equals') {
-							soql += txt + ' = \'' + v + '\' or ';
-						} else {
-							// notequals
-							soql += txt + ' <> \'' + v + '\' and ';
-						}
-					}
-					soql = soql.substring(0, soql.length() - 4);
-					soql += ')';
-				}
-			} else {
-				String cSql = this.makeTextSqlStr(txt1, con, val);
-				if (con != 'notcontains') {
-					soql += this.makeTextSqlStr(txt1, con, val);
-				} else {
-					// notcontains
-					if (!String.isBlank(cSql)) {
-						cSql = cSql.substring(5);                 // ' and ' 銇�5鏂囧瓧銈掑銇�
-						soql += ' and (NOT ' + cSql + ') ';
-					}
-				}
-			}
-		}
-		// //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-		// else{
-		//     soql += 'And AssetMark__c = \'涓绘満\'';
-		// }
-		// //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-		return soql;
-	}
-	
-	private String makeTextSqlStr(String txt1, String con, String val) {
-		String soql = '';
-		if (!String.isBlank(txt1)) {
-			String txt = txt1.substring(2);
-			String colType = txt1.substring(0, 2);
-			String tmpVal = val.trim();
-			// 绌虹櫧銇牬鍚�''銇仚銈�
-			if (String.isBlank(tmpVal)) {
-				if (con == 'equals') {
-					//soql += ' and ' + txt + ' = ' + tmpVal;
-					soql += ' and ' + txt + ' = null';
-				} else if (con == 'notequals') {
-					soql += ' and ' + txt + ' <> null';
-				} else {
-					// 绌虹櫧銇牬鍚堛�乧ontains, notcontains 銇� starts with銇劇瑕�
-				}
-			} else {
-				soql += ' and ' + txt;
-				if (con == 'equals') {
-					if (colType == 'S:') {
-						soql += ' = \'' + tmpVal + '\'';
-					} else {
-						soql += ' = ' + tmpVal + ' ';
-					}
-				} else if (con == 'notequals') {
-					if (colType == 'S:') {
-						soql += ' <> \'' + tmpVal + '\'';
-					} else {
-						soql += ' <> ' + tmpVal + ' ';
-					}
-				} else if (con == 'contains' || con == 'notcontains') {
-					soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
-				} else if (con == 'starts with') {
-					soql += ' like \'' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
-				} else {
-					if (colType == 'S:') {
-						soql += ' ' + con + '\'' + tmpVal + '\'';
-					} else {
-						soql += ' ' + con + ' ' + tmpVal + ' ';
-					}
-				}
-			}
-		}
-		return soql;
-	}
-	
-	//----------HWAG-B4R3SS------------------------------------------------------------
-	
-	
-	
-	
-	
-	
-	public Boolean getEnablePrintContract() {
-		if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-			return this.estimate.Estimation_Decision__c;
-		} else {
-			return false;
-		}
-	}
-	
-	public Boolean getUnDecideBtnDisabled() {
-		// 瑕嬬銈傘倞decide鍙栨秷銇椼仹銇嶃仾銇勬潯浠躲伄鍒ゆ柇
-		if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-			if (this.estimate.Estimation_Decision__c) {
-				return false;
-			}
-		}
-		// TODO 鏈綋銇壒鍒ヨ硣鏍笺亴銇傘倢銇� 姹哄畾鍙兘銇仚銈�
-		return true;
-	}
-	public Boolean getDecideBtnDisabled() {
-		// 瑕嬬銈傘倞decide銇с亶銇亜鏉′欢銇垽鏂�
-		if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-			if (this.estimate.Estimation_Decision__c) {
-				return true;
-			}
-			// TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 姹哄畾鍙兘銇仚銈�
-			return true;
-		}
-		if (this.estimate.Process_Status__c != '鎵瑰噯') {
-			return true;
-		} else {
-			if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
-				&& this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
-				&& this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
-				return true;
-			}
-		}
-		return false;
-	}
-	public Boolean getApprovalBtnDisabled() {
-	
-		// 瑕嬬銈傘倞鐢宠珛銇с亶銇亜鏉′欢銇垽鏂�
-		if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-			// TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 鐢宠珛鍙兘銇仚銈�
-			return true;
-		}
-		if (String.isBlank(this.estimate.Process_Status__c) == false
-			&& this.estimate.Process_Status__c != '鑽夋涓�'
-			//&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
-			) {
-			return true;
-		}
-		return false;
-	}
-	// 20200307 涓嶇敤
-	// public Boolean getcontactBtnDisabled() {
-	//     if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-	//         // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 鐢宠珛鍙兘銇仚銈�
-	//         return true;
-	//     }
-	//     if (String.isBlank(this.estimate.Process_Status__c) == false
-	//             && this.estimate.Process_Status__c != '鑽夋涓�'
-	//             && this.estimate.Process_Status__c != '鐢宠涓�'
-	//     ) {
-	//         return true;
-	//     }
-	//     return false;
-	// }
-	public Boolean getSaveBtnDisabled() {
-		// 瑕嬬銈傘倞save銇с亶銇亜鏉′欢銇垽鏂�
-		if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-			return true;
-		}
-		if (String.isBlank(this.estimate.Process_Status__c) == false
-			&& this.estimate.Process_Status__c != '鑽夋涓�'
-			//&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
-			) {
-			return true;
-		}
-		return false;
-	}
-	public Boolean getPrintBtnDisabled() {
-		// 鍗板埛銇с亶銇亜鏉′欢銇垽鏂�
-		if (this.estimate.Process_Status__c != '鎵瑰噯' || !this.contract.Status__c.equals('寮曞悎涓�') ) {
-			return true;
-		} else {
-			if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
-				&& this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
-				&& this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
-				return true;
-			}
-		}
-		return false;
-	}
-	// 椤甸潰椤圭洰闈炴椿鎬ц瀹�
-	public Boolean getPageDisabled() {
-		if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-			return true;
-		}
-		if (String.isBlank(this.estimate.Process_Status__c) == false
-			&& this.estimate.Process_Status__c != '鑽夋涓�'
-			) {
-			return true;
-		}
-		return false;
-	}
-	// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
-	// public Boolean getPageDisabled1() {
-	
-	//     if (
-	//         String.isBlank(this.ass.Name)
-	//     ) {
-	//         return true;
-	//     }
-	//     return false;
-	// }
-	// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
-	public Integer productCount {
-		get {
-			return checkedAssets == null ? 0 : checkedAssets.size();
-		}
-	}
-	public Integer productCount2 {
-		get {
-			return unCheckedAssets == null ? 0 : unCheckedAssets.size();
-		}
-	}
-	public Integer productCount3 {
-		get {
-			Integer cnt = 0;
-			for (AssetInfo input : this.checkedAssets) {
-				if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-					cnt += 1;
-				}
-			}
-			return cnt;
-		}
-	}
-	// TODO 銈偣銈裤儬銉┿儥銉亱銈夊彇寰�
-	public static Decimal oxygenPriceAdj { get { return 0.1; } }                                  // TODO katsu 閰稿寲姘淬倰浣跨敤銇椼仾銇勩倛銇嗐伀澶夋洿
-	public static Decimal isNewPriceAdj { get { return 1; } }
-	
-	//public String productName { get; set; }
-	public Integer productIdx { get; set; }
-	
-	public Integer isNewAddMonth { get { return Integer.valueOf(System.Label.MC_New_AddMonth); } }
-	
-	public Integer keepPriceMonth { get { return Integer.valueOf(System.Label.MC_KeepPrice_Month); } }
-	
-	public Boolean isPageAction = false;
-	
-	private Integer PosttoInstall { get { return Integer.valueOf(System.Label.Post_to_Install); }}
-	
-	public Boolean changedSubmitPrice {get; set;}
-	
-	public Boolean isSaveOrApproval {get; set;}
-	public String OldContractStartDate {get; set;}
-	public String OldMaintenancePrice { get; set; }
-	
-	/**
-	 * 銈炽兂銈广儓銉┿偗銈�
-	 */
-	public SelectAssetEstimateVMController() {
-		currPage = 1;
-		selRecordOption = '20';
-		totalRecords = 0;
-		checkDealerId = '';
-	}
-	/**
-	 * Visaulforce銇嬨倝鍛笺伆銈屻倠銈炽兂銈广儓銉┿偗銈�
-	 */
-	public SelectAssetEstimateVMController(ApexPages.StandardController controller) {
-		//HWAG-B4R3SS  START 20181026
-		currPage = 1;
-		selRecordOption = '20';
-		//this.targetEstimateId = (String)(ApexPages.currentPage().getParameters().get('id'));
-		totalRecords = 0;
-		//HWAG-B4R3SS  END 20181026
-	}
-	
-	private void setThisEstimate() {
-		//HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c start
-		this.estimate = [SELECT Id, Name, Maintenance_Contract__c, Estimation_Decision__c, CreatedDate, Service_Contract_Staff__c,
-						 JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, Finally_Approved_Staff__c,
-						 Contract_Esti_Start_Date__c, Contract_Esti_End_Date__c, Contract_Range__c, Contract_Start_Date__c, Contract_End_Date__c,
-						 Maintenance_Contract_Status__c, Discount_reason__c, Improve_ConsumptionRate_Idea__c, Process_Status__c,
-						 Estimate_Trial_Money__c, Maintenance_Price__c, Department__c, PrintDate__c, Quote_Date__c, Submit_quotation_day__c,
-						 Examination_Price__c, Service_contract_target_number__c,
-						 Maintenance_Contract__r.Payment_Plan_Sum_First__c, Maintenance_Contract__r.Payment_Plan_Date_First__c,
-						 Maintenance_Contract__r.Payment_Plan_Sum_Second__c,
-						 Maintenance_Contract__r.Payment_Plan_Sum_Third__c,
-						 Maintenance_Contract__r.Payment_Plan_Sum_Forth__c,
-						 Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c,
-						 Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c,
-						 Discount_Price__c, Discount_Percentage__c, IsSyncing__c,
-						 NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,Dealer__r.FirstParagraphEnd__c,Is_RecognitionModel__c,
-						 Append_Condition_Price__c, Asset_Sum_Price__c, Asset_Repair_Sum_Price__c,
-						 Print_Contract__c, Print_RepairPrice__c, Print_DiscountPercentage__c, Print_Agent__c, Change_Dealer_Approval__c,
-						 Print_DiscountPrice__c, Print_ListPrice__c, Print_MaintePrice__c, Print_SumPrice__c, Print_Tripartite__c, TKZongjianApprovalManager__c
-						 //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
-						 , IS_Clone_After_Decide__c, New_contract_offer__c, NewEstimation_Amount__c, EndUserType__c, Print_Simplify__c
-						 //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
-						 //鏈�浣庝环鏍� 鏈�楂樹环鏍� 鐢宠鑳屾櫙鐩稿叧瀛楁 20200108 start
-						 , GuidePrice_Up__c, GuidePrice_Down__c, finalPriceDecideWay__c, mainTalksTime__c, talksStartDate__c
-						 , Combined_rate__c, New_Contract_Type_TxT__c, Estimate_Price_range__c
-						 //鏈�浣庝环鏍� 鏈�楂樹环鏍艰绠� 20200108 end
-						 , Sales_incidental__c, Consumption_rate_Forecast__c, AgencyHos_Price__c
-						 // 鐢宠鎶ヤ环閲戦 鍜� 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼
-						 , Request_quotation_Amount__c, Service_discount_Rate__c, ContractPriceType__c
-						 , LastMContract1__c, LastMContract2__c, LastMContract3__c, LastMContract4__c, LastMContract5__c
-						 , LastMContract1_ConCount__c, LastMContract2_ConCount__c, LastMContract3_ConCount__c, LastMContract4_ConCount__c, LastMContract5_ConCount__c,
-						 LastMContract1_NO__c, LastMContract2_NO__c, LastMContract3_NO__c, LastMContract4_NO__c, LastMContract5_NO__c
-						 //璺宠繃鐐规鏍囪 2021/07/28 gzw start
-						 , Skip_DJ__c
-						 //璺宠繃鐐规鏍囪 2021/07/28 gzw start
-	
-						//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start
-						//, Maintenance_Contract__r.Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
-						//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
-	
-						 FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
-		//HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c end
-		decimal PriceSum =  (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c) +
-						   (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c) +
-						   (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c) +
-						   (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c) +
-						   (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c) +
-						   (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c);
-		if ( this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null
-			 //102018/10/26 HWAG-B5C88S 涓嶅啀鏍规嵁鏄惁濉啓绗竴娆′粯娆炬棩鏈熷垽鏂�
-			 ) {
-			isPaymentSet = 'false';
-		} else if (this.estimate.Maintenance_Price__c != PriceSum) {
-			isPaymentSet = 'Denied';
-		} else {
-			isPaymentSet = 'true';
-		}
-	}
-	
-	public void init() {
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		TopProductModel.add('CF-LV1I');
-		TopProductModel.add('CF-LV1L');
-		TopProductModel.add('CV-V1');
-		TopProductModel.add('GIF-LV1');
-		TopProductModel.add('OER-AW');
-		TopProductModel.add('OER-A');
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-		typeresult = null;
-		changedAfterPrint = false;
-		changedSubmitPrice = false;
-		isSaveOrApproval = false;
-		OldContractStartDate = null;
-		OldMaintenancePrice = null;
-	
-		inDicideFlag = false;
-	
-		isSoft = false;
-		activeOn = true;
-		//LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
-		contr = '1';
-		val1 = '涓绘満';
-		//LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
-	
-		Date systemToday = System.today();
-		if (isPageAction == false) {
-			//HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� start
-			if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false) {
-				if (ApexPages.currentPage().getParameters().get('completion') == '1') {
-					ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
-				} else if (ApexPages.currentPage().getParameters().get('completion') == '2') {
-					ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '瀹℃壒鎻愪氦鎴愬姛銆�'));
-				} else if (ApexPages.currentPage().getParameters().get('completion') == '3') {
-					ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Decided銆�'));
-				} else if (ApexPages.currentPage().getParameters().get('completion') == '4') {
-	
-				} else if (ApexPages.currentPage().getParameters().get('completion') == '5') {
-					ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
-				}
-			}
-			//HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� end
-		}
-		this.printAsset = false;
-		this.printContract = false;
-		this.printTripartite = false;
-		this.printAgent = false;
-		String copyid = '';
-		if (isPageAction == false) {
-			this.targetEstimateId = ApexPages.currentPage().getParameters().get('copyid');
-			copyid = ApexPages.currentPage().getParameters().get('copyid');
-			if (this.targetEstimateId == null) {
-				String paramId = ApexPages.currentPage().getParameters().get('id');
-				if (String.isBlank(paramId) == false && paramId.startsWith('a0z')) {
-					Maintenance_Contract_Asset_Estimate__c mcaeParam = [Select Maintenance_Contract_Estimate__c from Maintenance_Contract_Asset_Estimate__c where Id = :paramId];
-					this.targetEstimateId = mcaeParam.Maintenance_Contract_Estimate__c;
-				} else {
-					this.targetEstimateId = paramId;
-				}
-			} else {
-				this.newIns = true;
-			}
-			this.targetMaintenanceContractId = ApexPages.currentPage().getParameters().get('mcid');
-		}
-		// 绶ㄩ泦銇嬨倝
-		if (String.isBlank(this.targetEstimateId) == false) {
-			setThisEstimate();
-			this.targetMaintenanceContractId = this.estimate.Maintenance_Contract__c;
-			this.setContractInfo(this.targetMaintenanceContractId);
-		}
-		// 鏂拌銇嬨倝
-		else if (!String.isBlank(this.targetMaintenanceContractId)) {
-			this.estimate = new Maintenance_Contract_Estimate__c();
-			this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
-	
-			//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start
-			Date pastDate;
-			for(Maintenance_Contract__c mc1 : [SELECT Id, Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
-														FROM Maintenance_Contract__c 
-														WHERE Id = :this.targetMaintenanceContractId
-														]){
-				pastDate = mc1.Past_Contract_end_day__c;										
-			}
-			
-			System.debug('lt123pastDate涓婃湡鍚堝悓缁撴潫鏃�'+pastDate);
-			if(systemToday < pastDate){
-				this.estimate.Contract_Esti_Start_Date__c = pastDate.addDays(1);
-			}else{
-				this.estimate.Contract_Esti_Start_Date__c = systemToday;
-			}
-			//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
-	
-			//this.estimate.Contract_Esti_Start_Date__c = systemToday;
-			this.estimate.Contract_Start_Date__c = systemToday;
-			this.setContractInfo(this.targetMaintenanceContractId);
-			this.newIns = true;
-		}
-		// 浣曘倐銇亼銈屻伆銆佸康銇仧銈�
-		else {
-			throw new ControllerUtil.myException('鏃犳硶鏄剧ず缁翠慨鍚堝悓鎶ヤ环');
-			//return;
-		}
-		//HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
-		IS_Clone_After_Decide = false;
-		if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false &&
-			ApexPages.currentPage().getParameters().get('completion') == '5' &&
-			this.estimate != null && this.estimate.IS_Clone_After_Decide__c) {
-			IS_Clone_After_Decide = true;
-	
-		}
-		//HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
-		// 绱嶅叆姗熷櫒銇儏鍫便倰鍙栧緱
-		if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
-			//2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-				  //tcm 娣诲姞 Management_Code__c  20211201 start
-			assetRecords = [SELECT Id, Name,OwnershipMachine_No__c,Product2.ProductURF__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty__c, Reson_Can_not_Warranty__c,
-							InstallDate, isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c, EquipmentGuaranteeFlg__c,
-							CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c, CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__c,
-							CurrentContract_F_asset__c, CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c, CurrentContract_F_asset__r.endDateGurantee_Text__c, CurrentContract_F__r.Gurantee_Estimate_startDate__c,
-							CurrentContract_F__r.First_Estimate_Date__c,
-							CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
-							CurrentContract_F__r.Contract_Range__c, AssetMark__c,
-							// 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
-							NoPartRiskDate_F__c, NoPartRiskDate__c, SignableFlag__c,
-							Product2.PartSupplyFinishDate__c, Product2.PartSupplyFinishDateExp__c
-							// 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
-							FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '鑰楁潗' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty__c asc];
-			//JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-			// assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
-			//                      InstallDate,isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,EquipmentGuaranteeFlg__c,
-			//                      CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,
-			//                      CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,
-			//                      CurrentContract_F__r.First_Estimate_Date__c,
-			//                     CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,
-			//                     CurrentContract_F__r.Contract_Range__c ,AssetMark__c
-			//                      FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c = '涓绘満' ORDER BY ID,IF_Warranty__c asc];
-			//JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-		} else {
-			assetRecords = new List<Asset>();
-		}
-		//sqlStr += ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
-		this.checkedAssets = new List<AssetInfo>();
-		this.unCheckedAssets = new List<AssetInfo>();
-	
-		// 閬告姙娓堛伩銇磵鍏ユ鍣ㄦ儏鍫便倰鍙栧緱
-		Map<Id, Integer> selectedAssetIds = new Map<Id, Integer>();
-		List<Maintenance_Contract_Asset_Estimate__c> selectedMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
-		List<Maintenance_Contract_Asset_Estimate__c> newMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
-		// 鏂拌銆佷笖銇わ紤銇ょ洰瑕嬬銈傘倞銇牬鍚堛�併偝銉斻兗鍏冦伄淇濇湁瑷倷銈掓寔銇�
-		if (String.isBlank(this.targetEstimateId) && this.contract.Estimate_Num__c == 0) {
-			List<Maintenance_Contract_Asset__c> oldVals = [
-				select Id, Name, Asset__c, Asset__r.InstallDate, Asset__r.isNewDate_use__c,
-				Asset__r.Posting_Date__c, Asset__r.Maintenance_Price_Month__c,
-				Asset__r.EquipmentGuaranteeFlg__c,
-				Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
-				Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
-				Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
-				Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
-				Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
-				Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
-				Asset__r.CurrentContract_F__r.Contract_Range__c,
-				Asset__r.CurrentContract_F__r.Contract_End_Date__c,
-				Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c
-				from Maintenance_Contract_Asset__c
-				where Maintenance_Contract__c = :this.targetMaintenanceContractId
-			];
-			Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
-			for (Maintenance_Contract_Asset__c mca : oldVals) {
-				// old銈堛倞鏇存柊銇椼仧銇勯爡鐩�
-				Boolean isNew = false;
-				// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-				boolean isCheck = true;
-				// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-				Decimal listPrice = mca.Asset__r.Maintenance_Price_Month__c;
-				Decimal asset_Consumption_rate = null;
-				// 鍙栦笂涓�鏈熷悎鍚屾秷璐圭巼
-				if (mca.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && mca.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
-					asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
-				} else {
-					asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
-				}
-				// InstallDate 銇� 浠婃棩銈掓瘮杓�
-				// 1.瀹夎鏃ユ垨鑰呭彂璐ф棩鍜屼粖澶╂瘮杈� 瀹炴椂鍙樺寲
-				// 2.鎻愪氦鍚庝笉鍐嶅彉鍖�
-				//Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
-				Date createdDate = systemToday;
-				if (createdDate.addMonths(isNewAddMonth) < mca.Asset__r.isNewDate_use__c) {
-					isNew = true;
-					// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-					isCheck = true;
-					// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-					listPrice = mca.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
-				}
-				selectedAssetIds.put(mca.Asset__c, selectedMcaes.size());
-				selectedMcaes.add(new Maintenance_Contract_Asset_Estimate__c(
-							  Asset__c = mca.Asset__c,
-							  isNew__c = isNew,
-							  // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-							  Check_Object__c = isCheck,
-							  // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-							  Estimate_List_Price__c = listPrice,
-							  // 鍙栦笂涓�鏈熷悎鍚屼环鏍�
-							  LastMContract_Price__c = mca.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
-	
-							  Asset_Consumption_rate__c = asset_Consumption_rate,
-							  EquipmentGuaranteeFlgTxt__c = mca.Asset__r.EquipmentGuaranteeFlg__c
-							  ));
-			}
-		} else {
-			for (Maintenance_Contract_Asset_Estimate__c mcae : [SELECT Id,
-																Name,
-																Maintenance_Contract_Estimate__c,
-																Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c,
-																Asset__c,
-																Asset__r.Maintenance_Price_Month__c,
-																Asset__r.InstallDate,
-																Asset__r.isNewDate_use__c,
-																Asset__r.EquipmentGuaranteeFlg__c,
-																//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-																Asset__r.OwnershipMachine_No__c,
-																//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-																Asset_Consumption_rate__c,
-																Asset__r.CurrentContract_F__c,
-																Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
-																Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
-																Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
-																Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
-																Asset__r.CurrentContract_F__r.Contract_Range__c,
-																Asset__r.CurrentContract_F__r.Contract_End_Date__c,
-																Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c,
-																LastMContract_Price__c,
-																Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
-																Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
-																Product_Manual__c,
-																Product_Manual__r.EquipmentGuaranteeFlg__c,
-																Product_Manual__r.Maintenance_Price_Month__c,
-																Product_Manual__r.Name,
-																//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-																Product_Manual__r.Asset_Model_No__c,
-																//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-																//add 2021-02-07 mzy  start
-																//Product_Manual__r.NoPartRiskDate_F__c,
-																//Product_Manual__r.SignableFlag__c,
-																//add 2021-02-07 mzy  end
-																//add 2021.6.4 fxk  Start
-																Check_Object__c,
-																//add 2021.6.4 fxk  end
-																IsNew__c,
-																Estimate_List_Price__c,
-																//Maintenance_Price_YearTXT__c,
-																Estimate_Cost__c,
-																Adjustment_ratio_Upper__c,
-																Adjustment_ratio_Lower__c,
-																Adjustment_Lower_price__c,
-																Adjustment_Upper_price__c,
-																Last_inspection_day__c,
-																Check_Result__c,
-																Repair_Price__c,
-																Comment__c,
-																Asset__r.Posting_Date__c,
-																EquipmentGuaranteeFlgTxt__c,
-																EquipmentGuaranteeFlg__c,
-																ifHaveleftInPrevious__c,
-																// Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-																Last_MContract__c
-																// Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
-																// LJPH-C9GD34 gzw fix start
-																,Estimate_List_Price_Page__c
-																// LJPH-C9GD34 gzw fix end
-																FROM Maintenance_Contract_Asset_Estimate__c
-																WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId
-																										 ORDER BY
-																										 Id,
-																Asset__c,
-																Product_Manual__c,
-																Asset__r.SerialNumber,
-																Asset__r.Name,
-																Asset__r.Department_Name__c,
-																Asset__r.InstallDate
-				 ]) {
-				if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
-					//if (String.isBlank(copyid) == false) {
-					if (mcae.Asset__c <> null) {
-						mcae.EquipmentGuaranteeFlgTxt__c = mcae.Asset__r.EquipmentGuaranteeFlg__c;
-						if (systemToday.addMonths(isNewAddMonth) < mcae.Asset__r.isNewDate_use__c) {
-							mcae.IsNew__c = true;
-							mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
-						} else {
-							mcae.IsNew__c = false;
-							mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c;
-						}
-					} else if (mcae.Product_Manual__c <> null) {
-						mcae.IsNew__c = true;
-						mcae.Estimate_List_Price__c = mcae.Product_Manual__r.Maintenance_Price_Month__c * isNewPriceAdj;
-					}
-				}
-				if (mcae.Asset__c <> null) {
-					//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , mcae.Asset__c + 'IsNew  ' + mcae.IsNew__c));
-					selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
-					selectedMcaes.add(mcae);
-				} else {
-					newMcaes.add(mcae);
-				}
-			}
-			system.debug('椤哄簭妫�娴�4' + selectedMcaes);
-		}
-		// 閬告姙娓堛伩銇倐銇伀銉併偋銉冦偗銈掍粯銇戙倠
-		// TODO xudan 涓�瑕с伀鍑恒倠鏄庣窗浠舵暟銇岃冻銈娿仾銇勩偙銉笺偣銇屻亗銈�
-		// 鈶燗ssetA鈥曟槑绱癆銇ф槑绱扮櫥閷�
-		// 鈶sset銇绱㈡潯浠跺鏇淬伀銈堛倞銆丄ssetA銇案閬犮伀鍙栧緱銇с亶銇亜
-		// 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
-		// 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
-		List<Data> datatemp = new List<Data>();
-		datatemp = getChartData();
-		for (Asset ast : this.assetRecords) {
-			Boolean isNew = false;
-			Decimal listPrice = ast.Maintenance_Price_Month__c;
-			if (selectedAssetIds.containsKey(ast.Id)) {
-				Maintenance_Contract_Asset_Estimate__c selectedLocal = selectedMcaes.get(selectedAssetIds.get(ast.Id));
-				isNew = selectedLocal.isNew__c;
-				listPrice = selectedLocal.Estimate_List_Price__c;
-				// xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
-				//                if (systemToday.addMonths(-6) < ast.InstallDate) {
-				//                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ast.InstallDate) {
-				//                Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
-				//System.debug(createdDate + '.addMonths(' + isNewAddMonth + ')' + createdDate.addMonths(isNewAddMonth) + ' < ast.InstallDate:' + ast.InstallDate);
-				//                if (createdDate.addMonths(isNewAddMonth) < ast.InstallDate) {
-				//                    isNew = true;
-				//                    listPrice = ast.Maintenance_Price_Month__c * isNewPriceAdj;
-				//                }
-				//              // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
-				//              娌℃湁鎻愪氦 鎴栬�呭湪鎶ヤ环鏃朵粠鏂拌绠�
-				if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
-					Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
-					selectedLocal.LastMContract_Price__c = selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ?   selectedLocal.LastMContract_Price__c : selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
-					//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'LastMContract_Price__c--' + selectedLocal.LastMContract_Price__c));
-					if (selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
-						selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
-					} else {
-						selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
-					}
-					//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c + 'Asset_Consumption--- ' + selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c));
-	
-					if (String.isNotBlank(String.valueOf(selectedLocal.Asset_Consumption_rate__c))) {
-						//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'Contract_Consumption_rate__c ' + selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c));
-						for (Data da : datatemp) {
-							if (String.isBlank(String.valueOf(da.rate_Lower)) &&  selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
-								selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
-								selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
-								continue;
-							} else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
-								selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
-								selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
-								continue;
-							} else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower
-									   && selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
-								selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
-								selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
-								continue;
-	
-							}
-							//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�--- ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
-						}
-						//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�+++ ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
-					}
-				}
-	
-				//
-				//
-				//
-				checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal));
-			} else {
-				//update by rentongxiao 2020-09-23 start
-				if (ast.AssetMark__c == '涓绘満') {
-					totalRecords++;
-					if (unCheckedAssets.size() < selctRecordNum) {
-						unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
-					}
-				}
-				//update by rentongxiao 2020-09-23 end
-	
-			}
-			listCut(unCheckedAssets);
-			/*
-			   if (ast.CheckBox__c) {
-					checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice));
-			   } else {
-					unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
-			   }
-			 */
-		}
-	
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-	
-		system.debug('椤哄簭妫�娴�' + checkedAssets);
-		for (Maintenance_Contract_Asset_Estimate__c mcae : newMcaes) {
-			checkedAssets.add(new AssetInfo(checkedAssets.size(), mcae));
-		}
-	
-		// 鏈�寰�10琛岃拷鍔�
-		if (Schema.getGlobalDescribe().get('Maintenance_Contract_Asset_Estimate__c').getDescribe().isCreateable()) {
-			this.addNewRows();
-		}
-	
-		if (!String.isBlank(copyid)) {
-			this.targetEstimateId = null;
-			this.estimate = new Maintenance_Contract_Estimate__c();
-			this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
-		}
-		// 2021-02-07  gzw add  LJPH-BWY5QB start
-		setEndUserType(this.targetMaintenanceContractId);
-		// 2021-02-07  gzw add  LJPH-BWY5QB start
-		assetRecords.clear();
-		// 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
-		//contractStartDateChange();
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		List<AssetInfo> topAsset =new List<AssetInfo>();
-		List<AssetInfo> otherAsset =new List<AssetInfo>();
-		
-		for(AssetInfo ched : checkedAssets){
-			system.debug('椤哄簭妫�娴�2' + ched.ProductModelNoc);
-			system.debug('椤哄簭妫�娴�3' + ched.AssetModelNoc);
-			system.debug('椤哄簭妫�娴�5' + ched.rec.OwnershipMachine_No__c);
-			if(TopProductModel.contains(ched.ProductModelNoc)||TopProductModel.contains(ched.AssetModelNoc)||TopProductModel.contains(ched.rec.OwnershipMachine_No__c)){
-				ched.CheckRows = true;
-				ched.mcae.Check_Object__c = false;
-				topAsset.add(ched);
-			}else{
-				otherAsset.add(ched);
-			}
-		}
-		system.debug('椤哄簭妫�娴�16' + topAsset);
-		system.debug('椤哄簭妫�娴�17' + otherAsset);
-		topAsset.addAll(otherAsset);
-		List<AssetInfo> NumberSort =new List<AssetInfo>();
-		Integer i=0;
-		for (AssetInfo ched2 : topAsset) {
-			ched2.lineNo=i;
-			i++;
-			NumberSort.add(ched2);
-		}
-		checkedAssets=NumberSort;
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-	}
-	
-	//
-	
-	// 鍙栧緱鍒嗛〉鏁版嵁
-	private void setPageRecord() {
-		checkIdList = new List<String> ();
-		for (AssetInfo ass : this.checkedAssets) {
-			if (!ass.isManual) {
-				checkIdList.add(ass.rec.Id);
-			}
-		}
-	
-		if ((currPage * selctRecordNum) <= 2000) {
-			String notInId = '(\'';
-			if (checkIdList.size() > 0) {
-				for (String str : checkIdList) {
-					notInId += str + '\', \'';
-				}
-			}
-			notInId += '\')';
-			//2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-				//tcm 娣诲姞 Management_Code__c  20211201 start
-			String sqlStr = 'SELECT Id, Name,OwnershipMachine_No__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
-							+ 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
-							+ 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
-							+ 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c, '
-							+ 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
-							+ 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
-							+ 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
-							+ 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,'
-							+ 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' '
-							+ 'AND Id NOT IN ' + notInId;
-			//HWAG-B4R3SS  START 20181026
-			if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
-				sqlStr += makeTextSql(text1, cond1, val1);
-			}
-	
-			//JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
-			// else{
-			//     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
-			// }
-	
-			//JZHG-BSDUT4 ---20200904---update By rentongxiao---end
-			//HWAG-B4R3SS  END 20181026
-			//HWAG-BDJ43R---XHL---20190729---
-			sqlStr += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' )';
-			//HWAG-BDJ43R---XHL---20190729---
-			sqlStr += ' ORDER BY ID,IF_Warranty__c asc ';
-			if (currPage == 1) {
-				sqlStr += 'limit ' + selRecordOption;
-			} else {
-				sqlStr += 'limit ' + selRecordOption + ' offset ' + String.valueOf((currPage - 1) * selctRecordNum);
-			}
-			//system.debug();
-			//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,
-			//               '222222222222_____'+sqlStr));
-			//return;
-			assetRecords = Database.query(sqlStr);
-		} else {
-			assetRecords.clear();
-			Integer sqlLimit = currPage * selctRecordNum;
-			List<Asset> temAsset = new List<Asset> ();
-			//HWAG-BDJ43R ---XHL---20190729---
-			String sqlStr = '';
-			//2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-			//tcm 娣诲姞 Management_Code__c  20211201 start
-			sqlStr  = 'SELECT Id, Name,OwnershipMachine_No__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c,';
-			sqlStr += 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,InstallDate,isNewDate_use__c,';
-			sqlStr += 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,';
-			sqlStr += 'CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,';
-			sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,';
-			sqlStr += 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,';
-			sqlStr += 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,';
-			sqlStr += 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
-			sqlStr += ' CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\'';
-			//JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-			// sqlStr += '  AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
-			//JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-			//HWAG-B4R3SS  START 20181026
-			if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
-				sqlStr += makeTextSql(text1, cond1, val1);
-			}
-	
-			//JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
-			// else{
-			//     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
-			// }
-	
-			//JZHG-BSDUT4 ---20200904---update By rentongxiao---end
-			//HWAG-B4R3SS  END 20181026
-			if (checkIdList.size() > 0) {
-				sqlStr += '  AND Id NOT IN ' + checkIdList;
-				//temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
-				//            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
-				//            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND Id NOT IN : checkIdList AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
-			} else {
-				//temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
-				//            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
-				//            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
-			}
-			sqlStr += ' ORDER BY ID,IF_Warranty__c asc limit ' + sqlLimit;
-			temAsset = Database.query(sqlStr);
-			//HWAG-BDJ43R ---XHL---20190729---
-			if (temAsset.size() >= (currPage * selctRecordNum)) {
-				for (Integer i = ((currPage - 1) * selctRecordNum); i < (currPage * selctRecordNum); i++) {
-					assetRecords.add(temAsset.get(i));
-				}
-			} else {
-				for (Integer i = ((currPage - 1) * selctRecordNum); i < temAsset.size(); i++) {
-					assetRecords.add(temAsset.get(i));
-				}
-			}
-		}
-		this.unCheckedAssets = new List<AssetInfo>();
-		for (Asset ast : assetRecords) {
-			this.unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
-		}
-		listCut(unCheckedAssets);
-		// 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
-		//contractStartDateChange();
-	}
-	
-	// 缈婚〉鍒伴椤�
-	public void firstPage() {
-		getAssetSerialNumber();
-		currPage = 1;
-		//HWAG-B4R3SS  END 20181026
-		totalRecords = soqlNos();
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		//HWAG-B4R3SS  END 20181026
-		this.setPageRecord();
-	}
-	
-	// 鍚戝墠缈婚〉
-	public void previousPage() {
-		getAssetSerialNumber();
-		currPage--;
-		//HWAG-B4R3SS  START 20181026
-		totalRecords = soqlNos();
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		//HWAG-B4R3SS  END 20181026
-		this.setPageRecord();
-	}
-	
-	// 鍚戝悗缈婚〉
-	public void nextPage() {
-		getAssetSerialNumber();
-		//HWAG-B4R3SS  START 20181026
-		totalRecords = soqlNos();
-		//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'totalRecords鈥斺�斺�斺�斺�斺��' + totalRecords));
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		if (totalRecords == 0) {
-			currPage  = 1;
-			//this.unCheckedAssets.clear();
-		} else {
-			currPage++;
-			this.setPageRecord();
-		}
-		//HWAG-B4R3SS  END 20181026
-	
-	}
-	
-	// 缈婚〉鍒板熬椤�
-	public void endPage() {
-		getAssetSerialNumber();
-		//HWAG-B4R3SS  START 20181026
-		totalRecords = soqlNos();
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		if (totalRecords == 0) {
-			currPage  = 1;
-			this.unCheckedAssets.clear();
-		} else {
-			currPage = totalPage;
-			this.setPageRecord();
-		}
-		//HWAG-B4R3SS  END 20181026
-	}
-	
-	// 姣忛〉鏄剧ず璁板綍鏁板彉鏇�
-	public void recordNumChange() {
-		currPage = 1;
-		//totalRecords = soqlNos();
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		this.setPageRecord();
-	}
-	
-	//list鍒嗗壊 闆嗗悎澶у皬瓒呰繃1000瀵瑰簲
-	private void listCut(List<AssetInfo> records) {
-		List<AssetInfo> recordsbreak = new List<AssetInfo>();
-		List<AssetInfo> recordsbreakover = new List<AssetInfo>();
-		unCheckedAssetsView = new List<List<AssetInfo> >();
-		AssetInfo c = null;
-		recordsbreak.clear();
-		recordsbreakover.clear();
-		unCheckedAssetsView.clear();
-		unCheckedAssetsView.add(records);
-	}
-	/*
-	 *鏄剧ず杩囧幓涓ゅ勾鐨勭淮淇疄缁�
-	 *璁$畻璇ョ淮淇悎鍚屾姤浠风殑鎵�鏈変繚浣戣澶囷紝杩囧幓涓ゅ勾鐨勪慨鐞嗗疄缁�
-	 */
-	public static void ComputeLTYRepair(String targetHospitalId) {
-		system.debug('ComputeLTYRepair=====Start');
-		List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
-		McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
-					from Maintenance_Contract_Asset_Estimate__c
-					where Maintenance_Contract_Estimate__c = :targetHospitalId];
-		List<id> AsList = new List<id>();
-		Map<id, id> McaecToAsset = new Map<id, id>();
-		for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
-			AsList.add(Mcaes.asset__c);
-			McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
-		}
-		Maintenance_Contract_Estimate__c mcec = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetHospitalId];
-		//1骞村墠缁翠慨瀹炵哗
-		Date today = null;
-		Date LastYearDate = null;
-		Date LastSecondYearDate = null;
-		Date LastThirdYearDate = null;
-		Decimal LastYearPriceForMCAEC = 0;
-	
-		if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
-			today = mcec.Submit_quotation_day__c;
-			LastYearDate = mcec.Submit_quotation_day__c;
-			LastSecondYearDate = mcec.Submit_quotation_day__c;
-			LastThirdYearDate = mcec.Submit_quotation_day__c;
-		} else {
-			today = Date.valueOf(mcec.createdDate);
-			LastYearDate = Date.valueOf(mcec.createdDate);
-			LastSecondYearDate = Date.valueOf(mcec.createdDate);
-			LastThirdYearDate = Date.valueOf(mcec.createdDate);
-		}
-	
-		system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
-	
-		LastYearDate = LastYearDate.addYears(-1);
-		// LastYearDate = LastYearDate.addDays(1);
-	
-		//LastSecondYearDate = LastSecondYearDate.addDays(1);
-		LastSecondYearDate = LastSecondYearDate.addYears(-2);
-	
-		// LastThirdYearDate = LastThirdYearDate.addDays(1);
-		LastThirdYearDate = LastThirdYearDate.addYears(-3);
-		system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
-		// 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
-		List<AggregateResult> FriRepairList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c > :LastYearDate
-			and Agreed_Date__c <= :today
-			group by Delivered_Product__c
-		];
-		List<AggregateResult> SecRepairList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c <= :LastYearDate
-			and Agreed_Date__c > :LastSecondYearDate
-			group by Delivered_Product__c
-		];
-		// 杩囧幓3骞撮棿淇悊瀹炵哗
-		List<AggregateResult> ThiRepairList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c <= :LastSecondYearDate
-			and Agreed_Date__c > :LastThirdYearDate
-			group by Delivered_Product__c
-		];
-		// 杩囧幓3骞翠慨鐞嗗疄缁�
-		List<AggregateResult> ThreeyearList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c <= :today
-			and Agreed_Date__c > :LastThirdYearDate
-			group by Delivered_Product__c
-		];
-	
-		// system.debug('++++++++'+FriRepairList+'++++++++'+SecRepairList+'+++++++'+ThiRepairList+'+++++');
-		// 杩囧幓1骞撮棿
-		Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
-		// 杩囧幓2骞撮棿
-		Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
-		// 杩囧幓3骞撮棿
-		Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
-		// 杩囧幓3骞�
-		Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
-		Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
-		for (AggregateResult Rpc : FriRepairList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal Defir = sumPrice1(Rpc);
-			LastFriYearPriceSumMap.put(idf, Defir);
-		}
-		for (AggregateResult Rpc : SecRepairList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal Defir = sumPrice1(Rpc);
-			LastSecYearPriceSumMap.put(idf, Defir);
-		}
-		for (AggregateResult Rpc : ThiRepairList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal Defir = sumPrice1(Rpc);
-			LastThiYearPriceSumMap.put(idf, Defir);
-		}
-		for (AggregateResult Rpc : ThreeyearList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
-			Decimal Defir = sumPrice1(Rpc);
-			ThreeYearPriceSumMap.put(idf, Defir);
-			ThiYearMonthMap.put(idf, threeYearM);
-		}
-		for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
-			Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
-			Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
-	
-	
-		}
-		try {
-			system.debug('McaeList:::::' + McaeList);
-			update McaeList;
-	
-			//return '';
-		} catch (Exception e) {
-			//return 'McaeList Update Failed : '+e;
-		}
-	
-	}
-	
-	
-	
-	public void ComputeLTYRepair() {
-		system.debug('ComputeLTYRepair=====Start');
-		List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
-		McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
-					from Maintenance_Contract_Asset_Estimate__c
-					where Maintenance_Contract_Estimate__c = :targetEstimateId];
-		List<id> AsList = new List<id>();
-		Map<id, id> McaecToAsset = new Map<id, id>();
-		for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
-			AsList.add(Mcaes.asset__c);
-			McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
-		}
-		Maintenance_Contract_Estimate__c mcec = new Maintenance_Contract_Estimate__c();
-		List<Maintenance_Contract_Estimate__c>  mcecList = new List<Maintenance_Contract_Estimate__c>();
-		mcecList = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetEstimateId];
-		if (mcecList.size() == 0) {
-			ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, '璇峰厛淇濆瓨鎶ヤ环锛�'));
-			return;
-		} else {
-			mcec = mcecList[0];
-		}
-		//1骞村墠缁翠慨瀹炵哗
-		Date today = null;
-		Date LastYearDate = null;
-		Date LastSecondYearDate = null;
-		Date LastThirdYearDate = null;
-		Decimal LastYearPriceForMCAEC = 0;
-	
-		if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
-			today = mcec.Submit_quotation_day__c;
-			LastYearDate = mcec.Submit_quotation_day__c;
-			LastSecondYearDate = mcec.Submit_quotation_day__c;
-			LastThirdYearDate = mcec.Submit_quotation_day__c;
-		} else {
-			today = Date.valueOf(mcec.createdDate);
-			LastYearDate = Date.valueOf(mcec.createdDate);
-			LastSecondYearDate = Date.valueOf(mcec.createdDate);
-			LastThirdYearDate = Date.valueOf(mcec.createdDate);
-		}
-	
-		LastYearDate = LastYearDate.addYears(-1);
-		// LastYearDate = LastYearDate.addDays(1);
-	
-		// LastSecondYearDate = LastSecondYearDate.addDays(1);
-		LastSecondYearDate = LastSecondYearDate.addYears(-2);
-	
-		// LastThirdYearDate = LastThirdYearDate.addDays(1);
-		LastThirdYearDate = LastThirdYearDate.addYears(-3);
-		system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
-		// 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
-		List<AggregateResult> FriRepairList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c > :LastYearDate
-			and Agreed_Date__c <= :today
-			group by Delivered_Product__c
-		];
-		List<AggregateResult> SecRepairList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c <= :LastYearDate
-			and Agreed_Date__c > :LastSecondYearDate
-			group by Delivered_Product__c
-		];
-		// 杩囧幓3骞撮棿淇悊瀹炵哗
-		List<AggregateResult> ThiRepairList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c <= :LastSecondYearDate
-			and Agreed_Date__c > :LastThirdYearDate
-			group by Delivered_Product__c
-		];
-		// 杩囧幓3骞翠慨鐞嗗疄缁�
-		List<AggregateResult> ThreeyearList = [
-			select
-			sum(Discount_Price_formula__c) SumPrice,
-			//2019/1娣诲姞
-			sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-			sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-			sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-			sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-			sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-			sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-			sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-			sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-			sum(Repair_Quotation_Id__r.Other_discount__c) other,
-			AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-			Delivered_Product__c
-			from
-			Repair__c
-			where
-			Delivered_Product__c in:AsList
-			and Agreed_Date__c != null
-			and Agreed_Date__c <= :today
-			and Agreed_Date__c > :LastThirdYearDate
-			group by Delivered_Product__c
-		];
-		// 杩囧幓1骞撮棿
-		Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
-		// 杩囧幓2骞撮棿
-		Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
-		// 杩囧幓3骞撮棿
-		Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
-		// 杩囧幓3骞�
-		Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
-		Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
-		// system.debug('1'+FriRepairList);
-		// system.debug('2'+SecRepairList);
-		system.debug('3' + ThiRepairList);
-	
-		for (AggregateResult Rpc : FriRepairList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal Defir = this.sumPrice(Rpc);
-			LastFriYearPriceSumMap.put(idf, Defir);
-		}
-		for (AggregateResult Rpc : SecRepairList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal Defir = this.sumPrice(Rpc);
-			LastSecYearPriceSumMap.put(idf, Defir);
-		}
-		for (AggregateResult Rpc : ThiRepairList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal Defir = sumPrice1(Rpc);
-			LastThiYearPriceSumMap.put(idf, Defir);
-		}
-		for (AggregateResult Rpc : ThreeyearList) {
-			id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-			//Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-			Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
-			Decimal Defir = sumPrice1(Rpc);
-			ThreeYearPriceSumMap.put(idf, Defir);
-			ThiYearMonthMap.put(idf, threeYearM);
-		}
-		for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
-			Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-			Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
-			Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
-			system.debug('杩囧幓3骞村ぉ鏁�111 ' + Mca.id + '---' + Mca.Last_Third_Years_Repair_Cost_Text__c + ' +++ ' + Mca.Last_Third_Years_Repair_Month__c);
-		}
-		try {
-			update McaeList;
-			//return '';
-		} catch (Exception e) {
-			//return 'McaeList Update Failed : '+e;
-		}
-	
-	}
-	
-	private Decimal sumPrice(AggregateResult rpc) {
-		Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
-		system.debug(rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount'));
-		Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
-		Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
-		Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
-		Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
-		Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
-		Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
-		Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
-		Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
-		Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
-		system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
-					 rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
-					 + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
-		return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
-	}
-	
-	private static Decimal sumPrice1(AggregateResult rpc) {
-		Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
-		Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
-		Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
-		Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
-		Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
-		Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
-		Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
-		Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
-		Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
-		Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
-		system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
-					 rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
-					 + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
-		return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
-	}
-	
-	
-	//搴熷純涓�=========20161024==============//
-	public void ShowLTYRepair() {
-		system.debug('ShowLTYRepair=====Start');
-		lastFriYearsPriceSum = 0;
-		lastSecYearsPriceSum = 0;
-		//
-		List<Maintenance_Contract_Estimate__c> McecList = new List<Maintenance_Contract_Estimate__c>();
-		McecList = [select
-					Last_Year_Repair_Sum__c,
-					Year_Before_Last_Year_Re_Sum__c,
-					Last_Two_Year_Repair_sum__c,
-					Process_Status__c,                            //鎶ヤ环鐘舵��
-					Repair_Sum_Compute_Date__c
-					from
-					Maintenance_Contract_Estimate__c
-					where
-					id = :targetEstimateId
-		];
-		Maintenance_Contract_Estimate__c McecEle = new Maintenance_Contract_Estimate__c();
-		if (McecList.size() > 0) {
-			McecEle = McecList[0];
-			Date ComputeD = McecEle.Repair_Sum_Compute_Date__c == null ? Date.today() : McecEle.Repair_Sum_Compute_Date__c;
-			String DateString1 = ComputeD + '';
-			String DateString2 = ComputeD.addYears(-2).addDays(1) + '';
-			alertString = '闆嗚▓瀵捐薄鏈熼枔锛�' + DateString1.substring(0, 10) + '~' + DateString2.substring(0, 10) + '';
-			alertString2 = '鍘诲勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Last_Year_Repair_Sum__c + ' RMB ';
-			alertString3 = '鍓嶅勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Year_Before_Last_Year_Re_Sum__c + ' RMB';
-		} else {
-			alertString = '娌℃湁鏈夋晥鐨勭淮淇悎鍚屾姤浠�';
-		}
-	}
-	/**
-	 * 鎵嬪嫊銇у晢鍝侀伕鎶炲緦銇儶銉曘儸銉冦偡銉�
-	 **/
-	public void refreshProductData() {
-		System.debug('1535.......................杩涘叆refreshProductData鏂规硶');
-		System.debug('1536.......................杩涘叆refreshProductData鏂规硶');
-		for (Integer i = 0; i < checkedAssets.size(); i++) {
-			if (i == productIdx) {
-				AssetInfo ai = checkedAssets[i];
-				System.debug('--------:' + ai);
-				if (ai.mcae.Product_Manual__c == null) {
-					ai.mcae.Estimate_List_Price__c = null;
-					// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-					ai.CheckRows = true;
-					//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-					ai.ProductModelNoc=null;
-					ai.AssetModelNoc=null;
-					ai.MDMModelNoc=null;
-					ai.mcae.Check_Object__c = true;
-					//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-					// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
-					System.debug('--------23234234:' + productIdx);
-					System.debug('1540--'+i);
-				} else {
-					//2021-02-04 mzy select璇彞鏌ヨ缁撴灉涓姞浜� NoPartRiskDate_F__c
-					//2021-11-30 fy add LJPH-C8W8FV 缃《 start Asset_Model_No__c ProductURF__c
-					List<Product2> prd = [select Id,Asset_Model_No__c,ProductURF__c, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c, Name from Product2 where Id = :ai.mcae.Product_Manual__c];
-					ai.mcae.Estimate_List_Price__c = prd[0].Maintenance_Price_Month__c * isNewPriceAdj;
-					//ai.mcae.Maintenance_Price_YearTXT__c = ai.mcae.Estimate_List_Price__c * 12;
-					ai.orgPrice = prd[0].Maintenance_Price_Month__c;
-					ai.mcae.EquipmentGuaranteeFlgTxt__c = prd[0].EquipmentGuaranteeFlg__c;
-					ai.etGFlg = prd[0].EquipmentGuaranteeFlg__c;
-					//add by rentx 2020-11-12 LJPH-BV93RZ start
-					ai.proName = prd[0].Name;
-					//add by rentx 2020-11-12 LJPH-BV93RZ end
-					// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-					ai.CheckRows = false;
-	
-					//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-					ai.MDMModelNoc = prd[0].Asset_Model_No__c;
-					if(TopProductModel.contains(ai.MDMModelNoc)){
-						ai.CheckRows = true;
-						ai.mcae.Check_Object__c = false;
-					}else {
-						if(String.isNotBlank(prd[0].ProductURF__c)){
-							ai.mcae.Check_Object__c = false;
-						}else{
-							ai.mcae.Check_Object__c = true;
-						}
-						ai.CheckRows = false;
-					}
-					//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-	
-					// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
-					//add by mzy 2021-02-04 LJPH-BX9CVX start
-					//ai.NoPartRiskDate = prd[0].NoPartRiskDate_F__c;
-					//ai.proName2 = prd[0].Name;
-					//ai.SignableFlag = prd[0].SignableFlag__c;
-					//add by mzy 2021-02-04 LJPH-BX9CVX end
-				}
-				checkedAssets[i]=ai;
-			}
-		}
-		System.debug('--------kkkkkkk:' + checkedAssets);
-		// HWAG-BA73ZP
-		//contractStartDateChange();
-	}
-	
-	/**
-	 * 閬告姙娓堛伩锛忔湭閬告姙瑁藉搧銇疆銇嶆彌銇�
-	 */
-	public PageReference exchangeAsset() {
-		System.debug('exchangeAsset start');
-		Date systemToday = System.today();
-		List<AssetInfo> tmpChecked = new List<AssetInfo>();
-		List<AssetInfo> tmpNewRows = new List<AssetInfo>();
-		List<AssetInfo> tmpUnChecked = new List<AssetInfo>();
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		List<AssetInfo> tmpnewChecked = new List<AssetInfo>();
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-		List<Data> datatemp = new List<Data>();
-		datatemp = getChartData();
-		for (AssetInfo ass : this.checkedAssets) {
-			if (ass.isManual) {
-				tmpNewRows.add(ass);
-			} else if (ass.rec_checkBox_c) {
-				tmpChecked.add(ass);
-			} else {
-				ass.mcae = null;
-				tmpUnChecked.add(ass);
-				totalRecords++;
-			}
-		}
-		for (AssetInfo ass : this.unCheckedAssets) {
-			Boolean isNew = false;
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-			boolean isCheck = true;
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-			Decimal listPrice = ass.rec.Maintenance_Price_Month__c;
-			if (ass.rec_checkBox_c) {
-				//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'unCheckedAssets ' ));
-				// xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
-				//                if (systemToday.addMonths(-6) < ass.rec.InstallDate) {
-				//                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
-				//                Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
-				//                if (createdDate.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
-				//                    isNew = true;
-				//                    listPrice = ass.rec.Maintenance_Price_Month__c * isNewPriceAdj;
-				//                }
-				Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c(
-					isNew__c = isNew,
-					// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-					Check_Object__c = isCheck,
-					// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-					Estimate_List_Price__c = listPrice,
-					EquipmentGuaranteeFlgTxt__c = ass.rec.EquipmentGuaranteeFlg__c
-					);
-				ass.mcae = mcae;
-				// 璁$畻涓婁笅绾胯皟鏁存瘮渚�
-				if (!getPageDisabled()) {
-					// 鍙栧綋鍓嶆湀绗竴澶�
-					Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
-					mcae.LastMContract_Price__c = ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ? mcae.LastMContract_Price__c : ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
-					if (ass.rec.CurrentContract_F__r.First_Estimate_Date__c != null && ass.rec.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
-						mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c;
-					} else {
-						mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
-					}
-					if (String.isNotBlank(String.valueOf(mcae.Asset_Consumption_rate__c))) {
-						for (Data da : datatemp) {
-							if (String.isBlank(String.valueOf(da.rate_Lower)) &&  mcae.Asset_Consumption_rate__c < da.rate_Upper) {
-								mcae.Adjustment_ratio_Lower__c = da.price_Lower;
-								mcae.Adjustment_ratio_Upper__c = da.price_Upper;
-								continue;
-							} else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
-								mcae.Adjustment_ratio_Lower__c = da.price_Lower;
-								mcae.Adjustment_ratio_Upper__c = da.price_Upper;
-								continue;
-							} else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower
-									   && mcae.Asset_Consumption_rate__c < da.rate_Upper) {
-								mcae.Adjustment_ratio_Lower__c = da.price_Lower;
-								mcae.Adjustment_ratio_Upper__c = da.price_Upper;
-								continue;
-							}
-						}
-					}
-				}
-	
-	
-	
-				// tmpChecked.add(ass);
-				//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-				tmpnewChecked.add(ass);
-				//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-				totalRecords--;
-			} else {
-				ass.mcae = null;
-				tmpUnChecked.add(ass);
-			}
-		}
-	
-		this.checkedAssets = new List<AssetInfo>();
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		system.debug('tmpnewChecked======'+tmpnewChecked);
-		system.debug('tmpChecked======'+tmpChecked);
-		for (AssetInfo ass : tmpnewChecked) {
-			if(String.isNotBlank(ass.rec.Product2.ProductURF__c)){
-				ass.mcae.Check_Object__c = false;
-			}
-			tmpChecked.add(ass);
-		}
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-		for (AssetInfo ass : tmpChecked) {
-			ass.lineNo = this.checkedAssets.size();
-			this.checkedAssets.add(ass);
-		}
-		for (AssetInfo ass : tmpNewRows) {
-			ass.lineNo = this.checkedAssets.size();
-			this.checkedAssets.add(ass);
-		}
-		this.unCheckedAssets = new List<AssetInfo>();
-		this.unCheckedAssets.addAll(tmpUnChecked);
-	
-		totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-		this.setPageRecord();
-	
-		//listCut(unCheckedAssets);
-		// 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
-		//contractStartDateChange();
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		List<AssetInfo> topAsset =new List<AssetInfo>();
-		List<AssetInfo> otherAsset =new List<AssetInfo>();
-		system.debug('aaa'+this.checkedAssets);
-		for(AssetInfo ched : this.checkedAssets){
-			system.debug('ched.AssetModelNoc======'+ched.AssetModelNoc);
-			system.debug('ched.ProductModelNoc======'+ched.ProductModelNoc);
-			system.debug('ched.rec.OwnershipMachine_No__c======'+ched.rec.OwnershipMachine_No__c);
-			if(TopProductModel.contains(ched.ProductModelNoc)||TopProductModel.contains(ched.AssetModelNoc)||TopProductModel.contains(ched.rec.OwnershipMachine_No__c)||TopProductModel.contains(ched.MDMModelNoc)){
-				ched.CheckRows = true;
-				ched.mcae.Check_Object__c = false;
-				topAsset.add(ched);
-			}else{
-				otherAsset.add(ched);
-			}
-		}
-		topAsset.addAll(otherAsset);
-		List<AssetInfo> NumberSort =new List<AssetInfo>();
-		Integer i=0;
-		for (AssetInfo ched2 : topAsset) {
-			ched2.lineNo=i;
-			i++;
-			NumberSort.add(ched2);
-		}
-		this.checkedAssets=NumberSort;
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-		return null;
-	}
-	
-	// 鍚堝悓寮�濮嬫棩鍙樻洿锛岄噸鏂拌绠楁柊鍝�
-	// 鍚堝悓寮�濮嬫棩鍙樻洿锛屼笉璁$畻鏂板搧锛岃澶囦笂鐨勬柊鍝佸彧鐪嬫姤浠锋椂鐐圭殑鐘舵�� 娉ㄩ噴 BY GZW 20200325
-	// public PageReference contractStartDateChange() {
-	//     Date systemToday = System.today();
-	//     // 鍒涘缓鏃�
-	//     //Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
-	//     Date createdDate = systemToday;
-	//     // 鍒涘缓鏃�3涓湀
-	//     Date threeMonthAfter = createdDate.addMonths(keepPriceMonth);
-	//     // 鍒涘缓鏃�6涓湀
-	//     Date isNewAfter = createdDate.addMonths(-isNewAddMonth);
-	//     // 鍚堝悓寮�濮嬫棩
-	//     Date contractDate = estimate.Contract_Start_Date__c == null ? systemToday : estimate.Contract_Start_Date__c;
-	//     // 鍚堝悓寮�濮嬮瀹氭棩
-	//     Date contractEstiDate = estimate.Contract_Esti_Start_Date__c == null ? systemToday : estimate.Contract_Esti_Start_Date__c;
-	
-	//     /**********************HWAG-AYDCZX 2018/5/8 ADD START***************************/
-	//     // 鏂拌銆佸啀鎶ヤ环銆佽崏妗堜腑 缁翠慨鍚堝悓浠锋牸鏄剧ず
-	//     System.debug('********changedAfterPrint:'+ (changedAfterPrint ? 'true' : 'false'));
-	//     if (this.estimate.CreatedDate == null
-	//         || String.isBlank(ApexPages.currentPage().getParameters().get('copyid')) == false
-	//         || this.estimate.Process_Status__c == '鑽夋涓�'
-	//         || changedAfterPrint) {
-	//         for (AssetInfo info : checkedAssets) {System.debug('********contractDate changed:'+String.valueOf(contractDate));
-	
-	//             // 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�6涓湀锛岄兘涓嶇畻鏂板搧
-	//             if (contractEstiDate >= isNewAfter) {
-	//             //    if (!info.isManual) {
-	//             //        info.mcae.isNew__c = false;
-	//             //        info.mcae.Estimate_List_Price__c = info.orgPrice;
-	//             //    } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
-	//             //        info.mcae.isNew__c = false;
-	//             //        info.mcae.Estimate_List_Price__c = info.orgPrice;
-	//             //    }
-	//             }
-	//             // 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�3涓湀锛屼娇鐢ㄥ悎鍚屽紑濮嬫棩璁$畻鏂板搧
-	//             // 浣跨敤鍒涘缓鏃ヨ绠楁柊鍝�
-	//             //
-	//             //
-	//             // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚� 20200218 Gzw 鏈嶅姟鍚堝悓瀵瑰簲
-	//             else {
-	//                 Date isNewDate = contractDate;
-	//                 // Date isNewDate = null;
-	//                 // if (contractDate >= threeMonthAfter) {
-	//                 //     isNewDate = contractDate;
-	//                 // } else {
-	//                 //     isNewDate = createdDate;
-	//                 // }
-	//                 if (!info.isManual) {
-	//                     info.mcae.isNew__c = false;
-	//                     info.mcae.Estimate_List_Price__c = info.orgPrice;
-	//                     // 110銇嬨倝銇牬鍚堛�丳ost銇傘倞銆両nstall銇仐
-	//                     if (info.rec.Posting_Date__c != null && info.rec.InstallDate == null) {
-	//                         if (isNewDate.addMonths(isNewAddMonth) < info.rec.Posting_Date__c) {
-	//                             info.mcae.isNew__c = true;
-	//                             info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
-	//                         }
-	//                     }
-	//                     // Install銇傘倞
-	//                     else if (info.rec.Posting_Date__c != null && info.rec.InstallDate != null) {
-	//                         // Post銇嬨倝6鏈堢祵銇c仸銈侷nstall銇椼仸銇亜
-	//                         // if (info.rec.Posting_Date__c.addMonths(PosttoInstall) < info.rec.isNewDate_use__c) {
-	//                         //     // 鏂板搧閬╃敤銇椼仾銇�
-	//                         // }
-	//                         // else {
-	//                             if (isNewDate.addMonths(isNewAddMonth) < info.rec.isNewDate_use__c) {
-	//                                 info.mcae.isNew__c = true;
-	//                                 info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
-	//                             }
-	//                         // }
-	//                     }
-	//                     // Post銇仐
-	//                     else if (info.rec.Posting_Date__c == null && info.rec.InstallDate != null) {
-	//                         if (isNewDate.addMonths(isNewAddMonth) < info.rec.isNewDate_use__c) {
-	//                             info.mcae.isNew__c = true;
-	//                             info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
-	//                         }
-	//                     }
-	//                     else {
-	//                         // 鐗规畩鍑︾悊銇仐
-	//                     }
-	//                 } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
-	//                     info.mcae.isNew__c = true;
-	//                     info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
-	//                 }
-	//             }
-	//         }
-	//     }
-	//     return null;
-	// }
-	
-	/**
-	 * 淇濆瓨銉°偨銉冦儔
-	 */
-	public PageReference save() {
-		System.debug('save start');
-		//add by rentx 2020-11-13 LJPH-BV93RZ start
-		if (estimate.Contract_Range__c == null) {
-			this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
-			return null;
-		}
-		//add by rentx 2020-11-13 LJPH-BV93RZ end
-	
-	
-		Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
-		estimate.recordtypeid = vmMaintenance_Contract;
-		if (changedSubmitPrice) {
-			priceChangeReset();
-			return null;
-		}
-		if (syncEstimate(false, false)) {
-			ComputeLTYRepair();
-			//return null;
-			return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
-		}
-		return null;
-	}
-	
-	/**
-	 * 鍗板埛銉°偨銉冦儔銆乨ecide鍓嶃伅淇濇湁瑷倷銆乨ecide寰屻伅鍚堝悓閰嶇疆
-	 */
-	public void print() {
-		System.debug('print start');
-		this.printAsset = false;
-		this.printContract = false;
-		this.printTripartite = false;
-		this.printAgent = false;
-		this.estimate.PrintDate__c = Date.today();
-		//SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
-		if (this.estimate.Quote_Date__c == null) {
-			this.estimate.Quote_Date__c = Date.today();
-		}
-	
-	
-	
-		if (this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c) {
-			ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '涓嶈兘鍚屾椂閫変腑涓夋柟鍗忚鍜屼唬鐞嗗晢鍚堝悓锛�'));
-		} else
-	
-	
-		// 淇濆瓨銉溿偪銉炽仹銇嶃仾銇勫牬鍚堛�佸嵃鍒枫儨銈裤兂銇儠銉┿偘銇伩淇濆瓨
-		if (this.getSaveBtnDisabled()) {
-			if (savePrintFlg()) {
-				// 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
-				/*if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
-						// 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
-						this.printContract = true;
-				   } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
-						//鎵撳嵃涓夋柟鍚堝悓
-						this.printTripartite = true;
-				   } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
-						//鎵撳嵃缁忛攢鍟嗗悎鍚�
-						this.printAgent = true;
-				   }else{
-						// 鎵撳嵃淇濇湁瑷倷
-						this.printAsset = true;
-				   }*/
-				// 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
-				// 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
-				if (this.estimate.Print_Tripartite__c ) {
-					//鎵撳嵃涓夋柟鍚堝悓
-					this.printTripartite = true;
-				} else if (!this.estimate.Estimation_Decision__c) {
-					this.printAsset = true;
-	
-				} else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
-					this.printContract = true;
-	
-				} else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
-					this.printAgent = true;
-				}
-				// 2018/10/26 HWAG-B5C88S end
-			}
-		}
-		// 淇濆瓨銉溿偪銉炽仹銇嶃倠鍫村悎銆佸嵃鍒枫儨銈裤兂銇叏閮ㄤ繚瀛�
-		else {
-			if (syncEstimate(false, false)) {
-				// 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
-				/*
-				   if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
-						// 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
-						this.printContract = true;
-				   } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
-						//鎵撳嵃涓夋柟鍚堝悓
-						this.printTripartite = true;
-				   } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
-						//鎵撳嵃缁忛攢鍟嗗悎鍚�
-						this.printAgent = true;
-				   }else{
-						// 鎵撳嵃淇濇湁瑷倷
-						this.printAsset = true;
-				   }
-				 */
-				// 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
-				// 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
-				if (this.estimate.Print_Tripartite__c ) {
-					//鎵撳嵃涓夋柟鍚堝悓
-					this.printTripartite = true;
-				} else if (!this.estimate.Estimation_Decision__c) {
-					this.printAsset = true;
-	
-				} else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
-					this.printContract = true;
-	
-				} else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
-					this.printAgent = true;
-				}
-				// 2018/10/26 HWAG-B5C88S end
-			}
-		}
-		//ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '鍚堝悓'+this.printContract +'涓夋柟'+this.printTripartite+'淇濇湁'+this.printAsset+'缁忛攢鍟嗗悎鍚�'+this.printAgent));
-	}
-	
-	/**
-	 * 鐢宠珛銉°偨銉冦儔銆佹渶寰屽繀銇氭壙瑾嶃儣銉偦銈广伀杓夈仜銈�
-	 */
-	public PageReference approvalProcess() {
-	
-	
-		Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
-		estimate.recordtypeid = vmMaintenance_Contract;
-	
-		// Date systemToday = System.today();
-		// // 鍒涘缓鏃�/鎻愪氦鏃�
-		// Date createdDate = systemToday;
-		// // 鍒涘缓鏃�6涓湀
-		// Date isNewAfter = createdDate.addMonths(-isNewAddMonth);
-		// // 鍚堝悓寮�濮嬮瀹氭棩
-		// Date contractEstiDate = estimate.Contract_Esti_Start_Date__c == null ? systemToday : estimate.Contract_Esti_Start_Date__c;
-		//  for (AssetInfo info : checkedAssets) {
-		//       // 鍚堝悓棰勫畾寮�濮嬫棩 澶т簬鎻愪氦鏃�6涓湀锛岄兘涓嶇畻鏂板搧 20200218 Gzw 鏈嶅姟鍚堝悓瀵瑰簲
-		//       //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'contractEstiDate '+ contractEstiDate +'isNewAfter '+isNewAfter));
-		//       if (contractEstiDate >= isNewAfter) {
-		//           if (!info.isManual) {
-		//               info.mcae.isNew__c = false;
-		//               info.mcae.Estimate_List_Price__c = info.orgPrice;
-		//            } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
-		//               info.mcae.isNew__c = false;
-		//               info.mcae.Estimate_List_Price__c = info.orgPrice;
-		//            }
-		//        }
-		// }
-	
-		if (changedSubmitPrice) {
-			priceChangeReset();
-			return null;
-		}
-	
-	
-		if (syncEstimate(true, false)) {
-			Savepoint sp = Database.setSavepoint();
-			// 鎵胯獚銉椼儹銈汇偣銇級銇涖倠
-			try {
-	
-				// 宸插~鍐欑敵璇风姸鎬�
-				this.estimate.ApprovalProcess_Status__c = '宸插~鍐欏畬骞剁敵璇�';
-				ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-				// 鎵胯獚銉椼儹銈汇偣
-				Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
-				psr.setObjectId(this.estimate.id);
-				Approval.ProcessResult submitResult = Approval.process(psr);
-				ComputeLTYRepair();
-				if (changedAfterPrint) {
-					return new PageReference('/' + this.targetEstimateId);
-					//return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
-				} else {
-					return new PageReference('/' + this.targetEstimateId);
-					//return new PageReference('/' + this.targetEstimateId + '/e?completion=2');
-				}
-			} catch (Exception ex) {
-				System.debug('=====Exception:' + ex.getMessage());
-				Database.rollback(sp);
-				this.estimate.ApprovalProcess_Status__c = null;
-				ApexPages.addMessages(ex);
-			}
-		}
-		return null;
-	}
-	
-	/**
-	 * 姹哄畾鍙栨秷銉°偨銉冦儔
-	 */
-	public PageReference undecide() {
-	
-	
-		System.debug('undecide start');
-		this.estimate.Estimation_Decision__c = false;
-		this.estimate.Print_Contract__c = false;
-	
-		//娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
-		this.estimate.Quotation_Determines_Time__c = null;
-	
-		try {
-			ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-			return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
-		} catch (Exception ex) {
-			ApexPages.addMessages(ex);
-		}
-		return null;
-	}
-	
-	/**
-	 * 姹哄畾銉°偨銉冦儔
-	 */
-	public PageReference decide() {
-		System.debug('decide start');
-		inDicideFlag = true;
-		// TODO check decide 璧勬牸
-		Savepoint sp = Database.setSavepoint();
-		// gzw cputimeout 鎶ラ敊娣诲姞 20210729 start
-		Oly_TriggerHandler.bypass('AssetHandler');
-		StaticParameter.EscapeVMCTrigger = true;
-		// gzw cputimeout 鎶ラ敊娣诲姞 20210729 end
-		if (syncEstimate(false, true)) {
-			//鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
-			this.estimate.Quotation_Determines_Time__c = date.today();
-	
-			if (changedAfterPrint) {
-				return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
-			} else {
-				return new PageReference('/' + this.targetEstimateId + '/e?completion=3');
-			}
-		}
-	
-		return null;
-	}
-	
-	public PageReference decideCancle() {
-	
-		return new PageReference('/' + this.targetEstimateId + '/e?completion=4');
-	
-	}
-	
-	/**
-	 * Process鐢ㄣ伄銉︺兗銈躲兗鎯呭牨銈掋偦銉冦儓銆佹柊瑕忚绌嶃倐銈婃檪鐢�
-	 */
-	
-	private void setApprovalManager() {
-		User loginUser = [SELECT Id, Name, JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, TongkuoZongjian__c FROM User WHERE Id = :UserInfo.getUserId()];
-		// 瑕佹敞鎰� SaveMaintenanceByCopyController 銇� copy銇畊rl銇倐銆佷笅瑷樸伄闋呯洰銈傘偗銉偄
-		this.estimate.JingliApprovalManager__c = loginUser.JingliApprovalManager__c == null ? loginUser.Id : loginUser.JingliApprovalManager__c;
-		this.estimate.BuchangApprovalManager__c = loginUser.BuchangApprovalManager__c == null ? loginUser.Id : loginUser.BuchangApprovalManager__c;
-		this.estimate.ZongjianApprovalManager__c = loginUser.ZongjianApprovalManager__c == null ? loginUser.Id : loginUser.ZongjianApprovalManager__c;
-		this.estimate.Service_Contract_Staff__c = this.contract.Service_Contract_Staff__c;
-		this.estimate.TKZongjianApprovalManager__c = loginUser.TongkuoZongjian__c == null ? loginUser.Id : loginUser.TongkuoZongjian__c;
-	}
-	
-	/**
-	 * 鍗板埛銉曘儵銈般伄銇裤倰淇濆瓨
-	 */
-	@TestVisible
-	private Boolean savePrintFlg() {
-		try {
-			Maintenance_Contract_Estimate__c mce = new Maintenance_Contract_Estimate__c();
-			mce.Id = this.targetEstimateId;
-			//鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
-			mce.Print_Simplify__c = this.estimate.Print_Simplify__c;
-			//鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
-			mce.Print_ListPrice__c = this.estimate.Print_ListPrice__c;
-			mce.Print_RepairPrice__c = this.estimate.Print_RepairPrice__c;
-			mce.Print_SumPrice__c = this.estimate.Print_SumPrice__c;
-			mce.Print_DiscountPercentage__c = this.estimate.Print_DiscountPercentage__c;
-			mce.Print_DiscountPrice__c = this.estimate.Print_DiscountPrice__c;
-			mce.Print_MaintePrice__c = this.estimate.Print_MaintePrice__c;
-			mce.Print_Contract__c = this.estimate.Print_Contract__c;
-	
-			ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {mce});
-			return true;
-		} catch (Exception ex) {
-			ApexPages.addMessages(ex);
-		}
-		return false;
-	}
-	
-	/**
-	 * 鐢婚潰銇у叆鍔涖儑銉笺偪check, save, 瑕仺鍚屾湡 銇儹銈搞儍銈�
-	 */
-	// TODO xudan 銉併偋銉冦偗杩藉姞銆乧ls銇倐鍚堣▓閲戦銈掕▓绠椼�乧ls銇悎瑷堥噾椤嶃仺鐢婚潰銇嬨倝js銇悎瑷堥噾椤嶃倰姣旇純
-	// 鐣般仾銈嬪牬鍚堛�佷繚瀛樺畬浜嗐仐銇熴倝warning銈掑嚭銇�
-	public Boolean syncEstimate(boolean isApproval, boolean isDecide) {
-		System.debug('syncEstimate start');
-		Boolean hasDatabaseError = false;
-		Savepoint sp = Database.setSavepoint();
-	
-		//bug淇
-		//鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
-		// this.estimate.Quotation_Determines_Time__c = date.today();
-	
-		try {
-			if (!checkValidate()) {
-				return false;
-			}
-			if (checkChangedAfterPrint()) {
-				if (isDecide) {
-					// 銇俱仛 Approval
-					isApproval = true;
-					isDecide = false;
-				}
-			}
-			// 楠岃瘉 寮�濮嬫棩鏈燂紝鏈�鏃╁厑璁稿埗瀹氭棩涔嬪墠鍗婂勾
-			Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
-			createdDate = createdDate.addMonths(isNewAddMonth);
-			// if (estimate.Contract_Start_Date__c < createdDate) {
-			//     this.estimate.Contract_Start_Date__c.addError('鍚堝悓寮�濮嬫棩鏈�鏃╁厑璁歌拷婧埗瀹氭棩涔嬪墠鍗婂勾');
-			//     return false;
-			// }
-			// 楠岃瘉 鐢ㄦ埛绫诲瀷锛屽繀濉�
-			if (String.isBlank(estimate.EndUserType__c) ) {
-				this.estimate.EndUserType__c.addError('璇烽�夋嫨鐢ㄦ埛绫诲瀷锛�');
-				return false;
-			}
-			// 楠岃瘉 鐢宠鎶ヤ环閲戦锛岄渶瑕佸ぇ浜�0
-			if (estimate.Request_quotation_Amount__c <= 0 || estimate.Request_quotation_Amount__c == null) {
-				this.estimate.Request_quotation_Amount__c.addError('鐢宠鎶ヤ环閲戦蹇呴渶澶т簬0');
-				return false;
-			}
-			// fxk 鏀规姤閿欎綅缃� 2021銆�9銆�9 Star
-			if (estimate.Request_quotation_Amount__c > estimate.GuidePrice_Up__c || estimate.Request_quotation_Amount__c < estimate.GuidePrice_Down__c) {
-				if (!(this.estimate.mainTalksTime__c > 0)) {
-					this.estimate.mainTalksTime__c.addError('涓昏璋堝垽娆℃暟蹇呭~');
-					return false;
-				}
-	
-				if (this.estimate.talksStartDate__c == null) {
-					this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
-					return false;
-				}
-	
-				if (String.isBlank(this.estimate.Discount_reason__c)) {
-					this.estimate.Discount_reason__c.addError('浠锋牸鐢宠鐞嗙敱蹇呭~');
-					return false;
-				}
-				if (String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
-					this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
-					return false;
-				}
-			}
-			//fxk 鏀规姤閿欎綅缃� 2021/9/9 end
-			//>>>
-			if (isApproval || isDecide) {
-				Boolean hasError = false;
-				if (this.estimate.Maintenance_Price__c <= 0) {
-					this.estimate.Maintenance_Price__c.addError('鍚堝悓浠锋牸蹇呴渶澶т簬0');
-					hasError = true;
-				}
-				/*for (AssetInfo input : this.checkedAssets) {
-						if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-								if (String.isBlank(input.mcae.Check_Result__c)) {
-										input.mcae.Check_Result__c.addError('鐐规缁撴灉蹇呭~');
-										hasError = true;
-								}
-						}
-				   }*/
-				// if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Discount_reason__c)) {
-				//     this.estimate.Discount_reason__c.addError('鍑忎环鐢宠鐞嗙敱蹇呭~');
-				//     hasError = true;
-				// }
-				// if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
-				//     this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
-				//     hasError = true;
-				// }
-				if (hasError) {
-					return false;
-				}
-			}
-			System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉1锛� ' + '涓昏璋堝垽娆℃暟 ' + estimate.mainTalksTime__c + '璋堝垽鐨勫紑濮嬫椂闂� ' + estimate.talksStartDate__c + '浠锋牸鐢宠鐞嗙敱 ' + estimate.Discount_reason__c + '娑堣垂鐜囨敼鍠勬柟妗� ' + estimate.Improve_ConsumptionRate_Idea__c);
-			System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉2锛� ' + '鐢宠鎶ヤ环閲戦 ' + estimate.Request_quotation_Amount__c);
-			System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉3锛� ' + '鏈�浣庝环 ' + estimate.GuidePrice_Down__c + '鏈�楂樹环 ' + estimate.GuidePrice_Up__c);
-			if (isDecide && getDecideBtnDisabled()) {
-				ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide'));
-				return false;
-			}
-	
-			// 杩藉姞涓婃湡鍚堝悓淇℃伅 start
-			// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-			List<lastMContract> lastMContractRes;
-			if (isDecide) {
-				system.debug('鎵ц浜唗cm isDecide');
-				lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
-			} else{
-				system.debug('鎵ц浜唗cm NODecide');
-				lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
-			}
-			this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
-			this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
-			this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
-	
-			this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
-			this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
-			this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
-	
-			this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
-			this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
-			this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
-	
-			this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
-			this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
-			this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
-	
-			this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
-			this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
-			this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
-	
-	
-			// 鍘熸柟娉�
-			// List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets, this.estimate.Contract_Start_Date__c);
-			// // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'lastMContractRes +++++锛�' + lastMContractRes));
-			// // if (true) {
-			// //     return false;
-			// // }
-	
-			// this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
-			// this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
-			// this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
-	
-			// this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
-			// this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
-			// this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
-	
-			// this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
-			// this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
-			// this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
-	
-			// this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
-			// this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
-			// this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
-	
-			// this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
-			// this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
-			// this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
-			// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-	
-			// 杩藉姞涓婃湡鍚堝悓淇℃伅 end
-	
-	
-	
-			// 鍚屾湡鍑︾悊
-			// 鈶犵淮淇悎鍚屻伀鏃㈠瓨銇繚鏈夎澶囥倰鍓婇櫎
-			// 鈶′繚瀛樸仐銇熺淮淇悎鍚屾姤浠枫伄淇濇湁璁惧銈掔淮淇悎鍚屻伀銈炽償銉�(Asset__c銇岃ō瀹氥仌銇︺亜銈嬨儑銉笺偪銇犮亼)
-			// 鈶粬銇淮淇悎鍚屾姤浠枫伄鍚屾湡銉曘儵銈般倰澶栥仚
-			// 鈶g淮淇悎鍚屻伄 Estimate_Trial_Money__c銆丆ontract_Amount__c, Service_contract_target_number__c 銈掓洿鏂�
-			this.estimate.IsSyncing__c = true;
-			if (isDecide) {
-				// 20200923 Gzw bug 淇敼
-				//娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
-				this.estimate.Quotation_Determines_Time__c = Date.today();
-				this.estimate.Estimation_Decision__c = true;
-			}
-			// TODO validate
-	
-			// TODO validate check鏂板搧銉併偋銉冦偗锛堢磵鍝佹棩銇у垽鏂級
-	
-			// save
-			// 鈶� start
-			for (List<Maintenance_Contract_Estimate__c> otherEstimates : [select Id from Maintenance_Contract_Estimate__c where Id <> :this.estimate.Id
-																		  and Maintenance_Contract__c = :this.contract.Id
-																										and IsSyncing__c = true]) {
-				for (Maintenance_Contract_Estimate__c other : otherEstimates) {
-					other.IsSyncing__c = false;
-					if (isDecide) {
-						other.Estimation_Decision__c = false;
-					}
-				}
-				ControllerUtil.updateMaintenance_Contract_Estimate(otherEstimates);
-			}
-	
-			// 鍚堝悓缁撴潫棰勫畾鏃ャ倰绠楀嚭
-			Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-			// 20151217 xudan 缁翠慨鍚堝悓鎶ヤ环SH-RS-JS0046560-01 鏈熼棿鏄剧ず闂
-			// 銇嗐倠銇嗗勾鐗规畩瀵惧繙
-			if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
-				&& t.month() == 2) {
-				t = t;
-			} else {
-				t = t.addDays(-1);
-			}
-			this.estimate.Contract_Esti_End_Date__c = t;
-			// decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 start
-			if (!isDecide) {
-				this.estimate.New_Contract_Type_TxT__c = typeresult;
-			}
-			// decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 end
-			// 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
-			if (this.estimate.Contract_Start_Date__c == null) {
-				this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-			}
-			t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-			t = t.addDays(-1);
-			this.estimate.Contract_End_Date__c = t;
-			//add      wangweipeng                   2021/12/26                     start
-			if(String.isNotBlank(this.estimate.Dealer__c)){
-				checkDealerId = this.estimate.Dealer__c;
-				onChDealerUpdate();
-			}else{
-				this.estimate.Is_RecognitionModel__c = false;
-			}
-			//add      wangweipeng                   2021/12/26                     end
-			System.debug('---------345----'+this.estimate.Dealer__c+'-------'+this.estimate.Dealer__r.FirstParagraphEnd__c);
-			// 浣嶇疆璋冩暣 鍦�1951 line
-			// Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
-			// 锛撱兌鏈堣秴閬庛仐銇︺亜銈嬪牬鍚堛伀銇�丏ecide銇с亶銇亜
-			//if (createdDate.addMonths(3) <= System.today()) {
-			//    this.estimate.addError('宸茶秴杩�3涓湀锛岃鍏堟洿鏂版姤浠枫��');
-			//    return false;
-			//}
-			// 缁翠慨鍚堝悓鎶ヤ环
-			// ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'this.targetEstimateId ++++++ ' + this.targetEstimateId));
-			// if (true) {
-			//     return false;
-			// }
-			if (String.isBlank(this.targetEstimateId)) {
-				newIns = true;
-				this.estimate.Process_Status__c = '鑽夋涓�';
-				// name銇暘鍙枫倰銈汇儍銉�
-				List<Maintenance_Contract_Estimate__c> maxNameRecords = [select Name From Maintenance_Contract_Estimate__c Where Maintenance_Contract__c = :this.contract.Id order by Name desc limit 1];
-				String oppNo;
-				Integer l = 1;
-				if (maxNameRecords.size() > 0) {
-					try {
-						oppNo = maxNameRecords[0].Name;
-						l = Integer.valueOf(oppNo.substring(oppNo.length() - 2)) + 1;
-					} catch (System.TypeException e) {
-						System.debug('maxNameRecords Error: Maintenance_Contract__c.id=' + maxNameRecords[0].id);
-					}
-				} else {
-					System.debug('first Maintenance_Contract_Estimate__c');
-				}
-				oppNo = '00' + String.valueof(l);
-				oppNo = oppNo.substring(oppNo.length() - 2);
-				this.estimate.Name = this.contract.Management_Code__c + '-' + oppNo;
-				setApprovalManager();
-				System.debug('Process_Status__c=' + this.estimate.Process_Status__c);
-				insert this.estimate;
-				this.targetEstimateId = this.estimate.Id;
-				setThisEstimate();
-			} else {
-				if (isApproval) {
-					setApprovalManager();
-				}
-				ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-			}
-			// 缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
-			// delete and insert銇欍倠
-			List<Maintenance_Contract_Asset_Estimate__c> insertTarget = new List<Maintenance_Contract_Asset_Estimate__c>();
-			// 鏄惁浣跨敤棣栨鎶ヤ环鏃ユ洿鏂�
-			// 闇�瑕佹敞鎰忓鎶ヤ环鎻愪氦鏃�+3涓湀涓庡悎鍚岀粨鏉熸棩杩涜姣旇緝
-			// 1锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝灏忎簬鍚堝悓缁撴潫鏃ユ椂锛屼互鍚堝悓缁撴潫鏃ヤ綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
-			// 2锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝澶т簬鍚堝悓缁撴潫鏃ユ椂锛屾姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈熶綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
-			//
-			//
-			//  鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
-			Date toDate = Date.today();
-			Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
-			// list 淇敼 map
-			Map<id, Maintenance_Contract__c> mcList = new Map<id, Maintenance_Contract__c>();
-			for (AssetInfo input : this.checkedAssets) {
-				if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-					//Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c();
-					input.mcae.Id = null;                       // insert銇仧銈�
-					// 鍚屻仒銇牬鍚堣ō瀹氥仐銇亜
-					if (input.mcae.Maintenance_Contract_Estimate__c != this.targetEstimateId) {
-						// 瑕鏇淬仹銇嶃仾銇勫彲鑳芥�с亴銇傘倠銇熴倎銆佽ō瀹氥仚銈嬨仺銇嶃偍銉┿兗銇仾銈嬨亴銆併偍銉┿兗銇仾銈夈仾銇勩倛銇嗐伀浠栥伄銉偢銉冦偗銈掑伐澶仐銇︺亸銇犮仌銇勩��
-						input.mcae.Maintenance_Contract_Estimate__c = this.targetEstimateId;
-					}
-					input.mcae.Maintenance_Price_Month__c = input.rec.Maintenance_Price_Month__c;
-					// 鐥呴櫌銇墍灞炪仚銈嬩繚鏈夎ō鍌�
-	
-					if (!input.isManual) {
-						input.mcae.Asset__c = input.rec.Id;
-						input.mcae.Product_Manual__c = null;
-						input.mcae.Estimate_Cost__c = input.mcae.Estimate_Cost__c;
-						input.mcae.LastMContract_Price__c = input.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
-						//input.mcae.Asset_Consumption_rate__c = input.mcae.Asset_Consumption_rate__c;
-					}
-					// 鎻愪氦鏃讹紝鏇存柊 鏄惁浣跨敤涓婁竴鏈熺淮淇悎鍚岄娆℃姤浠锋棩
-					if (isApproval) {
-						Maintenance_Contract__c mctemp = new Maintenance_Contract__c();
-						//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '+++++ ' + ass.rec.CurrentContract_F__r.Contract_End_Date__c + '   ' + mon1stDate));
-						// 鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
-						if (input.rec.CurrentContract_F__r.Contract_End_Date__c >= mon1stDate) {
-							if (input.rec.CurrentContract_F__r.First_Estimate_Date__c == null) {
-								mctemp.Id = input.rec.CurrentContract_F__c;
-								mctemp.First_contract_usage_Rate__c = input.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
-								mctemp.First_Estimate_Date__c = Date.today();
-								mcList.put(mctemp.Id, mctemp);
-								input.mcae.ifHaveleftInPrevious__c = true;
-							}
-						}
-					}
-					// Manual鍟嗗搧
-					if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-						input.mcae.Asset__c = null;
-						//mcae.Product_Manual__c = input.mcae.Product_Manual__c;
-					}
-					//鏂拌鏃讹紝淇濆瓨鏂板悎鍚屽鍝佷繚璇佹彁渚� Decide 鍚�
-					if (!isDecide) {
-						input.mcae.EquipmentGuaranteeFlgTxt__c = input.etGFlg;
-					}
-					// Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-	
-					// 2020/10/30 songxiaoqi start
-					if (input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
-						input.mcae.Last_MContract__c = input.rec.CurrentContract_F__c;
-	
-					}
-					//songxiaoqi end
-	
-	
-					// Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
-					//mcae.Estimate_List_Price__c = input.mcae.Estimate_List_Price__c;
-					//mcae.IsNew__c = input.mcae.isNew__c;
-					//mcae.Check_Result__c = input.mcae.Check_Result__c;
-					//mcae.Repair_Price__c = input.mcae.Repair_Price__c;
-					//mcae.Comment__c = input.mcae.Comment__c;
-					insertTarget.add(input.mcae);
-				}
-			}
-			// 鏈綋銇繚瀛樸仐銇熺磵鍏ユ鍣ㄣ亴銇傘倢銇板墛闄�
-			List<Maintenance_Contract_Asset_Estimate__c> selectedAsset = [SELECT Id, Name, Maintenance_Contract_Estimate__c, Asset__c, IsNew__c FROM Maintenance_Contract_Asset_Estimate__c WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId];
-			if (selectedAsset.size() > 0) {
-				ControllerUtil.deleteMaintenance_Contract_Asset_Estimate(selectedAsset);
-			}
-			if (insertTarget.size() > 0) {
-				ControllerUtil.insertMaintenance_Contract_Asset_Estimate(insertTarget);
-			}
-	
-			// 鈶� start
-			for (List<Maintenance_Contract_Asset__c> oldList : [select Id from Maintenance_Contract_Asset__c
-																where Maintenance_Contract__c = :this.estimate.Maintenance_Contract__c]) {
-				delete oldList;
-			}
-			// 鈶� start
-			{
-				List<Maintenance_Contract_Asset__c> newValue = new List<Maintenance_Contract_Asset__c>();
-				for (Maintenance_Contract_Asset_Estimate__c target : [select Id, Asset__c, Estimate_List_Price__c, Estimate_Cost__c,
-																	  //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
-																	  Check_Object__c,
-																	  //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
-																	  IsNew__c, EquipmentGuaranteeFlgTxt__c,
-																	  // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-																	  Last_MContract__c
-																	  // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
-																	  , Last_MContract__r.RecordType_DeveloperName__c
-																	  // LJPH-C9GD34 gzw fix start
-																	  ,Estimate_List_Price_Page__c
-																	  // LJPH-C9GD34 gzw fix end
-																	  from Maintenance_Contract_Asset_Estimate__c
-																	  where Maintenance_Contract_Estimate__c = :this.estimate.Id and Asset__c <> null]) {
-	
-					Maintenance_Contract_Asset__c newVal = new Maintenance_Contract_Asset__c(
-						Maintenance_Contract__c = this.estimate.Maintenance_Contract__c,
-						Asset__c = target.Asset__c,
-						Maintenance_Contract_Asset_Estimate__c = target.Id,
-						Estimate_List_Price__c = target.Estimate_List_Price__c,
-						//Maintenance_Price_YearTXT__c = target.Maintenance_Price_YearTXT__c,
-						Estimate_IsNew__c = target.IsNew__c,
-						//add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
-						Check_Object__c = target.Check_Object__c,
-						//add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
-						//EquipmentGuaranteeFlgTxt__c = target.EquipmentGuaranteeFlgTxt__c,
-						// Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-						// LastMContract__c = target.Last_MContract__c
-						// Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
-						//濡傛灉鏄骞翠繚淇悎鍚�,涓嶆洿鏂颁笂鏈熺淮淇悎鍚屼俊鎭� LJPH-BUU3E3 update by rentx  2020-11-03
-						LastMContract__c = target.Last_MContract__r.RecordType_DeveloperName__c == 'VM_Contract' ? null : target.Last_MContract__c
-						);
-					newValue.add(newVal);
-				}
-				if (newValue.size() > 0) insert newValue;
-			}
-			// 鈶� start
-			this.contract.Estimation_Id__c = this.targetEstimateId;		
-			this.contract.Contract_Esti_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-			this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
-			this.contract.Contract_Esti_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
-			this.contract.Estimate_Target__c = this.estimate.Estimate_Target__c;
-			this.contract.Dealer__c = this.estimate.Dealer__c;
-			this.contract.old_Is_RecognitionModel__c = this.estimate.Is_RecognitionModel__c;
-			this.contract.NotUse_Oxygenated_Water__c = this.estimate.NotUse_Oxygenated_Water__c;
-			this.contract.Estimate_Trial_Money__c = this.estimate.Estimate_Trial_Money__c;
-			this.contract.Contract_Amount__c = this.estimate.Maintenance_Price__c;
-			// 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 start
-			// this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
-			// 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 end
-			this.contract.Contract_department_manual__c = this.estimate.Department__c;
-	
-			// 杩藉姞涓婃湡鍚堝悓淇℃伅 start
-			this.contract.LastMContract1__c = this.estimate.LastMContract1__c;
-			this.contract.LastMContract1_NO__c = this.estimate.LastMContract1_NO__c;
-			this.contract.LastMContract1_ConCount__c =  this.estimate.LastMContract1_ConCount__c;
-	
-			//add by rentx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂锛岀粰鍘诲勾鍚堝悓璧嬪�� start
-			this.contract.Last_year_service_contract__c = this.estimate.LastMContract1__c;
-			//add by renrx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂, 缁欏幓骞村悎鍚岃祴鍊� end
-	
-			this.contract.LastMContract2__c =  this.estimate.LastMContract2__c;
-			this.contract.LastMContract2_NO__c = this.estimate.LastMContract2_NO__c;
-			this.contract.LastMContract2_ConCount__c =  this.estimate.LastMContract2_ConCount__c;
-	
-			this.contract.LastMContract3__c =  this.estimate.LastMContract3__c;
-			this.contract.LastMContract3_NO__c = this.estimate.LastMContract3_NO__c;
-			this.contract.LastMContract3_ConCount__c =  this.estimate.LastMContract3_ConCount__c;
-	
-			this.contract.LastMContract4__c =  this.estimate.LastMContract4__c;
-			this.contract.LastMContract4_NO__c = this.estimate.LastMContract4_NO__c;
-			this.contract.LastMContract4_ConCount__c =  this.estimate.LastMContract4_ConCount__c;
-	
-			this.contract.LastMContract5__c =  this.estimate.LastMContract5__c;
-			this.contract.LastMContract5_NO__c = this.estimate.LastMContract5_NO__c;
-			this.contract.LastMContract5_ConCount__c =  this.estimate.LastMContract5_ConCount__c;
-			// 杩藉姞涓婃湡鍚堝悓淇℃伅 end
-	
-			system.debug('娴嬬畻isDecide鐨勭粨鏋淿1::::::::' + isDecide);
-			if (isDecide == true) {
-				system.debug('娴嬬畻isDecide鐨勭粨鏋淿2::::::::' + isDecide);
-				//              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-				this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
-				this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
-				//              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
-				this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
-				this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
-				this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
-				this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
-				this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
-				this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
-				// JZHG-BQV3P4 20200624 Gzw add
-				this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
-				// JZHG-BQV3P4 20200624 Gzw add
-			}
-			//娣诲姞鐨勯澶栧搴旇繃绋�
-			if (inDicideFlag == true && (this.contract.Contract_Start_Date__c == null || this.contract.Contract_End_Date__c == null)) {
-				system.debug('娴嬬畻inDicideFlag鐨勭粨鏋淿2::::::::' + isDecide);
-				//              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-				this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
-				this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
-				//              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
-				this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
-				this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
-				this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
-				this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
-				this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
-				this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
-				// JZHG-BQV3P4 20200624 Gzw add
-				this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
-				// JZHG-BQV3P4 20200624 Gzw add
-			}
-			String oldProcessStatus = this.estimate.Process_Status__c;
-			try {
-				if (mcList.size() > 0) {
-					ControllerUtil.updMcList(mcList.values());
-				}
-				ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-				update this.contract;
-			} catch (Exception e) {
-				// TODO 浠婂緦瑜囨暟浠躲伄鍫村悎銇┿亞銇欍倠锛�
-				this.estimate.addError(e);
-				// 涓�閮ㄣ伄鍊ゃ倰鎴汇仚
-				this.estimate.Process_Status__c = oldProcessStatus;
-				hasDatabaseError = true;
-				Database.rollback(sp);
-				ApexPages.addMessages(e);
-			}
-			if (hasDatabaseError) {
-				System.debug('syncEstimate hasDatabaseError');
-				return false;
-			}
-			if (isApproval) {
-				SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
-			}
-			return true;
-		} catch (DMLException ex) {
-			// TODO Insert澶辨晽銇甀D銈掓秷銇欏繀瑕侊紵
-			Database.rollback(sp);
-			ApexPages.addMessages(ex);
-		} catch (Exception ex) {
-			Database.rollback(sp);
-			ApexPages.addMessages(ex);
-		}
-		return false;
-	}
-	
-	/**
-	 * 鍗板埛寰屽鏇淬亴銇傘倠鍫村悎銆乼rue
-	 */
-	@TestVisible
-	private Boolean checkChangedAfterPrint() {
-		System.debug('checkChangedAfterPrint start');
-		if (changedAfterPrint) {
-			this.targetEstimateId = null;
-			this.estimate = this.estimate.clone();
-			this.estimate.IS_Clone_After_Decide__c = true;
-			this.estimate.PrintDate__c = null;
-			this.estimate.Quote_Date__c = null;
-			this.estimate.Print_Contract__c = false;
-			this.estimate.Print_RepairPrice__c = false;
-			this.estimate.Print_DiscountPercentage__c = false;
-			this.estimate.Print_DiscountPrice__c = false;
-			this.estimate.Print_ListPrice__c = false;
-			//鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
-			this.estimate.Print_Simplify__c = false;
-			//鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
-			this.estimate.Print_MaintePrice__c = false;
-			this.estimate.Print_SumPrice__c = false;
-			this.estimate.NotUse_Oxygenated_Water__c = false;
-			this.estimate.Contract_Esti_Start_Date__c = this.estimate.Contract_Start_Date__c;
-			//this.estimate.Process_Status__c = '鑽夋涓�';
-		}
-		return changedAfterPrint;
-	}
-	/**
-	 * 琛岃拷鍔�(10琛屻仛銇�)銆佸墠鎻愬繀銇氭渶寰�
-	 */
-	
-	public PageReference addNewRows() {
-		for (Integer i = 0; i < 10; i++) {
-			checkedAssets.add(new AssetInfo(checkedAssets.size()));
-		}
-		// ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '淇濇湁璁惧' + checkedAssets.size()));
-		return null;
-	}
-	
-	
-	
-	/** 淇濆瓨杩斿洖 **/
-	public PageReference saveAndCancel () {
-		//add by rentx 2020-11-13 LJPH-BV93RZ start
-		if (estimate.Contract_Range__c == null) {
-			this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
-			return null;
-		}
-		//add by rentx 2020-11-13 LJPH-BV93RZ end
-		if (syncEstimate(false, false)) {
-			PageReference ret = null;
-			if (this.targetMaintenanceContractId != null) {
-				ret = new PageReference('/' + this.targetMaintenanceContractId);
-			}
-			return ret;
-		}
-		return null;
-	}
-	
-	/**
-	 * 銈儯銉炽偦銉儭銈姐儍銉�
-	 */
-	public PageReference cancel() {
-		PageReference ret = null;
-		if (this.targetMaintenanceContractId != null) {
-			ret = new PageReference('/' + this.targetMaintenanceContractId);
-		}
-		return ret;
-	}
-	
-	//add     wangweipeng                     2021/12/26                 start
-	//鑾峰彇褰撳墠閫変腑鐨勭粡閿�鍟嗘槸鍚︿负鍏堟鏍囪瘑
-	public PageReference onChDealerUpdate(){
-		//checkDealerId  姝ゅ彉閲忓彲鑳戒細瀛� 缁忛攢鍟唅d鎴栫粡閿�鍟嗕腑鏂囧悕
-		if(String.isNotBlank(checkDealerId)){
-			try {
-				List<Account> accListC = [select id,name,FirstParagraphEnd__c from Account where id = :checkDealerId OR name = :checkDealerId];
-				if(accListC != null && accListC.size() == 1){
-					if(accListC[0].FirstParagraphEnd__c){
-						this.estimate.Is_RecognitionModel__c = true;
-					}else{
-						this.estimate.Is_RecognitionModel__c = false;
-					}
-				}else{
-					this.estimate.Is_RecognitionModel__c = false;
-				}
-			} catch (Exception e) {
-				//return 'McaeList Update Failed : '+e;
-			}
-		}else{
-			this.estimate.Is_RecognitionModel__c = false;
-		}
-		System.debug('----------------23--'+this.estimate.Is_RecognitionModel__c);
-		return null;
-	}
-	//add     wangweipeng                     2021/12/26                 end
-	
-	
-	// 2021-02-07  gzw add  LJPH-BWY5QB start
-	private void setEndUserType(String id) {
-		this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
-						 Estimate_Num__c, Management_Code__c, Hospital__c,
-						 Hospital__r.MaintenanceContractUserType__c,
-						 Contract_Start_Date__c, Contract_End_Date__c
-						 FROM Maintenance_Contract__c WHERE Id = :id];
-		if (this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)) {
-	
-			this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
-		}
-	}
-	// 2021-02-07  gzw add  LJPH-BWY5QB end
-	
-	private void setContractInfo(String id) {
-		this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
-						 Estimate_Num__c, Management_Code__c, Hospital__c,
-						 //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-						 // Hospital__r.MaintenanceContractUserType__c,
-						 //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-						 Contract_Start_Date__c, Contract_End_Date__c
-						 FROM Maintenance_Contract__c WHERE Id = :id];
-		this.targetHospitalId = this.contract.Hospital__c;
-		// 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-		// if(this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)){
-	
-		//    this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
-		// }
-		// 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-	}
-	
-	private Boolean checkValidate() {
-		Boolean rtn = true;
-		Date today = Date.today();
-		if (getPageDisabled()) {
-			today = estimate.Submit_quotation_day__c;
-		}
-		// 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 start
-		//鍚堝悓鏈堟暟
-		Decimal ContractRange = this.estimate.Contract_Range__c;
-		//鍚堝悓棰勫畾缁撴潫鏃ユ湡
-		Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-		if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
-			&& t.month() == 2) {
-			t = t;
-		} else {
-			t = t.addDays(-1);
-		}
-		this.estimate.Contract_Esti_End_Date__c  = t;
-		// 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
-		if (this.estimate.Contract_Start_Date__c == null) {
-			this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-		}
-		t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-		t = t.addDays(-1);
-		this.estimate.Contract_End_Date__c = t;
-		Date ContractEndDate = this.estimate.Contract_End_Date__c;
-		System.debug('鍚堝悓缁撴潫鏃ユ湡 :' + ContractEndDate);
-		// 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 end
-		// 閮ㄥ搧渚涚郸鍋滄銇=鍝併伅銈ㄣ儵銉�
-		for (AssetInfo input : this.checkedAssets) {
-			//濡傛灉鏄墜鍔ㄤ骇鍝�
-			// 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� start
-			if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-				// if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-				// 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� end
-				if (input.mcae.Estimate_List_Price__c == null || input.mcae.Estimate_List_Price__c == 0) {
-					//update by rentx 2020-11-12 LJPH-BV93RZ start
-					// input.mcae.Product_Manual__c.addError(System.Label.Error_Message47);
-					//add by rentx 2021-01-25 start
-					//濡傛灉淇濇湁璁惧涓嶄负绌虹殑璇濆湪淇濇湁璁惧涓婃姤閿�
-					if (input.rec != null) {
-						input.rec.Name.addError(input.rec.Name + ' (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') 鏃犲悎鍚岄噾棰�,涓嶅缓璁弬淇�');
-	
-					} else
-					//add by rentx 2021-01-25 end
-					if (String.isNotBlank(input.proName)) {
-						input.mcae.Product_Manual__c.addError(System.Label.Error_Message47 + '(' + input.proName + ')');
-					}
-					//update by rentx 2020-11-12 LJPH-BV93RZ end
-					rtn = false;
-				}
-			}
-			if (!input.isManual) {
-				//update by rentx 2020-11-13 start
-				if (!Test.isRunningTest() && (input.mcae.Adjustment_Upper_price__c == null || input.mcae.Adjustment_Upper_price__c == 0) ) {
-					// input.mcae.Adjustment_Upper_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-					input.mcae.Adjustment_Upper_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-					rtn = false;
-				}
-				if (!Test.isRunningTest() && (input.mcae.Adjustment_Lower_price__c == null || input.mcae.Adjustment_Lower_price__c == 0) ) {
-					input.mcae.Adjustment_Lower_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-					// input.mcae.Adjustment_Lower_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-					rtn = false;
-				}
-				//update by rentx 2020-11-13 end
-	
-				//1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
-				//2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
-				//3.绠$悊鍛樿烦杩囷紝
-				if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
-	
-					Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F__r.Contract_End_Date__c);
-					Decimal monthCon = (Decimal)noOfDays / 365 * 12;
-					// 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
-					if (input.rec.CurrentContract_F__r.Contract_Range__c >= 12 && monthCon > 6) {
-						input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
-						rtn = false;
-					}
-					//ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + monthCon  + ' +++ ' + Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c/2)));
-					//rtn = false;
-					if (input.rec.CurrentContract_F__r.Contract_Range__c < 12 && monthCon > Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c / 2)) {
-						input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 缁忓巻鏈堟暟杩囧崐鏂瑰彲鍒朵綔鎶ヤ环');
-						rtn = false;
-					}
-				}
-				// 澶氬勾淇濆垽鏂�
-				if ( String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
-					//if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
-	
-					//Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
-					//Decimal monthCon = (Decimal)noOfDays/365*12;
-					// 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
-					if (input.rec.CurrentContract_F__r.Gurantee_Estimate_startDate__c > Date.today()) {
-						input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
-						rtn = false;
-					}
-				}
-				//ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
-				if (inDicideFlag && String.isNotBlank(input.rec.CurrentContract_F__c) && estimate.Skip_DJ__c == false ) {
-					//ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '+++' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
-					// 鍚堝悓寮�濮嬫棩澶т簬涓婃湡鍚堝悓缁撴潫鏃ュ姞涓�涓湀锛屼笖娌℃湁鐐规鏃ユ湡鎴栬�呮渶杩戜竴娆$偣妫�鏃ユ湡鏄�3涓湀鍓�  鎶ラ敊
-					if (estimate.Contract_Start_Date__c > input.rec.CurrentContract_F__r.Contract_End_Date__c.addMonths(1)
-						&& (input.rec.Final_Examination_Date__c == null
-							|| input.rec.Final_Examination_Date__c < estimate.Contract_Start_Date__c.addMonths(-3))) {
-						input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁鏈�鏂扮殑鐐规璁板綍');
-						rtn = false;
-					}
-				}
-	
-				if (isSaveOrApproval) {
-					if (input.rec.IF_Warranty__c == '鍚�') {
-						input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 涓嶈兘閫夋嫨涓嶅彲鍙備繚璁惧');
-						rtn = false;
-					}
-				}
-				// 20200805 Gzw Bug淇
-				// isSaveOrApproval = false;
-			}
-	
-			// 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
-			if (input != null) {
-	
-				//鏍¢獙鏃犻浂浠堕闄�
-				if ( input.rec != null && input.rec.NoPartRiskDate_F__c != null ) {
-					// 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
-					String msg = checkAssetInfo(input.rec.NoPartRiskDate_F__c, input.rec.SignableFlag__c, ContractEndDate, ContractRange);
-					// 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
-					if (msg != '') {
-						input.rec.Name.addError('[' + input.rec.Name + '] (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') ' + msg);
-						rtn = false;
-					}
-	
-				}
-				/*else if(input.mcae!=null&&input.mcae.Product_Manual__c !=null&&input.NoPartRiskDate!=null ){
-						// 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
-						String msg = checkAssetInfo(input.NoPartRiskDate,input.SignableFlag,ContractEstiEndDate,ContractRange);
-						// 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
-						if(msg != ''){
-						   input.mcae.Product_Manual__c.addError('['+input.proName2+'] '+msg);
-						   rtn = false;
-						}
-				   }*/
-			}
-			// 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
-	
-		}
-		return rtn;
-	}
-	// 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
-	//鏍¢獙鏃犻浂浠堕闄╂棩鏈�
-	public static String checkAssetInfo(Date NoPartRiskDate, Boolean SignableFlag, Date ContractEndDate, Decimal ContractRange) {
-		String rtnStr = '';
-		//1.鍒ゆ柇
-		//鍚堝悓缁撴潫鏃ユ湡 > 鏃犻浂浠堕闄╂棩鏈�
-		if (ContractEndDate > NoPartRiskDate) {
-			//鍙绾︽爣璇� 鏈嬀閫�
-			if (SignableFlag == false) {
-				//鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�
-				rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�';
-			} else {
-				//鍕鹃��
-				//鍙互绛�1骞村悎鍚�
-				if (ContractRange > 12) {
-					rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂锛屽瓨鍦ㄩ浂浠跺仠姝緵搴旈闄╋紝寤鸿绛句竴骞存湡鍚堝悓銆�';
-				}
-			}
-		}
-	
-		return rtnStr;
-	}
-	// 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
-	// 浠锋牸鍙樻洿鍚庡厠闅嗘姤浠峰墠閲嶆柊璁$畻浠锋牸
-	@TestVisible
-	private void priceChangeReset() {
-		// 鍙栧緱master涓渶鏂颁环鏍�
-		List<Id> assIds = new List<Id>();
-		List<Id> pdIds = new List<Id>();
-		for (AssetInfo input : this.checkedAssets) {
-			if (!input.isManual) {
-				assIds.add(input.rec.Id);
-			}
-			if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-				pdIds.add(input.mcae.Product_Manual__c);
-			}
-		}
-		Map<Id, Asset> assMap = new Map<Id, Asset>();
-		Map<Id, Product2> pdMap = new Map<Id, Product2>();
-		if (assIds.size() > 0) {
-			assMap = new Map<Id, Asset>([select id, Maintenance_Price_Month__c from Asset where Id In: assIds]);
-		}
-		if (pdIds.size() > 0) {
-			pdMap = new Map<Id, Product2>([select id, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c from Product2 where Id In: pdIds]);
-		}
-		if (assMap.size() > 0 || pdMap.size() > 0) {
-			for (AssetInfo info : this.checkedAssets) {
-				if (!info.isManual) {
-					info.orgPrice = assMap.get(info.rec.Id).Maintenance_Price_Month__c;
-				}
-				if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
-					info.orgPrice = pdMap.get(info.mcae.Product_Manual__c).Maintenance_Price_Month__c;
-				}
-			}
-		}
-		//contractStartDateChange();
-	}
-	
-	
-	public class AssetInfo {
-	// 鏂板悎鍚屽鍝佺‘淇濇彁渚� 褰撳墠鏍囪
-	public Boolean etGFlg {get; set;}
-	public Integer lineNo {get; private set;}
-	public Boolean rec_checkBox_c {get; set;}
-	public Asset rec { get; set; }
-	public Maintenance_Contract_Asset_Estimate__c mcae { get; set; }
-	public Boolean isManual { get; set; }
-	public Decimal orgPrice {get; private set;}
-	public Decimal orgPrice12 {get; private set;}
-	// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-	public Boolean CheckRows {get; private set;}
-	// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
-	
-	//add by rentx 2020-11-12 LJPH-BV93RZ start
-	public String proName;
-	public String proSerialNumber;
-	public String proSerialName;
-	//add by rentx 2020-11-12 LJPH-BV93RZ end
-	//add by mzy 2020-11-12 LJPH-BX9CVX start
-	//public Date NoPartRiskDate;
-	//public String proName2;
-	//public Boolean SignableFlag;
-	//add by mzy 2020-11-12 LJPH-BX9CVX start
-	
-	//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-	public String ProductModelNoc;
-	public String AssetModelNoc;
-	public String MDMModelNoc;
-	//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-	
-	public Id getRecId() {
-		Id rtn = null;
-		if (rec != null) {
-			rtn = rec.Id;
-		}
-		return rtn;
-	}
-	public void setRecId(Id value) {
-		// 銇伀銈傘仐銇亜
-	}
-	
-	// Manual灏傜敤
-	public AssetInfo(Integer lineNo) {
-		this.lineNo = lineNo;
-		this.rec = null;
-		this.mcae = new Maintenance_Contract_Asset_Estimate__c(
-			isNew__c = true,
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-			Check_Object__c = true
-							  // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-			);
-		this.isManual = true;
-		this.rec_checkBox_c = false;
-		this.orgPrice = 0;
-		this.orgPrice12 = 0;
-		this.etGFlg = false;
-		// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-		this.CheckRows = true;
-		// add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
-	}
-	// 閬告姙銇曘倢銇熺敤锛堥潪Manual锛�
-	public AssetInfo(Integer lineNo, Asset record, Boolean isNew, Decimal listPrice, Maintenance_Contract_Asset_Estimate__c mcae) {
-		this.lineNo = lineNo;
-		this.rec = record;
-		this.mcae = new Maintenance_Contract_Asset_Estimate__c(
-			//                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
-			isNew__c = isNew,
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-			Check_Object__c = mcae.Check_Object__c,
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-			Estimate_List_Price__c = listPrice,
-			//Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
-			Check_Result__c = mcae.Check_Result__c,
-			Repair_Price__c = mcae.Repair_Price__c,
-			Comment__c = mcae.Comment__c,
-			EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
-			Estimate_Cost__c = mcae.Estimate_Cost__c,
-			Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
-			Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
-			Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
-			LastMContract_Price__c = mcae.LastMContract_Price__c,
-			Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
-			Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c
-			// LJPH-C9GD34 gzw fix start
-			,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
-			// LJPH-C9GD34 gzw fix end
-			);
-		this.isManual = false;
-		this.rec_checkBox_c = true;
-		this.orgPrice = record.Maintenance_Price_Month__c;
-		this.orgPrice12 = this.orgPrice * 12;
-		this.etGFlg = record.EquipmentGuaranteeFlg__c;
-		//add by rentx 2020-11-12 LJPH-BV93RZ start
-		this.proName = '鏈鸿韩缂栫爜涓�:' + record.SerialNumber;
-		this.proSerialNumber = record.SerialNumber;
-		this.proSerialName = record.Name;
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		this.ProductModelNoc = mcae.Product_Manual__r.Asset_Model_No__c;
-		this.AssetModelNoc = mcae.Asset__r.OwnershipMachine_No__c;
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-	
-		//add by rentx 2020-11-12 LJPH-BV93RZ end
-		//add by mzy 2021-02-07 start
-		//this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
-		//this.proName2 = mcae.Product_Manual__r.Name;
-		//this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
-		//add by mzy 2021-02-07 end
-	}
-	// 閬告姙銇曘倢銇熺敤銆佹湭绱嶅搧鐢紙Manual锛�
-	public AssetInfo(Integer lineNo, Maintenance_Contract_Asset_Estimate__c mcae) {
-		this.lineNo = lineNo;
-		this.rec = null;
-		this.mcae = new Maintenance_Contract_Asset_Estimate__c(
-			//                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
-			isNew__c = mcae.IsNew__c,
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-			Check_Object__c = mcae.Check_Object__c,
-			// add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-			Product_Manual__c = mcae.Product_Manual__c,
-			Estimate_List_Price__c = mcae.Estimate_List_Price__c,
-			//Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
-			Check_Result__c = mcae.Check_Result__c,
-			Repair_Price__c = mcae.Repair_Price__c,
-			Comment__c = mcae.Comment__c,
-			EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
-			Estimate_Cost__c = mcae.Estimate_Cost__c,
-			Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
-			Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
-			Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
-			LastMContract_Price__c = mcae.LastMContract_Price__c,
-			Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
-			Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c,
-			Contract_Esti_Start_Date__c = mcae.Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c
-										  // Contract_Esti_Start_Date__c=mcae.Contract_Esti_Start_Date__c
-			// LJPH-C9GD34 gzw fix start
-			,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
-			// LJPH-C9GD34 gzw fix end
-			);
-		this.isManual = true;
-		this.rec_checkBox_c = false;
-		this.orgPrice = mcae.Product_Manual__r.Maintenance_Price_Month__c;
-		this.orgPrice12 = this.orgPrice * 12;
-		this.etGFlg = mcae.Product_Manual__r.EquipmentGuaranteeFlg__c;
-		//add by mzy 2021-02-07 start
-		//this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
-		//this.proName2 = mcae.Product_Manual__r.Name;
-		//this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
-		//add by mzy 2021-02-07 end
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 start
-		this.ProductModelNoc = mcae.Product_Manual__r.Asset_Model_No__c;
-		this.AssetModelNoc = mcae.Asset__r.OwnershipMachine_No__c;
-		//2021-11-30 fy add LJPH-C8W8FV 缃《 end
-	}
-	// 閬告姙銇曘倢銇亱銇c仧鐢�
-	public AssetInfo(Integer lineNo, Asset record) {
-		this.lineNo = lineNo;
-		this.rec = record;
-		this.isManual = false;
-		this.rec_checkBox_c = false;
-		this.orgPrice = record.Maintenance_Price_Month__c;
-		this.orgPrice12 = this.orgPrice * 12;
-		this.etGFlg = record.EquipmentGuaranteeFlg__c;
-		this.proSerialName = record.Name;
-		this.proSerialNumber = record.SerialNumber;
-	}
-	}
-	
-	WebService static String pageDecide(String strId) {
-		String rs = '';
-		SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
-		saec.targetEstimateId = strId;
-		saec.isPageAction = true;
-		saec.init();
-		if (saec.getDecideBtnDisabled()) {
-			rs = '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide';
-			return rs;
-		}
-		if (saec.syncEstimate(false, true)) {
-			rs = '0';
-		} else {
-			rs = 'Decide澶辫触';
-		}
-		return rs;
-	}
-	
-	WebService static String pageUndecide(String strId) {
-		String rs = '';
-		SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
-		saec.targetEstimateId = strId;
-		saec.isPageAction = true;
-		saec.init();
-		if (saec.getUnDecideBtnDisabled()) {
-			rs = '涓嶆槸Decide杩囩殑鎶ヤ环锛屼笉鑳経ndecide';
-			return rs;
-		}
-		if (saec.undecide() != null) {
-			rs = '0';
-		} else {
-			rs = 'Undecide澶辫触';
-		}
-		return rs;
-	}
-	
-	
-	public static List<lastMContract> getlastMContract(List<AssetInfo> checkedAssets, Date startDate) {
-		Map<String, lastMContract> lastMContractMap = new Map<String, lastMContract>();
-		Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
-		for (AssetInfo ai : checkedAssets) {
-			lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Management_Code__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
-	
-			// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-			// 璁$畻绌虹櫧鏈�
-			if (startDate != null && lM.endDate != null) {
-				if (startDate.daysbetween(lM.endDate) > -366 && startDate.daysbetween(lM.endDate) < 366) {
-					lm.ayearcontract = true;
-				} else {
-					lm.ayearcontract = false;
-				}
-			} else {
-				lm.ayearcontract = false;
-			}
-			// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-	
-			// if (String.isNotBlank(ai.rec.CurrentContract_F__c) ) {
-			//鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 start
-			if (String.isNotBlank(ai.rec.CurrentContract_F__c) && ai.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
-	
-				// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-				if (lm.ayearcontract) {
-					// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-	
-					//鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 end
-					// 绌虹櫧鏈�
-					if (lastMContractMap.containsKey(ai.rec.CurrentContract_F__c)) {
-						lastMContractMap.get(ai.rec.CurrentContract_F__c).count++;
-					} else {
-						lastMContractMap.put(ai.rec.CurrentContract_F__c, lM);
-					}
-					// 闈炵┖鐧芥湡
-				} else {
-					if (lastMContractMap1.containsKey(ai.rec.CurrentContract_F__c)) {
-						lastMContractMap1.get(ai.rec.CurrentContract_F__c).count++;
-					} else {
-						lastMContractMap1.put(ai.rec.CurrentContract_F__c, lM);
-					}
-				}
-			}
-		}
-	
-		List<lastMContract> listResulttemp = new List<lastMContract>();
-		List<lastMContract> listResult = new List<lastMContract>();
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-		List<lastMContract> listResulttemp1 = new List<lastMContract>();
-		List<lastMContract> listResult1 = new List<lastMContract>();
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-		// 绌虹櫧鏈�
-		for ( lastMContract ll : lastMContractMap.values()) {
-			listResulttemp.add(ll);
-		}
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-		// 闈炵┖鐧芥湡
-		for ( lastMContract ll : lastMContractMap1.values()) {
-			listResulttemp1.add(ll);
-		}
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-		//ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'listResult +++++锛�' + listResult));
-	
-		// 绌虹櫧鏈�
-		listResulttemp.sort();
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start  锛堜慨鏀逛簡寰幆娆℃暟 鍘�5锛�
-		for (Integer i = 0; i < listResulttemp.size(); i++) {
-			// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-			if (listResulttemp.size() >= i + 1) {
-				listResult.add(listResulttemp[i]);
-			}
-		}
-	
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-		// 闈炵┖鐧芥湡
-		listResulttemp1.sort();
-		for (Integer i = 0; i < 5 - listResulttemp.size(); i++) {
-			if (listResulttemp1.size() >= i + 1) {
-				listResult1.add(listResulttemp1[i]);
-			} else {
-				listResult1.add(new lastMContract(null, null, null, null));
-			}
-		}
-		// 鍚堝苟
-		listResult.addAll(listResult1);
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-		//List<lastMContract> listResult = new List<lastMContract>();
-		return listResult;
-	}
-	
-	
-	public static List<Data> getChartData() {
-		List<Data> data = new List<Data>();
-		List<Achievement_linkage__c> achlist = [select id, Consumption_rate_Lower__c, Consumption_rate_Upper__c,
-												PriceCount_Lower__c, PriceCount_Upper__c from Achievement_linkage__c];
-		for (Achievement_linkage__c al : achlist ) {
-			data.add(new Data(al.Consumption_rate_Lower__c, al.Consumption_rate_Upper__c, al.PriceCount_Lower__c, al.PriceCount_Upper__c));
-		}
-		return data;
-	}
-	
-	// 浠锋牸浣撶郴 class
-	public class Data {
-	public Decimal rate_Upper { get; set; }
-	public Decimal rate_Lower { get; set; }
-	public Decimal price_Upper { get; set; }
-	public Decimal price_Lower { get; set; }
-	public Data(Decimal rate_Lower, Decimal rate_Upper, Decimal price_Lower, Decimal price_Upper) {
-		this.rate_Upper = rate_Upper;
-		this.rate_Lower = rate_Lower;
-		this.price_Upper = price_Upper;
-		this.price_Lower = price_Lower;
-	}
-	}
-	
-	// 缁鍚堝悓淇℃伅 class
-	public class lastMContract implements Comparable {
-	public Date endDate { get; set; }
-	public Integer count { get; set; }
-	public String contractId { get; set; }
-	public String contractNo { get; set; }
-	// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-	public Boolean ayearcontract { get; set; }
-	// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-	public lastMContract(String contractId, String contractNo, Date endDate, Integer count) {
-		this.endDate = endDate;
-		this.count = count;
-		this.contractId = contractId;
-		this.contractNo = contractNo;
-	}
-	
-	// 鎺掑簭
-	public Integer compareTo(Object compareTo) {
-		lastMContract compareToesd = (lastMContract)compareTo;
-		Integer returnValue = 0;
-	
-		// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-		// 鍒ゆ柇鍦ㄦ暟閲�
-		if (count  > compareToesd.count) {
-			returnValue = -1;
-		} else if (count  < compareToesd.count) {
-			returnValue = 1;
-		} else {
-			if (endDate  > compareToesd.endDate ) {
-				returnValue = 1;
-			} else {
-				returnValue = -1;
-			}
-		}
-		return returnValue;
-	}
-	
-	// 鍘熸柟妗�
-	// if (endDate  > compareToesd.endDate ) {
-	// 	returnValue = -1;
-	// } else if (endDate  < compareToesd.endDate ) {
-	// 	returnValue = 1;
-	// }else{
-	// if (count  > compareToesd.count ) {
-	// 	returnValue = -1;
-	// } else if (count  < compareToesd.count ) {
-	// 	returnValue = 1;
-	// 	}
-	// }
-	// return returnValue;
-	// 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-	}
-	}
\ No newline at end of file
+    //test
+    private String targetHospitalId = null;                                    // 浠婂緦绯诲垪鐥呴櫌鐢�
+    private String targetMaintenanceContractId = null;
+    public String typeresult {get; set;}
+    
+    public String targetEstimateId { get; private set; }
+    public Boolean changedAfterPrint {get; set;}                               // true 銇牬鍚堛�佺敾闈€伀 confirm 銉°儍銈汇兗銈搞亴琛ㄧず銇椼伨銇欍�俼uoId銈掓柊銇椼亜insert銆傚垽瀹氥伅js銇仸瀹熸柦
+    public Decimal lastFriYearsPriceSum {get; set;}
+    public Decimal lastSecYearsPriceSum {get; set;}
+    Public String alertString {get; set;}
+    Public String alertString2 {get; set;}
+    Public String alertString3 {get; set;}
+    public Boolean printAsset { get; private set; }
+    public Boolean printContract { get; private set; }
+    public Boolean printTripartite { get; private set; }
+    public Boolean printAgent { get; private set; }
+    public boolean inDicideFlag {get; set;}                         //浣滀负琛ュ厖锛屽搴旀姤浠峰喅瀹氫箣鍚庯紝鍗存湭鑳借鍚堝悓璧锋鏃ユ湡浼犻�掔粰鍚堝悓鐨勯棶棰�
+    public String isPaymentSet {get; set;}
+    //public String PaymentSet {get;set;}
+    // 寮曟暟銇偟銉笺儞銈瑰绱勩伄鎯呭牨銈掓牸绱嶃仚銈嬨��
+    public Maintenance_Contract__c contract { get; private set; }
+    public Maintenance_Contract_Estimate__c estimate { get; set; }
+    // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+    public Asset ass { get; set; }
+    // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+    // 鐥呴櫌閰嶄笅銇磵鍏ユ鍣ㄣ伄鎯呭牨銈掓牸绱嶃仚銈嬨��
+    private Transient List<Asset> assetRecords;                                               // TODO 绯诲垪鐥呴櫌銇牬鍚堛�併亾銇厤鍒椼伅鍥哄畾銇с亶銇亜銇с仚銆�
+    public List<AssetInfo> checkedAssets { get; set; }
+    private List<AssetInfo> unCheckedAssets = new List<AssetInfo>();
+    
+    //public List<List<AssetInfo>> checkedAssetsView { get; set; }
+    public List<List<AssetInfo> > unCheckedAssetsView { get; set; }
+    
+    // 鍒嗛〉鐢�
+    public Integer currPage { get; set; }                         // 褰撳墠椤�
+    public Integer totalPage { get; set; }                         // 鎬婚〉鏁�
+    public Integer selctRecordNum { get { return Integer.valueOf(selRecordOption); } }                         // 閫夋嫨鐨勬瘡椤佃褰曟暟
+    public Integer totalRecords { get; set; }                          // 鎬昏褰曟暟
+    public String selRecordOption { get; set; }
+    public static List<SelectOption> recordNum { get; private set; }                         // 閫夋嫨姣忛〉璁板綍鏁癓ist
+    
+    //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
+    public Boolean IS_Clone_After_Decide { get; set; }
+    //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
+    //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+    public List<String> TopProductModel =new List<String>();
+    //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    static {
+        recordNum = new List<SelectOption>();
+        recordNum.add(new SelectOption('10', '10'));
+        recordNum.add(new SelectOption('20', '20'));
+        recordNum.add(new SelectOption('50', '50'));
+        recordNum.add(new SelectOption('100', '100'));
+        recordNum.add(new SelectOption('200', '200'));
+    }
+    private List<String> checkIdList = new List<String> ();                         // 鍚堝悓瀵硅薄璁惧鐨勮澶嘔D
+    
+    //-------HWAG-B4R3SS----------------update----------------------------
+    public Boolean activeOn { get; set; }
+    public String sortKey { get; set; }
+    public Boolean sortOrderAsc { get; private set; }
+    private String[] columus = new String[] {'Asset_situation__c', 'Name', 'SerialNumber', 'CurrentContract__r.Management_Code__c', 'Department_Name__c', 'Status', 'Installation_Site__c', 'Room_Number__c', 'InstallDate', 'Asset_Owner__c', 'Accumulation_Repair_Amount__c', 'AssetMark__c'};
+    private Boolean isSoft;
+    // 鏄剧ず鏁版嵁鏉℃暟闄愬埗
+    private static Integer SELECT_LIMIT = 200;
+    public List<AssetInfo> unCheckedInfoList { get; set; }
+    private String text1ForSort = null;
+    private String cond1ForSort = null;
+    private String val1ForSort = null;
+    /*****************select option******************/
+    public static List<SelectOption> textOpts { get; private set; }
+    public Decimal countorder { get; set; }
+    public List<String> assetSerialNumberList = new List<String>();
+    // 鏂拌 鎴栬�� copy
+    private Boolean newIns = false;
+    //add   wangweipeng     2021/12/06     start
+    public String checkDealerId{get;set;}
+    //add   wangweipeng     2021/12/06     end
+    
+    static {
+        textOpts = new List<SelectOption>();
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
+        // textOpts.add(new SelectOption('','-鏃�-'));
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        /* 鍦ㄦ煡璇㈣鍙ヤ腑 鏂板浜� AssetMark__c 鐨勫瓧娈� */
+        // textOpts.add(new SelectOption('S:Asset_situation__c'  , Schema.SObjectType.Asset.fields.Asset_situation__c.label));
+        // 娣诲姞鏂版潯浠� -- 鑰楁潗/涓绘満
+        textOpts.add(new SelectOption('S:AssetMark__c', '涓绘満/鑰楁潗'));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        textOpts.add(new SelectOption('S:Name', Schema.SObjectType.Asset.fields.Name.label));
+        textOpts.add(new SelectOption('S:SerialNumber', Schema.SObjectType.Asset.fields.SerialNumber.label));
+        textOpts.add(new SelectOption('S:CurrentContract__r.Management_Code__c', Schema.SObjectType.Asset.fields.CurrentContract__c.label));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        // textOpts.add(new SelectOption('S:Status'              , Schema.SObjectType.Asset.fields.Status.label));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        textOpts.add(new SelectOption('S:Installation_Site__c', Schema.SObjectType.Asset.fields.Installation_Site__c.label));
+        textOpts.add(new SelectOption('S:Department_Name__c', Schema.SObjectType.Asset.fields.Department_Name__c.label));
+    }
+    public static List<SelectOption> equalOpts { get; private set; }
+    static {
+        equalOpts = new List<SelectOption>();
+        equalOpts.add(new SelectOption('equals', '绛変簬'));
+        equalOpts.add(new SelectOption('contains', '鍖呭惈'));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        //鏂板姞鍖归厤绗� 涓嶇瓑浜�
+        equalOpts.add(new SelectOption('notequals', '涓嶇瓑浜�'));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+    }
+    public String text1 { get; set; }                         // 瀵硅薄
+    public String cond1 { get; set; }                         // 鏉′欢
+    public String val1 { get; set; }                          // 鍊�
+    //LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
+    public String contr {get; set; }                         //鍒ゆ柇鏄惁init
+    //LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
+    
+    // 妫�绱㈡寜閽�
+    public PageReference searchBtn() {
+        countorder = 1;
+        //楠岃瘉
+        assetSerialNumberList.clear();
+        getAssetSerialNumber();
+        totalRecords = 0;
+        List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
+        for (Asset ast : assetconfimList) {
+            totalRecords++;
+        }
+    
+    
+        // 鑾峰彇assets
+        List<Asset> assetList = getAsset(text1, cond1, val1);
+    
+        // 浣滄垚鏄庣粏琛�
+        getSortedUnCheckedInfoList(assetList);
+        // 鎺掑簭鐢ㄦ绱㈡潯浠堕��閬�
+        text1ForSort = text1;
+        cond1ForSort = cond1;
+        val1ForSort = val1;
+        currPage = 1;
+    
+    
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        return null;
+    }
+    
+    // 鍙栧凡閫夋嫨璧勪骇鐨勬満韬紪鐮�
+    public void getAssetSerialNumber() {
+        //LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
+        contr = '2';
+        //LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
+        assetSerialNumberList = new List<String>();
+        assetSerialNumberList.clear();
+        for (AssetInfo ai : this.checkedAssets) {
+            system.debug('checkedAssets1111111' + this.checkedAssets);
+            //system.debug('ai.ah.SerialNumber__c' + ai.ah.SerialNumber__c);
+            if (String.isNotEmpty(ai.rec.SerialNumber)) {
+                assetSerialNumberList.add(ai.rec.SerialNumber);
+            }
+        }
+    }
+    
+    //
+    private void getSortedUnCheckedInfoList(List<Asset> assetList) {
+        Boolean overLimit = false;
+        Map<Id, AssetInfo> markUpUnCheckMap = new Map<Id, AssetInfo>();
+        for (AssetInfo unCheckinfo : unCheckedAssets) {
+    
+            // 鎵撳嬀锛岃涓轰紭鍏堟樉绀烘槑缁�
+            if (unCheckinfo.rec_checkBox_c == true) {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'unCheckinfo.rec_checkBox_c' + unCheckinfo.rec_checkBox_c));
+                markUpUnCheckMap.put(unCheckinfo.rec.Id, unCheckinfo);
+            }
+        }
+        unCheckedAssets.clear();
+        // 浼樺厛鏄剧ず鏄庣粏鏀惧湪鏈�鍓嶉潰
+        unCheckedInfoList = new List<AssetInfo>();
+        for (AssetInfo asInfo : markUpUnCheckMap.values()) {
+            unCheckedAssets.add(asInfo);
+        }
+        SELECT_LIMIT = selctRecordNum;
+        Integer selectCnt = unCheckedAssets.size();
+        for (Asset asset : assetList) {
+            // 201銈掕秴銇堛仧鍫村悎鍓�200銇伩銈掑嚭銇�
+            if (unCheckedAssets.size() >= SELECT_LIMIT) { overLimit = true; break; }
+            if (markUpUnCheckMap.containsKey(asset.Id) == false) {
+                //unCheckedInfoList.add(unCheckMap.get(asset.Id));
+                unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), asset));
+            }
+        }
+    }
+    
+    //妫�绱㈤獙璇�
+    private List<Asset> getAssetconfim(String txt, String con, String val) {
+        String soql = this.makeSoqlconfim();
+        soql += makeTextSql(txt, con, val);
+        system.debug('makeTextSql_soql' + soql);
+        if (isSoft) {
+            soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
+        } else {
+            soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
+        }
+        system.debug('====getAssetconfim:' + soql);
+        return Database.query(soql);
+    }
+    
+    private List<Asset> getAsset(String txt, String con, String val) {
+        String soql = this.makeSoqlconfim();
+        soql += makeTextSql(txt, con, val);
+    
+        if (isSoft) {
+            soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
+        } else {
+            soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
+        }
+        soql += ' limit ' + System.Label.Asset_Maxcount;
+        soql += ' OFFSET ' + (countorder - 1) * Integer.valueOf(System.Label.Asset_Maxcount);
+        return Database.query(soql);
+    }
+    
+    public Integer soqlNos() {
+        List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
+        totalRecords = assetconfimList.size();
+        //totalPage = (totalRecords/selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        return totalRecords;
+    }
+    
+    private String makeSoqlconfim() {
+        String sqlTail = '(\'';
+        system.debug('assetSerialNumberList.size()' + assetSerialNumberList.size());
+        for (Integer i = 0; i < assetSerialNumberList.size(); i++) {
+            if (i < assetSerialNumberList.size() - 1) {
+                sqlTail += assetSerialNumberList[i] + '\',\'';
+            } else {
+                sqlTail += assetSerialNumberList[i] + '\')';
+            }
+        }
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
+        //tcm 娣诲姞 Management_Code__c  20211201 start
+        String soql = 'SELECT Id, Name,OwnershipMachine_No__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
+                      + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
+                      + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
+                      + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
+                      + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
+                      + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
+                      + 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
+                      + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,AssetMark__c,NoPartRiskDate_F__c,NoPartRiskDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' ';
+        //HWAG-BDJ43R ---XHL---20190729---
+        //soql +=  ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        // soql +=  ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        //HWAG-BDJ43R ---XHL---20190729---
+        if (assetSerialNumberList.size() > 0) {
+            soql += ' AND SerialNumber not in ' + sqlTail;
+        }
+        return soql;
+    }
+    
+    // 鎷兼帴妫�绱㈡潯浠秙ql鏂�
+    private String makeTextSql(String txt1, String con, String val) {
+        String soql = '';
+        if (String.isBlank(con)) {
+            con = 'equals';
+        }
+        // contains銇牬鍚堛�佹棩鍫辩敾闈€伄鐥呴櫌妞滅储銈掔湡浼笺仐銆乻pace銇у垎銇戙仸銆乤nd妞滅储
+        // equals銇牬鍚堛�丼F妯欐簴銇绱€倰鐪熶技銇椼�併��,銆嶃仹鍒嗐亼銇︺�乷r妞滅储
+        if (!String.isBlank(txt1)) {
+            if ((con == 'contains' || con == 'notcontains') && val.contains(' ')) {
+                String[] vals = val.split(' ');
+    
+                String cSql = '';
+                if (vals.size() > 0) {
+                    String txt = txt1.substring(2);
+                    soql += ' and ( ';
+                    for (String v : vals) {
+                        if (String.isNotBlank(v)) {
+                            if (con == 'contains') {
+                                soql += txt + ' like \'%' + v + '%\' or ';
+                            } else {
+                                soql += txt + ' not like \'%' + v + '%\' and ';
+                            }
+                        }
+    
+    
+                    }
+                    soql = soql.substring(0, soql.length() - 4);
+                    soql += ')';
+                }
+                system.debug('containssoql:     ' + soql);
+            } else if ((con == 'equals' || con == 'notequals') && val.contains(',')) {
+                String[] vals = val.split(',');
+                if (vals.size() > 0) {
+                    String txt = txt1.substring(2);                 // S:Name 銆佹渶鍒濄伄锛掓枃瀛椼亴銈裤偆銉椼仹銇�
+                    soql += ' and ( ';
+                    for (String v : vals) {
+                        if (con == 'equals') {
+                            soql += txt + ' = \'' + v + '\' or ';
+                        } else {
+                            // notequals
+                            soql += txt + ' <> \'' + v + '\' and ';
+                        }
+                    }
+                    soql = soql.substring(0, soql.length() - 4);
+                    soql += ')';
+                }
+            } else {
+                String cSql = this.makeTextSqlStr(txt1, con, val);
+                if (con != 'notcontains') {
+                    soql += this.makeTextSqlStr(txt1, con, val);
+                } else {
+                    // notcontains
+                    if (!String.isBlank(cSql)) {
+                        cSql = cSql.substring(5);                 // ' and ' 銇�5鏂囧瓧銈掑銇�
+                        soql += ' and (NOT ' + cSql + ') ';
+                    }
+                }
+            }
+        }
+        // //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        // else{
+        //     soql += 'And AssetMark__c = \'涓绘満\'';
+        // }
+        // //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        return soql;
+    }
+    
+    private String makeTextSqlStr(String txt1, String con, String val) {
+        String soql = '';
+        if (!String.isBlank(txt1)) {
+            String txt = txt1.substring(2);
+            String colType = txt1.substring(0, 2);
+            String tmpVal = val.trim();
+            // 绌虹櫧銇牬鍚�''銇仚銈�
+            if (String.isBlank(tmpVal)) {
+                if (con == 'equals') {
+                    //soql += ' and ' + txt + ' = ' + tmpVal;
+                    soql += ' and ' + txt + ' = null';
+                } else if (con == 'notequals') {
+                    soql += ' and ' + txt + ' <> null';
+                } else {
+                    // 绌虹櫧銇牬鍚堛�乧ontains, notcontains 銇� starts with銇劇瑕�
+                }
+            } else {
+                soql += ' and ' + txt;
+                if (con == 'equals') {
+                    if (colType == 'S:') {
+                        soql += ' = \'' + tmpVal + '\'';
+                    } else {
+                        soql += ' = ' + tmpVal + ' ';
+                    }
+                } else if (con == 'notequals') {
+                    if (colType == 'S:') {
+                        soql += ' <> \'' + tmpVal + '\'';
+                    } else {
+                        soql += ' <> ' + tmpVal + ' ';
+                    }
+                } else if (con == 'contains' || con == 'notcontains') {
+                    soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else if (con == 'starts with') {
+                    soql += ' like \'' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else {
+                    if (colType == 'S:') {
+                        soql += ' ' + con + '\'' + tmpVal + '\'';
+                    } else {
+                        soql += ' ' + con + ' ' + tmpVal + ' ';
+                    }
+                }
+            }
+        }
+        return soql;
+    }
+    
+    //----------HWAG-B4R3SS------------------------------------------------------------
+    
+    
+    
+    
+    
+    
+    public Boolean getEnablePrintContract() {
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            return this.estimate.Estimation_Decision__c;
+        } else {
+            return false;
+        }
+    }
+    
+    public Boolean getUnDecideBtnDisabled() {
+        // 瑕嬬銈傘倞decide鍙栨秷銇椼仹銇嶃仾銇勬潯浠躲伄鍒ゆ柇
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            if (this.estimate.Estimation_Decision__c) {
+                return false;
+            }
+        }
+        // TODO 鏈綋銇壒鍒ヨ硣鏍笺亴銇傘倢銇� 姹哄畾鍙兘銇仚銈�
+        return true;
+    }
+    public Boolean getDecideBtnDisabled() {
+        // 瑕嬬銈傘倞decide銇с亶銇亜鏉′欢銇垽鏂�
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            if (this.estimate.Estimation_Decision__c) {
+                return true;
+            }
+            // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 姹哄畾鍙兘銇仚銈�
+            return true;
+        }
+        if (this.estimate.Process_Status__c != '鎵瑰噯') {
+            return true;
+        } else {
+            if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
+                && this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
+                && this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
+                return true;
+            }
+        }
+        return false;
+    }
+    public Boolean getApprovalBtnDisabled() {
+    
+        // 瑕嬬銈傘倞鐢宠珛銇с亶銇亜鏉′欢銇垽鏂�
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 鐢宠珛鍙兘銇仚銈�
+            return true;
+        }
+        if (String.isBlank(this.estimate.Process_Status__c) == false
+            && this.estimate.Process_Status__c != '鑽夋涓�'
+            //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
+            ) {
+            return true;
+        }
+        return false;
+    }
+    // 20200307 涓嶇敤
+    // public Boolean getcontactBtnDisabled() {
+    //     if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+    //         // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 鐢宠珛鍙兘銇仚銈�
+    //         return true;
+    //     }
+    //     if (String.isBlank(this.estimate.Process_Status__c) == false
+    //             && this.estimate.Process_Status__c != '鑽夋涓�'
+    //             && this.estimate.Process_Status__c != '鐢宠涓�'
+    //     ) {
+    //         return true;
+    //     }
+    //     return false;
+    // }
+    public Boolean getSaveBtnDisabled() {
+        // 瑕嬬銈傘倞save銇с亶銇亜鏉′欢銇垽鏂�
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            return true;
+        }
+        if (String.isBlank(this.estimate.Process_Status__c) == false
+            && this.estimate.Process_Status__c != '鑽夋涓�'
+            //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
+            ) {
+            return true;
+        }
+        return false;
+    }
+    public Boolean getPrintBtnDisabled() {
+        // 鍗板埛銇с亶銇亜鏉′欢銇垽鏂�
+        if (this.estimate.Process_Status__c != '鎵瑰噯' || !this.contract.Status__c.equals('寮曞悎涓�') ) {
+            return true;
+        } else {
+            if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
+                && this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
+                && this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
+                return true;
+            }
+        }
+        return false;
+    }
+    // 椤甸潰椤圭洰闈炴椿鎬ц瀹�
+    public Boolean getPageDisabled() {
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            return true;
+        }
+        if (String.isBlank(this.estimate.Process_Status__c) == false
+            && this.estimate.Process_Status__c != '鑽夋涓�'
+            ) {
+            return true;
+        }
+        return false;
+    }
+    // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+    // public Boolean getPageDisabled1() {
+    
+    //     if (
+    //         String.isBlank(this.ass.Name)
+    //     ) {
+    //         return true;
+    //     }
+    //     return false;
+    // }
+    // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+    public Integer productCount {
+        get {
+            return checkedAssets == null ? 0 : checkedAssets.size();
+        }
+    }
+    public Integer productCount2 {
+        get {
+            return unCheckedAssets == null ? 0 : unCheckedAssets.size();
+        }
+    }
+    public Integer productCount3 {
+        get {
+            Integer cnt = 0;
+            for (AssetInfo input : this.checkedAssets) {
+                if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                    cnt += 1;
+                }
+            }
+            return cnt;
+        }
+    }
+    // TODO 銈偣銈裤儬銉┿儥銉亱銈夊彇寰�
+    public static Decimal oxygenPriceAdj { get { return 0.1; } }                                  // TODO katsu 閰稿寲姘淬倰浣跨敤銇椼仾銇勩倛銇嗐伀澶夋洿
+    public static Decimal isNewPriceAdj { get { return 1; } }
+    
+    //public String productName { get; set; }
+    public Integer productIdx { get; set; }
+    
+    public Integer isNewAddMonth { get { return Integer.valueOf(System.Label.MC_New_AddMonth); } }
+    
+    public Integer keepPriceMonth { get { return Integer.valueOf(System.Label.MC_KeepPrice_Month); } }
+    
+    public Boolean isPageAction = false;
+    
+    private Integer PosttoInstall { get { return Integer.valueOf(System.Label.Post_to_Install); }}
+    
+    public Boolean changedSubmitPrice {get; set;}
+    
+    public Boolean isSaveOrApproval {get; set;}
+    public String OldContractStartDate {get; set;}
+    public String OldMaintenancePrice { get; set; }
+    
+    /**
+     * 銈炽兂銈广儓銉┿偗銈�
+     */
+    public SelectAssetEstimateVMController() {
+        currPage = 1;
+        selRecordOption = '20';
+        totalRecords = 0;
+        checkDealerId = '';
+    }
+    /**
+     * Visaulforce銇嬨倝鍛笺伆銈屻倠銈炽兂銈广儓銉┿偗銈�
+     */
+    public SelectAssetEstimateVMController(ApexPages.StandardController controller) {
+        //HWAG-B4R3SS  START 20181026
+        currPage = 1;
+        selRecordOption = '20';
+        //this.targetEstimateId = (String)(ApexPages.currentPage().getParameters().get('id'));
+        totalRecords = 0;
+        //HWAG-B4R3SS  END 20181026
+    }
+    
+    private void setThisEstimate() {
+        //HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c start
+        this.estimate = [SELECT Id, Name, Maintenance_Contract__c, Estimation_Decision__c, CreatedDate, Service_Contract_Staff__c,
+                         JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, Finally_Approved_Staff__c,
+                         Contract_Esti_Start_Date__c, Contract_Esti_End_Date__c, Contract_Range__c, Contract_Start_Date__c, Contract_End_Date__c,
+                         Maintenance_Contract_Status__c, Discount_reason__c, Improve_ConsumptionRate_Idea__c, Process_Status__c,
+                         Estimate_Trial_Money__c, Maintenance_Price__c, Department__c, PrintDate__c, Quote_Date__c, Submit_quotation_day__c,
+                         Examination_Price__c, Service_contract_target_number__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_First__c, Maintenance_Contract__r.Payment_Plan_Date_First__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Second__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Third__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Forth__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c,
+                         Discount_Price__c, Discount_Percentage__c, IsSyncing__c,
+                         NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,Dealer__r.FirstParagraphEnd__c,Is_RecognitionModel__c,
+                         Append_Condition_Price__c, Asset_Sum_Price__c, Asset_Repair_Sum_Price__c,
+                         Print_Contract__c, Print_RepairPrice__c, Print_DiscountPercentage__c, Print_Agent__c, Change_Dealer_Approval__c,
+                         Print_DiscountPrice__c, Print_ListPrice__c, Print_MaintePrice__c, Print_SumPrice__c, Print_Tripartite__c, TKZongjianApprovalManager__c
+                         //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
+                         , IS_Clone_After_Decide__c, New_contract_offer__c, NewEstimation_Amount__c, EndUserType__c, Print_Simplify__c
+                         //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
+                         //鏈�浣庝环鏍� 鏈�楂樹环鏍� 鐢宠鑳屾櫙鐩稿叧瀛楁 20200108 start
+                         , GuidePrice_Up__c, GuidePrice_Down__c, finalPriceDecideWay__c, mainTalksTime__c, talksStartDate__c
+                         , Combined_rate__c, New_Contract_Type_TxT__c, Estimate_Price_range__c
+                         //鏈�浣庝环鏍� 鏈�楂樹环鏍艰绠� 20200108 end
+                         , Sales_incidental__c, Consumption_rate_Forecast__c, AgencyHos_Price__c
+                         // 鐢宠鎶ヤ环閲戦 鍜� 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼
+                         , Request_quotation_Amount__c, Service_discount_Rate__c, ContractPriceType__c
+                         , LastMContract1__c, LastMContract2__c, LastMContract3__c, LastMContract4__c, LastMContract5__c
+                         , LastMContract1_ConCount__c, LastMContract2_ConCount__c, LastMContract3_ConCount__c, LastMContract4_ConCount__c, LastMContract5_ConCount__c,
+                         LastMContract1_NO__c, LastMContract2_NO__c, LastMContract3_NO__c, LastMContract4_NO__c, LastMContract5_NO__c
+                         //璺宠繃鐐规鏍囪 2021/07/28 gzw start
+                         , Skip_DJ__c
+                         //璺宠繃鐐规鏍囪 2021/07/28 gzw start
+    
+                        //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start
+                        //, Maintenance_Contract__r.Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
+                        //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
+    
+                         FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
+        //HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c end
+        decimal PriceSum =  (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c);
+        if ( this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null
+             //102018/10/26 HWAG-B5C88S 涓嶅啀鏍规嵁鏄惁濉啓绗竴娆′粯娆炬棩鏈熷垽鏂�
+             ) {
+            isPaymentSet = 'false';
+        } else if (this.estimate.Maintenance_Price__c != PriceSum) {
+            isPaymentSet = 'Denied';
+        } else {
+            isPaymentSet = 'true';
+        }
+    }
+    
+    public void init() {
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        TopProductModel.add('CF-LV1I');
+        TopProductModel.add('CF-LV1L');
+        TopProductModel.add('CV-V1');
+        TopProductModel.add('GIF-LV1');
+        TopProductModel.add('OER-AW');
+        TopProductModel.add('OER-A');
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+        typeresult = null;
+        changedAfterPrint = false;
+        changedSubmitPrice = false;
+        isSaveOrApproval = false;
+        OldContractStartDate = null;
+        OldMaintenancePrice = null;
+    
+        inDicideFlag = false;
+    
+        isSoft = false;
+        activeOn = true;
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
+        contr = '1';
+        val1 = '涓绘満';
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
+    
+        Date systemToday = System.today();
+        if (isPageAction == false) {
+            //HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� start
+            if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false) {
+                if (ApexPages.currentPage().getParameters().get('completion') == '1') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '2') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '瀹℃壒鎻愪氦鎴愬姛銆�'));
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '3') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Decided銆�'));
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '4') {
+    
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '5') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
+                }
+            }
+            //HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� end
+        }
+        this.printAsset = false;
+        this.printContract = false;
+        this.printTripartite = false;
+        this.printAgent = false;
+        String copyid = '';
+        if (isPageAction == false) {
+            this.targetEstimateId = ApexPages.currentPage().getParameters().get('copyid');
+            copyid = ApexPages.currentPage().getParameters().get('copyid');
+            if (this.targetEstimateId == null) {
+                String paramId = ApexPages.currentPage().getParameters().get('id');
+                if (String.isBlank(paramId) == false && paramId.startsWith('a0z')) {
+                    Maintenance_Contract_Asset_Estimate__c mcaeParam = [Select Maintenance_Contract_Estimate__c from Maintenance_Contract_Asset_Estimate__c where Id = :paramId];
+                    this.targetEstimateId = mcaeParam.Maintenance_Contract_Estimate__c;
+                } else {
+                    this.targetEstimateId = paramId;
+                }
+            } else {
+                this.newIns = true;
+            }
+            this.targetMaintenanceContractId = ApexPages.currentPage().getParameters().get('mcid');
+        }
+        // 绶ㄩ泦銇嬨倝
+        if (String.isBlank(this.targetEstimateId) == false) {
+            setThisEstimate();
+            this.targetMaintenanceContractId = this.estimate.Maintenance_Contract__c;
+            this.setContractInfo(this.targetMaintenanceContractId);
+        }
+        // 鏂拌銇嬨倝
+        else if (!String.isBlank(this.targetMaintenanceContractId)) {
+            this.estimate = new Maintenance_Contract_Estimate__c();
+            this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
+    
+            //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start
+            Date pastDate;
+            for(Maintenance_Contract__c mc1 : [SELECT Id, Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
+                                                        FROM Maintenance_Contract__c 
+                                                        WHERE Id = :this.targetMaintenanceContractId
+                                                        ]){
+                pastDate = mc1.Past_Contract_end_day__c;                                        
+            }
+            
+            System.debug('lt123pastDate涓婃湡鍚堝悓缁撴潫鏃�'+pastDate);
+            if(systemToday < pastDate){
+                this.estimate.Contract_Esti_Start_Date__c = pastDate.addDays(1);
+            }else{
+                this.estimate.Contract_Esti_Start_Date__c = systemToday;
+            }
+            //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
+    
+            //this.estimate.Contract_Esti_Start_Date__c = systemToday;
+            this.estimate.Contract_Start_Date__c = systemToday;
+            this.setContractInfo(this.targetMaintenanceContractId);
+            this.newIns = true;
+        }
+        // 浣曘倐銇亼銈屻伆銆佸康銇仧銈�
+        else {
+            throw new ControllerUtil.myException('鏃犳硶鏄剧ず缁翠慨鍚堝悓鎶ヤ环');
+            //return;
+        }
+        //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
+        IS_Clone_After_Decide = false;
+        if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false &&
+            ApexPages.currentPage().getParameters().get('completion') == '5' &&
+            this.estimate != null && this.estimate.IS_Clone_After_Decide__c) {
+            IS_Clone_After_Decide = true;
+    
+        }
+        //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
+        // 绱嶅叆姗熷櫒銇儏鍫便倰鍙栧緱
+        if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
+            //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
+                  //tcm 娣诲姞 Management_Code__c  20211201 start
+            assetRecords = [SELECT Id, Name,OwnershipMachine_No__c,Product2.ProductURF__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty__c, Reson_Can_not_Warranty__c,
+                            InstallDate, isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c, EquipmentGuaranteeFlg__c,
+                            CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c, CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__c,
+                            CurrentContract_F_asset__c, CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c, CurrentContract_F_asset__r.endDateGurantee_Text__c, CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+                            CurrentContract_F__r.First_Estimate_Date__c,
+                            CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
+                            CurrentContract_F__r.Contract_Range__c, AssetMark__c,
+                            // 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+                            NoPartRiskDate_F__c, NoPartRiskDate__c, SignableFlag__c,
+                            Product2.PartSupplyFinishDate__c, Product2.PartSupplyFinishDateExp__c
+                            // 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+                            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '鑰楁潗' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty__c asc];
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+            // assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
+            //                      InstallDate,isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,EquipmentGuaranteeFlg__c,
+            //                      CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,
+            //                      CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+            //                      CurrentContract_F__r.First_Estimate_Date__c,
+            //                     CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,
+            //                     CurrentContract_F__r.Contract_Range__c ,AssetMark__c
+            //                      FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c = '涓绘満' ORDER BY ID,IF_Warranty__c asc];
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        } else {
+            assetRecords = new List<Asset>();
+        }
+        //sqlStr += ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
+        this.checkedAssets = new List<AssetInfo>();
+        this.unCheckedAssets = new List<AssetInfo>();
+    
+        // 閬告姙娓堛伩銇磵鍏ユ鍣ㄦ儏鍫便倰鍙栧緱
+        Map<Id, Integer> selectedAssetIds = new Map<Id, Integer>();
+        List<Maintenance_Contract_Asset_Estimate__c> selectedMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
+        List<Maintenance_Contract_Asset_Estimate__c> newMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
+        // 鏂拌銆佷笖銇わ紤銇ょ洰瑕嬬銈傘倞銇牬鍚堛�併偝銉斻兗鍏冦伄淇濇湁瑷倷銈掓寔銇�
+        if (String.isBlank(this.targetEstimateId) && this.contract.Estimate_Num__c == 0) {
+            List<Maintenance_Contract_Asset__c> oldVals = [
+                select Id, Name, Asset__c, Asset__r.InstallDate, Asset__r.isNewDate_use__c,
+                Asset__r.Posting_Date__c, Asset__r.Maintenance_Price_Month__c,
+                Asset__r.EquipmentGuaranteeFlg__c,
+                Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
+                Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+                Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
+                Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
+                Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
+                Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
+                Asset__r.CurrentContract_F__r.Contract_Range__c,
+                Asset__r.CurrentContract_F__r.Contract_End_Date__c,
+                Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c
+                from Maintenance_Contract_Asset__c
+                where Maintenance_Contract__c = :this.targetMaintenanceContractId
+            ];
+            Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
+            for (Maintenance_Contract_Asset__c mca : oldVals) {
+                // old銈堛倞鏇存柊銇椼仧銇勯爡鐩�
+                Boolean isNew = false;
+                // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                boolean isCheck = true;
+                // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+                Decimal listPrice = mca.Asset__r.Maintenance_Price_Month__c;
+                Decimal asset_Consumption_rate = null;
+                // 鍙栦笂涓�鏈熷悎鍚屾秷璐圭巼
+                if (mca.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && mca.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
+                    asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
+                } else {
+                    asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
+                }
+                // InstallDate 銇� 浠婃棩銈掓瘮杓�
+                // 1.瀹夎鏃ユ垨鑰呭彂璐ф棩鍜屼粖澶╂瘮杈� 瀹炴椂鍙樺寲
+                // 2.鎻愪氦鍚庝笉鍐嶅彉鍖�
+                //Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
+                Date createdDate = systemToday;
+                if (createdDate.addMonths(isNewAddMonth) < mca.Asset__r.isNewDate_use__c) {
+                    isNew = true;
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                    isCheck = true;
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+                    listPrice = mca.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
+                }
+                selectedAssetIds.put(mca.Asset__c, selectedMcaes.size());
+                selectedMcaes.add(new Maintenance_Contract_Asset_Estimate__c(
+                              Asset__c = mca.Asset__c,
+                              isNew__c = isNew,
+                              // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                              Check_Object__c = isCheck,
+                              // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+                              Estimate_List_Price__c = listPrice,
+                              // 鍙栦笂涓�鏈熷悎鍚屼环鏍�
+                              LastMContract_Price__c = mca.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
+    
+                              Asset_Consumption_rate__c = asset_Consumption_rate,
+                              EquipmentGuaranteeFlgTxt__c = mca.Asset__r.EquipmentGuaranteeFlg__c
+                              ));
+            }
+        } else {
+            for (Maintenance_Contract_Asset_Estimate__c mcae : [SELECT Id,
+                                                                Name,
+                                                                Maintenance_Contract_Estimate__c,
+                                                                Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c,
+                                                                Asset__c,
+                                                                Asset__r.Maintenance_Price_Month__c,
+                                                                Asset__r.InstallDate,
+                                                                Asset__r.isNewDate_use__c,
+                                                                Asset__r.EquipmentGuaranteeFlg__c,
+                                                                //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+                                                                Asset__r.OwnershipMachine_No__c,
+                                                                //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+                                                                Asset_Consumption_rate__c,
+                                                                Asset__r.CurrentContract_F__c,
+                                                                Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
+                                                                Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
+                                                                Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
+                                                                Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
+                                                                Asset__r.CurrentContract_F__r.Contract_Range__c,
+                                                                Asset__r.CurrentContract_F__r.Contract_End_Date__c,
+                                                                Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+                                                                LastMContract_Price__c,
+                                                                Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
+                                                                Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+                                                                Product_Manual__c,
+                                                                Product_Manual__r.EquipmentGuaranteeFlg__c,
+                                                                Product_Manual__r.Maintenance_Price_Month__c,
+                                                                Product_Manual__r.Name,
+                                                                //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+                                                                Product_Manual__r.Asset_Model_No__c,
+                                                                //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+                                                                //add 2021-02-07 mzy  start
+                                                                //Product_Manual__r.NoPartRiskDate_F__c,
+                                                                //Product_Manual__r.SignableFlag__c,
+                                                                //add 2021-02-07 mzy  end
+                                                                //add 2021.6.4 fxk  Start
+                                                                Check_Object__c,
+                                                                //add 2021.6.4 fxk  end
+                                                                IsNew__c,
+                                                                Estimate_List_Price__c,
+                                                                //Maintenance_Price_YearTXT__c,
+                                                                Estimate_Cost__c,
+                                                                Adjustment_ratio_Upper__c,
+                                                                Adjustment_ratio_Lower__c,
+                                                                Adjustment_Lower_price__c,
+                                                                Adjustment_Upper_price__c,
+                                                                Last_inspection_day__c,
+                                                                Check_Result__c,
+                                                                Repair_Price__c,
+                                                                Comment__c,
+                                                                Asset__r.Posting_Date__c,
+                                                                EquipmentGuaranteeFlgTxt__c,
+                                                                EquipmentGuaranteeFlg__c,
+                                                                ifHaveleftInPrevious__c,
+                                                                // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+                                                                Last_MContract__c
+                                                                // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
+                                                                // LJPH-C9GD34 gzw fix start
+                                                                ,Estimate_List_Price_Page__c
+                                                                // LJPH-C9GD34 gzw fix end
+                                                                FROM Maintenance_Contract_Asset_Estimate__c
+                                                                WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId
+                                                                                                         ORDER BY
+                                                                                                         Id,
+                                                                Asset__c,
+                                                                Product_Manual__c,
+                                                                Asset__r.SerialNumber,
+                                                                Asset__r.Name,
+                                                                Asset__r.Department_Name__c,
+                                                                Asset__r.InstallDate
+                 ]) {
+                if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
+                    //if (String.isBlank(copyid) == false) {
+                    if (mcae.Asset__c <> null) {
+                        mcae.EquipmentGuaranteeFlgTxt__c = mcae.Asset__r.EquipmentGuaranteeFlg__c;
+                        if (systemToday.addMonths(isNewAddMonth) < mcae.Asset__r.isNewDate_use__c) {
+                            mcae.IsNew__c = true;
+                            mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
+                        } else {
+                            mcae.IsNew__c = false;
+                            mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c;
+                        }
+                    } else if (mcae.Product_Manual__c <> null) {
+                        mcae.IsNew__c = true;
+                        mcae.Estimate_List_Price__c = mcae.Product_Manual__r.Maintenance_Price_Month__c * isNewPriceAdj;
+                    }
+                }
+                if (mcae.Asset__c <> null) {
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , mcae.Asset__c + 'IsNew  ' + mcae.IsNew__c));
+                    selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
+                    selectedMcaes.add(mcae);
+                } else {
+                    newMcaes.add(mcae);
+                }
+            }
+            system.debug('椤哄簭妫�娴�4' + selectedMcaes);
+        }
+        // 閬告姙娓堛伩銇倐銇伀銉併偋銉冦偗銈掍粯銇戙倠
+        // TODO xudan 涓�瑕с伀鍑恒倠鏄庣窗浠舵暟銇岃冻銈娿仾銇勩偙銉笺偣銇屻亗銈�
+        // 鈶燗ssetA鈥曟槑绱癆銇ф槑绱扮櫥閷�
+        // 鈶sset銇绱㈡潯浠跺鏇淬伀銈堛倞銆丄ssetA銇案閬犮伀鍙栧緱銇с亶銇亜
+        // 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
+        // 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
+        List<Data> datatemp = new List<Data>();
+        datatemp = getChartData();
+        for (Asset ast : this.assetRecords) {
+            Boolean isNew = false;
+            Decimal listPrice = ast.Maintenance_Price_Month__c;
+            if (selectedAssetIds.containsKey(ast.Id)) {
+                Maintenance_Contract_Asset_Estimate__c selectedLocal = selectedMcaes.get(selectedAssetIds.get(ast.Id));
+                isNew = selectedLocal.isNew__c;
+                listPrice = selectedLocal.Estimate_List_Price__c;
+                // xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
+                //                if (systemToday.addMonths(-6) < ast.InstallDate) {
+                //                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ast.InstallDate) {
+                //                Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
+                //System.debug(createdDate + '.addMonths(' + isNewAddMonth + ')' + createdDate.addMonths(isNewAddMonth) + ' < ast.InstallDate:' + ast.InstallDate);
+                //                if (createdDate.addMonths(isNewAddMonth) < ast.InstallDate) {
+                //                    isNew = true;
+                //                    listPrice = ast.Maintenance_Price_Month__c * isNewPriceAdj;
+                //                }
+                //              // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
+                //              娌℃湁鎻愪氦 鎴栬�呭湪鎶ヤ环鏃朵粠鏂拌绠�
+                if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
+                    Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
+                    selectedLocal.LastMContract_Price__c = selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ?   selectedLocal.LastMContract_Price__c : selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'LastMContract_Price__c--' + selectedLocal.LastMContract_Price__c));
+                    if (selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
+                        selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
+                    } else {
+                        selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
+                    }
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c + 'Asset_Consumption--- ' + selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c));
+    
+                    if (String.isNotBlank(String.valueOf(selectedLocal.Asset_Consumption_rate__c))) {
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'Contract_Consumption_rate__c ' + selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c));
+                        for (Data da : datatemp) {
+                            if (String.isBlank(String.valueOf(da.rate_Lower)) &&  selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
+                                selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
+                                selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
+                                selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
+                                selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower
+                                       && selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
+                                selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
+                                selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+    
+                            }
+                            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�--- ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
+                        }
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�+++ ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
+                    }
+                }
+    
+                //
+                //
+                //
+                checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal));
+            } else {
+                //update by rentongxiao 2020-09-23 start
+                if (ast.AssetMark__c == '涓绘満') {
+                    totalRecords++;
+                    if (unCheckedAssets.size() < selctRecordNum) {
+                        unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+                    }
+                }
+                //update by rentongxiao 2020-09-23 end
+    
+            }
+            listCut(unCheckedAssets);
+            /*
+               if (ast.CheckBox__c) {
+                    checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice));
+               } else {
+                    unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+               }
+             */
+        }
+    
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+    
+        system.debug('椤哄簭妫�娴�' + checkedAssets);
+        for (Maintenance_Contract_Asset_Estimate__c mcae : newMcaes) {
+            checkedAssets.add(new AssetInfo(checkedAssets.size(), mcae));
+        }
+    
+        // 鏈�寰�10琛岃拷鍔�
+        if (Schema.getGlobalDescribe().get('Maintenance_Contract_Asset_Estimate__c').getDescribe().isCreateable()) {
+            this.addNewRows();
+        }
+    
+        if (!String.isBlank(copyid)) {
+            this.targetEstimateId = null;
+            this.estimate = new Maintenance_Contract_Estimate__c();
+            this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
+        }
+        // 2021-02-07  gzw add  LJPH-BWY5QB start
+        setEndUserType(this.targetMaintenanceContractId);
+        // 2021-02-07  gzw add  LJPH-BWY5QB start
+        assetRecords.clear();
+        // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+        //contractStartDateChange();
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        List<AssetInfo> topAsset =new List<AssetInfo>();
+        List<AssetInfo> otherAsset =new List<AssetInfo>();
+        
+        for(AssetInfo ched : checkedAssets){
+            system.debug('椤哄簭妫�娴�2' + ched.ProductModelNoc);
+            system.debug('椤哄簭妫�娴�3' + ched.AssetModelNoc);
+            system.debug('椤哄簭妫�娴�5' + ched.rec.OwnershipMachine_No__c);
+            if(TopProductModel.contains(ched.ProductModelNoc)||TopProductModel.contains(ched.AssetModelNoc)||TopProductModel.contains(ched.rec.OwnershipMachine_No__c)){
+                ched.CheckRows = true;
+                ched.mcae.Check_Object__c = false;
+                topAsset.add(ched);
+            }else{
+                otherAsset.add(ched);
+            }
+        }
+        system.debug('椤哄簭妫�娴�16' + topAsset);
+        system.debug('椤哄簭妫�娴�17' + otherAsset);
+        topAsset.addAll(otherAsset);
+        List<AssetInfo> NumberSort =new List<AssetInfo>();
+        Integer i=0;
+        for (AssetInfo ched2 : topAsset) {
+            ched2.lineNo=i;
+            i++;
+            NumberSort.add(ched2);
+        }
+        checkedAssets=NumberSort;
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    }
+    
+    //
+    
+    // 鍙栧緱鍒嗛〉鏁版嵁
+    private void setPageRecord() {
+        checkIdList = new List<String> ();
+        for (AssetInfo ass : this.checkedAssets) {
+            if (!ass.isManual) {
+                checkIdList.add(ass.rec.Id);
+            }
+        }
+    
+        if ((currPage * selctRecordNum) <= 2000) {
+            String notInId = '(\'';
+            if (checkIdList.size() > 0) {
+                for (String str : checkIdList) {
+                    notInId += str + '\', \'';
+                }
+            }
+            notInId += '\')';
+            //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
+                //tcm 娣诲姞 Management_Code__c  20211201 start
+            String sqlStr = 'SELECT Id, Name,OwnershipMachine_No__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
+                            + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
+                            + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
+                            + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c, '
+                            + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
+                            + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
+                            + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
+                            + 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,'
+                            + 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' '
+                            + 'AND Id NOT IN ' + notInId;
+            //HWAG-B4R3SS  START 20181026
+            if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
+                sqlStr += makeTextSql(text1, cond1, val1);
+            }
+    
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
+            // else{
+            //     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
+            // }
+    
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
+            //HWAG-B4R3SS  END 20181026
+            //HWAG-BDJ43R---XHL---20190729---
+            sqlStr += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' )';
+            //HWAG-BDJ43R---XHL---20190729---
+            sqlStr += ' ORDER BY ID,IF_Warranty__c asc ';
+            if (currPage == 1) {
+                sqlStr += 'limit ' + selRecordOption;
+            } else {
+                sqlStr += 'limit ' + selRecordOption + ' offset ' + String.valueOf((currPage - 1) * selctRecordNum);
+            }
+            //system.debug();
+            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,
+            //               '222222222222_____'+sqlStr));
+            //return;
+            assetRecords = Database.query(sqlStr);
+        } else {
+            assetRecords.clear();
+            Integer sqlLimit = currPage * selctRecordNum;
+            List<Asset> temAsset = new List<Asset> ();
+            //HWAG-BDJ43R ---XHL---20190729---
+            String sqlStr = '';
+            //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
+            //tcm 娣诲姞 Management_Code__c  20211201 start
+            sqlStr  = 'SELECT Id, Name,OwnershipMachine_No__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c,';
+            sqlStr += 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,InstallDate,isNewDate_use__c,';
+            sqlStr += 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,';
+            sqlStr += 'CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,';
+            sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,';
+            sqlStr += 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,';
+            sqlStr += 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,';
+            sqlStr += 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
+            sqlStr += ' CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\'';
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+            // sqlStr += '  AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+            //HWAG-B4R3SS  START 20181026
+            if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
+                sqlStr += makeTextSql(text1, cond1, val1);
+            }
+    
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
+            // else{
+            //     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
+            // }
+    
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
+            //HWAG-B4R3SS  END 20181026
+            if (checkIdList.size() > 0) {
+                sqlStr += '  AND Id NOT IN ' + checkIdList;
+                //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
+                //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
+                //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND Id NOT IN : checkIdList AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
+            } else {
+                //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
+                //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
+                //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
+            }
+            sqlStr += ' ORDER BY ID,IF_Warranty__c asc limit ' + sqlLimit;
+            temAsset = Database.query(sqlStr);
+            //HWAG-BDJ43R ---XHL---20190729---
+            if (temAsset.size() >= (currPage * selctRecordNum)) {
+                for (Integer i = ((currPage - 1) * selctRecordNum); i < (currPage * selctRecordNum); i++) {
+                    assetRecords.add(temAsset.get(i));
+                }
+            } else {
+                for (Integer i = ((currPage - 1) * selctRecordNum); i < temAsset.size(); i++) {
+                    assetRecords.add(temAsset.get(i));
+                }
+            }
+        }
+        this.unCheckedAssets = new List<AssetInfo>();
+        for (Asset ast : assetRecords) {
+            this.unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+        }
+        listCut(unCheckedAssets);
+        // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+        //contractStartDateChange();
+    }
+    
+    // 缈婚〉鍒伴椤�
+    public void firstPage() {
+        getAssetSerialNumber();
+        currPage = 1;
+        //HWAG-B4R3SS  END 20181026
+        totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        //HWAG-B4R3SS  END 20181026
+        this.setPageRecord();
+    }
+    
+    // 鍚戝墠缈婚〉
+    public void previousPage() {
+        getAssetSerialNumber();
+        currPage--;
+        //HWAG-B4R3SS  START 20181026
+        totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        //HWAG-B4R3SS  END 20181026
+        this.setPageRecord();
+    }
+    
+    // 鍚戝悗缈婚〉
+    public void nextPage() {
+        getAssetSerialNumber();
+        //HWAG-B4R3SS  START 20181026
+        totalRecords = soqlNos();
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'totalRecords鈥斺�斺�斺�斺�斺��' + totalRecords));
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        if (totalRecords == 0) {
+            currPage  = 1;
+            //this.unCheckedAssets.clear();
+        } else {
+            currPage++;
+            this.setPageRecord();
+        }
+        //HWAG-B4R3SS  END 20181026
+    
+    }
+    
+    // 缈婚〉鍒板熬椤�
+    public void endPage() {
+        getAssetSerialNumber();
+        //HWAG-B4R3SS  START 20181026
+        totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        if (totalRecords == 0) {
+            currPage  = 1;
+            this.unCheckedAssets.clear();
+        } else {
+            currPage = totalPage;
+            this.setPageRecord();
+        }
+        //HWAG-B4R3SS  END 20181026
+    }
+    
+    // 姣忛〉鏄剧ず璁板綍鏁板彉鏇�
+    public void recordNumChange() {
+        currPage = 1;
+        //totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        this.setPageRecord();
+    }
+    
+    //list鍒嗗壊 闆嗗悎澶у皬瓒呰繃1000瀵瑰簲
+    private void listCut(List<AssetInfo> records) {
+        List<AssetInfo> recordsbreak = new List<AssetInfo>();
+        List<AssetInfo> recordsbreakover = new List<AssetInfo>();
+        unCheckedAssetsView = new List<List<AssetInfo> >();
+        AssetInfo c = null;
+        recordsbreak.clear();
+        recordsbreakover.clear();
+        unCheckedAssetsView.clear();
+        unCheckedAssetsView.add(records);
+    }
+    /*
+     *鏄剧ず杩囧幓涓ゅ勾鐨勭淮淇疄缁�
+     *璁$畻璇ョ淮淇悎鍚屾姤浠风殑鎵�鏈変繚浣戣澶囷紝杩囧幓涓ゅ勾鐨勪慨鐞嗗疄缁�
+     */
+    public static void ComputeLTYRepair(String targetHospitalId) {
+        system.debug('ComputeLTYRepair=====Start');
+        List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
+        McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
+                    from Maintenance_Contract_Asset_Estimate__c
+                    where Maintenance_Contract_Estimate__c = :targetHospitalId];
+        List<id> AsList = new List<id>();
+        Map<id, id> McaecToAsset = new Map<id, id>();
+        for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
+            AsList.add(Mcaes.asset__c);
+            McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
+        }
+        Maintenance_Contract_Estimate__c mcec = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetHospitalId];
+        //1骞村墠缁翠慨瀹炵哗
+        Date today = null;
+        Date LastYearDate = null;
+        Date LastSecondYearDate = null;
+        Date LastThirdYearDate = null;
+        Decimal LastYearPriceForMCAEC = 0;
+    
+        if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
+            today = mcec.Submit_quotation_day__c;
+            LastYearDate = mcec.Submit_quotation_day__c;
+            LastSecondYearDate = mcec.Submit_quotation_day__c;
+            LastThirdYearDate = mcec.Submit_quotation_day__c;
+        } else {
+            today = Date.valueOf(mcec.createdDate);
+            LastYearDate = Date.valueOf(mcec.createdDate);
+            LastSecondYearDate = Date.valueOf(mcec.createdDate);
+            LastThirdYearDate = Date.valueOf(mcec.createdDate);
+        }
+    
+        system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
+    
+        LastYearDate = LastYearDate.addYears(-1);
+        // LastYearDate = LastYearDate.addDays(1);
+    
+        //LastSecondYearDate = LastSecondYearDate.addDays(1);
+        LastSecondYearDate = LastSecondYearDate.addYears(-2);
+    
+        // LastThirdYearDate = LastThirdYearDate.addDays(1);
+        LastThirdYearDate = LastThirdYearDate.addYears(-3);
+        system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
+        // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
+        List<AggregateResult> FriRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c > :LastYearDate
+            and Agreed_Date__c <= :today
+            group by Delivered_Product__c
+        ];
+        List<AggregateResult> SecRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastYearDate
+            and Agreed_Date__c > :LastSecondYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞撮棿淇悊瀹炵哗
+        List<AggregateResult> ThiRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastSecondYearDate
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞翠慨鐞嗗疄缁�
+        List<AggregateResult> ThreeyearList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :today
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+    
+        // system.debug('++++++++'+FriRepairList+'++++++++'+SecRepairList+'+++++++'+ThiRepairList+'+++++');
+        // 杩囧幓1骞撮棿
+        Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓2骞撮棿
+        Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞撮棿
+        Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞�
+        Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
+        Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
+        for (AggregateResult Rpc : FriRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastFriYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : SecRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastSecYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThiRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastThiYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThreeyearList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
+            Decimal Defir = sumPrice1(Rpc);
+            ThreeYearPriceSumMap.put(idf, Defir);
+            ThiYearMonthMap.put(idf, threeYearM);
+        }
+        for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
+            Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
+            Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
+    
+    
+        }
+        try {
+            system.debug('McaeList:::::' + McaeList);
+            update McaeList;
+    
+            //return '';
+        } catch (Exception e) {
+            //return 'McaeList Update Failed : '+e;
+        }
+    
+    }
+    
+    
+    
+    public void ComputeLTYRepair() {
+        system.debug('ComputeLTYRepair=====Start');
+        List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
+        McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
+                    from Maintenance_Contract_Asset_Estimate__c
+                    where Maintenance_Contract_Estimate__c = :targetEstimateId];
+        List<id> AsList = new List<id>();
+        Map<id, id> McaecToAsset = new Map<id, id>();
+        for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
+            AsList.add(Mcaes.asset__c);
+            McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
+        }
+        Maintenance_Contract_Estimate__c mcec = new Maintenance_Contract_Estimate__c();
+        List<Maintenance_Contract_Estimate__c>  mcecList = new List<Maintenance_Contract_Estimate__c>();
+        mcecList = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetEstimateId];
+        if (mcecList.size() == 0) {
+            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, '璇峰厛淇濆瓨鎶ヤ环锛�'));
+            return;
+        } else {
+            mcec = mcecList[0];
+        }
+        //1骞村墠缁翠慨瀹炵哗
+        Date today = null;
+        Date LastYearDate = null;
+        Date LastSecondYearDate = null;
+        Date LastThirdYearDate = null;
+        Decimal LastYearPriceForMCAEC = 0;
+    
+        if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
+            today = mcec.Submit_quotation_day__c;
+            LastYearDate = mcec.Submit_quotation_day__c;
+            LastSecondYearDate = mcec.Submit_quotation_day__c;
+            LastThirdYearDate = mcec.Submit_quotation_day__c;
+        } else {
+            today = Date.valueOf(mcec.createdDate);
+            LastYearDate = Date.valueOf(mcec.createdDate);
+            LastSecondYearDate = Date.valueOf(mcec.createdDate);
+            LastThirdYearDate = Date.valueOf(mcec.createdDate);
+        }
+    
+        LastYearDate = LastYearDate.addYears(-1);
+        // LastYearDate = LastYearDate.addDays(1);
+    
+        // LastSecondYearDate = LastSecondYearDate.addDays(1);
+        LastSecondYearDate = LastSecondYearDate.addYears(-2);
+    
+        // LastThirdYearDate = LastThirdYearDate.addDays(1);
+        LastThirdYearDate = LastThirdYearDate.addYears(-3);
+        system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
+        // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
+        List<AggregateResult> FriRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c > :LastYearDate
+            and Agreed_Date__c <= :today
+            group by Delivered_Product__c
+        ];
+        List<AggregateResult> SecRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastYearDate
+            and Agreed_Date__c > :LastSecondYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞撮棿淇悊瀹炵哗
+        List<AggregateResult> ThiRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastSecondYearDate
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞翠慨鐞嗗疄缁�
+        List<AggregateResult> ThreeyearList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :today
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓1骞撮棿
+        Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓2骞撮棿
+        Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞撮棿
+        Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞�
+        Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
+        Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
+        // system.debug('1'+FriRepairList);
+        // system.debug('2'+SecRepairList);
+        system.debug('3' + ThiRepairList);
+    
+        for (AggregateResult Rpc : FriRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = this.sumPrice(Rpc);
+            LastFriYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : SecRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = this.sumPrice(Rpc);
+            LastSecYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThiRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastThiYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThreeyearList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
+            Decimal Defir = sumPrice1(Rpc);
+            ThreeYearPriceSumMap.put(idf, Defir);
+            ThiYearMonthMap.put(idf, threeYearM);
+        }
+        for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
+            Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
+            Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
+            system.debug('杩囧幓3骞村ぉ鏁�111 ' + Mca.id + '---' + Mca.Last_Third_Years_Repair_Cost_Text__c + ' +++ ' + Mca.Last_Third_Years_Repair_Month__c);
+        }
+        try {
+            update McaeList;
+            //return '';
+        } catch (Exception e) {
+            //return 'McaeList Update Failed : '+e;
+        }
+    
+    }
+    
+    private Decimal sumPrice(AggregateResult rpc) {
+        Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
+        system.debug(rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount'));
+        Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
+        Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
+        Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
+        Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
+        Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
+        Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
+        Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
+        Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
+        Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
+        system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
+                     rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
+                     + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
+        return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
+    }
+    
+    private static Decimal sumPrice1(AggregateResult rpc) {
+        Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
+        Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
+        Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
+        Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
+        Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
+        Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
+        Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
+        Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
+        Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
+        Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
+        system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
+                     rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
+                     + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
+        return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
+    }
+    
+    
+    //搴熷純涓�=========20161024==============//
+    public void ShowLTYRepair() {
+        system.debug('ShowLTYRepair=====Start');
+        lastFriYearsPriceSum = 0;
+        lastSecYearsPriceSum = 0;
+        //
+        List<Maintenance_Contract_Estimate__c> McecList = new List<Maintenance_Contract_Estimate__c>();
+        McecList = [select
+                    Last_Year_Repair_Sum__c,
+                    Year_Before_Last_Year_Re_Sum__c,
+                    Last_Two_Year_Repair_sum__c,
+                    Process_Status__c,                            //鎶ヤ环鐘舵��
+                    Repair_Sum_Compute_Date__c
+                    from
+                    Maintenance_Contract_Estimate__c
+                    where
+                    id = :targetEstimateId
+        ];
+        Maintenance_Contract_Estimate__c McecEle = new Maintenance_Contract_Estimate__c();
+        if (McecList.size() > 0) {
+            McecEle = McecList[0];
+            Date ComputeD = McecEle.Repair_Sum_Compute_Date__c == null ? Date.today() : McecEle.Repair_Sum_Compute_Date__c;
+            String DateString1 = ComputeD + '';
+            String DateString2 = ComputeD.addYears(-2).addDays(1) + '';
+            alertString = '闆嗚▓瀵捐薄鏈熼枔锛�' + DateString1.substring(0, 10) + '~' + DateString2.substring(0, 10) + '';
+            alertString2 = '鍘诲勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Last_Year_Repair_Sum__c + ' RMB ';
+            alertString3 = '鍓嶅勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Year_Before_Last_Year_Re_Sum__c + ' RMB';
+        } else {
+            alertString = '娌℃湁鏈夋晥鐨勭淮淇悎鍚屾姤浠�';
+        }
+    }
+    /**
+     * 鎵嬪嫊銇у晢鍝侀伕鎶炲緦銇儶銉曘儸銉冦偡銉�
+     **/
+    public void refreshProductData() {
+        System.debug('1535.......................杩涘叆refreshProductData鏂规硶');
+        System.debug('1536.......................杩涘叆refreshProductData鏂规硶');
+        for (Integer i = 0; i < checkedAssets.size(); i++) {
+            if (i == productIdx) {
+                AssetInfo ai = checkedAssets[i];
+                System.debug('--------:' + ai);
+                if (ai.mcae.Product_Manual__c == null) {
+                    ai.mcae.Estimate_List_Price__c = null;
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+                    ai.CheckRows = true;
+                    //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+                    ai.ProductModelNoc=null;
+                    ai.AssetModelNoc=null;
+                    ai.MDMModelNoc=null;
+                    ai.mcae.Check_Object__c = true;
+                    //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+                    System.debug('--------23234234:' + productIdx);
+                    System.debug('1540--'+i);
+                } else {
+                    //2021-02-04 mzy select璇彞鏌ヨ缁撴灉涓姞浜� NoPartRiskDate_F__c
+                    //2021-11-30 fy add LJPH-C8W8FV 缃《 start Asset_Model_No__c ProductURF__c
+                    List<Product2> prd = [select Id,Asset_Model_No__c,ProductURF__c, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c, Name from Product2 where Id = :ai.mcae.Product_Manual__c];
+                    ai.mcae.Estimate_List_Price__c = prd[0].Maintenance_Price_Month__c * isNewPriceAdj;
+                    //ai.mcae.Maintenance_Price_YearTXT__c = ai.mcae.Estimate_List_Price__c * 12;
+                    ai.orgPrice = prd[0].Maintenance_Price_Month__c;
+                    ai.mcae.EquipmentGuaranteeFlgTxt__c = prd[0].EquipmentGuaranteeFlg__c;
+                    ai.etGFlg = prd[0].EquipmentGuaranteeFlg__c;
+                    //add by rentx 2020-11-12 LJPH-BV93RZ start
+                    ai.proName = prd[0].Name;
+                    //add by rentx 2020-11-12 LJPH-BV93RZ end
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+                    ai.CheckRows = false;
+    
+                    //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+                    ai.MDMModelNoc = prd[0].Asset_Model_No__c;
+                    if(TopProductModel.contains(ai.MDMModelNoc)){
+                        ai.CheckRows = true;
+                        ai.mcae.Check_Object__c = false;
+                    }else {
+                        if(String.isNotBlank(prd[0].ProductURF__c)){
+                            ai.mcae.Check_Object__c = false;
+                        }else{
+                            ai.mcae.Check_Object__c = true;
+                        }
+                        ai.CheckRows = false;
+                    }
+                    //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+                    //add by mzy 2021-02-04 LJPH-BX9CVX start
+                    //ai.NoPartRiskDate = prd[0].NoPartRiskDate_F__c;
+                    //ai.proName2 = prd[0].Name;
+                    //ai.SignableFlag = prd[0].SignableFlag__c;
+                    //add by mzy 2021-02-04 LJPH-BX9CVX end
+                }
+                checkedAssets[i]=ai;
+            }
+        }
+        System.debug('--------kkkkkkk:' + checkedAssets);
+        // HWAG-BA73ZP
+        //contractStartDateChange();
+    }
+    
+    /**
+     * 閬告姙娓堛伩锛忔湭閬告姙瑁藉搧銇疆銇嶆彌銇�
+     */
+    public PageReference exchangeAsset() {
+        System.debug('exchangeAsset start');
+        Date systemToday = System.today();
+        List<AssetInfo> tmpChecked = new List<AssetInfo>();
+        List<AssetInfo> tmpNewRows = new List<AssetInfo>();
+        List<AssetInfo> tmpUnChecked = new List<AssetInfo>();
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        List<AssetInfo> tmpnewChecked = new List<AssetInfo>();
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+        List<Data> datatemp = new List<Data>();
+        datatemp = getChartData();
+        for (AssetInfo ass : this.checkedAssets) {
+            if (ass.isManual) {
+                tmpNewRows.add(ass);
+            } else if (ass.rec_checkBox_c) {
+                tmpChecked.add(ass);
+            } else {
+                ass.mcae = null;
+                tmpUnChecked.add(ass);
+                totalRecords++;
+            }
+        }
+        for (AssetInfo ass : this.unCheckedAssets) {
+            Boolean isNew = false;
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            boolean isCheck = true;
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+            Decimal listPrice = ass.rec.Maintenance_Price_Month__c;
+            if (ass.rec_checkBox_c) {
+                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'unCheckedAssets ' ));
+                // xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
+                //                if (systemToday.addMonths(-6) < ass.rec.InstallDate) {
+                //                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
+                //                Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
+                //                if (createdDate.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
+                //                    isNew = true;
+                //                    listPrice = ass.rec.Maintenance_Price_Month__c * isNewPriceAdj;
+                //                }
+                Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c(
+                    isNew__c = isNew,
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                    Check_Object__c = isCheck,
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+                    Estimate_List_Price__c = listPrice,
+                    EquipmentGuaranteeFlgTxt__c = ass.rec.EquipmentGuaranteeFlg__c
+                    );
+                ass.mcae = mcae;
+                // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
+                if (!getPageDisabled()) {
+                    // 鍙栧綋鍓嶆湀绗竴澶�
+                    Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
+                    mcae.LastMContract_Price__c = ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ? mcae.LastMContract_Price__c : ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
+                    if (ass.rec.CurrentContract_F__r.First_Estimate_Date__c != null && ass.rec.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
+                        mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c;
+                    } else {
+                        mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
+                    }
+                    if (String.isNotBlank(String.valueOf(mcae.Asset_Consumption_rate__c))) {
+                        for (Data da : datatemp) {
+                            if (String.isBlank(String.valueOf(da.rate_Lower)) &&  mcae.Asset_Consumption_rate__c < da.rate_Upper) {
+                                mcae.Adjustment_ratio_Lower__c = da.price_Lower;
+                                mcae.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
+                                mcae.Adjustment_ratio_Lower__c = da.price_Lower;
+                                mcae.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower
+                                       && mcae.Asset_Consumption_rate__c < da.rate_Upper) {
+                                mcae.Adjustment_ratio_Lower__c = da.price_Lower;
+                                mcae.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            }
+                        }
+                    }
+                }
+    
+    
+    
+                // tmpChecked.add(ass);
+                //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+                tmpnewChecked.add(ass);
+                //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+                totalRecords--;
+            } else {
+                ass.mcae = null;
+                tmpUnChecked.add(ass);
+            }
+        }
+    
+        this.checkedAssets = new List<AssetInfo>();
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        system.debug('tmpnewChecked======'+tmpnewChecked);
+        system.debug('tmpChecked======'+tmpChecked);
+        for (AssetInfo ass : tmpnewChecked) {
+            if(String.isNotBlank(ass.rec.Product2.ProductURF__c)){
+                ass.mcae.Check_Object__c = false;
+            }
+            tmpChecked.add(ass);
+        }
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+        for (AssetInfo ass : tmpChecked) {
+            ass.lineNo = this.checkedAssets.size();
+            this.checkedAssets.add(ass);
+        }
+        for (AssetInfo ass : tmpNewRows) {
+            ass.lineNo = this.checkedAssets.size();
+            this.checkedAssets.add(ass);
+        }
+        this.unCheckedAssets = new List<AssetInfo>();
+        this.unCheckedAssets.addAll(tmpUnChecked);
+    
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        this.setPageRecord();
+    
+        //listCut(unCheckedAssets);
+        // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+        //contractStartDateChange();
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        List<AssetInfo> topAsset =new List<AssetInfo>();
+        List<AssetInfo> otherAsset =new List<AssetInfo>();
+        system.debug('aaa'+this.checkedAssets);
+        for(AssetInfo ched : this.checkedAssets){
+            system.debug('ched.AssetModelNoc======'+ched.AssetModelNoc);
+            system.debug('ched.ProductModelNoc======'+ched.ProductModelNoc);
+            system.debug('ched.rec.OwnershipMachine_No__c======'+ched.rec.OwnershipMachine_No__c);
+            if(TopProductModel.contains(ched.ProductModelNoc)||TopProductModel.contains(ched.AssetModelNoc)||TopProductModel.contains(ched.rec.OwnershipMachine_No__c)||TopProductModel.contains(ched.MDMModelNoc)){
+                ched.CheckRows = true;
+                ched.mcae.Check_Object__c = false;
+                topAsset.add(ched);
+            }else{
+                otherAsset.add(ched);
+            }
+        }
+        topAsset.addAll(otherAsset);
+        List<AssetInfo> NumberSort =new List<AssetInfo>();
+        Integer i=0;
+        for (AssetInfo ched2 : topAsset) {
+            ched2.lineNo=i;
+            i++;
+            NumberSort.add(ched2);
+        }
+        this.checkedAssets=NumberSort;
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+        return null;
+    }
+    
+    // 鍚堝悓寮�濮嬫棩鍙樻洿锛岄噸鏂拌绠楁柊鍝�
+    // 鍚堝悓寮�濮嬫棩鍙樻洿锛屼笉璁$畻鏂板搧锛岃澶囦笂鐨勬柊鍝佸彧鐪嬫姤浠锋椂鐐圭殑鐘舵�� 娉ㄩ噴 BY GZW 20200325
+    // public PageReference contractStartDateChange() {
+    //     Date systemToday = System.today();
+    //     // 鍒涘缓鏃�
+    //     //Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
+    //     Date createdDate = systemToday;
+    //     // 鍒涘缓鏃�3涓湀
+    //     Date threeMonthAfter = createdDate.addMonths(keepPriceMonth);
+    //     // 鍒涘缓鏃�6涓湀
+    //     Date isNewAfter = createdDate.addMonths(-isNewAddMonth);
+    //     // 鍚堝悓寮�濮嬫棩
+    //     Date contractDate = estimate.Contract_Start_Date__c == null ? systemToday : estimate.Contract_Start_Date__c;
+    //     // 鍚堝悓寮�濮嬮瀹氭棩
+    //     Date contractEstiDate = estimate.Contract_Esti_Start_Date__c == null ? systemToday : estimate.Contract_Esti_Start_Date__c;
+    
+    //     /**********************HWAG-AYDCZX 2018/5/8 ADD START***************************/
+    //     // 鏂拌銆佸啀鎶ヤ环銆佽崏妗堜腑 缁翠慨鍚堝悓浠锋牸鏄剧ず
+    //     System.debug('********changedAfterPrint:'+ (changedAfterPrint ? 'true' : 'false'));
+    //     if (this.estimate.CreatedDate == null
+    //         || String.isBlank(ApexPages.currentPage().getParameters().get('copyid')) == false
+    //         || this.estimate.Process_Status__c == '鑽夋涓�'
+    //         || changedAfterPrint) {
+    //         for (AssetInfo info : checkedAssets) {System.debug('********contractDate changed:'+String.valueOf(contractDate));
+    
+    //             // 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�6涓湀锛岄兘涓嶇畻鏂板搧
+    //             if (contractEstiDate >= isNewAfter) {
+    //             //    if (!info.isManual) {
+    //             //        info.mcae.isNew__c = false;
+    //             //        info.mcae.Estimate_List_Price__c = info.orgPrice;
+    //             //    } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+    //             //        info.mcae.isNew__c = false;
+    //             //        info.mcae.Estimate_List_Price__c = info.orgPrice;
+    //             //    }
+    //             }
+    //             // 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�3涓湀锛屼娇鐢ㄥ悎鍚屽紑濮嬫棩璁$畻鏂板搧
+    //             // 浣跨敤鍒涘缓鏃ヨ绠楁柊鍝�
+    //             //
+    //             //
+    //             // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚� 20200218 Gzw 鏈嶅姟鍚堝悓瀵瑰簲
+    //             else {
+    //                 Date isNewDate = contractDate;
+    //                 // Date isNewDate = null;
+    //                 // if (contractDate >= threeMonthAfter) {
+    //                 //     isNewDate = contractDate;
+    //                 // } else {
+    //                 //     isNewDate = createdDate;
+    //                 // }
+    //                 if (!info.isManual) {
+    //                     info.mcae.isNew__c = false;
+    //                     info.mcae.Estimate_List_Price__c = info.orgPrice;
+    //                     // 110銇嬨倝銇牬鍚堛�丳ost銇傘倞銆両nstall銇仐
+    //                     if (info.rec.Posting_Date__c != null && info.rec.InstallDate == null) {
+    //                         if (isNewDate.addMonths(isNewAddMonth) < info.rec.Posting_Date__c) {
+    //                             info.mcae.isNew__c = true;
+    //                             info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+    //                         }
+    //                     }
+    //                     // Install銇傘倞
+    //                     else if (info.rec.Posting_Date__c != null && info.rec.InstallDate != null) {
+    //                         // Post銇嬨倝6鏈堢祵銇c仸銈侷nstall銇椼仸銇亜
+    //                         // if (info.rec.Posting_Date__c.addMonths(PosttoInstall) < info.rec.isNewDate_use__c) {
+    //                         //     // 鏂板搧閬╃敤銇椼仾銇�
+    //                         // }
+    //                         // else {
+    //                             if (isNewDate.addMonths(isNewAddMonth) < info.rec.isNewDate_use__c) {
+    //                                 info.mcae.isNew__c = true;
+    //                                 info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+    //                             }
+    //                         // }
+    //                     }
+    //                     // Post銇仐
+    //                     else if (info.rec.Posting_Date__c == null && info.rec.InstallDate != null) {
+    //                         if (isNewDate.addMonths(isNewAddMonth) < info.rec.isNewDate_use__c) {
+    //                             info.mcae.isNew__c = true;
+    //                             info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+    //                         }
+    //                     }
+    //                     else {
+    //                         // 鐗规畩鍑︾悊銇仐
+    //                     }
+    //                 } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+    //                     info.mcae.isNew__c = true;
+    //                     info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+    //                 }
+    //             }
+    //         }
+    //     }
+    //     return null;
+    // }
+    
+    /**
+     * 淇濆瓨銉°偨銉冦儔
+     */
+    public PageReference save() {
+        System.debug('save start');
+        //add by rentx 2020-11-13 LJPH-BV93RZ start
+        if (estimate.Contract_Range__c == null) {
+            this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+            return null;
+        }
+        //add by rentx 2020-11-13 LJPH-BV93RZ end
+    
+    
+        Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+        estimate.recordtypeid = vmMaintenance_Contract;
+        if (changedSubmitPrice) {
+            priceChangeReset();
+            return null;
+        }
+        if (syncEstimate(false, false)) {
+            ComputeLTYRepair();
+            //return null;
+            return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
+        }
+        return null;
+    }
+    
+    /**
+     * 鍗板埛銉°偨銉冦儔銆乨ecide鍓嶃伅淇濇湁瑷倷銆乨ecide寰屻伅鍚堝悓閰嶇疆
+     */
+    public void print() {
+        System.debug('print start');
+        this.printAsset = false;
+        this.printContract = false;
+        this.printTripartite = false;
+        this.printAgent = false;
+        this.estimate.PrintDate__c = Date.today();
+        //SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
+        if (this.estimate.Quote_Date__c == null) {
+            this.estimate.Quote_Date__c = Date.today();
+        }
+    
+    
+    
+        if (this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c) {
+            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '涓嶈兘鍚屾椂閫変腑涓夋柟鍗忚鍜屼唬鐞嗗晢鍚堝悓锛�'));
+        } else
+    
+    
+        // 淇濆瓨銉溿偪銉炽仹銇嶃仾銇勫牬鍚堛�佸嵃鍒枫儨銈裤兂銇儠銉┿偘銇伩淇濆瓨
+        if (this.getSaveBtnDisabled()) {
+            if (savePrintFlg()) {
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
+                /*if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
+                        // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+                        this.printContract = true;
+                   } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
+                        //鎵撳嵃涓夋柟鍚堝悓
+                        this.printTripartite = true;
+                   } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
+                        //鎵撳嵃缁忛攢鍟嗗悎鍚�
+                        this.printAgent = true;
+                   }else{
+                        // 鎵撳嵃淇濇湁瑷倷
+                        this.printAsset = true;
+                   }*/
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
+                // 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
+                if (this.estimate.Print_Tripartite__c ) {
+                    //鎵撳嵃涓夋柟鍚堝悓
+                    this.printTripartite = true;
+                } else if (!this.estimate.Estimation_Decision__c) {
+                    this.printAsset = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
+                    this.printContract = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
+                    this.printAgent = true;
+                }
+                // 2018/10/26 HWAG-B5C88S end
+            }
+        }
+        // 淇濆瓨銉溿偪銉炽仹銇嶃倠鍫村悎銆佸嵃鍒枫儨銈裤兂銇叏閮ㄤ繚瀛�
+        else {
+            if (syncEstimate(false, false)) {
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
+                /*
+                   if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
+                        // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+                        this.printContract = true;
+                   } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
+                        //鎵撳嵃涓夋柟鍚堝悓
+                        this.printTripartite = true;
+                   } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
+                        //鎵撳嵃缁忛攢鍟嗗悎鍚�
+                        this.printAgent = true;
+                   }else{
+                        // 鎵撳嵃淇濇湁瑷倷
+                        this.printAsset = true;
+                   }
+                 */
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
+                // 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
+                if (this.estimate.Print_Tripartite__c ) {
+                    //鎵撳嵃涓夋柟鍚堝悓
+                    this.printTripartite = true;
+                } else if (!this.estimate.Estimation_Decision__c) {
+                    this.printAsset = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
+                    this.printContract = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
+                    this.printAgent = true;
+                }
+                // 2018/10/26 HWAG-B5C88S end
+            }
+        }
+        //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '鍚堝悓'+this.printContract +'涓夋柟'+this.printTripartite+'淇濇湁'+this.printAsset+'缁忛攢鍟嗗悎鍚�'+this.printAgent));
+    }
+    
+    /**
+     * 鐢宠珛銉°偨銉冦儔銆佹渶寰屽繀銇氭壙瑾嶃儣銉偦銈广伀杓夈仜銈�
+     */
+    public PageReference approvalProcess() {
+    
+    
+        Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+        estimate.recordtypeid = vmMaintenance_Contract;
+    
+        // Date systemToday = System.today();
+        // // 鍒涘缓鏃�/鎻愪氦鏃�
+        // Date createdDate = systemToday;
+        // // 鍒涘缓鏃�6涓湀
+        // Date isNewAfter = createdDate.addMonths(-isNewAddMonth);
+        // // 鍚堝悓寮�濮嬮瀹氭棩
+        // Date contractEstiDate = estimate.Contract_Esti_Start_Date__c == null ? systemToday : estimate.Contract_Esti_Start_Date__c;
+        //  for (AssetInfo info : checkedAssets) {
+        //       // 鍚堝悓棰勫畾寮�濮嬫棩 澶т簬鎻愪氦鏃�6涓湀锛岄兘涓嶇畻鏂板搧 20200218 Gzw 鏈嶅姟鍚堝悓瀵瑰簲
+        //       //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'contractEstiDate '+ contractEstiDate +'isNewAfter '+isNewAfter));
+        //       if (contractEstiDate >= isNewAfter) {
+        //           if (!info.isManual) {
+        //               info.mcae.isNew__c = false;
+        //               info.mcae.Estimate_List_Price__c = info.orgPrice;
+        //            } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+        //               info.mcae.isNew__c = false;
+        //               info.mcae.Estimate_List_Price__c = info.orgPrice;
+        //            }
+        //        }
+        // }
+    
+        if (changedSubmitPrice) {
+            priceChangeReset();
+            return null;
+        }
+    
+    
+        if (syncEstimate(true, false)) {
+            Savepoint sp = Database.setSavepoint();
+            // 鎵胯獚銉椼儹銈汇偣銇級銇涖倠
+            try {
+    
+                // 宸插~鍐欑敵璇风姸鎬�
+                this.estimate.ApprovalProcess_Status__c = '宸插~鍐欏畬骞剁敵璇�';
+                ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+                // 鎵胯獚銉椼儹銈汇偣
+                Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+                psr.setObjectId(this.estimate.id);
+                Approval.ProcessResult submitResult = Approval.process(psr);
+                ComputeLTYRepair();
+                if (changedAfterPrint) {
+                    return new PageReference('/' + this.targetEstimateId);
+                    //return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+                } else {
+                    return new PageReference('/' + this.targetEstimateId);
+                    //return new PageReference('/' + this.targetEstimateId + '/e?completion=2');
+                }
+            } catch (Exception ex) {
+                System.debug('=====Exception:' + ex.getMessage());
+                Database.rollback(sp);
+                this.estimate.ApprovalProcess_Status__c = null;
+                ApexPages.addMessages(ex);
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * 姹哄畾鍙栨秷銉°偨銉冦儔
+     */
+    public PageReference undecide() {
+    
+    
+        System.debug('undecide start');
+        this.estimate.Estimation_Decision__c = false;
+        this.estimate.Print_Contract__c = false;
+    
+        //娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
+        this.estimate.Quotation_Determines_Time__c = null;
+    
+        try {
+            ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+            return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+        } catch (Exception ex) {
+            ApexPages.addMessages(ex);
+        }
+        return null;
+    }
+    
+    /**
+     * 姹哄畾銉°偨銉冦儔
+     */
+    public PageReference decide() {
+        System.debug('decide start');
+        inDicideFlag = true;
+        // TODO check decide 璧勬牸
+        Savepoint sp = Database.setSavepoint();
+        // gzw cputimeout 鎶ラ敊娣诲姞 20210729 start
+        Oly_TriggerHandler.bypass('AssetHandler');
+        StaticParameter.EscapeVMCTrigger = true;
+        // gzw cputimeout 鎶ラ敊娣诲姞 20210729 end
+        if (syncEstimate(false, true)) {
+            //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
+            this.estimate.Quotation_Determines_Time__c = date.today();
+    
+            if (changedAfterPrint) {
+                return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+            } else {
+                return new PageReference('/' + this.targetEstimateId + '/e?completion=3');
+            }
+        }
+    
+        return null;
+    }
+    
+    public PageReference decideCancle() {
+    
+        return new PageReference('/' + this.targetEstimateId + '/e?completion=4');
+    
+    }
+    
+    /**
+     * Process鐢ㄣ伄銉︺兗銈躲兗鎯呭牨銈掋偦銉冦儓銆佹柊瑕忚绌嶃倐銈婃檪鐢�
+     */
+    
+    private void setApprovalManager() {
+        User loginUser = [SELECT Id, Name, JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, TongkuoZongjian__c FROM User WHERE Id = :UserInfo.getUserId()];
+        // 瑕佹敞鎰� SaveMaintenanceByCopyController 銇� copy銇畊rl銇倐銆佷笅瑷樸伄闋呯洰銈傘偗銉偄
+        this.estimate.JingliApprovalManager__c = loginUser.JingliApprovalManager__c == null ? loginUser.Id : loginUser.JingliApprovalManager__c;
+        this.estimate.BuchangApprovalManager__c = loginUser.BuchangApprovalManager__c == null ? loginUser.Id : loginUser.BuchangApprovalManager__c;
+        this.estimate.ZongjianApprovalManager__c = loginUser.ZongjianApprovalManager__c == null ? loginUser.Id : loginUser.ZongjianApprovalManager__c;
+        this.estimate.Service_Contract_Staff__c = this.contract.Service_Contract_Staff__c;
+        this.estimate.TKZongjianApprovalManager__c = loginUser.TongkuoZongjian__c == null ? loginUser.Id : loginUser.TongkuoZongjian__c;
+    }
+    
+    /**
+     * 鍗板埛銉曘儵銈般伄銇裤倰淇濆瓨
+     */
+    @TestVisible
+    private Boolean savePrintFlg() {
+        try {
+            Maintenance_Contract_Estimate__c mce = new Maintenance_Contract_Estimate__c();
+            mce.Id = this.targetEstimateId;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
+            mce.Print_Simplify__c = this.estimate.Print_Simplify__c;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
+            mce.Print_ListPrice__c = this.estimate.Print_ListPrice__c;
+            mce.Print_RepairPrice__c = this.estimate.Print_RepairPrice__c;
+            mce.Print_SumPrice__c = this.estimate.Print_SumPrice__c;
+            mce.Print_DiscountPercentage__c = this.estimate.Print_DiscountPercentage__c;
+            mce.Print_DiscountPrice__c = this.estimate.Print_DiscountPrice__c;
+            mce.Print_MaintePrice__c = this.estimate.Print_MaintePrice__c;
+            mce.Print_Contract__c = this.estimate.Print_Contract__c;
+    
+            ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {mce});
+            return true;
+        } catch (Exception ex) {
+            ApexPages.addMessages(ex);
+        }
+        return false;
+    }
+    
+    /**
+     * 鐢婚潰銇у叆鍔涖儑銉笺偪check, save, 瑕仺鍚屾湡 銇儹銈搞儍銈�
+     */
+    // TODO xudan 銉併偋銉冦偗杩藉姞銆乧ls銇倐鍚堣▓閲戦銈掕▓绠椼�乧ls銇悎瑷堥噾椤嶃仺鐢婚潰銇嬨倝js銇悎瑷堥噾椤嶃倰姣旇純
+    // 鐣般仾銈嬪牬鍚堛�佷繚瀛樺畬浜嗐仐銇熴倝warning銈掑嚭銇�
+    public Boolean syncEstimate(boolean isApproval, boolean isDecide) {
+        System.debug('syncEstimate start');
+        Boolean hasDatabaseError = false;
+        Savepoint sp = Database.setSavepoint();
+    
+        //bug淇
+        //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
+        // this.estimate.Quotation_Determines_Time__c = date.today();
+    
+        try {
+            if (!checkValidate()) {
+                return false;
+            }
+            if (checkChangedAfterPrint()) {
+                if (isDecide) {
+                    // 銇俱仛 Approval
+                    isApproval = true;
+                    isDecide = false;
+                }
+            }
+            // 楠岃瘉 寮�濮嬫棩鏈燂紝鏈�鏃╁厑璁稿埗瀹氭棩涔嬪墠鍗婂勾
+            Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
+            createdDate = createdDate.addMonths(isNewAddMonth);
+            // if (estimate.Contract_Start_Date__c < createdDate) {
+            //     this.estimate.Contract_Start_Date__c.addError('鍚堝悓寮�濮嬫棩鏈�鏃╁厑璁歌拷婧埗瀹氭棩涔嬪墠鍗婂勾');
+            //     return false;
+            // }
+            // 楠岃瘉 鐢ㄦ埛绫诲瀷锛屽繀濉�
+            if (String.isBlank(estimate.EndUserType__c) ) {
+                this.estimate.EndUserType__c.addError('璇烽�夋嫨鐢ㄦ埛绫诲瀷锛�');
+                return false;
+            }
+            // 楠岃瘉 鐢宠鎶ヤ环閲戦锛岄渶瑕佸ぇ浜�0
+            if (estimate.Request_quotation_Amount__c <= 0 || estimate.Request_quotation_Amount__c == null) {
+                this.estimate.Request_quotation_Amount__c.addError('鐢宠鎶ヤ环閲戦蹇呴渶澶т簬0');
+                return false;
+            }
+            // fxk 鏀规姤閿欎綅缃� 2021銆�9銆�9 Star
+            if (estimate.Request_quotation_Amount__c > estimate.GuidePrice_Up__c || estimate.Request_quotation_Amount__c < estimate.GuidePrice_Down__c) {
+                if (!(this.estimate.mainTalksTime__c > 0)) {
+                    this.estimate.mainTalksTime__c.addError('涓昏璋堝垽娆℃暟蹇呭~');
+                    return false;
+                }
+    
+                if (this.estimate.talksStartDate__c == null) {
+                    this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
+                    return false;
+                }
+    
+                if (String.isBlank(this.estimate.Discount_reason__c)) {
+                    this.estimate.Discount_reason__c.addError('浠锋牸鐢宠鐞嗙敱蹇呭~');
+                    return false;
+                }
+                if (String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
+                    this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
+                    return false;
+                }
+            }
+            //fxk 鏀规姤閿欎綅缃� 2021/9/9 end
+            //>>>
+            if (isApproval || isDecide) {
+                Boolean hasError = false;
+                if (this.estimate.Maintenance_Price__c <= 0) {
+                    this.estimate.Maintenance_Price__c.addError('鍚堝悓浠锋牸蹇呴渶澶т簬0');
+                    hasError = true;
+                }
+                /*for (AssetInfo input : this.checkedAssets) {
+                        if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                                if (String.isBlank(input.mcae.Check_Result__c)) {
+                                        input.mcae.Check_Result__c.addError('鐐规缁撴灉蹇呭~');
+                                        hasError = true;
+                                }
+                        }
+                   }*/
+                // if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Discount_reason__c)) {
+                //     this.estimate.Discount_reason__c.addError('鍑忎环鐢宠鐞嗙敱蹇呭~');
+                //     hasError = true;
+                // }
+                // if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
+                //     this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
+                //     hasError = true;
+                // }
+                if (hasError) {
+                    return false;
+                }
+            }
+            System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉1锛� ' + '涓昏璋堝垽娆℃暟 ' + estimate.mainTalksTime__c + '璋堝垽鐨勫紑濮嬫椂闂� ' + estimate.talksStartDate__c + '浠锋牸鐢宠鐞嗙敱 ' + estimate.Discount_reason__c + '娑堣垂鐜囨敼鍠勬柟妗� ' + estimate.Improve_ConsumptionRate_Idea__c);
+            System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉2锛� ' + '鐢宠鎶ヤ环閲戦 ' + estimate.Request_quotation_Amount__c);
+            System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉3锛� ' + '鏈�浣庝环 ' + estimate.GuidePrice_Down__c + '鏈�楂樹环 ' + estimate.GuidePrice_Up__c);
+            if (isDecide && getDecideBtnDisabled()) {
+                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide'));
+                return false;
+            }
+    
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+            List<lastMContract> lastMContractRes;
+            if (isDecide) {
+                system.debug('鎵ц浜唗cm isDecide');
+                lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
+            } else{
+                system.debug('鎵ц浜唗cm NODecide');
+                lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
+            }
+            this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
+            this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
+            this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
+    
+            this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
+            this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
+            this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
+    
+            this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
+            this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
+            this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
+    
+            this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
+            this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
+            this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
+    
+            this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
+            this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
+            this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
+    
+    
+            // 鍘熸柟娉�
+            // List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets, this.estimate.Contract_Start_Date__c);
+            // // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'lastMContractRes +++++锛�' + lastMContractRes));
+            // // if (true) {
+            // //     return false;
+            // // }
+    
+            // this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
+            // this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
+            // this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
+    
+            // this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
+            // this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
+            // this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
+    
+            // this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
+            // this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
+            // this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
+    
+            // this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
+            // this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
+            // this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
+    
+            // this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
+            // this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
+            // this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+    
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+    
+    
+    
+            // 鍚屾湡鍑︾悊
+            // 鈶犵淮淇悎鍚屻伀鏃㈠瓨銇繚鏈夎澶囥倰鍓婇櫎
+            // 鈶′繚瀛樸仐銇熺淮淇悎鍚屾姤浠枫伄淇濇湁璁惧銈掔淮淇悎鍚屻伀銈炽償銉�(Asset__c銇岃ō瀹氥仌銇︺亜銈嬨儑銉笺偪銇犮亼)
+            // 鈶粬銇淮淇悎鍚屾姤浠枫伄鍚屾湡銉曘儵銈般倰澶栥仚
+            // 鈶g淮淇悎鍚屻伄 Estimate_Trial_Money__c銆丆ontract_Amount__c, Service_contract_target_number__c 銈掓洿鏂�
+            this.estimate.IsSyncing__c = true;
+            if (isDecide) {
+                // 20200923 Gzw bug 淇敼
+                //娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
+                this.estimate.Quotation_Determines_Time__c = Date.today();
+                this.estimate.Estimation_Decision__c = true;
+            }
+            // TODO validate
+    
+            // TODO validate check鏂板搧銉併偋銉冦偗锛堢磵鍝佹棩銇у垽鏂級
+    
+            // save
+            // 鈶� start
+            for (List<Maintenance_Contract_Estimate__c> otherEstimates : [select Id from Maintenance_Contract_Estimate__c where Id <> :this.estimate.Id
+                                                                          and Maintenance_Contract__c = :this.contract.Id
+                                                                                                        and IsSyncing__c = true]) {
+                for (Maintenance_Contract_Estimate__c other : otherEstimates) {
+                    other.IsSyncing__c = false;
+                    if (isDecide) {
+                        other.Estimation_Decision__c = false;
+                    }
+                }
+                ControllerUtil.updateMaintenance_Contract_Estimate(otherEstimates);
+            }
+    
+            // 鍚堝悓缁撴潫棰勫畾鏃ャ倰绠楀嚭
+            Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+            // 20151217 xudan 缁翠慨鍚堝悓鎶ヤ环SH-RS-JS0046560-01 鏈熼棿鏄剧ず闂
+            // 銇嗐倠銇嗗勾鐗规畩瀵惧繙
+            if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
+                && t.month() == 2) {
+                t = t;
+            } else {
+                t = t.addDays(-1);
+            }
+            this.estimate.Contract_Esti_End_Date__c = t;
+            // decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 start
+            if (!isDecide) {
+                this.estimate.New_Contract_Type_TxT__c = typeresult;
+            }
+            // decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 end
+            // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
+            if (this.estimate.Contract_Start_Date__c == null) {
+                this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+            }
+            t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+            t = t.addDays(-1);
+            this.estimate.Contract_End_Date__c = t;
+            //add      wangweipeng                   2021/12/26                     start
+            if(String.isNotBlank(this.estimate.Dealer__c)){
+                checkDealerId = this.estimate.Dealer__c;
+                onChDealerUpdate();
+            }else{
+                this.estimate.Is_RecognitionModel__c = false;
+            }
+            //add      wangweipeng                   2021/12/26                     end
+            System.debug('---------345----'+this.estimate.Dealer__c+'-------'+this.estimate.Dealer__r.FirstParagraphEnd__c);
+            // 浣嶇疆璋冩暣 鍦�1951 line
+            // Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
+            // 锛撱兌鏈堣秴閬庛仐銇︺亜銈嬪牬鍚堛伀銇�丏ecide銇с亶銇亜
+            //if (createdDate.addMonths(3) <= System.today()) {
+            //    this.estimate.addError('宸茶秴杩�3涓湀锛岃鍏堟洿鏂版姤浠枫��');
+            //    return false;
+            //}
+            // 缁翠慨鍚堝悓鎶ヤ环
+            // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'this.targetEstimateId ++++++ ' + this.targetEstimateId));
+            // if (true) {
+            //     return false;
+            // }
+            if (String.isBlank(this.targetEstimateId)) {
+                newIns = true;
+                this.estimate.Process_Status__c = '鑽夋涓�';
+                // name銇暘鍙枫倰銈汇儍銉�
+                List<Maintenance_Contract_Estimate__c> maxNameRecords = [select Name From Maintenance_Contract_Estimate__c Where Maintenance_Contract__c = :this.contract.Id order by Name desc limit 1];
+                String oppNo;
+                Integer l = 1;
+                if (maxNameRecords.size() > 0) {
+                    try {
+                        oppNo = maxNameRecords[0].Name;
+                        l = Integer.valueOf(oppNo.substring(oppNo.length() - 2)) + 1;
+                    } catch (System.TypeException e) {
+                        System.debug('maxNameRecords Error: Maintenance_Contract__c.id=' + maxNameRecords[0].id);
+                    }
+                } else {
+                    System.debug('first Maintenance_Contract_Estimate__c');
+                }
+                oppNo = '00' + String.valueof(l);
+                oppNo = oppNo.substring(oppNo.length() - 2);
+                this.estimate.Name = this.contract.Management_Code__c + '-' + oppNo;
+                setApprovalManager();
+                System.debug('Process_Status__c=' + this.estimate.Process_Status__c);
+                insert this.estimate;
+                this.targetEstimateId = this.estimate.Id;
+                setThisEstimate();
+            } else {
+                if (isApproval) {
+                    setApprovalManager();
+                }
+                ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+            }
+            // 缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
+            // delete and insert銇欍倠
+            List<Maintenance_Contract_Asset_Estimate__c> insertTarget = new List<Maintenance_Contract_Asset_Estimate__c>();
+            // 鏄惁浣跨敤棣栨鎶ヤ环鏃ユ洿鏂�
+            // 闇�瑕佹敞鎰忓鎶ヤ环鎻愪氦鏃�+3涓湀涓庡悎鍚岀粨鏉熸棩杩涜姣旇緝
+            // 1锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝灏忎簬鍚堝悓缁撴潫鏃ユ椂锛屼互鍚堝悓缁撴潫鏃ヤ綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
+            // 2锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝澶т簬鍚堝悓缁撴潫鏃ユ椂锛屾姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈熶綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
+            //
+            //
+            //  鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
+            Date toDate = Date.today();
+            Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
+            // list 淇敼 map
+            Map<id, Maintenance_Contract__c> mcList = new Map<id, Maintenance_Contract__c>();
+            for (AssetInfo input : this.checkedAssets) {
+                if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                    //Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c();
+                    input.mcae.Id = null;                       // insert銇仧銈�
+                    // 鍚屻仒銇牬鍚堣ō瀹氥仐銇亜
+                    if (input.mcae.Maintenance_Contract_Estimate__c != this.targetEstimateId) {
+                        // 瑕鏇淬仹銇嶃仾銇勫彲鑳芥�с亴銇傘倠銇熴倎銆佽ō瀹氥仚銈嬨仺銇嶃偍銉┿兗銇仾銈嬨亴銆併偍銉┿兗銇仾銈夈仾銇勩倛銇嗐伀浠栥伄銉偢銉冦偗銈掑伐澶仐銇︺亸銇犮仌銇勩��
+                        input.mcae.Maintenance_Contract_Estimate__c = this.targetEstimateId;
+                    }
+                    input.mcae.Maintenance_Price_Month__c = input.rec.Maintenance_Price_Month__c;
+                    // 鐥呴櫌銇墍灞炪仚銈嬩繚鏈夎ō鍌�
+    
+                    if (!input.isManual) {
+                        input.mcae.Asset__c = input.rec.Id;
+                        input.mcae.Product_Manual__c = null;
+                        input.mcae.Estimate_Cost__c = input.mcae.Estimate_Cost__c;
+                        input.mcae.LastMContract_Price__c = input.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
+                        //input.mcae.Asset_Consumption_rate__c = input.mcae.Asset_Consumption_rate__c;
+                    }
+                    // 鎻愪氦鏃讹紝鏇存柊 鏄惁浣跨敤涓婁竴鏈熺淮淇悎鍚岄娆℃姤浠锋棩
+                    if (isApproval) {
+                        Maintenance_Contract__c mctemp = new Maintenance_Contract__c();
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '+++++ ' + ass.rec.CurrentContract_F__r.Contract_End_Date__c + '   ' + mon1stDate));
+                        // 鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
+                        if (input.rec.CurrentContract_F__r.Contract_End_Date__c >= mon1stDate) {
+                            if (input.rec.CurrentContract_F__r.First_Estimate_Date__c == null) {
+                                mctemp.Id = input.rec.CurrentContract_F__c;
+                                mctemp.First_contract_usage_Rate__c = input.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
+                                mctemp.First_Estimate_Date__c = Date.today();
+                                mcList.put(mctemp.Id, mctemp);
+                                input.mcae.ifHaveleftInPrevious__c = true;
+                            }
+                        }
+                    }
+                    // Manual鍟嗗搧
+                    if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                        input.mcae.Asset__c = null;
+                        //mcae.Product_Manual__c = input.mcae.Product_Manual__c;
+                    }
+                    //鏂拌鏃讹紝淇濆瓨鏂板悎鍚屽鍝佷繚璇佹彁渚� Decide 鍚�
+                    if (!isDecide) {
+                        input.mcae.EquipmentGuaranteeFlgTxt__c = input.etGFlg;
+                    }
+                    // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+    
+                    // 2020/10/30 songxiaoqi start
+                    if (input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
+                        input.mcae.Last_MContract__c = input.rec.CurrentContract_F__c;
+    
+                    }
+                    //songxiaoqi end
+    
+    
+                    // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
+                    //mcae.Estimate_List_Price__c = input.mcae.Estimate_List_Price__c;
+                    //mcae.IsNew__c = input.mcae.isNew__c;
+                    //mcae.Check_Result__c = input.mcae.Check_Result__c;
+                    //mcae.Repair_Price__c = input.mcae.Repair_Price__c;
+                    //mcae.Comment__c = input.mcae.Comment__c;
+                    insertTarget.add(input.mcae);
+                }
+            }
+            // 鏈綋銇繚瀛樸仐銇熺磵鍏ユ鍣ㄣ亴銇傘倢銇板墛闄�
+            List<Maintenance_Contract_Asset_Estimate__c> selectedAsset = [SELECT Id, Name, Maintenance_Contract_Estimate__c, Asset__c, IsNew__c FROM Maintenance_Contract_Asset_Estimate__c WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId];
+            if (selectedAsset.size() > 0) {
+                ControllerUtil.deleteMaintenance_Contract_Asset_Estimate(selectedAsset);
+            }
+            if (insertTarget.size() > 0) {
+                ControllerUtil.insertMaintenance_Contract_Asset_Estimate(insertTarget);
+            }
+    
+            // 鈶� start
+            for (List<Maintenance_Contract_Asset__c> oldList : [select Id from Maintenance_Contract_Asset__c
+                                                                where Maintenance_Contract__c = :this.estimate.Maintenance_Contract__c]) {
+                delete oldList;
+            }
+            // 鈶� start
+            {
+                List<Maintenance_Contract_Asset__c> newValue = new List<Maintenance_Contract_Asset__c>();
+                for (Maintenance_Contract_Asset_Estimate__c target : [select Id, Asset__c, Estimate_List_Price__c, Estimate_Cost__c,
+                                                                      //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+                                                                      Check_Object__c,
+                                                                      //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+                                                                      IsNew__c, EquipmentGuaranteeFlgTxt__c,
+                                                                      // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+                                                                      Last_MContract__c
+                                                                      // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
+                                                                      , Last_MContract__r.RecordType_DeveloperName__c
+                                                                      // LJPH-C9GD34 gzw fix start
+                                                                      ,Estimate_List_Price_Page__c
+                                                                      // LJPH-C9GD34 gzw fix end
+                                                                      from Maintenance_Contract_Asset_Estimate__c
+                                                                      where Maintenance_Contract_Estimate__c = :this.estimate.Id and Asset__c <> null]) {
+    
+                    Maintenance_Contract_Asset__c newVal = new Maintenance_Contract_Asset__c(
+                        Maintenance_Contract__c = this.estimate.Maintenance_Contract__c,
+                        Asset__c = target.Asset__c,
+                        Maintenance_Contract_Asset_Estimate__c = target.Id,
+                        Estimate_List_Price__c = target.Estimate_List_Price__c,
+                        //Maintenance_Price_YearTXT__c = target.Maintenance_Price_YearTXT__c,
+                        Estimate_IsNew__c = target.IsNew__c,
+                        //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+                        Check_Object__c = target.Check_Object__c,
+                        //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+                        //EquipmentGuaranteeFlgTxt__c = target.EquipmentGuaranteeFlgTxt__c,
+                        // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+                        // LastMContract__c = target.Last_MContract__c
+                        // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
+                        //濡傛灉鏄骞翠繚淇悎鍚�,涓嶆洿鏂颁笂鏈熺淮淇悎鍚屼俊鎭� LJPH-BUU3E3 update by rentx  2020-11-03
+                        LastMContract__c = target.Last_MContract__r.RecordType_DeveloperName__c == 'VM_Contract' ? null : target.Last_MContract__c
+                        );
+                    newValue.add(newVal);
+                }
+                if (newValue.size() > 0) insert newValue;
+            }
+            // 鈶� start
+            this.contract.Estimation_Id__c = this.targetEstimateId;     
+            this.contract.Contract_Esti_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+            this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
+            this.contract.Contract_Esti_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
+            this.contract.Estimate_Target__c = this.estimate.Estimate_Target__c;
+            this.contract.Dealer__c = this.estimate.Dealer__c;
+            this.contract.old_Is_RecognitionModel__c = this.estimate.Is_RecognitionModel__c;
+            this.contract.NotUse_Oxygenated_Water__c = this.estimate.NotUse_Oxygenated_Water__c;
+            this.contract.Estimate_Trial_Money__c = this.estimate.Estimate_Trial_Money__c;
+            this.contract.Contract_Amount__c = this.estimate.Maintenance_Price__c;
+            // 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 start
+            // this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
+            // 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 end
+            this.contract.Contract_department_manual__c = this.estimate.Department__c;
+    
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
+            this.contract.LastMContract1__c = this.estimate.LastMContract1__c;
+            this.contract.LastMContract1_NO__c = this.estimate.LastMContract1_NO__c;
+            this.contract.LastMContract1_ConCount__c =  this.estimate.LastMContract1_ConCount__c;
+    
+            //add by rentx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂锛岀粰鍘诲勾鍚堝悓璧嬪�� start
+            this.contract.Last_year_service_contract__c = this.estimate.LastMContract1__c;
+            //add by renrx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂, 缁欏幓骞村悎鍚岃祴鍊� end
+    
+            this.contract.LastMContract2__c =  this.estimate.LastMContract2__c;
+            this.contract.LastMContract2_NO__c = this.estimate.LastMContract2_NO__c;
+            this.contract.LastMContract2_ConCount__c =  this.estimate.LastMContract2_ConCount__c;
+    
+            this.contract.LastMContract3__c =  this.estimate.LastMContract3__c;
+            this.contract.LastMContract3_NO__c = this.estimate.LastMContract3_NO__c;
+            this.contract.LastMContract3_ConCount__c =  this.estimate.LastMContract3_ConCount__c;
+    
+            this.contract.LastMContract4__c =  this.estimate.LastMContract4__c;
+            this.contract.LastMContract4_NO__c = this.estimate.LastMContract4_NO__c;
+            this.contract.LastMContract4_ConCount__c =  this.estimate.LastMContract4_ConCount__c;
+    
+            this.contract.LastMContract5__c =  this.estimate.LastMContract5__c;
+            this.contract.LastMContract5_NO__c = this.estimate.LastMContract5_NO__c;
+            this.contract.LastMContract5_ConCount__c =  this.estimate.LastMContract5_ConCount__c;
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+    
+            system.debug('娴嬬畻isDecide鐨勭粨鏋淿1::::::::' + isDecide);
+            if (isDecide == true) {
+                system.debug('娴嬬畻isDecide鐨勭粨鏋淿2::::::::' + isDecide);
+                //              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+                this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
+                this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
+                //              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
+                this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
+                this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
+                this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
+                this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
+                this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
+                this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
+                // JZHG-BQV3P4 20200624 Gzw add
+                this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
+                // JZHG-BQV3P4 20200624 Gzw add
+            }
+            //娣诲姞鐨勯澶栧搴旇繃绋�
+            if (inDicideFlag == true && (this.contract.Contract_Start_Date__c == null || this.contract.Contract_End_Date__c == null)) {
+                system.debug('娴嬬畻inDicideFlag鐨勭粨鏋淿2::::::::' + isDecide);
+                //              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+                this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
+                this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
+                //              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
+                this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
+                this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
+                this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
+                this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
+                this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
+                this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
+                // JZHG-BQV3P4 20200624 Gzw add
+                this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
+                // JZHG-BQV3P4 20200624 Gzw add
+            }
+            String oldProcessStatus = this.estimate.Process_Status__c;
+            try {
+                if (mcList.size() > 0) {
+                    ControllerUtil.updMcList(mcList.values());
+                }
+                ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+                update this.contract;
+            } catch (Exception e) {
+                // TODO 浠婂緦瑜囨暟浠躲伄鍫村悎銇┿亞銇欍倠锛�
+                this.estimate.addError(e);
+                // 涓�閮ㄣ伄鍊ゃ倰鎴汇仚
+                this.estimate.Process_Status__c = oldProcessStatus;
+                hasDatabaseError = true;
+                Database.rollback(sp);
+                ApexPages.addMessages(e);
+            }
+            if (hasDatabaseError) {
+                System.debug('syncEstimate hasDatabaseError');
+                return false;
+            }
+            if (isApproval) {
+                SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
+            }
+            return true;
+        } catch (DMLException ex) {
+            // TODO Insert澶辨晽銇甀D銈掓秷銇欏繀瑕侊紵
+            Database.rollback(sp);
+            ApexPages.addMessages(ex);
+        } catch (Exception ex) {
+            Database.rollback(sp);
+            ApexPages.addMessages(ex);
+        }
+        return false;
+    }
+    
+    /**
+     * 鍗板埛寰屽鏇淬亴銇傘倠鍫村悎銆乼rue
+     */
+    @TestVisible
+    private Boolean checkChangedAfterPrint() {
+        System.debug('checkChangedAfterPrint start');
+        if (changedAfterPrint) {
+            this.targetEstimateId = null;
+            this.estimate = this.estimate.clone();
+            this.estimate.IS_Clone_After_Decide__c = true;
+            this.estimate.PrintDate__c = null;
+            this.estimate.Quote_Date__c = null;
+            this.estimate.Print_Contract__c = false;
+            this.estimate.Print_RepairPrice__c = false;
+            this.estimate.Print_DiscountPercentage__c = false;
+            this.estimate.Print_DiscountPrice__c = false;
+            this.estimate.Print_ListPrice__c = false;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
+            this.estimate.Print_Simplify__c = false;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
+            this.estimate.Print_MaintePrice__c = false;
+            this.estimate.Print_SumPrice__c = false;
+            this.estimate.NotUse_Oxygenated_Water__c = false;
+            this.estimate.Contract_Esti_Start_Date__c = this.estimate.Contract_Start_Date__c;
+            //this.estimate.Process_Status__c = '鑽夋涓�';
+        }
+        return changedAfterPrint;
+    }
+    /**
+     * 琛岃拷鍔�(10琛屻仛銇�)銆佸墠鎻愬繀銇氭渶寰�
+     */
+    
+    public PageReference addNewRows() {
+        for (Integer i = 0; i < 10; i++) {
+            checkedAssets.add(new AssetInfo(checkedAssets.size()));
+        }
+        // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '淇濇湁璁惧' + checkedAssets.size()));
+        return null;
+    }
+    
+    
+    
+    /** 淇濆瓨杩斿洖 **/
+    public PageReference saveAndCancel () {
+        //add by rentx 2020-11-13 LJPH-BV93RZ start
+        if (estimate.Contract_Range__c == null) {
+            this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+            return null;
+        }
+        //add by rentx 2020-11-13 LJPH-BV93RZ end
+        if (syncEstimate(false, false)) {
+            PageReference ret = null;
+            if (this.targetMaintenanceContractId != null) {
+                ret = new PageReference('/' + this.targetMaintenanceContractId);
+            }
+            return ret;
+        }
+        return null;
+    }
+    
+    /**
+     * 銈儯銉炽偦銉儭銈姐儍銉�
+     */
+    public PageReference cancel() {
+        PageReference ret = null;
+        if (this.targetMaintenanceContractId != null) {
+            ret = new PageReference('/' + this.targetMaintenanceContractId);
+        }
+        return ret;
+    }
+    
+    //add     wangweipeng                     2021/12/26                 start
+    //鑾峰彇褰撳墠閫変腑鐨勭粡閿�鍟嗘槸鍚︿负鍏堟鏍囪瘑
+    public PageReference onChDealerUpdate(){
+        //checkDealerId  姝ゅ彉閲忓彲鑳戒細瀛� 缁忛攢鍟唅d鎴栫粡閿�鍟嗕腑鏂囧悕
+        if(String.isNotBlank(checkDealerId)){
+            try {
+                List<Account> accListC = [select id,name,FirstParagraphEnd__c from Account where id = :checkDealerId OR name = :checkDealerId];
+                if(accListC != null && accListC.size() == 1){
+                    if(accListC[0].FirstParagraphEnd__c){
+                        this.estimate.Is_RecognitionModel__c = true;
+                    }else{
+                        this.estimate.Is_RecognitionModel__c = false;
+                    }
+                }else{
+                    this.estimate.Is_RecognitionModel__c = false;
+                }
+            } catch (Exception e) {
+                //return 'McaeList Update Failed : '+e;
+            }
+        }else{
+            this.estimate.Is_RecognitionModel__c = false;
+        }
+        System.debug('----------------23--'+this.estimate.Is_RecognitionModel__c);
+        return null;
+    }
+    //add     wangweipeng                     2021/12/26                 end
+    
+    
+    // 2021-02-07  gzw add  LJPH-BWY5QB start
+    private void setEndUserType(String id) {
+        this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
+                         Estimate_Num__c, Management_Code__c, Hospital__c,
+                         Hospital__r.MaintenanceContractUserType__c,
+                         Contract_Start_Date__c, Contract_End_Date__c
+                         FROM Maintenance_Contract__c WHERE Id = :id];
+        if (this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)) {
+    
+            this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
+        }
+    }
+    // 2021-02-07  gzw add  LJPH-BWY5QB end
+    
+    private void setContractInfo(String id) {
+        this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
+                         Estimate_Num__c, Management_Code__c, Hospital__c,
+                         //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+                         // Hospital__r.MaintenanceContractUserType__c,
+                         //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+                         Contract_Start_Date__c, Contract_End_Date__c
+                         FROM Maintenance_Contract__c WHERE Id = :id];
+        this.targetHospitalId = this.contract.Hospital__c;
+        // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+        // if(this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)){
+    
+        //    this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
+        // }
+        // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+    }
+    
+    private Boolean checkValidate() {
+        Boolean rtn = true;
+        Date today = Date.today();
+        if (getPageDisabled()) {
+            today = estimate.Submit_quotation_day__c;
+        }
+        // 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 start
+        //鍚堝悓鏈堟暟
+        Decimal ContractRange = this.estimate.Contract_Range__c;
+        //鍚堝悓棰勫畾缁撴潫鏃ユ湡
+        Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+        if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
+            && t.month() == 2) {
+            t = t;
+        } else {
+            t = t.addDays(-1);
+        }
+        this.estimate.Contract_Esti_End_Date__c  = t;
+        // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
+        if (this.estimate.Contract_Start_Date__c == null) {
+            this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+        }
+        t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+        t = t.addDays(-1);
+        this.estimate.Contract_End_Date__c = t;
+        Date ContractEndDate = this.estimate.Contract_End_Date__c;
+        System.debug('鍚堝悓缁撴潫鏃ユ湡 :' + ContractEndDate);
+        // 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 end
+        // 閮ㄥ搧渚涚郸鍋滄銇=鍝併伅銈ㄣ儵銉�
+        for (AssetInfo input : this.checkedAssets) {
+            //濡傛灉鏄墜鍔ㄤ骇鍝�
+            // 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� start
+            if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                // if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                // 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� end
+                if (input.mcae.Estimate_List_Price__c == null || input.mcae.Estimate_List_Price__c == 0) {
+                    //update by rentx 2020-11-12 LJPH-BV93RZ start
+                    // input.mcae.Product_Manual__c.addError(System.Label.Error_Message47);
+                    //add by rentx 2021-01-25 start
+                    //濡傛灉淇濇湁璁惧涓嶄负绌虹殑璇濆湪淇濇湁璁惧涓婃姤閿�
+                    if (input.rec != null) {
+                        input.rec.Name.addError(input.rec.Name + ' (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') 鏃犲悎鍚岄噾棰�,涓嶅缓璁弬淇�');
+    
+                    } else
+                    //add by rentx 2021-01-25 end
+                    if (String.isNotBlank(input.proName)) {
+                        input.mcae.Product_Manual__c.addError(System.Label.Error_Message47 + '(' + input.proName + ')');
+                    }
+                    //update by rentx 2020-11-12 LJPH-BV93RZ end
+                    rtn = false;
+                }
+            }
+            if (!input.isManual) {
+                //update by rentx 2020-11-13 start
+                if (!Test.isRunningTest() && (input.mcae.Adjustment_Upper_price__c == null || input.mcae.Adjustment_Upper_price__c == 0) ) {
+                    // input.mcae.Adjustment_Upper_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    input.mcae.Adjustment_Upper_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    rtn = false;
+                }
+                if (!Test.isRunningTest() && (input.mcae.Adjustment_Lower_price__c == null || input.mcae.Adjustment_Lower_price__c == 0) ) {
+                    input.mcae.Adjustment_Lower_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    // input.mcae.Adjustment_Lower_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    rtn = false;
+                }
+                //update by rentx 2020-11-13 end
+    
+                //1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+                //2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+                //3.绠$悊鍛樿烦杩囷紝
+                if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
+    
+                    Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F__r.Contract_End_Date__c);
+                    Decimal monthCon = (Decimal)noOfDays / 365 * 12;
+                    // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+                    if (input.rec.CurrentContract_F__r.Contract_Range__c >= 12 && monthCon > 6) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
+                        rtn = false;
+                    }
+                    //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + monthCon  + ' +++ ' + Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c/2)));
+                    //rtn = false;
+                    if (input.rec.CurrentContract_F__r.Contract_Range__c < 12 && monthCon > Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c / 2)) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 缁忓巻鏈堟暟杩囧崐鏂瑰彲鍒朵綔鎶ヤ环');
+                        rtn = false;
+                    }
+                }
+                // 澶氬勾淇濆垽鏂�
+                if ( String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
+                    //if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
+    
+                    //Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
+                    //Decimal monthCon = (Decimal)noOfDays/365*12;
+                    // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+                    if (input.rec.CurrentContract_F__r.Gurantee_Estimate_startDate__c > Date.today()) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
+                        rtn = false;
+                    }
+                }
+                //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
+                if (inDicideFlag && String.isNotBlank(input.rec.CurrentContract_F__c) && estimate.Skip_DJ__c == false ) {
+                    //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '+++' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
+                    // 鍚堝悓寮�濮嬫棩澶т簬涓婃湡鍚堝悓缁撴潫鏃ュ姞涓�涓湀锛屼笖娌℃湁鐐规鏃ユ湡鎴栬�呮渶杩戜竴娆$偣妫�鏃ユ湡鏄�3涓湀鍓�  鎶ラ敊
+                    if (estimate.Contract_Start_Date__c > input.rec.CurrentContract_F__r.Contract_End_Date__c.addMonths(1)
+                        && (input.rec.Final_Examination_Date__c == null
+                            || input.rec.Final_Examination_Date__c < estimate.Contract_Start_Date__c.addMonths(-3))) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁鏈�鏂扮殑鐐规璁板綍');
+                        rtn = false;
+                    }
+                }
+    
+                if (isSaveOrApproval) {
+                    if (input.rec.IF_Warranty__c == '鍚�') {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 涓嶈兘閫夋嫨涓嶅彲鍙備繚璁惧');
+                        rtn = false;
+                    }
+                }
+                // 20200805 Gzw Bug淇
+                // isSaveOrApproval = false;
+            }
+    
+            // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
+            if (input != null) {
+    
+                //鏍¢獙鏃犻浂浠堕闄�
+                if ( input.rec != null && input.rec.NoPartRiskDate_F__c != null ) {
+                    // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
+                    String msg = checkAssetInfo(input.rec.NoPartRiskDate_F__c, input.rec.SignableFlag__c, ContractEndDate, ContractRange);
+                    // 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
+                    if (msg != '') {
+                        input.rec.Name.addError('[' + input.rec.Name + '] (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') ' + msg);
+                        rtn = false;
+                    }
+    
+                }
+                /*else if(input.mcae!=null&&input.mcae.Product_Manual__c !=null&&input.NoPartRiskDate!=null ){
+                        // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
+                        String msg = checkAssetInfo(input.NoPartRiskDate,input.SignableFlag,ContractEstiEndDate,ContractRange);
+                        // 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
+                        if(msg != ''){
+                           input.mcae.Product_Manual__c.addError('['+input.proName2+'] '+msg);
+                           rtn = false;
+                        }
+                   }*/
+            }
+            // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
+    
+        }
+        return rtn;
+    }
+    // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
+    //鏍¢獙鏃犻浂浠堕闄╂棩鏈�
+    public static String checkAssetInfo(Date NoPartRiskDate, Boolean SignableFlag, Date ContractEndDate, Decimal ContractRange) {
+        String rtnStr = '';
+        //1.鍒ゆ柇
+        //鍚堝悓缁撴潫鏃ユ湡 > 鏃犻浂浠堕闄╂棩鏈�
+        if (ContractEndDate > NoPartRiskDate) {
+            //鍙绾︽爣璇� 鏈嬀閫�
+            if (SignableFlag == false) {
+                //鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�
+                rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�';
+            } else {
+                //鍕鹃��
+                //鍙互绛�1骞村悎鍚�
+                if (ContractRange > 12) {
+                    rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂锛屽瓨鍦ㄩ浂浠跺仠姝緵搴旈闄╋紝寤鸿绛句竴骞存湡鍚堝悓銆�';
+                }
+            }
+        }
+    
+        return rtnStr;
+    }
+    // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
+    // 浠锋牸鍙樻洿鍚庡厠闅嗘姤浠峰墠閲嶆柊璁$畻浠锋牸
+    @TestVisible
+    private void priceChangeReset() {
+        // 鍙栧緱master涓渶鏂颁环鏍�
+        List<Id> assIds = new List<Id>();
+        List<Id> pdIds = new List<Id>();
+        for (AssetInfo input : this.checkedAssets) {
+            if (!input.isManual) {
+                assIds.add(input.rec.Id);
+            }
+            if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                pdIds.add(input.mcae.Product_Manual__c);
+            }
+        }
+        Map<Id, Asset> assMap = new Map<Id, Asset>();
+        Map<Id, Product2> pdMap = new Map<Id, Product2>();
+        if (assIds.size() > 0) {
+            assMap = new Map<Id, Asset>([select id, Maintenance_Price_Month__c from Asset where Id In: assIds]);
+        }
+        if (pdIds.size() > 0) {
+            pdMap = new Map<Id, Product2>([select id, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c from Product2 where Id In: pdIds]);
+        }
+        if (assMap.size() > 0 || pdMap.size() > 0) {
+            for (AssetInfo info : this.checkedAssets) {
+                if (!info.isManual) {
+                    info.orgPrice = assMap.get(info.rec.Id).Maintenance_Price_Month__c;
+                }
+                if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+                    info.orgPrice = pdMap.get(info.mcae.Product_Manual__c).Maintenance_Price_Month__c;
+                }
+            }
+        }
+        //contractStartDateChange();
+    }
+    
+    
+    public class AssetInfo {
+    // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 褰撳墠鏍囪
+    public Boolean etGFlg {get; set;}
+    public Transient Integer lineNo {get; private set;}
+    public Boolean rec_checkBox_c {get; set;}
+    public Asset rec { get; set; }
+    public Maintenance_Contract_Asset_Estimate__c mcae { get; set; }
+    public Boolean isManual { get; set; }
+    public Transient Decimal orgPrice {get; private set;}
+    public Transient Decimal orgPrice12 {get; private set;}
+    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+    public Boolean CheckRows {get; private set;}
+    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+    
+    //add by rentx 2020-11-12 LJPH-BV93RZ start
+    public Transient String proName;
+    public Transient String proSerialNumber;
+    public Transient String proSerialName;
+    //add by rentx 2020-11-12 LJPH-BV93RZ end
+    //add by mzy 2020-11-12 LJPH-BX9CVX start
+    //public Date NoPartRiskDate;
+    //public String proName2;
+    //public Boolean SignableFlag;
+    //add by mzy 2020-11-12 LJPH-BX9CVX start
+    
+    //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+    public String ProductModelNoc;
+    public String AssetModelNoc;
+    public String MDMModelNoc;
+    //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    
+    public Id getRecId() {
+        Id rtn = null;
+        if (rec != null) {
+            rtn = rec.Id;
+        }
+        return rtn;
+    }
+    public void setRecId(Id value) {
+        // 銇伀銈傘仐銇亜
+    }
+    
+    // Manual灏傜敤
+    public AssetInfo(Integer lineNo) {
+        this.lineNo = lineNo;
+        this.rec = null;
+        this.mcae = new Maintenance_Contract_Asset_Estimate__c(
+            isNew__c = true,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            Check_Object__c = true
+                              // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+            );
+        this.isManual = true;
+        this.rec_checkBox_c = false;
+        this.orgPrice = 0;
+        this.orgPrice12 = 0;
+        this.etGFlg = false;
+        // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+        this.CheckRows = true;
+        // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+    }
+    // 閬告姙銇曘倢銇熺敤锛堥潪Manual锛�
+    public AssetInfo(Integer lineNo, Asset record, Boolean isNew, Decimal listPrice, Maintenance_Contract_Asset_Estimate__c mcae) {
+        this.lineNo = lineNo;
+        this.rec = record;
+        this.mcae = new Maintenance_Contract_Asset_Estimate__c(
+            //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
+            isNew__c = isNew,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            Check_Object__c = mcae.Check_Object__c,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+            Estimate_List_Price__c = listPrice,
+            //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
+            Check_Result__c = mcae.Check_Result__c,
+            Repair_Price__c = mcae.Repair_Price__c,
+            Comment__c = mcae.Comment__c,
+            EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
+            Estimate_Cost__c = mcae.Estimate_Cost__c,
+            Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
+            Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
+            Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
+            LastMContract_Price__c = mcae.LastMContract_Price__c,
+            Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
+            Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c
+            // LJPH-C9GD34 gzw fix start
+            ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
+            // LJPH-C9GD34 gzw fix end
+            );
+        this.isManual = false;
+        this.rec_checkBox_c = true;
+        this.orgPrice = record.Maintenance_Price_Month__c;
+        this.orgPrice12 = this.orgPrice * 12;
+        this.etGFlg = record.EquipmentGuaranteeFlg__c;
+        //add by rentx 2020-11-12 LJPH-BV93RZ start
+        this.proName = '鏈鸿韩缂栫爜涓�:' + record.SerialNumber;
+        this.proSerialNumber = record.SerialNumber;
+        this.proSerialName = record.Name;
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        this.ProductModelNoc = mcae.Product_Manual__r.Asset_Model_No__c;
+        this.AssetModelNoc = mcae.Asset__r.OwnershipMachine_No__c;
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    
+        //add by rentx 2020-11-12 LJPH-BV93RZ end
+        //add by mzy 2021-02-07 start
+        //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
+        //this.proName2 = mcae.Product_Manual__r.Name;
+        //this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
+        //add by mzy 2021-02-07 end
+    }
+    // 閬告姙銇曘倢銇熺敤銆佹湭绱嶅搧鐢紙Manual锛�
+    public AssetInfo(Integer lineNo, Maintenance_Contract_Asset_Estimate__c mcae) {
+        this.lineNo = lineNo;
+        this.rec = null;
+        this.mcae = new Maintenance_Contract_Asset_Estimate__c(
+            //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
+            isNew__c = mcae.IsNew__c,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            Check_Object__c = mcae.Check_Object__c,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+            Product_Manual__c = mcae.Product_Manual__c,
+            Estimate_List_Price__c = mcae.Estimate_List_Price__c,
+            //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
+            Check_Result__c = mcae.Check_Result__c,
+            Repair_Price__c = mcae.Repair_Price__c,
+            Comment__c = mcae.Comment__c,
+            EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
+            Estimate_Cost__c = mcae.Estimate_Cost__c,
+            Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
+            Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
+            Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
+            LastMContract_Price__c = mcae.LastMContract_Price__c,
+            Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
+            Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c,
+            Contract_Esti_Start_Date__c = mcae.Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c
+                                          // Contract_Esti_Start_Date__c=mcae.Contract_Esti_Start_Date__c
+            // LJPH-C9GD34 gzw fix start
+            ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
+            // LJPH-C9GD34 gzw fix end
+            );
+        this.isManual = true;
+        this.rec_checkBox_c = false;
+        this.orgPrice = mcae.Product_Manual__r.Maintenance_Price_Month__c;
+        this.orgPrice12 = this.orgPrice * 12;
+        this.etGFlg = mcae.Product_Manual__r.EquipmentGuaranteeFlg__c;
+        //add by mzy 2021-02-07 start
+        //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
+        //this.proName2 = mcae.Product_Manual__r.Name;
+        //this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
+        //add by mzy 2021-02-07 end
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        this.ProductModelNoc = mcae.Product_Manual__r.Asset_Model_No__c;
+        this.AssetModelNoc = mcae.Asset__r.OwnershipMachine_No__c;
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    }
+    // 閬告姙銇曘倢銇亱銇c仧鐢�
+    public AssetInfo(Integer lineNo, Asset record) {
+        this.lineNo = lineNo;
+        this.rec = record;
+        this.isManual = false;
+        this.rec_checkBox_c = false;
+        this.orgPrice = record.Maintenance_Price_Month__c;
+        this.orgPrice12 = this.orgPrice * 12;
+        this.etGFlg = record.EquipmentGuaranteeFlg__c;
+        this.proSerialName = record.Name;
+        this.proSerialNumber = record.SerialNumber;
+    }
+    }
+    
+    WebService static String pageDecide(String strId) {
+        String rs = '';
+        SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
+        saec.targetEstimateId = strId;
+        saec.isPageAction = true;
+        saec.init();
+        if (saec.getDecideBtnDisabled()) {
+            rs = '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide';
+            return rs;
+        }
+        if (saec.syncEstimate(false, true)) {
+            rs = '0';
+        } else {
+            rs = 'Decide澶辫触';
+        }
+        return rs;
+    }
+    
+    WebService static String pageUndecide(String strId) {
+        String rs = '';
+        SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
+        saec.targetEstimateId = strId;
+        saec.isPageAction = true;
+        saec.init();
+        if (saec.getUnDecideBtnDisabled()) {
+            rs = '涓嶆槸Decide杩囩殑鎶ヤ环锛屼笉鑳経ndecide';
+            return rs;
+        }
+        if (saec.undecide() != null) {
+            rs = '0';
+        } else {
+            rs = 'Undecide澶辫触';
+        }
+        return rs;
+    }
+    
+    
+    public static List<lastMContract> getlastMContract(List<AssetInfo> checkedAssets, Date startDate) {
+        Map<String, lastMContract> lastMContractMap = new Map<String, lastMContract>();
+        Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
+        for (AssetInfo ai : checkedAssets) {
+            lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Management_Code__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
+    
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+            // 璁$畻绌虹櫧鏈�
+            if (startDate != null && lM.endDate != null) {
+                if (startDate.daysbetween(lM.endDate) > -366 && startDate.daysbetween(lM.endDate) < 366) {
+                    lm.ayearcontract = true;
+                } else {
+                    lm.ayearcontract = false;
+                }
+            } else {
+                lm.ayearcontract = false;
+            }
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+    
+            // if (String.isNotBlank(ai.rec.CurrentContract_F__c) ) {
+            //鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 start
+            if (String.isNotBlank(ai.rec.CurrentContract_F__c) && ai.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
+    
+                // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+                if (lm.ayearcontract) {
+                    // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+    
+                    //鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 end
+                    // 绌虹櫧鏈�
+                    if (lastMContractMap.containsKey(ai.rec.CurrentContract_F__c)) {
+                        lastMContractMap.get(ai.rec.CurrentContract_F__c).count++;
+                    } else {
+                        lastMContractMap.put(ai.rec.CurrentContract_F__c, lM);
+                    }
+                    // 闈炵┖鐧芥湡
+                } else {
+                    if (lastMContractMap1.containsKey(ai.rec.CurrentContract_F__c)) {
+                        lastMContractMap1.get(ai.rec.CurrentContract_F__c).count++;
+                    } else {
+                        lastMContractMap1.put(ai.rec.CurrentContract_F__c, lM);
+                    }
+                }
+            }
+        }
+    
+        List<lastMContract> listResulttemp = new List<lastMContract>();
+        List<lastMContract> listResult = new List<lastMContract>();
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        List<lastMContract> listResulttemp1 = new List<lastMContract>();
+        List<lastMContract> listResult1 = new List<lastMContract>();
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+        // 绌虹櫧鏈�
+        for ( lastMContract ll : lastMContractMap.values()) {
+            listResulttemp.add(ll);
+        }
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        // 闈炵┖鐧芥湡
+        for ( lastMContract ll : lastMContractMap1.values()) {
+            listResulttemp1.add(ll);
+        }
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+        //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'listResult +++++锛�' + listResult));
+    
+        // 绌虹櫧鏈�
+        listResulttemp.sort();
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start  锛堜慨鏀逛簡寰幆娆℃暟 鍘�5锛�
+        for (Integer i = 0; i < listResulttemp.size(); i++) {
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+            if (listResulttemp.size() >= i + 1) {
+                listResult.add(listResulttemp[i]);
+            }
+        }
+    
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        // 闈炵┖鐧芥湡
+        listResulttemp1.sort();
+        for (Integer i = 0; i < 5 - listResulttemp.size(); i++) {
+            if (listResulttemp1.size() >= i + 1) {
+                listResult1.add(listResulttemp1[i]);
+            } else {
+                listResult1.add(new lastMContract(null, null, null, null));
+            }
+        }
+        // 鍚堝苟
+        listResult.addAll(listResult1);
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+        //List<lastMContract> listResult = new List<lastMContract>();
+        return listResult;
+    }
+    
+    
+    public static List<Data> getChartData() {
+        List<Data> data = new List<Data>();
+        List<Achievement_linkage__c> achlist = [select id, Consumption_rate_Lower__c, Consumption_rate_Upper__c,
+                                                PriceCount_Lower__c, PriceCount_Upper__c from Achievement_linkage__c];
+        for (Achievement_linkage__c al : achlist ) {
+            data.add(new Data(al.Consumption_rate_Lower__c, al.Consumption_rate_Upper__c, al.PriceCount_Lower__c, al.PriceCount_Upper__c));
+        }
+        return data;
+    }
+    
+    // 浠锋牸浣撶郴 class
+    public class Data {
+    public Decimal rate_Upper { get; set; }
+    public Decimal rate_Lower { get; set; }
+    public Decimal price_Upper { get; set; }
+    public Decimal price_Lower { get; set; }
+    public Data(Decimal rate_Lower, Decimal rate_Upper, Decimal price_Lower, Decimal price_Upper) {
+        this.rate_Upper = rate_Upper;
+        this.rate_Lower = rate_Lower;
+        this.price_Upper = price_Upper;
+        this.price_Lower = price_Lower;
+    }
+    }
+    
+    // 缁鍚堝悓淇℃伅 class
+    public class lastMContract implements Comparable {
+    public Date endDate { get; set; }
+    public Integer count { get; set; }
+    public String contractId { get; set; }
+    public String contractNo { get; set; }
+    // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+    public Boolean ayearcontract { get; set; }
+    // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+    public lastMContract(String contractId, String contractNo, Date endDate, Integer count) {
+        this.endDate = endDate;
+        this.count = count;
+        this.contractId = contractId;
+        this.contractNo = contractNo;
+    }
+    
+    // 鎺掑簭
+    public Integer compareTo(Object compareTo) {
+        lastMContract compareToesd = (lastMContract)compareTo;
+        Integer returnValue = 0;
+    
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        // 鍒ゆ柇鍦ㄦ暟閲�
+        if (count  > compareToesd.count) {
+            returnValue = -1;
+        } else if (count  < compareToesd.count) {
+            returnValue = 1;
+        } else {
+            if (endDate  > compareToesd.endDate ) {
+                returnValue = 1;
+            } else {
+                returnValue = -1;
+            }
+        }
+        return returnValue;
+    }
+    
+    // 鍘熸柟妗�
+    // if (endDate  > compareToesd.endDate ) {
+    //  returnValue = -1;
+    // } else if (endDate  < compareToesd.endDate ) {
+    //  returnValue = 1;
+    // }else{
+    // if (count  > compareToesd.count ) {
+    //  returnValue = -1;
+    // } else if (count  < compareToesd.count ) {
+    //  returnValue = 1;
+    //  }
+    // }
+    // return returnValue;
+    // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+    }
+    }
\ No newline at end of file

--
Gitblit v1.9.1