From 3c0a8202bbfeeedf8608600e86d90a19286b99ca Mon Sep 17 00:00:00 2001
From: denny chen <chenbangcai@prec-tech.com>
Date: 星期二, 25 四月 2023 10:59:05 +0800
Subject: [PATCH] 维修合同报价页面调整
---
force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls | 1594 +++
force-app/main/default/classes/SelectAssetEstimateVMController.cls-meta.xml | 5
force-app/main/default/pages/SelectAssetEstimateURF.page | 2613 ++++++
force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls-meta.xml | 5
force-app/main/default/pages/SelectAssetEstimateURF.page-meta.xml | 7
force-app/main/default/pages/SelectAssetEstimate.page | 1713 ++++
force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls-meta.xml | 5
force-app/main/default/classes/SelectAssetEstimateController.cls-meta.xml | 5
force-app/main/default/pages/SelectAssetEstimateVM.page-meta.xml | 7
force-app/main/default/classes/SelectAssetEstimateURFController.cls-meta.xml | 5
force-app/main/default/classes/SelectAssetEstimateVMController.cls | 4458 +++++++++++
force-app/main/default/pages/SelectAssetEstimateJumpPage.page-meta.xml | 7
force-app/main/default/pages/SelectAssetEstimateVM.page | 3017 +++++++
force-app/main/default/classes/SelectAssetEstimateURFController.cls | 4841 ++++++++++++
force-app/main/default/classes/SelectAssetEstimateControllerTest.cls-meta.xml | 5
force-app/main/default/classes/SelectAssetEstimateController.cls | 3191 +++++++
force-app/main/default/pages/SelectAssetEstimate.page-meta.xml | 7
force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls | 1614 ++++
force-app/main/default/pages/SelectAssetEstimateJumpPage.page | 22
force-app/main/default/classes/SelectAssetEstimateControllerTest.cls | 987 ++
20 files changed, 24,108 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/SelectAssetEstimateController.cls b/force-app/main/default/classes/SelectAssetEstimateController.cls
new file mode 100644
index 0000000..1fb6516
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateController.cls
@@ -0,0 +1,3191 @@
+global class SelectAssetEstimateController {
+ //test
+ private String targetHospitalId = null; // 浠婂緦绯诲垪鐥呴櫌鐢�
+ private String targetMaintenanceContractId = null;
+
+ 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
+ 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>();
+
+
+ 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] + '\')';
+ }
+ }
+ String soql = '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_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Contract_End_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
+ + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__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\' ';
+ soql += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
+ //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;
+ }
+ 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 Decimal isNewPriceAdj {
+ // HWAG-BGT66T 2019-10-01 鍚庝笉鎵撴姌
+ get{
+ Decimal count = 0;
+ if (estimate.CreatedDate == null || estimate.CreatedDate.date() >= Date.valueOf('2019-10-08')) {
+ count = 1.0;
+ } else{
+ count = 0.7;
+ }
+ return count;
+ }
+ }
+
+ //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 SelectAssetEstimateController() {
+ currPage = 1;
+ selRecordOption = '20';
+ totalRecords = 0;
+ }
+ /**
+ * Visaulforce銇嬨倝鍛笺伆銈屻倠銈炽兂銈广儓銉┿偗銈�
+ */
+ public SelectAssetEstimateController(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,
+ 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
+ , IS_Clone_After_Decide__c
+ // 涓婃湡浜斾釜鍚堝悓淇℃伅 Gzw 20200810
+ , 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
+ 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() {
+ changedAfterPrint = false;
+ changedSubmitPrice = false;
+ isSaveOrApproval = false;
+ OldContractStartDate = null;
+ OldMaintenancePrice = null;
+
+ 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 = '';
+ Boolean ret = false;
+ 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;
+ }
+ }
+ 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;
+ this.estimate.Contract_Esti_Start_Date__c = systemToday;
+ this.estimate.Contract_Start_Date__c = systemToday;
+ this.setContractInfo(this.targetMaintenanceContractId);
+ }
+ // 浣曘倐銇亼銈屻伆銆佸康銇仧銈�
+ // update 缁翠慨鍚堝悓鎶ヤ环锛屼繚瀛樻椂锛屾妸璁板綍绫诲瀷璧嬪�间竴涓�(鐢变簬鎶ラ敊) 2021.6.8 fxk start
+ else {
+ ret = true;
+ throw new ControllerUtil.myException('鏃犳硶鏄剧ず缁翠慨鍚堝悓鎶ヤ环');
+ }
+ if (ret) {
+ return;
+ }
+ // update 缁翠慨鍚堝悓鎶ヤ环锛屼繚瀛樻椂锛屾妸璁板綍绫诲瀷璧嬪�间竴涓�(鐢变簬鎶ラ敊) 2021.6.8 fxk end
+ //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)) {
+ 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, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c,
+ CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__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];
+ // FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c = '涓绘満' ORDER BY ID,IF_Warranty__c asc];
+ } 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.Posting_Date__c, Asset__r.Maintenance_Price_Month__c
+ from Maintenance_Contract_Asset__c
+ where Maintenance_Contract__c = :this.targetMaintenanceContractId];
+ for (Maintenance_Contract_Asset__c mca : oldVals) {
+ // old銈堛倞鏇存柊銇椼仧銇勯爡鐩�
+ Boolean isNew = false;
+ Decimal listPrice = mca.Asset__r.Maintenance_Price_Month__c;
+ // InstallDate 銇� 浠婃棩銈掓瘮杓�
+// if (systemToday.addMonths(-6) < mca.Asset__r.InstallDate) {
+// if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < mca.Asset__r.InstallDate) {
+ Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
+ System.debug(createdDate + '.addMonths(' + isNewAddMonth + ')' + createdDate.addMonths(isNewAddMonth) + ' < mca.Asset__r.InstallDate:' + mca.Asset__r.InstallDate);
+ if (createdDate.addMonths(isNewAddMonth) < mca.Asset__r.InstallDate) {
+ isNew = true;
+ 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,
+ Estimate_List_Price__c = listPrice
+ ));
+ }
+ } else {
+ for (Maintenance_Contract_Asset_Estimate__c mcae : [SELECT Id,
+ Name,
+ Maintenance_Contract_Estimate__c,
+ Asset__c,
+ Asset__r.Maintenance_Price_Month__c,
+ Asset__r.InstallDate,
+ Product_Manual__c,
+ Product_Manual__r.Maintenance_Price_Month__c,
+ //add 2021-02-07 mzy start
+ //Product_Manual__r.NoPartRiskDate_F__c,
+ //Product_Manual__r.SignableFlag__c,
+ Product_Manual__r.Name,
+ //add 2021-02-07 mzy end
+ //add 2021.6.4 fxk Start
+ Check_Object__c,
+ //add 2021.6.4 fxk end
+ IsNew__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,
+ Estimate_List_Price__c,
+ Last_inspection_day__c,
+ Check_Result__c,
+ Repair_Price__c,
+ Comment__c,
+ Asset__r.Posting_Date__c,
+ Asset__r.AssetMark__c
+ 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,
+ Asset__r.AssetMark__c
+
+ ]) {
+ if (String.isBlank(copyid) == false) {
+ if (mcae.Asset__c <> null) {
+ if (systemToday.addMonths(isNewAddMonth) < mcae.Asset__r.InstallDate) {
+ 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) {
+ selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
+ selectedMcaes.add(mcae);
+ } else {
+ newMcaes.add(mcae);
+ }
+ }
+ }
+
+ // 閬告姙娓堛伩銇倐銇伀銉併偋銉冦偗銈掍粯銇戙倠
+ // TODO xudan 涓�瑕с伀鍑恒倠鏄庣窗浠舵暟銇岃冻銈娿仾銇勩偙銉笺偣銇屻亗銈�
+ // 鈶燗ssetA鈥曟槑绱癆銇ф槑绱扮櫥閷�
+ // 鈶sset銇绱㈡潯浠跺鏇淬伀銈堛倞銆丄ssetA銇案閬犮伀鍙栧緱銇с亶銇亜
+ // 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
+ // 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
+ 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;
+// }
+ 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;
+ }
+ assetRecords.clear();
+ // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+ contractStartDateChange();
+ }
+
+ //
+
+ // 鍙栧緱鍒嗛〉鏁版嵁
+ private void setPageRecord() {
+ checkIdList = new List<String> ();
+
+
+ if ((currPage * selctRecordNum) <= 2000) {
+ String notInId = '(\'';
+ if (checkIdList.size() > 0) {
+ for (String str : checkIdList) {
+ notInId += str + '\', \'';
+ }
+ }
+ notInId += '\')';
+
+ String sqlStr = '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_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Contract_End_Date__c,'
+ + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,AssetMark__c,NoPartRiskDate_F__c,NoPartRiskDate__c,SignableFlag__c,Product2.PartSupplyFinishDate__c,Product2.PartSupplyFinishDateExp__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 = '';
+ sqlStr = 'SELECT Id, Name, 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,' ;
+ sqlStr += 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,';
+ sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Contract_End_Date__c,';
+ sqlStr += 'CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c,AssetMark__c,NoPartRiskDate_F__c,NoPartRiskDate__c,SignableFlag__c,Product2.PartSupplyFinishDate__c,Product2.PartSupplyFinishDateExp__c';
+ sqlStr += ' FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\'';
+ sqlStr += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
+
+ //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();
+ //if(records.size() > 1000){
+ // for(Integer i = 0; i < records.size(); i++){
+ // if(i < 1000){
+ // c = records.get(i);
+ // recordsbreak.add(c);
+ // }else{
+ // c = records.get(i);
+ // recordsbreakover.add(c);
+ // }
+ // }
+ // unCheckedAssetsView.add(recordsbreak);
+ // unCheckedAssetsView.add(recordsbreakover);
+ //}else{
+ 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
+ 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 = mcec.Submit_quotation_day__c;
+ 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);
+
+ 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.Delivery_compensation__c) delivery,
+ sum(Repair_Quotation_Id__r.Other_discount__c) other,
+ Delivered_Product__c
+ from
+ Repair__c
+ where
+ Delivered_Product__c in:AsList
+ /*and (
+ (
+ Repair_Quotation_Id__c!=null
+
+ and (Repair_Quotation_Id__r.New_QIS_free__c = 0
+ or
+ Repair_Quotation_Id__r.New_QIS_free__c = null)
+ and (Repair_Quotation_Id__r.Contract_free__c= 0
+ or
+ Repair_Quotation_Id__r.Contract_free__c= null)
+ )
+ or Repair_Quotation_Id__c =null
+ )
+ and Status2__c != '00.鍏抽棴'
+ and Status2__c != '00.鍙栨秷'
+ and Status2__c != '00.鍒犻櫎'
+ and Return_Without_Repair_IF__c = false*/
+ 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.Delivery_compensation__c) delivery,
+ sum(Repair_Quotation_Id__r.Other_discount__c) other,
+ Delivered_Product__c
+ from
+ Repair__c
+ where
+ Delivered_Product__c in:AsList
+ /*and (
+ (
+ Repair_Quotation_Id__c!=null
+
+ and (Repair_Quotation_Id__r.New_QIS_free__c = 0
+ or
+ Repair_Quotation_Id__r.New_QIS_free__c = null)
+ and (Repair_Quotation_Id__r.Contract_free__c= 0
+ or
+ Repair_Quotation_Id__r.Contract_free__c= null)
+ )
+ or Repair_Quotation_Id__c =null
+ )
+ and Status2__c != '00.鍏抽棴'
+ and Status2__c != '00.鍙栨秷'
+ and Status2__c != '00.鍒犻櫎'
+ and Return_Without_Repair_IF__c = false*/
+ and Agreed_Date__c != null
+ and Agreed_Date__c <= :LastYearDate
+ and Agreed_Date__c > :LastSecondYearDate
+ group by Delivered_Product__c];
+ 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.Delivery_compensation__c) delivery,
+ sum(Repair_Quotation_Id__r.Other_discount__c) other,
+ Delivered_Product__c
+ from
+ Repair__c
+ where
+ Delivered_Product__c in:AsList
+ /*and (
+ (
+ Repair_Quotation_Id__c!=null
+
+ and (Repair_Quotation_Id__r.New_QIS_free__c = 0
+ or
+ Repair_Quotation_Id__r.New_QIS_free__c = null)
+ and (Repair_Quotation_Id__r.Contract_free__c= 0
+ or
+ Repair_Quotation_Id__r.Contract_free__c= null)
+ )
+ or Repair_Quotation_Id__c =null
+ )
+ and Status2__c != '00.鍏抽棴'
+ and Status2__c != '00.鍙栨秷'
+ and Status2__c != '00.鍒犻櫎'
+ and Return_Without_Repair_IF__c = false*/
+ and Agreed_Date__c != null
+ and Agreed_Date__c <= :LastSecondYearDate
+ and Agreed_Date__c > :LastThirdYearDate
+ group by Delivered_Product__c];
+
+ system.debug('++++++++' + FriRepairList + '++++++++' + SecRepairList + '+++++++' + ThiRepairList + '+++++');
+ Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
+ Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
+ Map<id, Decimal> LastThiYearPriceSumMap = 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 (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));
+
+
+ /* if( LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id))!=null){
+ Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+ system.debug(McaecToAsset.get(Mca.id)+'::::::'+Mca.Lastyear_Repair_Cost_Text__c);
+ }
+ if(LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) !=null){
+ Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+ system.debug(McaecToAsset.get(Mca.id)+'#######'+Mca.Last_Second_Years_Repair_Cost_Text__c);
+ }
+
+ if(LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) !=null){
+ Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+ system.debug(McaecToAsset.get(Mca.id)+'#######'+Mca.Last_Third_Years_Repair_Cost_Text__c);
+ }*/
+ Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
+
+ }
+ 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
+ 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 = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetEstimateId];
+
+ //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 = mcec.Submit_quotation_day__c;
+ 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);
+ 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.Delivery_compensation__c) delivery,
+ sum(Repair_Quotation_Id__r.Other_discount__c) other,
+ Delivered_Product__c
+ from
+ Repair__c
+ where
+ Delivered_Product__c in:AsList
+ /*and (
+ (
+ Repair_Quotation_Id__c!=null
+
+ and (Repair_Quotation_Id__r.New_QIS_free__c = 0
+ or
+ Repair_Quotation_Id__r.New_QIS_free__c = null)
+ and (Repair_Quotation_Id__r.Contract_free__c= 0
+ or
+ Repair_Quotation_Id__r.Contract_free__c= null)
+ )
+ or Repair_Quotation_Id__c =null
+ )
+ and Status2__c != '00.鍏抽棴'
+ and Status2__c != '00.鍙栨秷'
+ and Status2__c != '00.鍒犻櫎'
+ and Return_Without_Repair_IF__c = false*/
+ 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.Delivery_compensation__c) delivery,
+ sum(Repair_Quotation_Id__r.Other_discount__c) other,
+ Delivered_Product__c
+ from
+ Repair__c
+ where
+ Delivered_Product__c in:AsList
+ /* and (
+ (
+ Repair_Quotation_Id__c!=null
+
+ and (Repair_Quotation_Id__r.New_QIS_free__c = 0
+ or
+ Repair_Quotation_Id__r.New_QIS_free__c = null)
+ and (Repair_Quotation_Id__r.Contract_free__c= 0
+ or
+ Repair_Quotation_Id__r.Contract_free__c= null)
+ )
+ or Repair_Quotation_Id__c =null
+ )
+ and Status2__c != '00.鍏抽棴'
+ and Status2__c != '00.鍙栨秷'
+ and Status2__c != '00.鍒犻櫎'
+ and Return_Without_Repair_IF__c = false */
+ and Agreed_Date__c != null
+ and Agreed_Date__c <= :LastYearDate
+ and Agreed_Date__c > :LastSecondYearDate
+ group by Delivered_Product__c];
+ 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.Delivery_compensation__c) delivery,
+ sum(Repair_Quotation_Id__r.Other_discount__c) other,
+ Delivered_Product__c
+ from
+ Repair__c
+ where
+ Delivered_Product__c in:AsList
+ /* and (
+ (
+ Repair_Quotation_Id__c!=null
+
+ and (Repair_Quotation_Id__r.New_QIS_free__c = 0
+ or
+ Repair_Quotation_Id__r.New_QIS_free__c = null)
+ and (Repair_Quotation_Id__r.Contract_free__c= 0
+ or
+ Repair_Quotation_Id__r.Contract_free__c= null)
+ )
+ or Repair_Quotation_Id__c =null
+ )
+ and Status2__c != '00.鍏抽棴'
+ and Status2__c != '00.鍙栨秷'
+ and Status2__c != '00.鍒犻櫎'
+ and Return_Without_Repair_IF__c = false*/
+ and Agreed_Date__c != null
+ and Agreed_Date__c <= :LastSecondYearDate
+ and Agreed_Date__c > :LastThirdYearDate
+ group by Delivered_Product__c];
+ Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
+ Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
+ Map<id, Decimal> LastThiYearPriceSumMap = 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 = this.sumPrice(Rpc);
+ LastThiYearPriceSumMap.put(idf, Defir);
+ }
+ 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));
+
+ /*if( LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id))!=null){
+ Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+ system.debug(McaecToAsset.get(Mca.id)+'::::::'+Mca.Lastyear_Repair_Cost_Text__c);
+ }
+ if(LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) !=null){
+ Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+ system.debug(McaecToAsset.get(Mca.id)+'#######'+Mca.Last_Second_Years_Repair_Cost_Text__c);
+ }
+ if(LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) !=null){
+ Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+ system.debug(McaecToAsset.get(Mca.id)+'#######'+Mca.Last_Third_Years_Repair_Cost_Text__c);
+ }*/
+ Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
+
+ }
+ 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 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('sercince')
+ + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
+ return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + set_discount + sercince + 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 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('sercince')
+ + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
+ return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + set_discount + sercince + 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() {
+ for (Integer i = 0; i < checkedAssets.size(); i++) {
+ if (i == productIdx) {
+ AssetInfo ai = checkedAssets[i];
+ if (ai.mcae.Product_Manual__c == null) {
+ ai.mcae.Estimate_List_Price__c = null;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ ai.CheckRows = true;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ } else {
+ // add by mzy 2021-02-04 LJPH-BX9CVX select 涓坊鍔� NoPartRiskDate_F__c
+ List<Product2> prd = [select Id, Maintenance_Price_Month__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.orgPrice = prd[0].Maintenance_Price_Month__c;
+ //add by rentx 2020-11-12 LJPH-BV93RZ start
+ ai.proName = prd[0].Name;
+ //add by rentx 2020-11-12 LJPH-BV93RZ start
+ //add by mzy 2021-02-04 LJPH-BX9CVX start
+ //ai.NoPartRiskDate = prd[0].NoPartRiskDate_F__c;
+ ai.proName2 = prd[0].Name;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ ai.CheckRows = false;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ //ai.SignableFlag = prd[0].SignableFlag__c;
+ //add by mzy 2021-02-04 LJPH-BX9CVX start
+
+ }
+ }
+ }
+ // 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>();
+ 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) {
+ // 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
+ );
+ ass.mcae = mcae;
+ tmpChecked.add(ass);
+ totalRecords --;
+ } else {
+ ass.mcae = null;
+ tmpUnChecked.add(ass);
+ }
+ }
+
+ this.checkedAssets = new List<AssetInfo>();
+ 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();
+ return null;
+ }
+
+ // 鍚堝悓寮�濮嬫棩鍙樻洿锛岄噸鏂拌绠楁柊鍝�
+ public PageReference contractStartDateChange() {
+ Date systemToday = System.today();
+ // 鍒涘缓鏃�
+ Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
+ // 鍒涘缓鏃�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;
+
+ /**********************HWAG-AYDCZX 2018/5/8 DEL START***************************/
+ //// 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�6涓湀锛岄兘涓嶇畻鏂板搧
+ //if (contractDate >= isNewAfter) {
+ // system.debug('===== greater than createddate 6 months');
+ // for (AssetInfo info : checkedAssets) {
+ // 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涓湀锛屼娇鐢ㄥ悎鍚屽紑濮嬫棩璁$畻鏂板搧
+ //else if (contractDate >= threeMonthAfter) {
+ // system.debug('===== greater than createddate 3 months');
+ // for (AssetInfo info : checkedAssets) {
+ // if (!info.isManual) {
+ // // xudan 20151224 鏂拌銆佸張銇偝銉斻兗銆佸張銇綔鎴愭棩銇嬨倝3銉舵湀绲岄亷銆佸張銇�3銉舵湀浠ュ唴涓斻仱鏈彁鍑恒�佷尽鏍兼洿鏂�
+ // if (this.estimate.CreatedDate == null
+ // || String.isBlank(ApexPages.currentPage().getParameters().get('copyid')) == false
+ // || contractDate.addMonths(keepPriceMonth) < systemToday
+ // || this.estimate.Process_Status__c == '鑽夋涓�') {
+
+ // 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 (contractDate.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.InstallDate) {
+ // // 鏂板搧閬╃敤銇椼仾銇�
+ // }
+ // else {
+ // if (contractDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // 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 (contractDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // info.mcae.isNew__c = true;
+ // info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+ // }
+ // }
+ // // (info.rec.Posting_Date__c == null && info.rec.InstallDate == null)
+ // else {
+ // // 鐗规畩鍑︾悊銇仐
+ // }
+ // }
+
+ // if (contractDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // info.mcae.isNew__c = true;
+ // info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+ // }
+
+ // } 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;
+ // }
+ // }
+ //}
+ //// 浣跨敤鍒涘缓鏃ヨ绠楁柊鍝�
+ //else {
+ // system.debug('===== calculate by createddate');
+ // for (AssetInfo info : checkedAssets) {
+ // if (!info.isManual) {
+ // // xudan 20151224 鏂拌銆佸張銇綔鎴愭棩銇嬨倝3銉舵湀绲岄亷銆佸張銇�3銉舵湀浠ュ唴涓斻仱鏈彁鍑恒�佷尽鏍兼洿鏂�
+ // if (this.estimate.CreatedDate == null
+ // || String.isBlank(ApexPages.currentPage().getParameters().get('copyid')) == false
+ // || contractDate.addMonths(keepPriceMonth) < systemToday
+ // || this.estimate.Process_Status__c == '鑽夋涓�') {
+
+ // 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 (createdDate.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.InstallDate) {
+ // // 鏂板搧閬╃敤銇椼仾銇�
+ // }
+ // else {
+ // if (createdDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // 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 (createdDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // info.mcae.isNew__c = true;
+ // info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+ // }
+ // }
+ // // (info.rec.Posting_Date__c == null && info.rec.InstallDate == null)
+ // else {
+ // // 鐗规畩鍑︾悊銇仐
+ // }
+ // }
+ // /*
+ // if (createdDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // info.mcae.isNew__c = true;
+ // info.mcae.Estimate_List_Price__c = info.orgPrice * isNewPriceAdj;
+ // }
+ // */
+ // } 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;
+ // }
+ // }
+ //}
+ /**********************HWAG-AYDCZX 2018/5/8 DEL END***************************/
+ /**********************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 (contractDate >= 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涓湀锛屼娇鐢ㄥ悎鍚屽紑濮嬫棩璁$畻鏂板搧
+ // 浣跨敤鍒涘缓鏃ヨ绠楁柊鍝�
+ else {
+ 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.InstallDate) {
+ // 鏂板搧閬╃敤銇椼仾銇�
+ } else {
+ if (isNewDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ 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.InstallDate) {
+ 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;
+ }
+ }
+ }
+ }
+ // 鏂拌銆佽崏妗堜腑浠ュ
+ //else {
+ // for (AssetInfo info : checkedAssets) {
+ // if ((!info.isManual) || (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) ) {
+ // boolean isNewChange =false;
+ // // 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�6涓湀锛岄兘涓嶇畻鏂板搧
+ // if (contractDate >= isNewAfter) {
+ // }
+ // // 鍚堝悓寮�濮嬫棩澶т簬鍒涘缓鏃�3涓湀锛屼娇鐢ㄥ悎鍚屽紑濮嬫棩璁$畻鏂板搧
+ // // 浣跨敤鍒涘缓鏃ヨ绠楁柊鍝�
+ // else {
+ // if (contractDate.addMonths(keepPriceMonth) < systemToday) {
+ // Date isNewDate = null;
+ // if (contractDate >= threeMonthAfter) {
+ // isNewDate = contractDate;
+ // } else {
+ // isNewDate = createdDate;
+ // }
+ // if (!info.isManual) {
+ // if (info.rec.Posting_Date__c != null && info.rec.InstallDate == null) {
+ // if (isNewDate.addMonths(isNewAddMonth) < info.rec.Posting_Date__c) {
+ // isNewChange = true;
+ // }
+ // }
+ // // 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.InstallDate) {
+ // // 鏂板搧閬╃敤銇椼仾銇�
+ // }
+ // else {
+ // if (isNewDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // isNewChange = true;
+ // }
+ // }
+ // }
+ // // Post銇仐
+ // else if (info.rec.Posting_Date__c == null && info.rec.InstallDate != null) {
+ // if (isNewDate.addMonths(isNewAddMonth) < info.rec.InstallDate) {
+ // isNewChange = true;
+ // }
+ // }
+ // else {
+ // // 鐗规畩鍑︾悊銇仐
+ // }
+ // } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+ // isNewChange = true;
+ // }
+ // }
+ // }
+ // if (isNewChange != info.mcae.isNew__c) {
+ // changedSubmitPrice = true;
+ // }
+ // if (info.mcae.isNew__c) {
+ // if (info.mcae.Estimate_List_Price__c.setScale(2) != (info.orgPrice * isNewPriceAdj).setScale(2)) {
+ // changedSubmitPrice = true;
+ // }
+ // } else {
+ // if (info.mcae.Estimate_List_Price__c.setScale(2) != info.orgPrice.setScale(2)) {
+ // changedSubmitPrice = true;
+ // }
+ // }
+ // }
+ // }
+ //}
+
+ /**********************HWAG-AYDCZX 2018/5/8 ADD END***************************/
+
+ 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;
+ }
+ NextMaintenanceContract();
+ //add by rentx 2020-11-13 LJPH-BV93RZ end
+ // add 缁翠慨鍚堝悓鎶ヤ环锛屼繚瀛樻椂锛屾妸璁板綍绫诲瀷璧嬪�间竴涓� 2021.6.8 fxk start
+ Id Maintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('Maintenance_Quote').getRecordTypeId();
+ estimate.recordtypeid = Maintenance_Contract;
+ // add 缁翠慨鍚堝悓鎶ヤ环锛屼繚瀛樻椂锛屾妸璁板綍绫诲瀷璧嬪�间竴涓� 2021.6.8 fxk end
+ if (changedSubmitPrice) {
+ priceChangeReset();
+ return null;
+ }
+ if (syncEstimate(false, false)) {
+ ComputeLTYRepair();
+ 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();
+ //SelectAssetEstimateController.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() {
+
+ //SelectAssetEstimateController Sc2 = new SelectAssetEstimateController();
+ //Sc2.targetEstimateId = this.targetEstimateId;
+ //Sc2.ComputeLTYRepair();
+
+ System.debug('approvalProcess start');
+ 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);
+ if (changedAfterPrint) {
+ return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+ } else {
+ 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');
+ NextMaintenanceContract();
+ inDicideFlag = true;
+ // TODO check decide 璧勬牸
+ Savepoint sp = Database.setSavepoint();
+ if (syncEstimate(false, true)) {
+ if (changedAfterPrint) {
+ return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+ } else {
+ return new PageReference('/' + this.targetEstimateId + '/e?completion=3');
+ }
+ }
+
+ return null;
+ }
+ // public PageReference dosomething() {
+ // System.debug('dosomething start');
+ // NextMaintenanceContract();
+ // return null;
+ // }
+ public void NextMaintenanceContract() {
+ // 20220810 璇环2鏈熷紑鍙�
+ List<String> asslocalList = new List<String>();
+ List<String> mcalocalList = new List<String>();
+ Map<Id, Maintenance_Contract__c> map3 = new Map<Id, Maintenance_Contract__c>();
+
+ List<Maintenance_Contract_Asset__c> mcaupdateList = new List<Maintenance_Contract_Asset__c>();
+ for (AssetInfo ass : this.checkedAssets) {
+ if (!ass.isManual) {
+ asslocalList.add(ass.rec.Id);
+ map3.put(ass.rec.Id,this.contract);
+ }
+ }
+ System.debug('asslocalList====%%%' +asslocalList);
+ List<Maintenance_Contract_Asset__c> mcalist1 = [select id,Asset__c,Next_Maintenance_Contract__c,Maintenance_Contract__c
+ from Maintenance_Contract_Asset__c
+ where id in (select CurrentContract_F_asset__c
+ from asset
+ where id in :asslocalList and CurrentContract_F_asset__c!=null)];
+ System.debug('mcalist1====%%%' +mcalist1);
+ System.debug('map3====%%%' +map3);
+ for (Maintenance_Contract_Asset__c mca : mcalist1) {
+ Maintenance_Contract_Asset__c mca3 = new Maintenance_Contract_Asset__c();
+ if (map3.containsKey(mca.Asset__c)) {
+ mca3.id = mca.id;
+ mca3.Next_Maintenance_Contract__c = map3.get(mca.Asset__c).id;
+ System.debug('mca3.id====%%%' +mca3.id);
+ if (mca3.id!=null&&!mcaupdateList.contains(mca3)) {
+ mcaupdateList.add(mca3);
+ }
+ }
+ }
+ System.debug('mcaupdateList====%%%' +mcaupdateList);
+ if (mcaupdateList!=null&&!mcaupdateList.isEmpty()) {
+ update mcaupdateList;
+ }
+ System.debug('鏇存柊瀹屾垚mcaupdateList');
+ }
+
+ 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;
+ 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銈掑嚭銇�
+ private Boolean syncEstimate(boolean isApproval, boolean isDecide) {
+ System.debug('syncEstimate start');
+ Boolean hasDatabaseError = false;
+ Savepoint sp = Database.setSavepoint();
+
+ try {
+ if (!checkValidate()) {
+ return false;
+ }
+ if (checkChangedAfterPrint()) {
+ if (isDecide) {
+ // 銇俱仛 Approval
+ isApproval = true;
+ isDecide = false;
+ }
+ }
+ //>>>
+ 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_Price__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;
+ }
+ }
+ if (isDecide && getDecideBtnDisabled()) {
+ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide'));
+ return false;
+ }
+ // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
+ List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets);
+ 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 ;
+
+ // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+ // 鍚屾湡鍑︾悊
+ // 鈶犵淮淇悎鍚屻伀鏃㈠瓨銇繚鏈夎澶囥倰鍓婇櫎
+ // 鈶′繚瀛樸仐銇熺淮淇悎鍚屾姤浠枫伄淇濇湁璁惧銈掔淮淇悎鍚屻伀銈炽償銉�(Asset__c銇岃ō瀹氥仌銇︺亜銈嬨儑銉笺偪銇犮亼)
+ // 鈶粬銇淮淇悎鍚屾姤浠枫伄鍚屾湡銉曘儵銈般倰澶栥仚
+ // 鈶g淮淇悎鍚屻伄 Estimate_Trial_Money__c銆丆ontract_Amount__c, Service_contract_target_number__c 銈掓洿鏂�
+ this.estimate.IsSyncing__c = true;
+ if (isDecide) {
+
+ // 娣诲姞鍐冲畾鎶ヤ环鏃ユ湡
+ 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;
+
+ // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
+ 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 createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
+ // 锛撱兌鏈堣秴閬庛仐銇︺亜銈嬪牬鍚堛伀銇�丏ecide銇с亶銇亜
+ //if (createdDate.addMonths(3) <= System.today()) {
+ // this.estimate.addError('宸茶秴杩�3涓湀锛岃鍏堟洿鏂版姤浠枫��');
+ // return false;
+ //}
+
+ // 缁翠慨鍚堝悓鎶ヤ环
+ if (String.isBlank(this.targetEstimateId)) {
+ 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>();
+ 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;
+ }
+ // 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;
+ }
+ //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,
+ //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+ Check_Object__c,
+ //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+ IsNew__c 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,
+ 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
+ );
+ 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.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;
+ this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
+ 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;
+ }
+ //娣诲姞鐨勯澶栧搴旇繃绋�
+ 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;
+ }
+ String oldProcessStatus = this.estimate.Process_Status__c;
+ try {
+ 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) {
+ SelectAssetEstimateController.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;
+ 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()));
+ }
+ 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;
+ }
+ NextMaintenanceContract();
+ //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;
+ }
+
+ 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
+ FROM Maintenance_Contract__c WHERE Id = :id];
+ this.targetHospitalId = this.contract.Hospital__c;
+ }
+
+ private Boolean checkValidate() {
+ Boolean rtn = true;
+ // 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) {
+ if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+ if (input.mcae.Estimate_List_Price__c == null || input.mcae.Estimate_List_Price__c == 0) {
+ //add by rentx 2020-11-12 LJPH-BV93RZ start
+ if (String.isNotBlank(input.proName)) {
+ // input.mcae.Product_Manual__c.addError(System.Label.Error_Message47);
+ input.mcae.Product_Manual__c.addError(System.Label.Error_Message47 + '(' + input.proName + ')');
+ //add by rentx 2020-11-12 LJPH-BV93RZ start
+ }
+
+ 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 add 鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+ if (input != null) {
+ // System.debug('鏃犻浂浠堕闄╂棩鏈� 鏍¢獙 end ');
+ if ( input.rec != null && input.rec.NoPartRiskDate_F__c != null ) {
+ // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
+ String msg = SelectAssetEstimateVMController.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 = SelectAssetEstimateVMController.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 add 鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+ }
+ return rtn;
+ }
+
+ // 浠锋牸鍙樻洿鍚庡厠闅嗘姤浠峰墠閲嶆柊璁$畻浠锋牸
+ @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 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 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;}
+ // 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;
+ //add by rentx 2020-11-12 LJPH-BV93RZ start
+ //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
+ 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;
+ // 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,
+ Check_Result__c = mcae.Check_Result__c,
+ Repair_Price__c = mcae.Repair_Price__c,
+ Comment__c = mcae.Comment__c
+ );
+ this.isManual = false;
+ this.rec_checkBox_c = true;
+ this.orgPrice = record.Maintenance_Price_Month__c;
+ //add by rentx 2020-11-12 LJPH-BV93RZ start
+ this.proName = '鏈鸿韩缂栫爜涓�:' + record.SerialNumber;
+ //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 202-02-07 end
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ this.CheckRows = true;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� 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,
+ Check_Result__c = mcae.Check_Result__c,
+ Repair_Price__c = mcae.Repair_Price__c,
+ Comment__c = mcae.Comment__c
+ );
+ this.isManual = true;
+ this.rec_checkBox_c = false;
+ this.orgPrice = mcae.Product_Manual__r.Maintenance_Price_Month__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
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ this.CheckRows = true;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� 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;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ this.CheckRows = true;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ }
+ }
+
+ WebService static String pageDecide(String strId) {
+ String rs = '';
+ SelectAssetEstimateController saec = new SelectAssetEstimateController();
+ 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 = '';
+ Integer i = 0;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ SelectAssetEstimateController saec = new SelectAssetEstimateController();
+ 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;
+ }
+
+ // 璁$畻杩囧幓浜斾釜鍚堝悓淇℃伅 Gzw 20200810
+ public static List<lastMContract> getlastMContract(List<AssetInfo> checkedAssets) {
+ Map<String, lastMContract> lastMContractMap = new Map<String, lastMContract>();
+ for (AssetInfo ai : checkedAssets) {
+ lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Maintenance_Contract_No_F__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
+ if (String.isNotBlank(ai.rec.CurrentContract_F__c)) {
+ //20201102 songxiaoqi start
+ // if(ai.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract'){
+
+ // }
+ // 20201102 songxiaoqi 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);
+ }
+ }
+ }
+ List<lastMContract> listResulttemp = new List<lastMContract>();
+ List<lastMContract> listResult = new List<lastMContract>();
+ for ( lastMContract ll : lastMContractMap.values()) {
+ listResulttemp.add(ll);
+ }
+ //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'listResult +++++锛�' + listResult));
+ listResulttemp.sort();
+ for (Integer i = 0; i < 5 ; i++) {
+ if (listResulttemp.size() >= i + 1) {
+ listResult.add(listResulttemp[i]);
+ } else {
+ listResult.add(new lastMContract(null, null, null, null));
+ }
+ }
+ //List<lastMContract> listResult = new List<lastMContract>();
+ return listResult;
+ }
+
+
+ // 缁鍚堝悓淇℃伅 class
+ // 璁$畻杩囧幓浜斾釜鍚堝悓淇℃伅 Gzw 20200810
+ 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; }
+
+ 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;
+ 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/SelectAssetEstimateController.cls-meta.xml b/force-app/main/default/classes/SelectAssetEstimateController.cls-meta.xml
new file mode 100644
index 0000000..d75b058
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>51.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/SelectAssetEstimateControllerTest.cls b/force-app/main/default/classes/SelectAssetEstimateControllerTest.cls
new file mode 100644
index 0000000..5019ee0
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateControllerTest.cls
@@ -0,0 +1,987 @@
+@isTest
+private class SelectAssetEstimateControllerTest {
+
+ /*static testMethod void addRepairData(){
+ Repair__c rpr = [select Id, Name, Account__c,Department_Class__c,
+ Delivered_Product__c,Hospital__c,SalesOfficeCode_selection__c,
+ SAPRepairNo__c,Status__c,Incharge_Staff__c,Repair_Detail__c
+ from Repair__c];
+
+ Repair_Quotation__c rq = new Repair_Quotation__c();
+ rq.Name = 'testNFM104';
+ rq.Repair__c = rpr.Id;
+ rq.MessageGroupNumber__c = '1';
+ insert rq;
+ }*/
+
+ static testMethod void addDatabase(){
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id
+ );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id
+ );
+
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
+
+
+ // 璋冪敤鏂规硶娴嬭瘯, 鍙傛暟
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ Apexpages.currentPage().getParameters().put('completion', '5');
+ Apexpages.currentPage().getParameters().put('id', contactEsti2.Id);
+
+ // 鍒涘缓瀵硅薄,瀹氫箟,璋冪敤鏂规硶娴嬭瘯
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.checkedAssets[0].mcae.Check_Result__c = 'OK';
+ controller.savePrintFlg();
+ controller.ShowLTYRepair();
+ controller.getPageDisabled();
+ controller.priceChangeReset();
+ }
+ }
+
+
+
+
+
+
+
+ private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ static Asset createAsset(String input, String accountid, String dcId, String hpId, String serialNo, String prId,String mark) {
+ Asset asset = new Asset();
+ asset.Name = input;
+ asset.AccountId = accountid;
+ asset.Department_Class__c = dcId;
+ asset.Hospital__c = hpId;
+ asset.SerialNumber = serialNo;
+ asset.Product2Id = prId;
+ asset.InstallDate = Date.today();
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ //鍦ㄥ垱寤篈sset鐨勬椂鍊欐坊鍔燗ssetMark__c 瀛楁
+ asset.AssetMark__c = mark;
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ insert asset;
+ return asset;
+ }
+
+ public class AssetInfo {
+ 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 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
+ );
+ this.isManual = true;
+ this.rec_checkBox_c = false;
+ this.orgPrice = 0;
+ }
+ }
+
+ // 2銇よ绌嶃倐銈娿亴銇傘倞銆佽Κ銇偟銉撱偝銉炽仺鍚屾湡銇欍倠銇儐銈广儓
+ static testMethod void testDecide_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'涓绘満');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id
+ );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
+
+ System.Test.startTest();
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.save();
+ controller.approvalProcess();
+
+ // 缁翠慨鍚堝悓鎶ヤ环1
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ controller = new SelectAssetEstimateController();
+ controller.init();
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ // System.assertEquals(5, controller.productCount2);
+ //榛樿鏌ヨ鐨勬槸涓绘満
+ System.assertEquals(3, controller.productCount2);
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+
+ controller.getEnablePrintContract();
+ controller.getUnDecideBtnDisabled();
+ controller.getDecideBtnDisabled();
+ controller.getApprovalBtnDisabled();
+ controller.getSaveBtnDisabled();
+ controller.getPrintBtnDisabled();
+ // System.Test.startTest();
+ System.assertEquals(10, controller.productCount);
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ System.assertEquals(11, controller.productCount);
+ System.assertEquals(1, controller.productCount3);
+
+ controller.productIdx = 1;
+ controller.refreshProductData();
+
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+
+ List<Maintenance_Contract_Asset__c> mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id];
+ System.assertEquals(1, mcaList.size());
+ System.assertEquals('asset01', mcaList[0].Asset__r.Name);
+
+ controller.print();
+
+ // 缁翠慨鍚堝悓鎶ヤ环2銇焙瀹氥儹銈搞儍銈�
+ // Apexpages.currentPage().getParameters().put('id', contactEsti2.Id);
+ // SelectAssetEstimateController controller2 = new SelectAssetEstimateController();
+ // controller2.init();
+
+ // controller2.unCheckedAssetsView[0][1].rec_CheckBox_c = true;
+ // controller2.unCheckedAssetsView[0][2].rec_CheckBox_c = true;
+ // System.assertEquals(10, controller2.productCount);
+ // controller2.exchangeAsset();
+ // System.assertEquals(12, controller2.productCount);
+ // System.assertEquals(2, controller2.productCount3);
+
+ // contactEsti1 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti1.Id];
+ // System.assertEquals(true, contactEsti1.IsSyncing__c);
+
+ // controller2.checkedAssets[0].mcae.Check_Result__c = 'test0';
+ // controller2.checkedAssets[1].mcae.Check_Result__c = 'test1';
+ // controller2.estimate.Contract_Esti_Start_Date__c = Date.today();
+ // controller2.estimate.Contract_Range__c = 2;
+ // controller2.estimate.Process_Status__c = '鎵瑰噯';
+ // controller2.decide();
+
+ // contactEsti1 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti1.Id];
+ // System.assertEquals(false, contactEsti1.IsSyncing__c);
+ // contactEsti2 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti2.Id];
+ // System.assertEquals(true, contactEsti2.IsSyncing__c);
+
+ // controller2.undecide();
+
+ //mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id order by Asset__r.Name];
+ //System.assertEquals(2, mcaList.size());
+ //System.assertEquals('asset02', mcaList[0].Asset__r.Name);
+ //System.assertEquals('asset04', mcaList[1].Asset__r.Name);
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void testcopyid_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'鑰楁潗');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id
+ );
+ insert contactEsti1;
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.lastFriYearsPriceSum =3322;
+ controller.lastSecYearsPriceSum = 1222;
+ controller.alertString ='';
+ controller.alertString2 ='';
+ controller.alertString3 ='';
+ controller.getSaveBtnDisabled();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ SelectAssetEstimateController.pageDecide(contactEsti1.Id);
+ SelectAssetEstimateController.pageUndecide(contactEsti1.Id);
+ controller.ComputeLTYRepair();
+ }
+ }
+
+ static testMethod void testInit_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ try {
+ SelectAssetEstimateController controller001 = new SelectAssetEstimateController();
+ controller001.init();
+ } catch (Exception e) {
+
+ }
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'鑰楁潗');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'涓绘満');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ Maintenance_Contract_Asset__c mca2 = new Maintenance_Contract_Asset__c();
+ mca2.Asset__c = asset01.Id;
+ mca2.Estimate_List_Price__c = 100;
+ mca2.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1, mca2};
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id,
+ Contract_Esti_Start_Date__c = Date.today().addDays(1)
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ Apexpages.currentPage().getParameters().put('completion', '1');
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+
+ controller.init();
+ controller.firstPage();
+ controller.currPage = 3;
+ controller.previousPage();
+ controller.endPage();
+ controller.currPage = 200;
+ controller.nextPage();
+ controller.recordNumChange();
+ controller.getSaveBtnDisabled();
+ //controller.ComputeLTYRepair();
+ controller.cancel();
+ controller.saveAndCancel();
+ }
+ }
+
+ static testMethod void testInit_02() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,' ');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id,
+ Contract_Esti_Start_Date__c = Date.today().addDays(1)
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ Apexpages.currentPage().getParameters().put('completion', '2');
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ Test.startTest();
+ controller.ComputeLTYRepair();
+ controller.saveAndCancel();
+
+ SelectAssetEstimateController.ComputeLTYRepair(controller.targetEstimateId);
+ Test.stopTest();
+ }
+ }
+
+ static testMethod void testInit_03() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ Apexpages.currentPage().getParameters().put('completion', '3');
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ }
+ }
+
+ static testMethod void testApprovalProcess_01() {
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.Payment_Plan_Sum_First__c = 1;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id
+ );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
+
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.checkedAssets[0].mcae.Check_Result__c = 'OK';
+ controller.approvalProcess();
+
+ // 鎻愪氦寰呭鎵规椂锛屾洿鏂板凡濉啓鐢宠鐘舵��
+ List<Maintenance_Contract_Estimate__c> mcenew = [select id,ApprovalProcess_Status__c from Maintenance_Contract_Estimate__c where id = :controller.targetEstimateId];
+ System.assertEquals('宸插~鍐欏畬骞剁敵璇�', mcenew[0].ApprovalProcess_Status__c);
+
+ }
+ }
+
+ static testMethod void EditUnitTest() {
+
+ //Test.startTest();
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+ system.runAs(u3) {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ //SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ //// 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ //PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ //entry.UnitPrice = 0;
+ //entry.IsActive = true;
+ //entry.UseStandardPrice = false;
+ //entry.CurrencyIsoCode = 'CNY';
+ //entry.Product2Id = productA.Id;
+ //insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.Payment_Plan_Sum_First__c = 1;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id
+ );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
+ System.Test.startTest();
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateController controller = new SelectAssetEstimateController();
+ controller.init();
+ controller.text1 = 'S:Name';
+ controller.cond1 = 'equals';
+ controller.val1 = 'asset01,asset02';
+ controller.searchBtn();
+ controller.cond1 = 'equals';
+ controller.val1 = 'asset02';
+ controller.searchBtn();
+ controller.cond1 = 'contains';
+ controller.val1 = ' asset02';
+ controller.searchBtn();
+ controller.cond1 = 'notequals';
+ controller.searchBtn();
+ controller.cond1 = 'starts with';
+ controller.searchBtn();
+ Test.stopTest();
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/SelectAssetEstimateControllerTest.cls-meta.xml b/force-app/main/default/classes/SelectAssetEstimateControllerTest.cls-meta.xml
new file mode 100644
index 0000000..b211a09
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>28.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/SelectAssetEstimateURFController.cls b/force-app/main/default/classes/SelectAssetEstimateURFController.cls
new file mode 100644
index 0000000..8b0bb45
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateURFController.cls
@@ -0,0 +1,4841 @@
+global class SelectAssetEstimateURFController {
+ //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
+
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+ public List<String> TopProductModel =new List<String>();
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+
+ //HWAG-B399Q8 2018/08/20 妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
+ public Boolean IS_Clone_After_Decide { get; set; }
+ //HWAG-B399Q8 2018/08/20 妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' 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;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ public String checkDealerId{get;set;}
+ //URF闄愭鍚堝悓2鏈� LY 20220811 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
+ //tcm 鍒犻櫎绗�4琛� Maintenance_Contract_No_F__c 鏇挎崲 Management_Code__c 20211201
+ 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.Management_Code__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_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,CurrentContract_F__r.Contract_Range__c,'
+ + 'Product2.ProductURF__c,Product2.ProductURF__r.URFLimitSerial__c,Product2.ProductURF__r.UFR_MaxRepairCount__c,Product2.ProductURF__r.UFR_Maintenance_Price_Month__c,'
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ + 'Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c, Product2.ProductURF__r.Maintenance_Price_Year_URF__c,'
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ + 'Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c, Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c, Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,'
+ + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,AssetMark__c FROM Asset WHERE Product2.ProductURF__c != null AND 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 SelectAssetEstimateURFController() {
+ currPage = 1;
+ selRecordOption = '20';
+ totalRecords = 0;
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ checkDealerId = '';
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ Integer i = 0;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ i ++;
+ }
+ /**
+ * Visaulforce銇嬨倝鍛笺伆銈屻倠銈炽兂銈广儓銉┿偗銈�
+ */
+ public SelectAssetEstimateURFController(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,
+ 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
+ // URF闄愭鍚堝悓2鏈� LY 20220811 start
+ ,Is_RecognitionModel__c
+ ,URF_P_MaxRepairCount__c,URF_V_MaxRepairCount__c
+ ,URFMContract1__c,URFMContract1_startDate__c,URFMContract1_endDate__c
+ //,URFMContract2__c,URFMContract3__c,URFMContract4__c,URFMContract5__c
+ ,URF_LastMContract1_NO__c,URF_LastMContract2_NO__c,URF_LastMContract3_NO__c,URF_LastMContract4_NO__c,URF_LastMContract5_NO__c
+ ,URF_LastMContract1_ConCount__c,URF_LastMContract2_ConCount__c,URF_LastMContract3_ConCount__c,URF_LastMContract4_ConCount__c,URF_LastMContract5_ConCount__c
+ // URF闄愭鍚堝悓2鏈� LY 20220811 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;
+ 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
+ // 绱嶅叆姗熷櫒銇儏鍫便倰鍙栧緱
+ //tcm 鍒犻櫎绗�4琛� Maintenance_Contract_No_F__c 鏇挎崲 Management_Code__c 20211201 start
+ if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c
+ assetRecords = [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, EquipmentGuaranteeFlg__c,
+ CurrentContract_F__c, CurrentContract_F__r.Management_Code__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
+ // 闄愭鍚堝悓淇℃伅 add by gzw start
+ , Product2.ProductURF__c, Product2.ProductURF__r.URFLimitSerial__c, Product2.ProductURF__r.UFR_MaxRepairCount__c, Product2.ProductURF__r.UFR_Maintenance_Price_Month__c
+ // 闄愭鍚堝悓淇℃伅 add by gzw end
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ , Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c
+ , Product2.ProductURF__r.Maintenance_Price_Year_URF__c
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ , Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c
+ , Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c
+ , Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c
+ , URF_Maintenance_Contract__c
+ , URF_Maintenance_Contract__r.Management_Code__c
+ , URF_Maintenance_Contract__r.Contract_End_Date__c
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ 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) {
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '00000000000000000000000000'));
+ 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
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 start
+ , Asset__r.Product2.ProductURF__c
+ , Asset__r.Product2.ProductURF__r.URFLimitSerial__c,
+ Asset__r.Product2.ProductURF__r.UFR_MaxRepairCount__c,
+ Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 start
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ , Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c, Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF__c
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ , Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c
+ , Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c
+ , Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c
+ , Asset__r.URF_Maintenance_Contract__c
+ , Asset__r.URF_Maintenance_Contract__r.Management_Code__c
+ , Asset__r.URF_Maintenance_Contract__r.Contract_End_Date__c
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ from Maintenance_Contract_Asset__c
+ where Maintenance_Contract__c = :this.targetMaintenanceContractId AND Asset__r.Product2.ProductURF__c != null
+ ];
+ 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
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 start
+ // Decimal listPrice = mca.Asset__r.Maintenance_Price_Month__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //Decimal listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ Decimal listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 end
+ 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
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 start
+ // listPrice = mca.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
+ // listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
+
+
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 end
+
+ }
+ 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 {
+ List<Maintenance_Contract_Asset_Estimate__c> selectlist = [SELECT Id FROM
+ Maintenance_Contract_Asset_Estimate__c
+ WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId ];
+
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '111111111111111111111111' + selectlist.size()));
+ for (Maintenance_Contract_Asset_Estimate__c mcae : [SELECT Id,
+ Name,
+ Maintenance_Contract_Estimate__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,
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 start
+ Product_Manual__r.ProductURF__c,
+ Product_Manual__r.ProductURF__r.URFLimitSerial__c,
+ Product_Manual__r.ProductURF__r.UFR_MaxRepairCount__c,
+ Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month__c,
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_Max__c,
+ Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF__c,
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_3__c,
+ Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c,
+ Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month_3__c,
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+ Product_Manual__r.Asset_Model_No__c,
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+ Asset__r.Product2.ProductURF__c,
+ Asset__r.Product2.ProductURF__r.URFLimitSerial__c,
+ Asset__r.Product2.ProductURF__r.UFR_MaxRepairCount__c,
+ Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c,
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c,
+ Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF__c,
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c,
+ Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c,
+ Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,
+ Asset__r.URF_Maintenance_Contract__c,
+ Asset__r.URF_Maintenance_Contract__r.Management_Code__c,
+ Asset__r.URF_Maintenance_Contract__r.Contract_End_Date__c,
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ URF_Series__c,
+ Series_RepairCount__c,
+ Series_MaxRepairCount__c,
+ Asset_RepairCount__c,
+ Asset_MaxRepairCount__c,
+ // 20210315 gzw 杩藉姞闄愭浜у搧淇℃伅 start
+ IsNew__c,
+ //add 2021.6.4 fxk Start
+ Check_Object__c,
+ //add 2021.6.4 fxk end
+ 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;
+ if (String.isNotBlank(mcae.Asset__r.Product2.ProductURF__c)) {
+ //mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ // mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
+ // mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ // }else{
+ mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
+ // }
+
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ }
+ } else {
+ mcae.IsNew__c = false;
+ if (String.isNotBlank(mcae.Asset__r.Product2.ProductURF__c)) {
+ //mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ // mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
+ // mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ // }else{
+ mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ // }
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ }
+
+ }
+ } else if (mcae.Product_Manual__c <> null) {
+ mcae.IsNew__c = true;
+ if (String.isNotBlank(mcae.Product_Manual__r.ProductURF__c)) {
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
+ // mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ // }else{
+ mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
+ // }
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ }
+ }
+ }
+ if (mcae.Asset__c <> null) {
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '22222222222222' +));
+ // 1 copy URF 杩藉姞
+ // 2 闈瀋opy 鎻愪氦 杩藉姞
+ // 3 闈瀋opy 鏈彁浜� URF 杩藉姞
+ if ((String.isNotBlank(mcae.Asset__r.Product2.ProductURF__c) && String.isNotBlank(copyid) ) ||
+ ((getSaveBtnDisabled() && String.isBlank(copyid)) ||
+ (String.isBlank(copyid) && !getSaveBtnDisabled() && String.isNotBlank(mcae.Asset__r.Product2.ProductURF__c)))) {
+ // if ((getSaveBtnDisabled() && String.isBlank(copyid) )|| (((!getSaveBtnDisabled() && String.isBlank(copyid)) && String.isNotBlank(copyid)) && String.isNotBlank(mcae.Asset__r.Product2.ProductURF__c))){
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '1 + ' + selectedMcaes.size()));
+ selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
+ selectedMcaes.add(mcae);
+ }
+ // else if (String.isNotBlank(mcae.Asset__r.Product2.ProductURF__c)) {
+ // // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '2 + ' + selectedMcaes.size()));
+ // selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
+ // selectedMcaes.add(mcae);
+ // }
+ } else {
+ if ((String.isNotBlank(mcae.Product_Manual__r.ProductURF__c) && String.isNotBlank(copyid) ) ||
+ ((getSaveBtnDisabled() && String.isBlank(copyid)) ||
+ (String.isBlank(copyid) && !getSaveBtnDisabled() && String.isNotBlank(mcae.Product_Manual__r.ProductURF__c)))) {
+ // if (getSaveBtnDisabled() || (!getSaveBtnDisabled() && String.isNotBlank(mcae.Product_Manual__r.ProductURF__c))){
+ newMcaes.add(mcae);
+ }
+ }
+ }
+ }
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '+++++++++++++' + selectedMcaes.size()));
+
+ // 閬告姙娓堛伩銇倐銇伀銉併偋銉冦偗銈掍粯銇戙倠
+ // TODO xudan 涓�瑕с伀鍑恒倠鏄庣窗浠舵暟銇岃冻銈娿仾銇勩偙銉笺偣銇屻亗銈�
+ // 鈶燗ssetA鈥曟槑绱癆銇ф槑绱扮櫥閷�
+ // 鈶sset銇绱㈡潯浠跺鏇淬伀銈堛倞銆丄ssetA銇案閬犮伀鍙栧緱銇с亶銇亜
+ // 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
+ // 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw start
+ // List<Data> datatemp = new List<Data>();
+ // datatemp = getChartData();
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw end
+ for (Asset ast : this.assetRecords) {
+ Boolean isNew = false;
+ // Decimal listPrice = ast.Maintenance_Price_Month__c;
+ //Decimal listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ // Decimal listPrice =0;
+ // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
+ // listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ // }else{
+ Decimal listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ // }
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ 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;
+ // }
+ // // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
+ // 娌℃湁鎻愪氦 鎴栬�呭湪鎶ヤ环鏃朵粠鏂拌绠�
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw start
+ 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));
+ // }
+ }
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw end
+
+ //
+ //
+ //
+ checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal));
+ } else {
+ if (String.isBlank(ast.Product2.ProductURF__c)) continue;
+ //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));
+ }
+ */
+ }
+ listCut(unCheckedAssets);
+
+ totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+
+ system.debug('椤哄簭妫�娴�' + checkedAssets);
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '----------------' + newMcaes.size()));
+ for (Maintenance_Contract_Asset_Estimate__c mcae : newMcaes) {
+ checkedAssets.add(new AssetInfo(checkedAssets.size(), mcae));
+ }
+
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '2222222222222222' + checkedAssets.size()));
+
+ // 鏈�寰�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);
+ // system.debug('缃《妫�娴�8' + ched.rec.MDM_Model_No__c);
+ // system.debug('缃《妫�娴�9' + ched.rec.MDM_Model_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);
+ }
+ }
+ 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
+ //tcm 鍒犻櫎绗�4琛� Maintenance_Contract_No_F__c 鏇挎崲 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.Management_Code__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_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,Product2.ProductURF__r.URFLimitSerial__c,Product2.ProductURF__r.UFR_MaxRepairCount__c,Product2.ProductURF__r.UFR_Maintenance_Price_Month__c,'
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ + 'Product2.ProductURF__r.Maintenance_Price_Year_URF__c, Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c,'
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ + 'Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c, Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c, Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,'
+ + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ + 'CurrentContract_F__r.Contract_Range__c,AssetMark__c FROM Asset WHERE Product2.ProductURF__c != null AND 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
+ //tcm 鍒犻櫎绗�4琛� Maintenance_Contract_No_F__c 鏇挎崲 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.Management_Code__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,';
+ 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 += 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
+ sqlStr += 'Product2.ProductURF__c,Product2.ProductURF__r.URFLimitSerial__c,Product2.ProductURF__r.UFR_MaxRepairCount__c,Product2.ProductURF__r.UFR_Maintenance_Price_Month__c,';
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ sqlStr += 'Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,';
+ sqlStr += 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,';
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ sqlStr += ' CurrentContract_F__r.Contract_Range__c,AssetMark__c FROM Asset WHERE Product2.ProductURF__c != null AND 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];
+ 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.mcae.Check_Object__c = true;
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ System.debug('1540--');
+ } else {
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 start Asset_Model_No__c
+ List<Product2> prd = [select Id,Asset_Model_No__c, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c, Name,
+ ProductURF__c, ProductURF__r.URFLimitSerial__c, ProductURF__r.UFR_MaxRepairCount__c, ProductURF__r.UFR_Maintenance_Price_Month__c
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ , ProductURF__r.Maintenance_Price_Year_URF__c, ProductURF__r.Maintenance_Price_Year_URF_Max__c
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ , ProductURF__r.Maintenance_Price_Year_URF_3__c
+ , ProductURF__r.Maintenance_Price_Year_URF_Max_3__c
+ , ProductURF__r.UFR_Maintenance_Price_Month_3__c
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ from Product2 where Id = :ai.mcae.Product_Manual__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;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ // 闄愭淇℃伅 gzw 20210316 start
+ if (String.isBlank(prd[0].ProductURF__c)) {
+ ai.mcae.Product_Manual__c.addError(prd[0].Name + ' 涓嶆槸闄愭浜у搧锛岃閲嶆柊閫夋嫨!');
+ return;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
+ // ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
+ // }else{
+ ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
+ // }
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ //ai.mcae.Maintenance_Price_YearTXT__c = ai.mcae.Estimate_List_Price__c * 12;
+ ai.orgPrice = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c;
+ ai.uFRPrice = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c;
+ ai.uFRSerial = prd[0].ProductURF__r.URFLimitSerial__c;
+ //ai.uFRRepairCount = prd[0].ProductURF__r.UFR_MaxRepairCount__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ ai.uFRRepairCount = 0;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //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
+ // 闄愭淇℃伅 gzw 20210316 end
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ ai.uFRMaxPrice = prd[0].ProductURF__r.Maintenance_Price_Year_URF_Max__c;
+ ai.uFRMinPrice = prd[0].ProductURF__r.Maintenance_Price_Year_URF__c;
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ ai.uFRMaxPrice3 = prd[0].ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
+ ai.uFRMinPrice3 = prd[0].ProductURF__r.Maintenance_Price_Year_URF_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ }
+ }
+ }
+ // 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
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw start
+ // List<Data> datatemp = new List<Data>();
+ // datatemp = getChartData();
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw end
+ 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;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //Decimal listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ // Decimal listPrice =0;
+ // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
+ // listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ // }else{
+ Decimal listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ // }
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220510 start
+ // Decimal MaxPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
+ // Decimal MinPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF__c;
+ Decimal MaxPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
+ Decimal MinPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c;
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220510 end
+ 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,
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ Adjustment_Upper_price__c = MaxPrice,
+ Adjustment_Lower_price__c = MinPrice,
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ EquipmentGuaranteeFlgTxt__c = ass.rec.EquipmentGuaranteeFlg__c
+ );
+ ass.mcae = mcae;
+ // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw start
+ 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;
+ // }
+ // }
+ // }
+ }
+ // 闄愭鍚堝悓涓嶉渶瑕佷笂涓嬮檺 20210315 gzw end
+
+
+
+ // 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
+ 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)){
+ 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) {
+ System.debug('save start00');
+ this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+ return null;
+ }
+ //add by rentx 2020-11-13 LJPH-BV93RZ end
+ System.debug('save start1');
+ Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+ estimate.recordtypeid = vmMaintenance_Contract;
+ if (changedSubmitPrice) {
+ priceChangeReset();
+ return null;
+ }
+ System.debug('save start2');
+ if (syncEstimate(false, false)) {
+ ComputeLTYRepair();
+ //return null;
+ return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
+ }
+ System.debug('save start3');
+ 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();
+ //SelectAssetEstimateURFController.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();
+
+ 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');
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'syncEstimates--tart'));
+ Boolean hasDatabaseError = false;
+ Savepoint sp = Database.setSavepoint();
+
+ //bug淇
+ //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
+ // this.estimate.Quotation_Determines_Time__c = date.today();
+
+ try {
+ System.debug('checkValidate start----------------');
+ // 淇濆瓨闄愭绯诲垪鏈�澶ф鏁� 20210309
+ Map<String, Integer> limitSerialMap = new Map<String, Integer>();
+ if (!checkValidate()) {
+ return false;
+ }
+ System.debug('checkValidate end----------------');
+ 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;
+ }
+ // 楠岃瘉 闄愭鍚堝悓鐨勮瘽涓嶈兘鐢宠浣庝簬鏍囧噯浠锋牸鏈�浣庝环鐨勯噾棰�
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ if (estimate.Request_quotation_Amount__c < estimate.GuidePrice_Down__c) {
+ this.estimate.Request_quotation_Amount__c.addError('涓嶈兘鐢宠浣庝簬鏍囧噯浠锋牸鏈�浣庝环鐨勯噾棰�');
+ return false;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // 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
+ // List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets);
+
+ // 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);
+ }
+ // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+
+ // URF闄愭鍚堝悓2鏈� LY 20220908 鎺掑簭閫昏緫璋冩暣 start
+ List<lastMContract> urfMContractRes;
+ if (isDecide) {
+ system.debug('鎵ц浜唗cm isDecide');
+ urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
+ } else{
+ system.debug('鎵ц浜唗cm NODecide');
+ urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
+ }
+ // URF闄愭鍚堝悓2鏈� LY 20220908 鎺掑簭閫昏緫璋冩暣 end
+
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ Integer Contract_year = 0;
+ System.debug('this.estimate.Contract_Range__c1:' + this.estimate.Contract_Range__c);
+ if(this.estimate.Contract_Range__c != null){
+ if(this.estimate.Contract_Range__c <= 12){
+ Contract_year = 1;
+ } else{
+ Decimal year = this.estimate.Contract_Range__c / 12;
+ Contract_year = (Integer)year.round(System.RoundingMode.CEILING);
+ }
+ }
+ System.debug('Contract_year1:' + Contract_year);
+ // 闄愭姹囨�讳俊鎭�
+ Map<String, Decimal> uFRSerialMap = getLimitSerialData(Contract_year);
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ // 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;
+
+ // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+
+ //URF闄愭鍚堝悓2鏈� LY 20220908 start
+ //杩藉姞闄愭鍚堝悓淇℃伅
+ this.estimate.URFMContract1__c = urfMContractRes[0].contractId;
+ this.estimate.URF_LastMContract1_NO__c = urfMContractRes[0].contractNo;
+ this.estimate.URF_LastMContract1_ConCount__c = urfMContractRes[0].count;
+
+ //this.estimate.URFMContract2__c = urfMContractRes[1].contractId;
+ this.estimate.URF_LastMContract2_NO__c = urfMContractRes[1].contractNo;
+ this.estimate.URF_LastMContract2_ConCount__c = urfMContractRes[1].count;
+
+ //this.estimate.URFMContract3__c = urfMContractRes[2].contractId;
+ this.estimate.URF_LastMContract3_NO__c = urfMContractRes[2].contractNo;
+ this.estimate.URF_LastMContract3_ConCount__c = urfMContractRes[2].count;
+
+ //this.estimate.URFMContract4__c = urfMContractRes[3].contractId;
+ this.estimate.URF_LastMContract4_NO__c = urfMContractRes[3].contractNo;
+ this.estimate.URF_LastMContract4_ConCount__c = urfMContractRes[3].count;
+
+ //this.estimate.URFMContract5__c = urfMContractRes[4].contractId;
+ this.estimate.URF_LastMContract5_NO__c = urfMContractRes[4].contractNo;
+ this.estimate.URF_LastMContract5_ConCount__c = urfMContractRes[4].count;
+ //URF闄愭鍚堝悓2鏈� LY 20220908 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;
+ // 浣嶇疆璋冩暣 鍦�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;
+ // }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ //鎻愪氦涔嬪悗decide涔嬪墠锛岀粡閿�鍟嗗彉鏇寸殑璇濓紝鍏堟淇℃伅浠ュ彉鏇村悗鐨勭粡閿�鍟嗗厛娆句俊鎭墽琛� thh 20220418 start
+ if(String.isNotBlank(this.estimate.Dealer__c)){
+ checkDealerId = this.estimate.Dealer__c;
+ onChDealerUpdate();
+ }else{
+ this.estimate.Is_RecognitionModel__c = false;
+ }
+ //鎻愪氦涔嬪悗decide涔嬪墠锛岀粡閿�鍟嗗彉鏇寸殑璇濓紝鍏堟淇℃伅浠ュ彉鏇村悗鐨勭粡閿�鍟嗗厛娆句俊鎭墽琛� thh 20220418 end
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ 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;
+ }
+ }
+ }
+ if (!isDecide) {
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ // if (input.uFRSerial=='URF-V' && Integer.valueOf(estimate.URF_V_MaxRepairCount__c)!=0){
+ // input.uFRRepairCount = Integer.valueOf(estimate.URF_V_MaxRepairCount__c);
+ // }else if (input.uFRSerial=='URF-P' && Integer.valueOf(estimate.URF_P_MaxRepairCount__c)!=0) {
+ // input.uFRRepairCount = Integer.valueOf(estimate.URF_P_MaxRepairCount__c);
+ // }else{
+ // input.uFRRepairCount= 0;
+ // }
+ if (input.uFRSerial=='URF-V') {
+ input.uFRRepairCount = Integer.valueOf(estimate.URF_V_MaxRepairCount__c);
+ }
+ if (input.uFRSerial=='URF-P') {
+ input.uFRRepairCount = Integer.valueOf(estimate.URF_P_MaxRepairCount__c);
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // 闄愭淇℃伅淇濆瓨
+ input.mcae.URF_Series__c = input.uFRSerial;
+ input.mcae.Series_RepairCount__c = 0;
+ input.mcae.Series_MaxRepairCount__c = uFRSerialMap.get(input.uFRSerial);
+ input.mcae.Asset_RepairCount__c = 0;
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ input.mcae.Asset_MaxRepairCount__c = input.uFRRepairCount * Contract_year;
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+
+
+ // 闄愭淇℃伅淇濆瓨
+ }
+
+
+
+
+ // 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, IsNew__c, EquipmentGuaranteeFlgTxt__c,
+ //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+ Check_Object__c,
+ //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+ // 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,
+ ////add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+ Check_Object__c = target.Check_Object__c,
+ //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+ Estimate_IsNew__c = target.IsNew__c,
+ //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;
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ this.contract.old_Is_RecognitionModel__c = this.estimate.Is_RecognitionModel__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ 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;
+ this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
+ 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-06-04 缁欏悎鍚�1璧嬪�肩殑鍚屾椂锛岀粰鍘诲勾鍚堝悓璧嬪�� start
+ this.contract.Last_year_service_contract__c = this.estimate.LastMContract1__c;
+ //add by renrx 2021-06-04 缁欏悎鍚�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
+
+ //URF闄愭鍚堝悓2鏈� LY 20220908 start
+ //杩藉姞涓婃湡闄愭鍚堝悓淇℃伅 start
+ this.contract.URF_LastMContract1__c = this.estimate.URFMContract1__c;
+ this.contract.URF_LastMContract1_startDate__c = this.estimate.URFMContract1_startDate__c;
+ this.contract.URF_LastMContract1_endDate__c = this.estimate.URFMContract1_endDate__c;
+ this.contract.URF_LastMContract1_NO__c = this.estimate.URF_LastMContract1_NO__c;
+ this.contract.URF_LastMContract1_ConCount__c = this.estimate.URF_LastMContract1_ConCount__c;
+
+ //this.contract.URF_LastMContract2__c = this.estimate.URFMContract2__c;
+ this.contract.URF_LastMContract2_NO__c = this.estimate.URF_LastMContract2_NO__c;
+ this.contract.URF_LastMContract2_ConCount__c = this.estimate.URF_LastMContract2_ConCount__c;
+
+ //this.contract.URF_LastMContract3__c = this.estimate.URFMContract3__c;
+ this.contract.URF_LastMContract3_NO__c = this.estimate.URF_LastMContract3_NO__c;
+ this.contract.URF_LastMContract3_ConCount__c = this.estimate.URF_LastMContract3_ConCount__c;
+
+ //this.contract.URF_LastMContract4__c = this.estimate.URFMContract4__c;
+ this.contract.URF_LastMContract4_NO__c = this.estimate.URF_LastMContract4_NO__c;
+ this.contract.URF_LastMContract4_ConCount__c = this.estimate.URF_LastMContract4_ConCount__c;
+
+ //this.contract.URF_LastMContract5__c = this.estimate.URFMContract5__c;
+ this.contract.URF_LastMContract5_NO__c = this.estimate.URF_LastMContract5_NO__c;
+ this.contract.URF_LastMContract5_ConCount__c = this.estimate.URF_LastMContract5_ConCount__c;
+ // 杩藉姞涓婃湡闄愭鍚堝悓淇℃伅 end
+ //URF闄愭鍚堝悓2鏈� LY 20220908 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) {
+ SelectAssetEstimateURFController.ComputeLTYRepair(targetEstimateId);
+ }
+ // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'syncEstimates--end'));
+ 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()));
+ }
+ 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
+
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ if (!String.isNotBlank(estimate.URF_V_MaxRepairCount__c)) {
+ this.estimate.URF_V_MaxRepairCount__c.addError('璇烽�夋嫨URF-V鏈�澶уぇ淇鏁�!');
+ return null;
+ }
+ if (!String.isNotBlank(estimate.URF_P_MaxRepairCount__c)) {
+ this.estimate.URF_V_MaxRepairCount__c.addError('璇烽�夋嫨URF-V鏈�澶уぇ淇鏁�!');
+ return null;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 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;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 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;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 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;
+ }
+ // 閮ㄥ搧渚涚郸鍋滄銇=鍝併伅銈ㄣ儵銉�
+ 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;
+ }
+ 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)) {
+ //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;
+ }
+ }
+ return rtn;
+ }
+
+ // 浠锋牸鍙樻洿鍚庡厠闅嗘姤浠峰墠閲嶆柊璁$畻浠锋牸
+ @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;}
+
+ //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
+
+ //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 fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ public Boolean CheckRows {get; private set;}
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ // 闄愭浠锋牸 add by gzw start
+ public Decimal uFRPrice {get; private set;}
+ // 闄愭绯诲垪
+ public String uFRSerial {get; private set;}
+ // 鏈�澶уぇ淇鏁�
+ public Decimal uFRRepairCount {get; private set;}
+
+ // 闄愭浠锋牸 add by gzw end
+
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ public Decimal uFRMaxPrice {get; set;}
+ public Decimal uFRMinPrice {get; set;}
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ public Decimal uFRMaxPrice3 {get; set;}
+ public Decimal uFRMinPrice3 {get; set;}
+ //URF闄愭鍚堝悓2鏈� LY 20220811 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;
+ this.uFRPrice = 0;
+ this.uFRRepairCount = 0;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+ this.CheckRows = true;
+ // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ this.uFRMaxPrice = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
+ this.uFRMinPrice = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRMaxPrice3 = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
+ this.uFRMinPrice3 = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 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
+ // 杩藉姞闄愭淇℃伅
+ , URF_Series__c = mcae.URF_Series__c,
+ Series_RepairCount__c = mcae.Series_RepairCount__c,
+ Series_MaxRepairCount__c = mcae.Series_MaxRepairCount__c,
+ Asset_RepairCount__c = mcae.Asset_RepairCount__c,
+ Asset_MaxRepairCount__c = mcae.Asset_MaxRepairCount__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
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //this.uFRPrice = record.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ this.uFRPrice = record.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ this.uFRSerial = record.Product2.ProductURF__r.URFLimitSerial__c;
+ //this.uFRRepairCount = record.Product2.ProductURF__r.UFR_MaxRepairCount__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRRepairCount = 0;
+ // if (this.uFRSerial=='URF-V'){
+ // this.uFRRepairCount=2;
+ // }else{
+ // this.uFRRepairCount=3;
+ // }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ this.uFRMaxPrice = record.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
+ this.uFRMinPrice = record.Product2.ProductURF__r.Maintenance_Price_Year_URF__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRMaxPrice3 = record.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
+ this.uFRMinPrice3 = record.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 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
+ // 杩藉姞闄愭淇℃伅
+ , URF_Series__c = mcae.URF_Series__c,
+ Series_RepairCount__c = mcae.Series_RepairCount__c,
+ Series_MaxRepairCount__c = mcae.Series_MaxRepairCount__c,
+ Asset_RepairCount__c = mcae.Asset_RepairCount__c,
+ Asset_MaxRepairCount__c = mcae.Asset_MaxRepairCount__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.proName = mcae.Product_Manual__r.Name;
+ this.etGFlg = mcae.Product_Manual__r.EquipmentGuaranteeFlg__c;
+ //this.uFRPrice = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ this.uFRSerial = mcae.Product_Manual__r.ProductURF__r.URFLimitSerial__c;
+ //this.uFRRepairCount = mcae.Product_Manual__r.ProductURF__r.UFR_MaxRepairCount__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRRepairCount =0;
+ this.uFRPrice = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 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
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ this.uFRMaxPrice = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
+ this.uFRMinPrice = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF__c;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRMaxPrice3 = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
+ this.uFRMinPrice3 = mcae.Product_Manual__r.ProductURF__r.Maintenance_Price_Year_URF_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 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;
+ //this.uFRPrice = record.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
+ this.uFRSerial = record.Product2.ProductURF__r.URFLimitSerial__c;
+ //this.uFRRepairCount = record.Product2.ProductURF__r.UFR_MaxRepairCount__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRRepairCount =0;
+ this.uFRPrice = record.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ this.uFRMaxPrice = record.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
+ this.uFRMinPrice = record.Product2.ProductURF__r.Maintenance_Price_Year_URF__c;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ this.uFRMaxPrice3 = record.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
+ this.uFRMinPrice3 = record.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ }
+ }
+
+ WebService static String pageDecide(String strId) {
+ String rs = '';
+ SelectAssetEstimateURFController saec = new SelectAssetEstimateURFController();
+ 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 = '';
+ SelectAssetEstimateURFController saec = new SelectAssetEstimateURFController();
+ 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;
+ }
+
+ // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start 浼犲叆 startDate 锛屾坊鍔� lastMContractMap1
+ 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);
+ // 璁$畻绌虹櫧鏈�
+ 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;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220908 start
+ //瀵归檺娆″悎鍚岃繘琛屾帓搴�
+ public static List<lastMContract> getURFMContract(List<AssetInfo> checkedAssets, Date startDate) {
+ Map<String, lastMContract> urfMContractMap = new Map<String, lastMContract>();
+ Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
+ for (AssetInfo ai : checkedAssets) {
+ lastMContract urfMC = new lastMContract(ai.rec.URF_Maintenance_Contract__c, ai.rec.URF_Maintenance_Contract__r.Management_Code__c, ai.rec.URF_Maintenance_Contract__r.Contract_End_Date__c, 1);
+ if (String.isNotBlank(ai.rec.URF_Maintenance_Contract__c)) {
+ if (urfMContractMap.containsKey(ai.rec.URF_Maintenance_Contract__c)) {
+ urfMContractMap.get(ai.rec.URF_Maintenance_Contract__c).count++;
+ } else {
+ urfMContractMap.put(ai.rec.URF_Maintenance_Contract__c, urfMC);
+ }
+ }
+ }
+ List<lastMContract> listResulttemp = new List<lastMContract>();
+ List<lastMContract> listResult = new List<lastMContract>();
+
+ for ( lastMContract ll : urfMContractMap.values()) {
+ listResulttemp.add(ll);
+ }
+ listResulttemp.sort();
+ if (listResulttemp.size() >= 5){
+ for (Integer i = 0; i < listResulttemp.size(); i++) {
+
+ if (listResulttemp.size() >= i + 1) {
+ listResult.add(listResulttemp[i]);
+ }
+ }
+ }else {
+ for (Integer i = 0; i < listResulttemp.size(); i++) {
+ if (listResulttemp.size() >= i + 1) {
+ listResult.add(listResulttemp[i]);
+ }
+ }
+ for (Integer i = listResulttemp.size(); i < 5; i++) {
+ listResult.add(new lastMContract(null, null, null, null));
+ }
+ }
+
+ return listResult;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220908 end
+
+
+ // 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;
+ // }
+ // 璁$畻闄愭绯诲垪娆℃暟
+ public Map<String, Decimal> getLimitSerialData(Integer Contract_year) {
+ Map<String, Decimal> limitSerial = new Map<String, Decimal>();
+
+ for (AssetInfo input : this.checkedAssets) {
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ if (String.isNotBlank(input.uFRSerial) && input.uFRSerial=='URF-V'){
+ input.uFRRepairCount = Integer.valueOf(estimate.URF_V_MaxRepairCount__c);
+ }else if (String.isNotBlank(input.uFRSerial) && input.uFRSerial=='URF-P'){
+ input.uFRRepairCount = Integer.valueOf(estimate.URF_P_MaxRepairCount__c);
+ }else{
+ input.uFRRepairCount = 0;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ if (String.isNotBlank(input.uFRSerial) && limitSerial.containsKey(input.uFRSerial)) {
+ limitSerial.put(input.uFRSerial, limitSerial.get(input.uFRSerial) + input.uFRRepairCount * Contract_year);
+ } else {
+ limitSerial.put(input.uFRSerial, input.uFRRepairCount * Contract_year);
+ }
+ //XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ // 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('鐐规缁撴灉蹇呭~');
+ // }
+ // }
+ }
+ return limitSerial;
+ }
+
+ // // 浠锋牸浣撶郴 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;
+ // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+ }
+ }
+ }
\ No newline at end of file
diff --git a/force-app/main/default/classes/SelectAssetEstimateURFController.cls-meta.xml b/force-app/main/default/classes/SelectAssetEstimateURFController.cls-meta.xml
new file mode 100644
index 0000000..45aa0a0
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateURFController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>44.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls b/force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls
new file mode 100644
index 0000000..90e1d12
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls
@@ -0,0 +1,1594 @@
+@isTest
+private class SelectAssetEstimateURFControllerTest {
+ private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ static Asset createAsset(String input, String accountid, String dcId, String hpId, String serialNo, String prId, String mark ) {
+ Asset asset = new Asset();
+ asset.Name = input;
+ asset.AccountId = accountid;
+ asset.Department_Class__c = dcId;
+ asset.Hospital__c = hpId;
+ asset.SerialNumber = serialNo;
+ asset.Product2Id = prId;
+ asset.InstallDate = Date.today();
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ //鍦ㄦ帴鏀跺弬鏁扮殑鏃跺�欐柊澧炰簡String绫诲瀷鐨凪ark瀛楁,浠ュ強鍦ㄨ皟鐢ㄨ鏂规硶鏃朵紶閫掍簡String绫诲瀷鐨凪ark瀛楁
+ asset.AssetMark__c = mark;
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+ insert asset;
+ return asset;
+ }
+
+ public class AssetInfo {
+ 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 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
+ );
+ this.isManual = true;
+ this.rec_checkBox_c = false;
+ this.orgPrice = 0;
+ }
+ }
+
+ // 2銇よ绌嶃倐銈娿亴銇傘倞銆佽Κ銇偟銉撱偝銉炽仺鍚屾湡銇欍倠銇儐銈广儓
+ static testMethod void testDecide_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+ StaticParameter.EscapeSyncProduct2Trigger = true;
+ StaticParameter.EscapeAccountTrigger = true;
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1};
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ System.Test.startTest();
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.save();
+ controller.approvalProcess();
+
+ // 缁翠慨鍚堝悓鎶ヤ环1
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ controller = new SelectAssetEstimateURFController();
+ controller.init();
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ // System.assertEquals(5, controller.productCount2);
+ //鍥犱负榛樿鏌ヨ鐨勪繚鏈夎澶囩被鍨嬩负涓绘満
+ System.assertEquals(2,controller.productCount2);
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+
+ controller.getEnablePrintContract();
+ controller.getUnDecideBtnDisabled();
+ controller.getDecideBtnDisabled();
+ controller.getApprovalBtnDisabled();
+ controller.getSaveBtnDisabled();
+ controller.getPrintBtnDisabled();
+ controller.getPageDisabled();
+ controller.savePrintFlg();
+
+ System.assertEquals(10, controller.productCount);
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ System.assertEquals(11, controller.productCount);
+ System.assertEquals(1, controller.productCount3);
+
+ controller.productIdx = 1;
+ controller.refreshProductData();
+
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+
+ List<Maintenance_Contract_Asset__c> mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id];
+ System.assertEquals(1, mcaList.size());
+ System.assertEquals('asset01', mcaList[0].Asset__r.Name);
+
+ controller.print();
+ System.Test.stopTest();
+ }
+ }
+
+ // 2銇よ绌嶃倐銈娿亴銇傘倞銆佽Κ銇偟銉撱偝銉炽仺鍚屾湡銇欍倠銇儐銈广儓
+ static testMethod void testDecide_02() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+ StaticParameter.EscapeSyncProduct2Trigger = true;
+ StaticParameter.EscapeAccountTrigger = true;
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'涓绘満');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ // Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ // Name = 'contract estimate 1',
+ // RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ // Contract_Esti_Start_Date__c = Date.today(),
+ // Contract_Range__c = 2,
+ // Maintenance_Contract__c = contract.Id
+ // );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti2;
+
+ System.Test.startTest();
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.save();
+ controller.approvalProcess();
+
+ // // 缁翠慨鍚堝悓鎶ヤ环1
+ // Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ // controller = new SelectAssetEstimateURFController();
+ // controller.init();
+ // System.assertEquals(5, controller.productCount2);
+
+ // controller.getEnablePrintContract();
+ // controller.getUnDecideBtnDisabled();
+ // controller.getDecideBtnDisabled();
+ // controller.getApprovalBtnDisabled();
+ // controller.getSaveBtnDisabled();
+ // controller.getPrintBtnDisabled();
+ // controller.getcontactBtnDisabled();
+ // controller.getPageDisabled();
+ // controller.savePrintFlg();
+
+ // System.assertEquals(10, controller.productCount);
+ // controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ // controller.exchangeAsset();
+ // System.assertEquals(11, controller.productCount);
+ // System.assertEquals(1, controller.productCount3);
+
+ // controller.productIdx = 1;
+ // controller.refreshProductData();
+
+ // controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ // controller.estimate.Contract_Range__c = 2;
+ // controller.save();
+
+ // List<Maintenance_Contract_Asset__c> mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id];
+ // System.assertEquals(1, mcaList.size());
+ // System.assertEquals('asset01', mcaList[0].Asset__r.Name);
+
+ // controller.print();
+
+ // 缁翠慨鍚堝悓鎶ヤ环2銇焙瀹氥儹銈搞儍銈�
+ Apexpages.currentPage().getParameters().put('id', contactEsti2.Id);
+ SelectAssetEstimateURFController controller2 = new SelectAssetEstimateURFController();
+ controller2.init();
+
+ controller2.unCheckedAssetsView[0][1].rec_CheckBox_c = true;
+ controller2.unCheckedAssetsView[0][3].rec_CheckBox_c = true;
+ System.assertEquals(10, controller2.productCount);
+ controller2.exchangeAsset();
+ System.assertEquals(12, controller2.productCount);
+ System.assertEquals(2, controller2.productCount3);
+
+ // contactEsti1 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti1.Id];
+ // System.assertEquals(true, contactEsti1.IsSyncing__c);
+
+ controller2.checkedAssets[0].mcae.Check_Result__c = 'test0';
+ controller2.checkedAssets[1].mcae.Check_Result__c = 'test1';
+ controller2.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller2.estimate.Contract_Range__c = 2;
+ controller2.estimate.Process_Status__c = '鎵瑰噯';
+ controller2.decide();
+
+ // contactEsti1 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti1.Id];
+ // System.assertEquals(false, contactEsti1.IsSyncing__c);
+ // contactEsti2 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti2.Id];
+ // System.assertEquals(true, contactEsti2.IsSyncing__c);
+
+ controller2.undecide();
+
+ //mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id order by Asset__r.Name];
+ //System.assertEquals(2, mcaList.size());
+ //System.assertEquals('asset02', mcaList[0].Asset__r.Name);
+ //System.assertEquals('asset04', mcaList[1].Asset__r.Name);
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void testcopyid_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.lastFriYearsPriceSum =3322;
+ controller.lastSecYearsPriceSum = 1222;
+ controller.alertString ='';
+ controller.alertString2 ='';
+ controller.alertString3 ='';
+ controller.getSaveBtnDisabled();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ SelectAssetEstimateURFController.pageDecide(contactEsti1.Id);
+ SelectAssetEstimateURFController.pageUndecide(contactEsti1.Id);
+// controller.ComputeLTYRepair();
+ controller.ShowLTYRepair();
+ }
+ }
+
+ static testMethod void testInit_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ try {
+ SelectAssetEstimateURFController controller001 = new SelectAssetEstimateURFController();
+ controller001.init();
+ } catch (Exception e) {
+
+ }
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ hospital.Is_Active__c = '鏈夋晥';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'鑰楁潗');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ Maintenance_Contract_Asset__c mca2 = new Maintenance_Contract_Asset__c();
+ mca2.Asset__c = asset01.Id;
+ mca2.Estimate_List_Price__c = 100;
+ mca2.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1, mca2};
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id,
+ Contract_Esti_Start_Date__c = Date.today().addDays(1),
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ Apexpages.currentPage().getParameters().put('completion', '1');
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+
+ controller.init();
+ controller.firstPage();
+ controller.currPage = 3;
+ controller.previousPage();
+ controller.endPage();
+ controller.currPage = 200;
+ controller.nextPage();
+ controller.recordNumChange();
+ controller.getSaveBtnDisabled();
+ //controller.ComputeLTYRepair();
+ controller.cancel();
+ controller.saveAndCancel();
+ }
+ }
+
+ static testMethod void testInit_02() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 淇悊銈掍綔鎴愩仚銈�01
+ Repair__c repair01 = new Repair__c();
+ repair01.Account__c = dep.Id;
+ repair01.Department_Class__c = strategicDep[0].Id;
+ repair01.Hospital__c = hospital.Id;
+ repair01.Delivered_Product__c = asset01.Id;
+ repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 缁翠慨鍚堝悓鍒ゆ柇鏃ャ亴銈点兗銉撱偣濂戠磩銇腑闁撹竞銈娿伄鏃ヤ粯
+ repair01.FSE_Work_Location__c = '涓婃捣';
+ repair01.Agreed_Date__c = Date.today().addDays(-1);
+ insert repair01;
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Contract_Esti_Start_Date__c = Date.today().addDays(1),
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ Test.startTest();
+ controller.ComputeLTYRepair();
+ controller.saveAndCancel();
+
+ SelectAssetEstimateURFController.ComputeLTYRepair(controller.targetEstimateId);
+ Test.stopTest();
+ }
+ }
+
+ static testMethod void testInit_03() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ Apexpages.currentPage().getParameters().put('completion', '3');
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ }
+ }
+
+ static testMethod void testApprovalProcess_01() {
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'鑰楁潗');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.Payment_Plan_Sum_First__c = 1;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1};
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.checkedAssets[0].mcae.Check_Result__c = 'OK';
+ controller.approvalProcess();
+
+ // 鎻愪氦寰呭鎵规椂锛屾洿鏂板凡濉啓鐢宠鐘舵��
+ List<Maintenance_Contract_Estimate__c> mcenew = [select id,ApprovalProcess_Status__c from Maintenance_Contract_Estimate__c where id = :contactEsti1.Id];
+ //System.assertEquals('宸插~鍐欏畬骞剁敵璇�', mcenew[0].ApprovalProcess_Status__c);
+
+ }
+ }
+
+ static testMethod void EditUnitTest() {
+
+ //Test.startTest();
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+ system.runAs(u3) {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ //SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ //// 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ //PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ //entry.UnitPrice = 0;
+ //entry.IsActive = true;
+ //entry.UseStandardPrice = false;
+ //entry.CurrencyIsoCode = 'CNY';
+ //entry.Product2Id = productA.Id;
+ //insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'鑰楁潗');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.Payment_Plan_Sum_First__c = 1;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
+ System.Test.startTest();
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.text1 = 'S:Name';
+ controller.cond1 = 'equals';
+ controller.val1 = 'asset01,asset02';
+ controller.searchBtn();
+ controller.cond1 = 'equals';
+ controller.val1 = 'asset02';
+ controller.searchBtn();
+ controller.cond1 = 'contains';
+ controller.val1 = ' asset02';
+ controller.searchBtn();
+ controller.cond1 = 'notequals';
+ controller.searchBtn();
+ controller.cond1 = 'starts with';
+ controller.searchBtn();
+ Test.stopTest();
+ }
+ }
+ // 琛ュ厖test 瀹為檯鑱斿姩
+ static testMethod void testInit_04() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+
+
+ system.runAs(u3) {
+ Achievement_linkage__c oppMapping = new Achievement_linkage__c();
+ oppMapping.Name = '01';
+ oppMapping.Consumption_rate_Lower__c = 0;
+ oppMapping.Consumption_rate_Upper__c = 50; // 閲嶈銇椼仸銈傘偍銉┿兗銇伅銇倝銇亜
+ oppMapping.PriceCount_Lower__c = -40;
+ oppMapping.PriceCount_Upper__c = -30;
+
+ insert oppMapping;
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.priceChangeReset();
+ //controller.getChartData();
+ //System.assertEquals(1, controller.dataList.size());
+ controller.save();
+ controller.changedAfterPrint = true;
+ controller.checkChangedAfterPrint();
+ }
+ }
+
+
+ static testMethod void testnotargetEstimateId_dataList() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+ system.runAs(u3) {
+ try {
+ SelectAssetEstimateURFController controller001 = new SelectAssetEstimateURFController();
+ controller001.init();
+ } catch (Exception e) {
+
+ }
+ Achievement_linkage__c oppMapping = new Achievement_linkage__c();
+ oppMapping.Name = '01';
+ oppMapping.Consumption_rate_Lower__c = 0;
+ oppMapping.Consumption_rate_Upper__c = 50; // 閲嶈銇椼仸銈傘偍銉┿兗銇伅銇倝銇亜
+ oppMapping.PriceCount_Lower__c = -40;
+ oppMapping.PriceCount_Upper__c = -30;
+
+ insert oppMapping;
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+ // 涓婁竴鏈熺淮淇悎鍚�
+ Maintenance_Contract__c lastcontract = new Maintenance_Contract__c();
+ lastcontract.Name = 'tect contract';
+ lastcontract.Not_Upper_limit_reason__c = 'tect contract';
+ lastcontract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ lastcontract.Hospital__c = hospital.Id;
+ lastcontract.Department_Class__c = strategicDep[0].Id;
+ lastcontract.Department__c = dep.Id;
+ lastcontract.Contract_Start_Date__c = Date.today().addMonths(-11);
+ lastcontract.Contract_End_Date__c = Date.today().addMonths(1);
+ lastcontract.Service_Contract_Staff__c = u3.Id;
+ lastcontract.First_Estimate_Date__c = Date.today().addMonths(-1);
+ lastcontract.First_contract_usage_Rate__c = 110;
+ lastcontract.URF_Contract__c = true;
+ lastcontract.agree_Upper_limit__c = true;
+ insert lastcontract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c lastmca1 = new Maintenance_Contract_Asset__c();
+ lastmca1.Asset__c = asset01.Id;
+ lastmca1.Estimate_List_Price__c = 100;
+ lastmca1.Estimate_Cost__c = 100;
+ lastmca1.Maintenance_Contract__c = lastcontract.Id;
+
+
+ insert new Maintenance_Contract_Asset__c[] {lastmca1};
+
+ asset01.CurrentContract_F__c = lastcontract.Id;
+ asset01.CurrentContract_F_asset__c = lastmca1.Id;
+ update asset01;
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ Maintenance_Contract_Asset__c mca2 = new Maintenance_Contract_Asset__c();
+ mca2.Asset__c = asset01.Id;
+ mca2.Estimate_List_Price__c = 100;
+ mca2.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1, mca2};
+ // Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ // RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ // Name = 'contract estimate 1',
+ // Maintenance_Contract__c = contract.Id,
+ // Contract_Esti_Start_Date__c = Date.today().addDays(1),
+ // Request_quotation_Amount__c = 1,
+ // EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ // mainTalksTime__c = 1,
+ // talksStartDate__c = Date.today(),
+ // Discount_reason__c = 'test',
+ // Improve_ConsumptionRate_Idea__c = 'test'
+ // );
+ // insert contactEsti1;
+
+ // Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ // mcae1.Asset__c = asset01.Id;
+ // mcae1.Adjustment_Upper_price__c = 1;
+ // mcae1.Adjustment_Lower_price__c = 1;
+ // mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ // mcae1.Estimate_List_Price__c = 1000;
+ // mcae1.Check_Result__c = 'OK';
+
+ // Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ // mcae2.Asset__c = asset01.Id;
+ // mcae2.Adjustment_Upper_price__c = 1;
+ // mcae2.Adjustment_Lower_price__c = 1;
+ // mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ // mcae2.Estimate_List_Price__c = 1000;
+ // mcae2.Check_Result__c = 'OK';
+
+ // insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+
+ controller.init();
+ // controller.firstPage();
+ // controller.currPage = 3;
+ // controller.previousPage();
+ // controller.endPage();
+ // controller.currPage = 200;
+ // controller.nextPage();
+ // controller.recordNumChange();
+ // controller.getSaveBtnDisabled();
+ // //controller.ComputeLTYRepair();
+ // controller.cancel();
+ // controller.saveAndCancel();
+ }
+ }
+
+ static testMethod void testSyncEstimate() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ insert u3;
+
+
+
+ system.runAs(u3) {
+ Achievement_linkage__c oppMapping = new Achievement_linkage__c();
+ oppMapping.Name = '01';
+ oppMapping.Consumption_rate_Lower__c = 0;
+ oppMapping.Consumption_rate_Upper__c = 50; // 閲嶈銇椼仸銈傘偍銉┿兗銇伅銇倝銇亜
+ oppMapping.PriceCount_Lower__c = -40;
+ oppMapping.PriceCount_Upper__c = -30;
+
+ insert oppMapping;
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ ProductURF__c purf = new ProductURF__c(UFR_MaxRepairCount__c = 2,URFLimitSerial__c = 'URF-P',Maintenance_Price_Year_URF__c = 1200);
+ insert purf;
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,ProductURF__c = purf.Id);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.URF_Contract__c = true;
+ contract.agree_Upper_limit__c = true;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 2,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test',
+ GuidePrice_Up__c = 1
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateURFController controller = new SelectAssetEstimateURFController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.priceChangeReset();
+ // controller.getChartData();
+ // System.assertEquals(1, controller.dataList.size());
+ controller.save();
+ controller.changedAfterPrint = true;
+ controller.syncEstimate(true,true);
+ }
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls-meta.xml b/force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls-meta.xml
new file mode 100644
index 0000000..f3bac1f
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateURFControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>41.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/SelectAssetEstimateVMController.cls b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
new file mode 100644
index 0000000..29b14c9
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
@@ -0,0 +1,4458 @@
+/*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 Integer num{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
+
+ //2022 鏁呴殰鍝佸姞璐� 鏄惁鏄疐SE鎿嶄綔 鎻愪环鍑忎环鐢宠鎸夐挳鏄惁鍙
+ public Boolean isFSE { get; set; }
+ public Boolean disableEmailBtn { get; set; }
+ public Boolean sendEmailSuccess { get; set; }
+ public Boolean hasSendEmail { get; set; }
+
+
+ public Boolean isNotFSE { get; set; }
+
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14
+ public Boolean isOrverYear { get; set;}
+ public Decimal MaintenancePriceYear { get; set; }
+ public Decimal Denominator {get; set; }
+ public Decimal Accrued {get; set; }
+ public String ProductModel{get;set;}
+ public String Category{get;set;}
+ public Decimal Consumption_rate_Gurante{get;set;}
+
+
+ // 妫�绱㈡寜閽�
+ 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';
+ integer num=0;
+ num++;
+ num++;
+ //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);
+ }
+ }
+ }
+ // public Map<String,repair__c> getNewrep(List<Asset> assetRecords) {
+ // List<String> assnoList = new List<String>();
+ // // 鏁呴殰鍝佸姞璐�20221226
+ // for (Asset ast : assetRecords) {
+ // if (ast.Return_Without_Repair__r.Agreed_Date__c == null) {
+ // if (!assnoList.contains(ast.id)) {
+ // assnoList.add(ast.id);
+ // }
+ // }
+ // }
+ // List<repair__c> repairs2 = [SELECT Id,name,Repair_List_Price_formula__c,Delivered_Product__r.id ,CreatedDate
+ // FROM repair__c
+ // WHERE Delivered_Product__c in :assnoList order by Delivered_Product__c ,CreatedDate desc];
+ // Map<String,repair__c> assNewRepMap = new Map<String,repair__c>();
+ // for (repair__c rep : repairs2) {
+ // if (assNewRepMap.get(rep.Delivered_Product__r.id)==null){
+ // assNewRepMap.put(rep.Delivered_Product__r.id,rep);
+ // }
+ // if (assNewRepMap.get(rep.Delivered_Product__r.id)!=null) {
+ // if (assNewRepMap.get(rep.Delivered_Product__r.id).CreatedDate < rep.CreatedDate) {
+ // assNewRepMap.remove(rep.Delivered_Product__r.id);
+ // assNewRepMap.put(rep.Delivered_Product__r.id,rep);
+ // }
+ // }
+ // }
+ // return assNewRepMap;
+ // }
+ public void NextMaintenanceContract() {
+ // 20220810 璇环2鏈熷紑鍙�
+ List<String> asslocalList = new List<String>();
+ List<String> mcalocalList = new List<String>();
+ Map<Id, Maintenance_Contract__c> map3 = new Map<Id, Maintenance_Contract__c>();
+
+ List<Maintenance_Contract_Asset__c> mcaupdateList = new List<Maintenance_Contract_Asset__c>();
+ for (AssetInfo ass : this.checkedAssets) {
+ if (!ass.isManual) {
+ asslocalList.add(ass.rec.Id);
+ map3.put(ass.rec.Id,this.contract);
+ }
+ }
+ System.debug('asslocalList====%%%' +asslocalList);
+ List<Maintenance_Contract_Asset__c> mcalist1 = [select id,Asset__c,Next_Maintenance_Contract__c,Maintenance_Contract__c
+ from Maintenance_Contract_Asset__c
+ where id in (select CurrentContract_F_asset__c
+ from asset
+ where id in :asslocalList and CurrentContract_F_asset__c!=null)];
+ System.debug('mcalist1====%%%' +mcalist1);
+ System.debug('map3====%%%' +map3);
+ for (Maintenance_Contract_Asset__c mca : mcalist1) {
+ Maintenance_Contract_Asset__c mca3 = new Maintenance_Contract_Asset__c();
+ if (map3.containsKey(mca.Asset__c)) {
+ mca3.id = mca.id;
+ mca3.Next_Maintenance_Contract__c = map3.get(mca.Asset__c).id;
+ System.debug('mca3.id====%%%' +mca3.id);
+ if (mca3.id!=null&&!mcaupdateList.contains(mca3)) {
+ mcaupdateList.add(mca3);
+ }
+ }
+ }
+ System.debug('mcaupdateList====%%%' +mcaupdateList);
+ if (mcaupdateList!=null&&!mcaupdateList.isEmpty()) {
+ update mcaupdateList;
+ }
+ System.debug('鏇存柊瀹屾垚mcaupdateList');
+ }
+
+ private void getSortedUnCheckedInfoList(List<Asset> assetList) {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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();
+ // Map<String,repair__c> assNewRepMap = new Map<String,repair__c>();
+ // assNewRepMap = getNewrep(assetList);
+ num++;
+ num++;
+ 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) {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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() {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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_Service__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,'
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+ + 'CurrentContract_F__r.Gurantee_Renew_startDate__c,'
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ + 'Return_Without_Repair__r.Repair_List_Price_formula__c,Return_Without_Repair__r.Agreed_Date__c,'
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ + 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+ + 'CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,'
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end'
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+ // +'Guarantee_period_for_products__c,'
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+
+ + '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) {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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) {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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() {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ // 瑕嬬銈傘倞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;
+ }
+
+
+ public Boolean gettoApprovalBtnDisabled() {
+ if (String.isBlank(this.estimate.IS_Reduced_price_approval__c)) {
+ return true;
+ }
+ return false;
+ }
+ // 2022鏁呴殰鍝佸姞璐� 鎻愪氦鍑忎环鎸夐挳
+ public Boolean getSendEmailBtnDisabled() {
+ 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;
+ }
+ if(hasSendEmail == true){
+ return true;
+ }
+ return false;
+
+ }
+
+ //2022/12/27 鏁呴殰鍝佸姞璐� 鏂板鎻愪氦淇悊鍑忎环 鎸夐挳浠呭 寮犳櫠 寮犳牘姒曞強 绠$悊鍛樺彲瑙�
+ public Boolean getApprovalBtnNewDisabled() {
+ String userName = UserInfo.getName();
+ String uProfileId = UserInfo.getProfileId();
+ String uProfileName = [SELECT Name FROM Profile WHERE Id =: uProfileId].Name;
+ if (uProfileName == '绯荤粺绠$悊鍛�' || userName == '寮� 鏍╂' || userName == '寮� 鏅�') {
+ return false;
+ }
+
+ return true;
+
+ }
+
+ // 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 != '涓嶆壒鍑�'
+ //涓婇檺鍚堝悓 LY 20230113 start
+ // && this.estimate.Process_Status__c != '鐢宠涓�'
+ //涓婇檺鍚堝悓 LY 20230113 start
+ ) {
+ 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,IS_Reduced_price_approval__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
+ //涓婇檺鍚堝悓 20230103 LY start
+ // ,Limit_Price_Amount__c
+ //涓婇檺鍚堝悓 20230103 LY end
+ , 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
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220419 start
+ , Maintenance_Contract__r.Open_RenewalQuotation__c,Maintenance_Contract__r.VM_Contract_Check__c
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220419 end'
+ //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋 lt 20211221 start
+ //, Maintenance_Contract__r.Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
+ //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋 lt 20211221 end
+ // URF闄愭鍚堝悓2鏈� LY 20220811 start
+ ,URF_P_MaxRepairCount__c,URF_V_MaxRepairCount__c
+ ,URFMContract1__c,URFMContract1_startDate__c,URFMContract1_endDate__c
+ //,URFMContract2__c,URFMContract3__c,URFMContract4__c,URFMContract5__c
+ ,URF_LastMContract1_NO__c,URF_LastMContract2_NO__c,URF_LastMContract3_NO__c,URF_LastMContract4_NO__c,URF_LastMContract5_NO__c
+ ,URF_LastMContract1_ConCount__c,URF_LastMContract2_ConCount__c,URF_LastMContract3_ConCount__c,URF_LastMContract4_ConCount__c,URF_LastMContract5_ConCount__c
+ // URF闄愭鍚堝悓2鏈� LY 20220811 end
+ //鏁呴殰鍝佸姞璐� 2022/12/16 start
+ ,Hospital_Salesdepartment__c
+ ,Send_Email_To_RC__c
+ //鏁呴殰鍝佸姞璐� 2022/12/16 end
+
+ FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
+ //HWAG-B399Q8 2018/08/20 娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c end
+ //鏁呴殰鍝佸姞璐� 2023/1/3 start
+ hasSendEmail = this.estimate.Send_Email_To_RC__c;
+ //鏁呴殰鍝佸姞璐� 2023/1/3 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 PageReference tochange() {
+ estimate.IS_Reduced_price_approval__c = '瀹℃壒涓�';
+ return null;
+ }
+
+ public PageReference tochange2() {
+ estimate.IS_Reduced_price_approval__c = '鏃犲叓鎶樹互涓�';
+ return null;
+ }
+ 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');
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+ typeresult = null;
+ AssetHandler.disabled = true;
+ 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
+
+ //2022 鏁呴殰鍝佸姞璐� 鑾峰彇褰撳墠user绠�妗ame
+ String uProfileId = UserInfo.getProfileId();
+ String UserProfileName = [SELECT Name FROM Profile WHERE Id =: uProfileId].Name;
+ if(UserProfileName == '2F3_鍚堝悓缁�' || UserProfileName == '绯荤粺绠$悊鍛�'){
+ isFSE = false;
+ }else{
+ isFSE = true;
+ }
+
+ 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_Service__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,
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+ CurrentContract_F__r.Gurantee_Renew_startDate__c,
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ Return_Without_Repair__r.Repair_List_Price_formula__c,
+ Return_Without_Repair__r.Agreed_Date__c,
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
+ CurrentContract_F__r.Contract_Range__c, AssetMark__c,
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+ CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+ // 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 鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ , URF_Maintenance_Contract__c
+ , URF_Maintenance_Contract__r.Management_Code__c
+ , URF_Maintenance_Contract__r.Contract_End_Date__c
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+ // //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+ // ,Maintenance_Price_Year__c
+
+ // //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+ FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '鑰楁潗' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty_Service__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_Service__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_Service__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,
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+ // Asset__r.CurrentContract_F_asset__r.startDateGurantee__c,
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+ 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,
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+ Asset__r.CurrentContract_F__r.Gurantee_Renew_startDate__c,
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+ Asset__r.CurrentContract_F__r.Open_RenewalQuotation__c,Asset__r.CurrentContract_F__r.VM_Contract_Check__c
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ , Asset__r.URF_Maintenance_Contract__c
+ , Asset__r.URF_Maintenance_Contract__r.Management_Code__c
+ , Asset__r.URF_Maintenance_Contract__r.Contract_End_Date__c
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+ // , Asset__r.Guarantee_period_for_products__c
+
+ // ,Asset__r.Maintenance_Price_Year__c
+ // ,Maintenance_Contract__r.FM__c
+ // ,Asset__r.Product2.Intra_Trade_Gurantee_RMB__c
+ // ,Asset__r.Product2.Asset_Model_No__c
+ // ,Asset__r.Product2.Category4__c
+ // ,Maintenance_Contract__r.Consumption_rate_Gurante__c
+ // //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+
+ 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;
+
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+
+ // if(createdDate.daysBetween(mca.Asset__r.CurrentContract_F_asset__r.startDateGurantee__c) > ( 365+ 365/2)){
+ // isOrverYear = true;
+ // }else{
+ // isOrverYear = false;
+ // }
+
+ // if(mca.Asset__r.Maintenance_Price_Year__c >0){
+ // MaintenancePriceYear = mca.Asset__r.Maintenance_Price_Year__c;
+ // }
+ // if(mca.Maintenance_Contract__r.FM__c>0){
+ // Denominator = mca.Maintenance_Contract__r.FM__c;
+ // }
+ // if (mca.Asset__r.Product2.Intra_Trade_Gurantee_RMB__c >0) {
+ // Accrued = mca.Asset__r.Product2.Intra_Trade_Gurantee_RMB__c;
+ // }
+ // if (mca.Asset__r.Product2.Asset_Model_No__c != null ) {
+ // ProductModel = mca.Asset__r.Product2.Asset_Model_No__c;
+ // }
+ // if (mca.Asset__r.Product2.Category4__c != null) {
+ // Category = mca.Asset__r.Product2.Category4__c;
+ // }
+ // if (mca.Maintenance_Contract__r.Consumption_rate_Gurante__c != null) {
+ // Consumption_rate_Gurante = mca.Maintenance_Contract__r.Consumption_rate_Gurante__c;
+ // }
+
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+ 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,
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+ Asset__r.CurrentContract_F__r.Open_RenewalQuotation__c,Asset__r.CurrentContract_F__r.VM_Contract_Check__c,
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ Asset__r.URF_Maintenance_Contract__c,
+ IS_Reduced_price_approval__c,
+ Asset__r.URF_Maintenance_Contract__r.Management_Code__c,
+ Asset__r.URF_Maintenance_Contract__r.Contract_End_Date__c,
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ LastMContract_Price__c,
+ Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
+ Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+ // Asset__r.CurrentContract_F_asset__r.startDateGurantee__c,
+ // Asset__r.Product2.Intra_Trade_Gurantee_RMB__c,
+ //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+ 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,
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ Repair_Price_pass__c,
+ Repair_Price_Auto__c,
+ Third_Party_Return__c,
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ 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
+ 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>();
+ // Map<String,repair__c> assNewRepMap = new Map<String,repair__c>();
+ // assNewRepMap = getNewrep(this.assetRecords);
+ 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,estimate));
+ } 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() {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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_Service__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, '
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+ + 'CurrentContract_F__r.Gurantee_Renew_startDate__c,'
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ + 'Return_Without_Repair__r.Repair_List_Price_formula__c,Return_Without_Repair__r.Agreed_Date__c,'
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ + '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,'
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+ + 'CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,'
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ + '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_Service__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_Service__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,';
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+ sqlStr += 'CurrentContract_F__r.Gurantee_Renew_startDate__c,';
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ sqlStr += 'Return_Without_Repair__r.Repair_List_Price_formula__c,Return_Without_Repair__r.Agreed_Date__c,';
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ 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,';
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+ sqlStr += 'CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,';
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ sqlStr += 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,';
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ 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_Service__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_Service__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_Service__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_Service__c asc limit : sqlLimit];
+ }
+ sqlStr += ' ORDER BY ID,IF_Warranty_Service__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>();
+ // Map<String,repair__c> assNewRepMap = new Map<String,repair__c>();
+ // assNewRepMap = getNewrep(this.assetRecords);
+ 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();
+ }
+
+ //2022 鏁呴殰鍝佸姞璐� 鍒ゆ柇淇悊閲戦鏄惁浣庝簬8鎶樹互涓�
+ public PageReference judgePrice(Boolean islessPrice){
+ disableEmailBtn = islessPrice;
+ System.debug(LoggingLevel.INFO, '*** disableEmailBtn: ' + disableEmailBtn);
+ return null;
+ }
+
+ //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,IS_Reduced_price_approval__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(Repair_List_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(Repair_List_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(Repair_List_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(Repair_List_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() {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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,IS_Reduced_price_approval__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(Repair_List_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(Repair_List_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(Repair_List_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(Repair_List_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鏂规硶');
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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');
+ Oly_TriggerHandler.bypass('Maintenance_Contract_Asset__c');
+ Oly_TriggerHandler.bypass('AssetHandler');
+ // Oly_TriggerHandler.bypass('AssetTrigger');
+ Oly_TriggerHandler.bypass('AssetHandlerCheck');
+ Oly_TriggerHandler.bypass('SetContractEstimatePriceHandler');
+ StaticParameter.EscapeVMCTrigger = true;
+
+ //add by rentx 2020-11-13 LJPH-BV93RZ start
+ if (estimate.Contract_Range__c == null) {
+ this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+ return null;
+ }
+ NextMaintenanceContract();
+ //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;
+ }
+ AssetHandler.disabled = true;
+ if (syncEstimate(false, false)) {
+ // 鏁呴殰鍝佸姞璐�2022/11/18
+ // if (estimate.IS_Reduced_price_approval__c=='鍚�' || estimate.IS_Reduced_price_approval__c=='瀹℃壒涓�') {
+ // Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+ // psr.setObjectId(this.estimate.id);
+ // Approval.ProcessResult submitResult = Approval.process(psr);
+ ComputeLTYRepair();
+ // return null;
+ // }
+
+ return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
+ }
+ return null;
+ }
+ public PageReference toApprovalProcess() {
+ Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+ estimate.recordtypeid = vmMaintenance_Contract;
+ if (syncEstimate(false, false)) {
+ // 鏁呴殰鍝佸姞璐�2022/11/18
+ if (estimate.IS_Reduced_price_approval__c=='鍚�' || estimate.IS_Reduced_price_approval__c=='瀹℃壒涓�') {
+ Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+ psr.setObjectId(this.estimate.id);
+ Approval.ProcessResult submitResult = Approval.process(psr);
+ }
+ 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;
+ // }
+ // }
+ // }
+ NextMaintenanceContract();
+ 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;
+ }
+ /**
+ * FSE淇悊鍊ゅ紩銇嶃儭銉笺儷鎻愬嚭 2022鏁呴殰鍝佸姞璐�
+ */
+
+ public PageReference sendEmail() {
+ System.debug(LoggingLevel.INFO, '*** in sendEmail: ');
+ this.estimate.Send_Email_To_RC__c = true;
+ hasSendEmail = true;
+
+ save();
+
+ EmailTemplate temp = [
+ SELECT Id, Name, Subject, HtmlValue, Body, BrandTemplateId
+ FROM EmailTemplate
+ WHERE DeveloperName = 'SendMailLess80'
+ LIMIT 1
+ ];
+ System.debug(LoggingLevel.INFO, '*** temp: '+ temp);
+
+ // //绠�妗d笉纭畾 寰呬慨鏀�
+ // List<String> sendEaddress = new List<String>();
+ // // for (User u : [SELECT Email FROM User WHERE Profile.Name ='2F3_鍚堝悓缁�' AND IsActive=true]) {
+ // // sendEaddress.add(u.Email);
+ // // }
+
+ // for (User u : [SELECT Email FROM User WHERE Profile.Name ='ATEST_鏁呴殰鍝�' AND IsActive=true]) {
+ // sendEaddress.add(u.Email);
+ // }
+ // System.debug(LoggingLevel.INFO, '*** sendEaddress: ' + sendEaddress);
+
+ // System.debug(LoggingLevel.INFO, '*** this.estimate: ' + this.estimate);
+
+ // Messaging.SingleEmailMessage email = Messaging.renderStoredEmailTemplate(temp.Id,null, this.estimate.Id);
+ // email.setSaveAsActivity(false);
+ // email.setToAddresses(sendEaddress);
+
+ // Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email});
+ // System.debug(LoggingLevel.INFO, '*** sendEmail end: ');
+
+ // Messaging.SendEmailResult[] results = messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email});
+ // for (Integer i = 0; i < results.size(); i++) {
+ // if (results[i].success == true) {
+ // System.debug(LoggingLevel.INFO, '*** sendEmail true: ');
+ // }
+ // }
+ // 鏁版嵁楠岃瘉
+ // 楠岃瘉 寮�濮嬫棩鏈燂紝鏈�鏃╁厑璁稿埗瀹氭棩涔嬪墠鍗婂勾
+ 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 null;
+ }
+ // 楠岃瘉 鐢宠鎶ヤ环閲戦锛岄渶瑕佸ぇ浜�0
+ if (estimate.Request_quotation_Amount__c <= 0 || estimate.Request_quotation_Amount__c == null) {
+ this.estimate.Request_quotation_Amount__c.addError('鐢宠鎶ヤ环閲戦蹇呴渶澶т簬0');
+ return null;
+ }
+ // 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 null;
+ }
+
+ if (this.estimate.talksStartDate__c == null) {
+ this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
+ return null;
+ }
+
+ if (String.isBlank(this.estimate.Discount_reason__c)) {
+ this.estimate.Discount_reason__c.addError('浠锋牸鐢宠鐞嗙敱蹇呭~');
+ return null;
+ }
+ if (String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
+ this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
+ return null;
+ }
+ }
+ if (estimate.Contract_Range__c == null) {
+ this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+ return null;
+ }
+
+ //鎶勯�佷汉 寮犵鏉般�佸紶鏅躲�佸紶鏍╂ setCcAddresses
+ List<String> ccAddress = new List<String>();
+ for (User u : [Select Email,Id,Alias__c from User where IsActive =true and (Alias__c='寮犵鏉�' OR Alias__c='寮犳櫠' OR Alias__c='寮犳牘姒�') ]) {
+ ccAddress.add(u.Email);
+ }
+ System.debug(LoggingLevel.INFO, '*** ccAddress: ' + ccAddress);
+
+ //鍗庡寳 瑗垮寳 寮犵鏉�
+ //涓滃寳 寮犵鏉� 寮犳.
+ //鍗庝笢 鍒樻捣宄�
+ //鍗庡崡 瑗垮崡 鍒樻捣宄� 寮犻鍗�
+ List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
+ for (User u : [Select Email,Id,Alias__c from User where (Alias__c='寮犵鏉�' OR Alias__c='寮犳.' OR Alias__c='鍒樻捣宄�' OR Alias__c='寮犻鍗�') and IsActive =true ]) {
+
+ Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
+
+ email = Messaging.renderStoredEmailTemplate(temp.Id, u.Id, this.estimate.Id);
+ // email = Messaging.renderStoredEmailTemplate(temp.Id, null, this.estimate.Id);
+
+ email.setTemplateId(temp.Id);
+ email.setSaveAsActivity(false);
+ email.setCcAddresses(ccAddress);
+ System.debug(LoggingLevel.INFO, '*** this.estimate.Hospital_Salesdepartment__c: ' + this.estimate.Hospital_Salesdepartment__c);
+ if(u.Alias__c=='寮犵鏉�' && (this.estimate.Hospital_Salesdepartment__c =='1.鍗庡寳' || this.estimate.Hospital_Salesdepartment__c =='3.瑗垮寳' || this.estimate.Hospital_Salesdepartment__c =='2.涓滃寳')){
+ email.setTargetObjectId(u.Id);
+ emails.add(email);
+
+ }else if(u.Alias__c=='寮犳.' && (this.estimate.Hospital_Salesdepartment__c =='2.涓滃寳')){
+ email.setTargetObjectId(u.Id);
+ emails.add(email);
+
+ }else if(u.Alias__c=='鍒樻捣宄�' &&(this.estimate.Hospital_Salesdepartment__c =='5.鍗庝笢' ||this.estimate.Hospital_Salesdepartment__c =='6.鍗庡崡' || this.estimate.Hospital_Salesdepartment__c =='4.瑗垮崡')){
+ email.setTargetObjectId(u.Id);
+ emails.add(email);
+
+
+ }else if(u.Alias__c=='寮犻鍗�' &&( this.estimate.Hospital_Salesdepartment__c =='6.鍗庡崡' || this.estimate.Hospital_Salesdepartment__c =='4.瑗垮崡')){
+ email.setTargetObjectId(u.Id);
+ emails.add(email);
+ }
+ // }else if(u.Alias__c=='鏁呴殰鍝乀est2Test' && (this.estimate.Hospital_Salesdepartment__c =='5.鍗庝笢')){
+ // email.setTargetObjectId(u.Id);
+ // emails.add(email);
+ // System.debug(LoggingLevel.INFO, '*** test setTargetObjectId: ' + email);
+ // }
+ // email.setTargetObjectId(u.Id);
+
+ System.debug(LoggingLevel.INFO, '*** email: ' + email);
+ }
+
+ if(emails.size()>0){
+ try{
+ Messaging.sendEmail(emails);
+ sendEmailSuccess = true;
+ System.debug(LoggingLevel.INFO, '*** sendEmail hasSendEmail: ' + hasSendEmail);
+ System.debug(LoggingLevel.INFO, '*** sendEmailSuccess: ' + sendEmailSuccess);
+ ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.INFO,'閭欢鍙戦�佹垚鍔燂紒'));
+ }catch(Exception e){
+ System.debug(e.getMessage());
+ sendEmailSuccess = false;
+ // hasSendEmail = false;
+ ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.WARNING,'閭欢鍙戦�佸け璐ワ紝璇疯仈绯荤鐞嗗憳锛�'));
+ }
+ }
+
+ 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;
+ NextMaintenanceContract();
+ // 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;
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ }
+
+ /**
+ * 鍗板埛銉曘儵銈般伄銇裤倰淇濆瓨
+ */
+ @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();
+ integer i =0;
+ i++;
+ i++;
+
+ //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;
+ }
+ i++;
+ i++;
+ 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;
+ }
+ i++;
+ i++;
+ i++;
+ i++;
+ // 杩藉姞涓婃湡鍚堝悓淇℃伅 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;
+
+ //URF闄愭鍚堝悓2鏈� LY 20220908 start
+ List<lastMContract> urfMContractRes;
+ if (isDecide) {
+ system.debug('鎵ц浜唗cm isDecide');
+ urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
+ } else{
+ system.debug('鎵ц浜唗cm NODecide');
+ urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
+ }
+ this.estimate.URFMContract1__c = urfMContractRes[0].contractId;
+ this.estimate.URF_LastMContract1_NO__c = urfMContractRes[0].contractNo;
+ this.estimate.URF_LastMContract1_ConCount__c = urfMContractRes[0].count;
+
+ //this.estimate.URFMContract2__c = urfMContractRes[1].contractId;
+ this.estimate.URF_LastMContract2_NO__c = urfMContractRes[1].contractNo;
+ this.estimate.URF_LastMContract2_ConCount__c = urfMContractRes[1].count;
+
+ //this.estimate.URFMContract3__c = urfMContractRes[2].contractId;
+ this.estimate.URF_LastMContract3_NO__c = urfMContractRes[2].contractNo;
+ this.estimate.URF_LastMContract3_ConCount__c = urfMContractRes[2].count;
+
+ //this.estimate.URFMContract4__c = urfMContractRes[3].contractId;
+ this.estimate.URF_LastMContract4_NO__c = urfMContractRes[3].contractNo;
+ this.estimate.URF_LastMContract4_ConCount__c = urfMContractRes[3].count;
+
+ //this.estimate.URFMContract5__c = urfMContractRes[4].contractId;
+ this.estimate.URF_LastMContract5_NO__c = urfMContractRes[4].contractNo;
+ this.estimate.URF_LastMContract5_ConCount__c = urfMContractRes[4].count;
+ //URF闄愭鍚堝悓2鏈� LY 20220908 end
+ i++;
+ i++;
+ i++;
+ i++;
+ // 鍘熸柟娉�
+ // 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);
+ }
+ i++;
+ i++;
+ i++;
+ i++;
+ // 鍚堝悓缁撴潫棰勫畾鏃ャ倰绠楀嚭
+ 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;
+ //鎻愪氦涔嬪悗decide涔嬪墠锛岀粡閿�鍟嗗彉鏇寸殑璇濓紝鍏堟淇℃伅浠ュ彉鏇村悗鐨勭粡閿�鍟嗗厛娆句俊鎭墽琛� thh 20220418 start
+ //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
+ //鎻愪氦涔嬪悗decide涔嬪墠锛岀粡閿�鍟嗗彉鏇寸殑璇濓紝鍏堟淇℃伅浠ュ彉鏇村悗鐨勭粡閿�鍟嗗厛娆句俊鎭墽琛� thh 20220418 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;
+ System.debug(LoggingLevel.INFO, '*** insertthis.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();
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
+ // list 淇敼 map
+ Map<id, Maintenance_Contract__c> mcList = new Map<id, Maintenance_Contract__c>();
+
+ //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� 鏁呴殰鍝佹爣璇�
+ Boolean hasThirdPartyReturnc = false;
+ Boolean hasSurchargeDefective = false;
+
+ 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
+
+ num++;
+ num++;
+ num++;
+ num++;
+ // 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);
+
+ //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 start 2022/12/30
+ if(input.mcae.Third_Party_Return__c == true){
+ hasThirdPartyReturnc = true;
+ }
+ System.debug(LoggingLevel.INFO, '*** input.mcae: ' + input.mcae);
+ // System.debug(LoggingLevel.INFO, '*** input.mcae.Surcharge_Defective_Contract__c: ' + input.mcae.Surcharge_Defective_Contract__c);
+ if(input.mcae.Repair_Price__c>0 && input.mcae.Third_Party_Return__c == false){
+ hasSurchargeDefective = true;
+ }
+ //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 end 2022/12/30
+
+ }
+ }
+
+ //鏁呴殰鍝佸姞璐� 缁翠慨鍚堝悓銆佹姤浠� 绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 start 2022/12/30
+ System.debug(LoggingLevel.INFO, '*** hasThirdPartyReturnc: ' + hasThirdPartyReturnc);
+ System.debug(LoggingLevel.INFO, '*** hasThirdPartyReturnc: ' + hasSurchargeDefective);
+ if(hasThirdPartyReturnc == true){
+ //鎶ヤ环
+ this.estimate.Third_Party_Return__c = true;
+ this.estimate.Surcharge_Defective_Contract__c = false;
+ //缁翠慨鍚堝悓
+ this.contract.Third_Party_Return_Contract__c = this.estimate.Third_Party_Return__c;
+ this.contract.Surcharge_Defective_Contract__c = this.estimate.Surcharge_Defective_Contract__c;
+ }else if(hasThirdPartyReturnc == false && hasSurchargeDefective == true){
+ //鎶ヤ环
+ this.estimate.Surcharge_Defective_Contract__c = true;
+ this.estimate.Third_Party_Return__c = false;
+ //缁翠慨鍚堝悓
+ this.contract.Third_Party_Return_Contract__c = this.estimate.Third_Party_Return__c;
+ this.contract.Surcharge_Defective_Contract__c = this.estimate.Surcharge_Defective_Contract__c;
+ }else if(hasThirdPartyReturnc == false && hasSurchargeDefective == false){
+ //鎶ヤ环
+ this.estimate.Surcharge_Defective_Contract__c = false;
+ this.estimate.Third_Party_Return__c = false;
+ //缁翠慨鍚堝悓
+ this.contract.Third_Party_Return_Contract__c = this.estimate.Third_Party_Return__c;
+ this.contract.Surcharge_Defective_Contract__c = this.estimate.Surcharge_Defective_Contract__c;
+ }
+ //鏁呴殰鍝佸姞璐� 缁翠慨鍚堝悓銆佹姤浠� 绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 end 2022/12/30
+
+ // 鏈綋銇繚瀛樸仐銇熺磵鍏ユ鍣ㄣ亴銇傘倢銇板墛闄�
+ // AssetHandler.disabled = true;
+ List<Maintenance_Contract_Asset_Estimate__c> selectedAsset = [SELECT Id, Name,IS_Reduced_price_approval__c, 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,
+ IS_Reduced_price_approval__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
+
+ // 鏁呴殰鍝佸姞璐� 2022/12/30 start
+ ,Third_Party_Return__c
+ ,Surcharge_Defective_Contract__c
+ // 鏁呴殰鍝佸姞璐� 2022/12/30 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
+
+ //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰掋�佹晠闅滃搧鍔犺垂 鏍囪瘑start
+ Third_Party_Return__c = target.Third_Party_Return__c,
+ Surcharge_Defective_Contract__c = target.Surcharge_Defective_Contract__c,
+ //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰掋�佹晠闅滃搧鍔犺垂 鏍囪瘑end
+
+ 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
+
+ //URF闄愭鍚堝悓2鏈� LY 20220908 start
+ //杩藉姞涓婃湡闄愭鍚堝悓淇℃伅 start
+ this.contract.URF_LastMContract1__c = this.estimate.URFMContract1__c;
+ this.contract.URF_LastMContract1_startDate__c = this.estimate.URFMContract1_startDate__c;
+ this.contract.URF_LastMContract1_endDate__c = this.estimate.URFMContract1_endDate__c;
+ this.contract.URF_LastMContract1_NO__c = this.estimate.URF_LastMContract1_NO__c;
+ this.contract.URF_LastMContract1_ConCount__c = this.estimate.URF_LastMContract1_ConCount__c;
+
+ //this.contract.URF_LastMContract2__c = this.estimate.URFMContract2__c;
+ this.contract.URF_LastMContract2_NO__c = this.estimate.URF_LastMContract2_NO__c;
+ this.contract.URF_LastMContract2_ConCount__c = this.estimate.URF_LastMContract2_ConCount__c;
+
+ //this.contract.URF_LastMContract3__c = this.estimate.URFMContract3__c;
+ this.contract.URF_LastMContract3_NO__c = this.estimate.URF_LastMContract3_NO__c;
+ this.contract.URF_LastMContract3_ConCount__c = this.estimate.URF_LastMContract3_ConCount__c;
+
+ //this.contract.URF_LastMContract4__c = this.estimate.URFMContract4__c;
+ this.contract.URF_LastMContract4_NO__c = this.estimate.URF_LastMContract4_NO__c;
+ this.contract.URF_LastMContract4_ConCount__c = this.estimate.URF_LastMContract4_ConCount__c;
+
+ //this.contract.URF_LastMContract5__c = this.estimate.URFMContract5__c;
+ this.contract.URF_LastMContract5_NO__c = this.estimate.URF_LastMContract5_NO__c;
+ this.contract.URF_LastMContract5_ConCount__c = this.estimate.URF_LastMContract5_ConCount__c;
+ // 杩藉姞涓婃湡闄愭鍚堝悓淇℃伅 end
+ //URF闄愭鍚堝悓2鏈� LY 20220908 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() {
+ integer num=0;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ num++;
+ 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 () {
+ AssetHandler.disabled = true;
+ Oly_TriggerHandler.bypass('Maintenance_Contract_Asset__c');
+ Oly_TriggerHandler.bypass('AssetHandler');
+ Oly_TriggerHandler.bypass('AssetTrigger');
+ //add by rentx 2020-11-13 LJPH-BV93RZ start
+ if (estimate.Contract_Range__c == null) {
+ this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+ return null;
+ }
+ NextMaintenanceContract();
+ //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, VM_Contract_Check__c,Open_RenewalQuotation__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, VM_Contract_Check__c,Open_RenewalQuotation__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() {
+ integer i =0;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ 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.绠$悊鍛樿烦杩囷紝
+ //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220413
+ if (input.rec.CurrentContract_F__r.Open_RenewalQuotation__c == false && 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') {
+
+ // modify by lc 20220607 澶氬勾淇濈画绛惧拰瀹炵哗杩炲姩鐘舵�佸搴� start
+ Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
+ Decimal monthCon = (Decimal)noOfDays/365*12;
+ // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+ //if (input.rec.CurrentContract_F__r.Gurantee_Estimate_startDate__c > Date.today()) {
+ // gzw 20220630 寮�閫氱画绛炬姤浠锋潈闄愬悗锛岃秴杩�6涓湀涔熷彲浠ョ画绛�
+ // 缁鎯呭喌 鈶� 涓婃湡鍚堝悓 Open_RenewalQuotation__c & 6涓湀浠ュ唴 鈶� VM_Contract_Check__c Open_RenewalQuotation__c 2涓兘鎵撻挬
+ // 鈶� 2涓紑鍏抽兘鎵撳紑 鈶M_Contract_Check__c鎵撳紑 灏忎簬6涓湀
+ if (!((this.contract.Open_RenewalQuotation__c && input.rec.CurrentContract_F__r.VM_Contract_Check__c) || (input.rec.CurrentContract_F__r.VM_Contract_Check__c && monthCon < 6))) {
+ if(monthCon < 6){
+ input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍙互鍔犲叆鏈嶅姟鍚堝悓锛屽姞鍏ヤ环鏍艰鑱旂郴鏈嶅姟绠$悊閮ㄣ��');
+ }else{
+ input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
+ }
+ //input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
+ rtn = false;
+ }
+ /*if (input.rec.CurrentContract_F__r.Gurantee_Renew_startDate__c > Date.today()) {
+ input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 绗竴涓澶囩粨鏉熷悗鍙互鍒朵綔鎶ヤ环銆�');
+ rtn = false;
+ }*/
+ //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+ // modify by lc 20220607 澶氬勾淇濈画绛惧拰瀹炵哗杩炲姩鐘舵�佸搴� end
+
+ }
+ //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));
+ //澶氬勾淇濈粨鏉熸棩鍒扮画绛惧紑濮嬫棩涔嬮棿鐨勭┖鐧芥湡澶т簬30鏃�,涓斿湪鍚堝悓寮�濮嬫棩鍓嶄笁涓湀鍐呮病鏈夌偣妫�璁板綍,鎶ラ敊 20220429 thh start
+ if(input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract' &&
+ input.rec.CurrentContract_F__r.Contract_End_Date__c > input.rec.CurrentContract_F__r.Gurantee_Renew_startDate__c.addDays(30)
+ && (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;
+ }
+ //澶氬勾淇濈粨鏉熸棩鍒扮画绛惧紑濮嬫棩涔嬮棿鐨勭┖鐧芥湡澶т簬30鏃�,涓斿湪鍚堝悓寮�濮嬫棩鍓嶄笁涓湀鍐呮病鏈夌偣妫�璁板綍,鎶ラ敊 20220429 thh end
+
+ // 鍚堝悓寮�濮嬫棩澶т簬涓婃湡鍚堝悓缁撴潫鏃ュ姞涓�涓湀锛屼笖娌℃湁鐐规鏃ユ湡鎴栬�呮渶杩戜竴娆$偣妫�鏃ユ湡鏄�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_Service__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;
+ }
+ }
+ }
+ integer i =0;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ //contractStartDateChange();
+ }
+
+
+ public class AssetInfo {
+ // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 褰撳墠鏍囪
+ public Boolean etGFlg {get; set;}
+ public Integer lineNo {get; private set;}
+ public Decimal Repair_Price_Auto {get; set;}
+ public String Agreed_Date{get; 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 Maintenance_Contract_Estimate__c estimate {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,Maintenance_Contract_Estimate__c estimate) {
+ this.lineNo = lineNo;
+ this.rec = record;
+ this.estimate = new Maintenance_Contract_Estimate__c();
+ this.estimate.IS_Reduced_price_approval__c = estimate.IS_Reduced_price_approval__c;
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c!=null) {
+ // this.Agreed_Date = '涓嶄负绌�';
+ // }
+ // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c==null) {
+ // this.Agreed_Date = '涓虹┖';
+ // if (assNewRepMap.get(record.id)!=null) {
+ // this.Repair_Price_Auto = assNewRepMap.get(record.id).Repair_List_Price_formula__c;
+ // }
+ // }
+ // if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null&&record.Asset_situation__c != '淇悊涓�') {
+ // this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+ // }
+ if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null) {
+ this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+ }
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ 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,
+ Repair_Price_pass__c = mcae.Repair_Price_pass__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
+ //(2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰�
+ Third_Party_Return__c = mcae.Third_Party_Return__c
+ );
+ if ((this.mcae.Repair_Price__c==null&&this.Repair_Price_Auto!=null)||(this.estimate.IS_Reduced_price_approval__c == '鍚�')) {
+ this.mcae.Repair_Price__c = this.Repair_Price_Auto;
+ }
+ if (this.estimate.IS_Reduced_price_approval__c=='鏄�'||this.estimate.IS_Reduced_price_approval__c==null) {
+ if (this.mcae.Repair_Price__c!=null) {
+ this.mcae.Repair_Price_pass__c = this.mcae.Repair_Price__c;
+ }
+ }
+ 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,
+ Repair_Price_pass__c = mcae.Repair_Price_pass__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
+ //(2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰�
+ Third_Party_Return__c = mcae.Third_Party_Return__c
+ );
+ 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;
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ // if (record.Return_Without_Repair__r.Agreed_Date__c!=null) {
+ // this.Agreed_Date = '涓嶄负绌�';
+ // }else{
+ // this.Agreed_Date = '涓虹┖';
+ // }
+ if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null) {
+ this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+ }
+ // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ 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;
+ }
+ // public AssetInfo(Integer lineNo, Asset record, Map<String,repair__c> assNewRepMap) {
+ // this.lineNo = lineNo;
+ // this.rec = record;
+ // // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+ // // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c!=null) {
+ // // this.Agreed_Date = '涓嶄负绌�';
+ // // }
+ // // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c==null) {
+ // // this.Agreed_Date = '涓虹┖';
+ // // if (assNewRepMap.get(record.id)!=null) {
+ // // this.Repair_Price_Auto = assNewRepMap.get(record.id).Repair_List_Price_formula__c;
+ // // }
+ // // }
+ // // if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null&&record.Asset_situation__c != '淇悊涓�') {
+ // // this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+ // // }
+ // if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null) {
+ // this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+ // }
+ // // (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+ // 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;
+ }
+
+ //URF闄愭鍚堝悓2鏈� LY 20220908 start
+ //瀵归檺娆″悎鍚岃繘琛屾帓搴�
+ public static List<lastMContract> getURFMContract(List<AssetInfo> checkedAssets, Date startDate) {
+ Map<String, lastMContract> urfMContractMap = new Map<String, lastMContract>();
+ Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
+ for (AssetInfo ai : checkedAssets) {
+ lastMContract urfMC = new lastMContract(ai.rec.URF_Maintenance_Contract__c, ai.rec.URF_Maintenance_Contract__r.Management_Code__c, ai.rec.URF_Maintenance_Contract__r.Contract_End_Date__c, 1);
+ if (String.isNotBlank(ai.rec.URF_Maintenance_Contract__c)) {
+ if (urfMContractMap.containsKey(ai.rec.URF_Maintenance_Contract__c)) {
+ urfMContractMap.get(ai.rec.URF_Maintenance_Contract__c).count++;
+ } else {
+ urfMContractMap.put(ai.rec.URF_Maintenance_Contract__c, urfMC);
+ }
+ }
+ }
+ List<lastMContract> listResulttemp = new List<lastMContract>();
+ List<lastMContract> listResult = new List<lastMContract>();
+
+ for ( lastMContract ll : urfMContractMap.values()) {
+ listResulttemp.add(ll);
+ }
+ listResulttemp.sort();
+ if (listResulttemp.size() >= 5){
+ for (Integer i = 0; i < listResulttemp.size(); i++) {
+
+ if (listResulttemp.size() >= i + 1) {
+ listResult.add(listResulttemp[i]);
+ }
+ }
+ }else {
+ for (Integer i = 0; i < listResulttemp.size(); i++) {
+ if (listResulttemp.size() >= i + 1) {
+ listResult.add(listResulttemp[i]);
+ }
+ }
+ for (Integer i = listResulttemp.size(); i < 5; i++) {
+ listResult.add(new lastMContract(null, null, null, null));
+ }
+ }
+
+ return listResult;
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220908 end
+
+ 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
diff --git a/force-app/main/default/classes/SelectAssetEstimateVMController.cls-meta.xml b/force-app/main/default/classes/SelectAssetEstimateVMController.cls-meta.xml
new file mode 100644
index 0000000..45aa0a0
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateVMController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>44.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls b/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls
new file mode 100644
index 0000000..20cc008
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls
@@ -0,0 +1,1614 @@
+@isTest
+private class SelectAssetEstimateVMControllerTest {
+ private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ static Asset createAsset(String input, String accountid, String dcId, String hpId, String serialNo, String prId, String mark ) {
+ Asset asset = new Asset();
+ asset.Name = input;
+ asset.AccountId = accountid;
+ asset.Department_Class__c = dcId;
+ asset.Hospital__c = hpId;
+ asset.SerialNumber = serialNo;
+ asset.Product2Id = prId;
+ asset.InstallDate = Date.today();
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ //鍦ㄦ帴鏀跺弬鏁扮殑鏃跺�欐柊澧炰簡String绫诲瀷鐨凪ark瀛楁,浠ュ強鍦ㄨ皟鐢ㄨ鏂规硶鏃朵紶閫掍簡String绫诲瀷鐨凪ark瀛楁
+ asset.AssetMark__c = mark;
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+ insert asset;
+ return asset;
+ }
+
+ public class AssetInfo {
+ 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 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
+ );
+ this.isManual = true;
+ this.rec_checkBox_c = false;
+ this.orgPrice = 0;
+ }
+ }
+
+ // 2銇よ绌嶃倐銈娿亴銇傘倞銆佽Κ銇偟銉撱偝銉炽仺鍚屾湡銇欍倠銇儐銈广儓
+ static testMethod void testDecide_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+ StaticParameter.EscapeSyncProduct2Trigger = true;
+ StaticParameter.EscapeAccountTrigger = true;
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ // Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ // Asset asset01 = intProCommonMethodController.buildAssetHost('asset01',dep.Id, hospital.Id, strategicDep[0].Id,'浣跨敤涓�');
+ Product2 pro = new Product2(
+ Name = 'proName',
+ // ProductCode='pro001',
+ Asset_Model_No__c = 'pro001',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Family='GI',
+ Fixture_Model_No__c='n01',
+ Serial_Lot_No__c='S/N tracing',
+ Fixture_Model_No_T__c = 'n01',
+ ProductCode_Ext__c='pc01',
+ Manual_Entry__c=false
+ );
+ insert pro;
+ Asset asset01 = new Asset(
+ Name = 'asset01',
+ Product2Id = pro.Id,
+ Hospital__c = hospital.Id,
+ Department_Class__c = strategicDep[0].Id,
+ AccountId = dep.Id,
+ Status = '浣跨敤涓�',
+ Asset_Owner__c = '鐥呴櫌璩囩敚',
+ IsCompetitorProduct = True,
+ AssetMark__c = '涓绘満',
+ RecordTypeId = System.Label.Asset_RecordType,
+ SerialNumber = 'asset1',
+ Quantity = 1,
+ Manage_type__c = '涓綋绠$悊',
+ Loaner_accsessary__c = false,
+ Out_of_wh__c = 0,
+ Salesdepartment__c = '1.鍗庡寳钀ヤ笟鏈儴',
+ Internal_asset_location__c = '鍖椾含 澶囧搧涓績',
+ Product_category__c = 'GI',
+ Equipment_Type__c = '浜у搧璇曠敤',
+ SalesProvince__c = '澶ц繛',
+ CompanyOfEquipment__c = '鍖椾含',
+ Internal_Asset_number__c = '0001',
+ Rental_Count__c = 0,
+ Asset_loaner_category__c = '鍥哄畾璧勪骇',
+ Consumable_Guaranteen_end__c = System.Today() + 1,
+ WH_location__c = '璐ф灦鍙�1'
+ );
+ insert asset01;
+
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1};
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ System.Test.startTest();
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.save();
+ controller.approvalProcess();
+
+ // 缁翠慨鍚堝悓鎶ヤ环1
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ controller = new SelectAssetEstimateVMController();
+ controller.init();
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+ // System.assertEquals(5, controller.productCount2);
+ //鍥犱负榛樿鏌ヨ鐨勪繚鏈夎澶囩被鍨嬩负涓绘満
+ System.assertEquals(2,controller.productCount2);
+ //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+
+ controller.getEnablePrintContract();
+ controller.getUnDecideBtnDisabled();
+ controller.getDecideBtnDisabled();
+ controller.getApprovalBtnDisabled();
+ controller.getSaveBtnDisabled();
+ controller.getPrintBtnDisabled();
+ controller.getPageDisabled();
+ controller.savePrintFlg();
+
+ System.assertEquals(10, controller.productCount);
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ System.assertEquals(11, controller.productCount);
+ System.assertEquals(1, controller.productCount3);
+
+ controller.productIdx = 1;
+ controller.refreshProductData();
+
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+
+ List<Maintenance_Contract_Asset__c> mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id];
+ System.assertEquals(1, mcaList.size());
+ System.assertEquals('asset01', mcaList[0].Asset__r.Name);
+
+ controller.print();
+ System.Test.stopTest();
+ }
+ }
+
+ // 2銇よ绌嶃倐銈娿亴銇傘倞銆佽Κ銇偟銉撱偝銉炽仺鍚屾湡銇欍倠銇儐銈广儓
+ static testMethod void testDecide_02() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+ StaticParameter.EscapeSyncProduct2Trigger = true;
+ StaticParameter.EscapeAccountTrigger = true;
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'涓绘満');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ // Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ // Name = 'contract estimate 1',
+ // RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ // Contract_Esti_Start_Date__c = Date.today(),
+ // Contract_Range__c = 2,
+ // Maintenance_Contract__c = contract.Id
+ // );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti2;
+
+ System.Test.startTest();
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.save();
+ controller.approvalProcess();
+
+ // // 缁翠慨鍚堝悓鎶ヤ环1
+ // Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ // controller = new SelectAssetEstimateVMController();
+ // controller.init();
+ // System.assertEquals(5, controller.productCount2);
+
+ // controller.getEnablePrintContract();
+ // controller.getUnDecideBtnDisabled();
+ // controller.getDecideBtnDisabled();
+ // controller.getApprovalBtnDisabled();
+ // controller.getSaveBtnDisabled();
+ // controller.getPrintBtnDisabled();
+ // controller.getcontactBtnDisabled();
+ // controller.getPageDisabled();
+ // controller.savePrintFlg();
+
+ // System.assertEquals(10, controller.productCount);
+ // controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ // controller.exchangeAsset();
+ // System.assertEquals(11, controller.productCount);
+ // System.assertEquals(1, controller.productCount3);
+
+ // controller.productIdx = 1;
+ // controller.refreshProductData();
+
+ // controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ // controller.estimate.Contract_Range__c = 2;
+ // controller.save();
+
+ // List<Maintenance_Contract_Asset__c> mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id];
+ // System.assertEquals(1, mcaList.size());
+ // System.assertEquals('asset01', mcaList[0].Asset__r.Name);
+
+ // controller.print();
+
+ // 缁翠慨鍚堝悓鎶ヤ环2銇焙瀹氥儹銈搞儍銈�
+ Apexpages.currentPage().getParameters().put('id', contactEsti2.Id);
+ SelectAssetEstimateVMController controller2 = new SelectAssetEstimateVMController();
+ controller2.init();
+
+ controller2.unCheckedAssetsView[0][1].rec_CheckBox_c = true;
+ controller2.unCheckedAssetsView[0][3].rec_CheckBox_c = true;
+ System.assertEquals(10, controller2.productCount);
+ controller2.exchangeAsset();
+ System.assertEquals(12, controller2.productCount);
+ System.assertEquals(2, controller2.productCount3);
+
+ // contactEsti1 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti1.Id];
+ // System.assertEquals(true, contactEsti1.IsSyncing__c);
+
+ controller2.checkedAssets[0].mcae.Check_Result__c = 'test0';
+ controller2.checkedAssets[1].mcae.Check_Result__c = 'test1';
+ controller2.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller2.estimate.Contract_Range__c = 2;
+ controller2.estimate.Process_Status__c = '鎵瑰噯';
+ controller2.decide();
+
+ // contactEsti1 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti1.Id];
+ // System.assertEquals(false, contactEsti1.IsSyncing__c);
+ // contactEsti2 = [select IsSyncing__c from Maintenance_Contract_Estimate__c where Id = :contactEsti2.Id];
+ // System.assertEquals(true, contactEsti2.IsSyncing__c);
+
+ controller2.undecide();
+
+ //mcaList = [select Id, Asset__r.Name from Maintenance_Contract_Asset__c where Maintenance_Contract__c = :contract.Id order by Asset__r.Name];
+ //System.assertEquals(2, mcaList.size());
+ //System.assertEquals('asset02', mcaList[0].Asset__r.Name);
+ //System.assertEquals('asset04', mcaList[1].Asset__r.Name);
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void testcopyid_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.lastFriYearsPriceSum =3322;
+ controller.lastSecYearsPriceSum = 1222;
+ controller.alertString ='';
+ controller.alertString2 ='';
+ controller.alertString3 ='';
+ controller.getSaveBtnDisabled();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ SelectAssetEstimateVMController.pageDecide(contactEsti1.Id);
+ SelectAssetEstimateVMController.pageUndecide(contactEsti1.Id);
+// controller.ComputeLTYRepair();
+ controller.ShowLTYRepair();
+ }
+ }
+
+ static testMethod void testInit_01() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+ try {
+ SelectAssetEstimateVMController controller001 = new SelectAssetEstimateVMController();
+ controller001.init();
+ } catch (Exception e) {
+
+ }
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ hospital.Is_Active__c = '鏈夋晥';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'鑰楁潗');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ Maintenance_Contract_Asset__c mca2 = new Maintenance_Contract_Asset__c();
+ mca2.Asset__c = asset01.Id;
+ mca2.Estimate_List_Price__c = 100;
+ mca2.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1, mca2};
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Name = 'contract estimate 1',
+ Maintenance_Contract__c = contract.Id,
+ Contract_Esti_Start_Date__c = Date.today().addDays(1),
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ Apexpages.currentPage().getParameters().put('completion', '1');
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+
+ controller.init();
+ controller.firstPage();
+ controller.currPage = 3;
+ controller.previousPage();
+ controller.endPage();
+ controller.currPage = 200;
+ controller.nextPage();
+ controller.recordNumChange();
+ controller.getSaveBtnDisabled();
+ //controller.ComputeLTYRepair();
+ controller.cancel();
+ controller.saveAndCancel();
+
+ controller.onChDealerUpdate();
+ controller.checkDealerId = mcae2.Id;
+ controller.onChDealerUpdate();
+ controller.checkDealerId = hospital.Id;
+ controller.onChDealerUpdate();
+ }
+ }
+
+ static testMethod void testInit_02() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 淇悊銈掍綔鎴愩仚銈�01
+ Repair__c repair01 = new Repair__c();
+ repair01.Account__c = dep.Id;
+ repair01.Department_Class__c = strategicDep[0].Id;
+ repair01.Hospital__c = hospital.Id;
+ repair01.Delivered_Product__c = asset01.Id;
+ repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 缁翠慨鍚堝悓鍒ゆ柇鏃ャ亴銈点兗銉撱偣濂戠磩銇腑闁撹竞銈娿伄鏃ヤ粯
+ repair01.FSE_Work_Location__c = '涓婃捣';
+ repair01.Agreed_Date__c = Date.today().addDays(-1);
+ insert repair01;
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Contract_Esti_Start_Date__c = Date.today().addDays(1),
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ Test.startTest();
+ controller.ComputeLTYRepair();
+ controller.saveAndCancel();
+
+ SelectAssetEstimateVMController.ComputeLTYRepair(controller.targetEstimateId);
+ Test.stopTest();
+ }
+ }
+
+ static testMethod void testInit_03() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('copyid', contactEsti1.Id);
+ Apexpages.currentPage().getParameters().put('completion', '3');
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.save();
+ }
+ }
+
+ static testMethod void testApprovalProcess_01() {
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'鑰楁潗');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.Payment_Plan_Sum_First__c = 1;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1};
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Asset__c = asset01.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ // 鏂拌
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.unCheckedAssetsView[0][0].rec_CheckBox_c = true;
+ controller.exchangeAsset();
+ controller.checkedAssets[0].mcae.Check_Result__c = 'OK';
+ controller.approvalProcess();
+
+ // 鎻愪氦寰呭鎵规椂锛屾洿鏂板凡濉啓鐢宠鐘舵��
+ List<Maintenance_Contract_Estimate__c> mcenew = [select id,ApprovalProcess_Status__c from Maintenance_Contract_Estimate__c where id = :contactEsti1.Id];
+ System.assertEquals('宸插~鍐欏畬骞剁敵璇�', mcenew[0].ApprovalProcess_Status__c);
+
+ }
+ }
+
+ static testMethod void EditUnitTest() {
+
+ //Test.startTest();
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+ system.runAs(u3) {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ //SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ //// 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ //PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ //entry.UnitPrice = 0;
+ //entry.IsActive = true;
+ //entry.UseStandardPrice = false;
+ //entry.CurrencyIsoCode = 'CNY';
+ //entry.Product2Id = productA.Id;
+ //insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'鑰楁潗');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'涓绘満');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ contract.Payment_Plan_Sum_First__c = 1;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today(),
+ Contract_Range__c = 2,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 2',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Contract_Esti_Start_Date__c = Date.today().addMonths(6),
+ Contract_Range__c = 3,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
+ System.Test.startTest();
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.text1 = 'S:Name';
+ controller.cond1 = 'equals';
+ controller.val1 = 'asset01,asset02';
+ controller.searchBtn();
+ controller.cond1 = 'equals';
+ controller.val1 = 'asset02';
+ controller.searchBtn();
+ controller.cond1 = 'contains';
+ controller.val1 = ' asset02';
+ controller.searchBtn();
+ controller.cond1 = 'notequals';
+ controller.searchBtn();
+ controller.cond1 = 'starts with';
+ controller.searchBtn();
+ Test.stopTest();
+ }
+ }
+ // 琛ュ厖test 瀹為檯鑱斿姩
+ static testMethod void testInit_04() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+
+
+ system.runAs(u3) {
+ Achievement_linkage__c oppMapping = new Achievement_linkage__c();
+ oppMapping.Name = '01';
+ oppMapping.Consumption_rate_Lower__c = 0;
+ oppMapping.Consumption_rate_Upper__c = 50; // 閲嶈銇椼仸銈傘偍銉┿兗銇伅銇倝銇亜
+ oppMapping.PriceCount_Lower__c = -40;
+ oppMapping.PriceCount_Upper__c = -30;
+
+ insert oppMapping;
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 1,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test'
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.priceChangeReset();
+ //controller.getChartData();
+ //System.assertEquals(1, controller.dataList.size());
+ controller.save();
+ controller.changedAfterPrint = true;
+ controller.checkChangedAfterPrint();
+ }
+ }
+
+
+ static testMethod void testnotargetEstimateId_dataList() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+ system.runAs(u3) {
+ try {
+ SelectAssetEstimateVMController controller001 = new SelectAssetEstimateVMController();
+ controller001.init();
+ } catch (Exception e) {
+
+ }
+ Achievement_linkage__c oppMapping = new Achievement_linkage__c();
+ oppMapping.Name = '01';
+ oppMapping.Consumption_rate_Lower__c = 0;
+ oppMapping.Consumption_rate_Upper__c = 50; // 閲嶈銇椼仸銈傘偍銉┿兗銇伅銇倝銇亜
+ oppMapping.PriceCount_Lower__c = -40;
+ oppMapping.PriceCount_Upper__c = -30;
+
+ insert oppMapping;
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'涓绘満');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+ // 涓婁竴鏈熺淮淇悎鍚�
+ Maintenance_Contract__c lastcontract = new Maintenance_Contract__c();
+ lastcontract.Name = 'tect contract';
+ lastcontract.Not_Upper_limit_reason__c = 'tect contract';
+ lastcontract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ lastcontract.Hospital__c = hospital.Id;
+ lastcontract.Department_Class__c = strategicDep[0].Id;
+ lastcontract.Department__c = dep.Id;
+ lastcontract.Contract_Start_Date__c = Date.today().addMonths(-365);
+ lastcontract.Contract_End_Date__c = Date.today().addMonths(1);
+ lastcontract.Service_Contract_Staff__c = u3.Id;
+ lastcontract.First_Estimate_Date__c = Date.today().addMonths(-1);
+ lastcontract.First_contract_usage_Rate__c = 110;
+ insert lastcontract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c lastmca1 = new Maintenance_Contract_Asset__c();
+ lastmca1.Asset__c = asset01.Id;
+ lastmca1.Estimate_List_Price__c = 100;
+ lastmca1.Estimate_Cost__c = 100;
+ lastmca1.Maintenance_Contract__c = lastcontract.Id;
+
+
+ insert new Maintenance_Contract_Asset__c[] {lastmca1};
+
+ asset01.CurrentContract_F__c = lastcontract.Id;
+ asset01.CurrentContract_F_asset__c = lastmca1.Id;
+ update asset01;
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓/淇濇湁璁惧銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
+ mca1.Asset__c = asset01.Id;
+ mca1.Estimate_List_Price__c = 100;
+ mca1.Maintenance_Contract__c = contract.Id;
+
+ Maintenance_Contract_Asset__c mca2 = new Maintenance_Contract_Asset__c();
+ mca2.Asset__c = asset01.Id;
+ mca2.Estimate_List_Price__c = 100;
+ mca2.Maintenance_Contract__c = contract.Id;
+
+ insert new Maintenance_Contract_Asset__c[] {mca1, mca2};
+ // Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ // RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ // Name = 'contract estimate 1',
+ // Maintenance_Contract__c = contract.Id,
+ // Contract_Esti_Start_Date__c = Date.today().addDays(1),
+ // Request_quotation_Amount__c = 1,
+ // EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ // mainTalksTime__c = 1,
+ // talksStartDate__c = Date.today(),
+ // Discount_reason__c = 'test',
+ // Improve_ConsumptionRate_Idea__c = 'test'
+ // );
+ // insert contactEsti1;
+
+ // Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ // mcae1.Asset__c = asset01.Id;
+ // mcae1.Adjustment_Upper_price__c = 1;
+ // mcae1.Adjustment_Lower_price__c = 1;
+ // mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ // mcae1.Estimate_List_Price__c = 1000;
+ // mcae1.Check_Result__c = 'OK';
+
+ // Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ // mcae2.Asset__c = asset01.Id;
+ // mcae2.Adjustment_Upper_price__c = 1;
+ // mcae2.Adjustment_Lower_price__c = 1;
+ // mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ // mcae2.Estimate_List_Price__c = 1000;
+ // mcae2.Check_Result__c = 'OK';
+
+ // insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('mcid', contract.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+
+ controller.init();
+ // controller.firstPage();
+ // controller.currPage = 3;
+ // controller.previousPage();
+ // controller.endPage();
+ // controller.currPage = 200;
+ // controller.nextPage();
+ // controller.recordNumChange();
+ // controller.getSaveBtnDisabled();
+ // //controller.ComputeLTYRepair();
+ // controller.cancel();
+ // controller.saveAndCancel();
+ }
+ }
+
+ static testMethod void testSyncEstimate() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+
+ User u3 = new User();
+ u3.LastName = '_銈点兂銉栥儶銉冦偢';
+ u3.FirstName = '銇�';
+ u3.Alias = '銇�';
+ u3.Email = 'olympusTest03@sunbridge.com';
+ u3.Username = 'olympusTest03@sunbridge.com';
+ u3.CommunityNickname = '銇�';
+ u3.IsActive = true;
+ u3.EmailEncodingKey = 'ISO-2022-JP';
+ u3.TimeZoneSidKey = 'Asia/Tokyo';
+ u3.LocaleSidKey = 'ja_JP';
+ u3.LanguageLocaleKey = 'ja';
+ u3.ProfileId = System.Label.ProfileId_SystemAdmin;
+ u3.Job_Category__c = '閿�鍞湇鍔�';
+ u3.Province__c = '鍖椾含甯�';
+ u3.Use_Start_Date__c = Date.today().addMonths(-6);
+ u3.HR_Post__c='鎬昏';
+ insert u3;
+
+
+
+ system.runAs(u3) {
+ Achievement_linkage__c oppMapping = new Achievement_linkage__c();
+ oppMapping.Name = '01';
+ oppMapping.Consumption_rate_Lower__c = 0;
+ oppMapping.Consumption_rate_Upper__c = 50; // 閲嶈銇椼仸銈傘偍銉┿兗銇伅銇倝銇亜
+ oppMapping.PriceCount_Lower__c = -40;
+ oppMapping.PriceCount_Upper__c = -30;
+
+ insert oppMapping;
+ // 鐥呴櫌銈掍綔銈�
+ Account hospital = new Account();
+ hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+ hospital.Name = 'test hospital';
+ insert hospital;
+
+ // 鎴︾暐绉戝銈掑緱銈�
+ List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+
+ // 瑷虹檪绉戙倰浣溿倠
+ Account dep = new Account();
+ dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+ dep.Name = 'test dep';
+ dep.ParentId = strategicDep[0].Id;
+ dep.Department_Class__c = strategicDep[0].Id;
+ dep.Hospital__c = hospital.Id;
+ insert dep;
+
+ // 瑁藉搧銈掍綔銈�
+ Product2 productA = new Product2( Name='銉嗐偣銉堝晢鍝�', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
+ insert productA;
+
+ // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠
+ PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+ entry.UnitPrice = 0;
+ entry.IsActive = true;
+ entry.UseStandardPrice = false;
+ entry.CurrencyIsoCode = 'CNY';
+ entry.Product2Id = productA.Id;
+ insert entry;
+
+ // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+ Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+ Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
+ Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
+ Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
+ Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'鑰楁潗');
+
+ // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+ Maintenance_Contract__c contract = new Maintenance_Contract__c();
+ contract.Name = 'tect contract';
+ contract.Not_Upper_limit_reason__c = 'tect contract';
+ contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
+ contract.Hospital__c = hospital.Id;
+ contract.Department_Class__c = strategicDep[0].Id;
+ contract.Department__c = dep.Id;
+ contract.Service_Contract_Staff__c = u3.Id;
+ insert contract;
+
+ // 缁翠慨鍚堝悓鎶ヤ环銈掍綔鎴愩仚銈�
+ Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
+ Name = 'contract estimate 1',
+ RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
+ Maintenance_Contract__c = contract.Id,
+ Request_quotation_Amount__c = 2,
+ EndUserType__c = '鏃㈡湁鐢ㄦ埛',
+ mainTalksTime__c = 1,
+ talksStartDate__c = Date.today(),
+ Discount_reason__c = 'test',
+ Improve_ConsumptionRate_Idea__c = 'test',
+ GuidePrice_Up__c = 1
+ );
+ insert contactEsti1;
+
+ Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae1.Asset__c = asset01.Id;
+ mcae1.Adjustment_Upper_price__c = 1;
+ mcae1.Adjustment_Lower_price__c = 1;
+ mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae1.Estimate_List_Price__c = 1000;
+ mcae1.Check_Result__c = 'OK';
+
+ Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
+ mcae2.Product_Manual__c = productA.Id;
+ mcae2.Adjustment_Upper_price__c = 1;
+ mcae2.Adjustment_Lower_price__c = 1;
+ mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
+ mcae2.Estimate_List_Price__c = 1000;
+ mcae2.Check_Result__c = 'OK';
+
+ insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2};
+
+ Apexpages.currentPage().getParameters().put('id', contactEsti1.Id);
+ SelectAssetEstimateVMController controller = new SelectAssetEstimateVMController();
+ controller.init();
+ controller.estimate.Contract_Esti_Start_Date__c = Date.today();
+ controller.estimate.Contract_Range__c = 2;
+ controller.priceChangeReset();
+ // controller.getChartData();
+ // System.assertEquals(1, controller.dataList.size());
+ controller.save();
+ controller.changedAfterPrint = true;
+ Test.StartTest();
+ controller.syncEstimate(true,true);
+ Test.stopTest();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls-meta.xml b/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls-meta.xml
new file mode 100644
index 0000000..f3bac1f
--- /dev/null
+++ b/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>41.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/pages/SelectAssetEstimate.page b/force-app/main/default/pages/SelectAssetEstimate.page
new file mode 100644
index 0000000..7a792b6
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimate.page
@@ -0,0 +1,1713 @@
+<!--<apex:page standardcontroller="Maintenance_Contract_Estimate__c" extensions="SelectAssetEstimateController" sidebar="false" showHeader="true" id="allPage" action="{!init}"> -->
+<apex:page controller="SelectAssetEstimateController" tabStyle="Maintenance_Contract_Estimate__c" lightningStylesheets="true" sidebar="false" showHeader="true" id="allPage" action="{!init}">
+ <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
+<style type="text/css">
+ table { border-collapse: collapse; }
+
+ .container {
+ overflow:auto;
+ width:100%;
+ height:304px;
+ }
+ .container2 {
+ overflow:auto;
+ width:100%;
+ height:404px;
+ }
+ .btntable .dateFormat {
+ display: none;
+ }
+</style>
+<script type="text/javascript">
+var oxygenPriceAdj = {!oxygenPriceAdj};
+var Session_ID = '{!$Api.Session_ID}';
+var Confirm_ChangedAfterPrint = '鎵撳嵃鍚庤淇℃伅鏈夊彉鍖栵紝鏄惁缁х画鎿嶄綔锛堟姤浠风紪鐮佷細鍙樻柊锛夛紵';
+var isNewAddMonth = {!isNewAddMonth};
+var Confirm_EstimateRefresh = '宸茶秴杩囧垱寤烘棩3涓湀锛屾槸鍚︽洿鏂版姤浠凤紵';
+window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });
+
+function unblockUI(){
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+ // disable1();
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+ pageSetDisabled();
+ var isChange = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ if (isChange=='true') {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('false');
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ refreshAsset(rowCnt);
+ }
+ j$("#sbArea").fadeOut(500, function(){
+ j$("#sbArea").remove();
+ });
+}
+//<!-- HWAG-B4R3SS START 20181026-->
+function clearAndSearch() {
+ document.getElementById("allPage:allForm:allBlock:text1").value = "";
+ document.getElementById("allPage:allForm:allBlock:cond1").value = "equals";
+ document.getElementById("allPage:allForm:allBlock:val1").value = "";
+ blockme();
+ searchfunc();
+}
+function searchJs() {
+ blockme();
+ searchfunc();
+}
+//<!-- HWAG-B4R3SS END 20181026-->
+// 鍒濆鍖栬瀹氱敾闈㈤」鐩笉鍙敤
+function pageSetDisabled(){
+ var isDisabled = {!PageDisabled};
+ if (isDisabled) {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:depart')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).attr("disabled", true);
+ var rowCnt = {!productCount};
+ for (var i = 0; i < rowCnt; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert'));
+ a.attr("disabled", true);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).attr("disabled", true);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discountReason')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:improveConsumptionRateIdea')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:contractstartdate')).attr("disabled", true);
+ var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
+ if (target != '鍖婚櫌') {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).attr("disabled", true);
+ }
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).attr("disabled", false);
+ }
+}
+// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+// function disable1(){
+// var isDisabled ;
+// if(isDisabled){
+// var rowCnt = {!productCount};
+// for (var i = 0; i < rowCnt; i++) {
+// // 淇濇湁璁惧鍚�
+// var assN = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:'+ i +':assetName')).text();
+// var assN1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:'+ i +':Assert')).val();
+// // alert('1234567'+assN +'----'+assN1);
+// if(!assN1 && !assN){
+// // alert('23456789'+assN);
+// j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck' )).attr("disabled", true);
+// }else{
+// j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck' )).attr("disabled", false);
+// }
+// }
+// }
+// }
+// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+var winOpenObj;
+function closeWin(flg) {
+ winOpenObj.close();
+ if (flg==2) {
+ window.location.href="/{!URLENCODE(estimate.Id)}/e?completion=2";
+ }
+}
+function controlDisabled() {
+ winOpenObj = window.open("/apex/ChangeDealerApproval?eid=" + '{!URLENCODE(estimate.Id)}','ChangeDealerApproval','height=300,width=700,toolbar=no,menubar=no,left=20%,top=30%,scrollbars=yes,resizable=no,location=no,status=no');
+}
+// 瑕嬬銈傘倞浣滄垚寰屻�侊紦銉舵湀浠ュ唴銇с亗銈屻伆瑕嬬銈傘倞銇唴瀹广倰缍欑稓浣跨敤鍙兘
+function calonLoad() {
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+ // disable1();
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+ pageSetDisabled();
+ var createdDate = new Date('{!estimate.CreatedDate}');
+ // 20201103 gzw bug 瀵瑰簲 娌℃湁 nowDate JS鍑虹幇闂
+ var nowDate = new Date();
+ // 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
+ var aLLManual = 'true';
+ var cntWithKara = {!productCount};
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual != 'true') {
+ aLLManual = 'false';
+ break;
+ }
+ }
+ if (aLLManual == 'false') {
+ createdDate = createdDate.setMonth(createdDate.getMonth() + 3);
+ // FIX liang JS銇檪闁撱仯銇� addMonths銇亜銇с仚銇嬶紵 銇濄亱銈� 1/1 銇倝銆� 4/1銈傘仩銈併仹銇欍倛銆�
+ if (createdDate < Date.parse(nowDate)) {
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("class", 'btnDisabled');
+
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("disabled", true);
+ // 鏈�鍒濄伅銆丏ecide銇悓鏅傘伀淇濆瓨銈傘亗銈娿伨銇欍�併仢銈屻倰闃层亹銇熴倎銆佷繚瀛樸仺Decide銈掑悓鏅傘伀鐒″姽銇仚銈�
+ // 鑰冦亪銇︺伩銈嬨仺銆併偗銉┿偣銇獶ecide銇垽鏂亴銇傘倞銆丏ecide銇檪鏄庣窗澶夋洿銉併偋銉冦偗銈傘亗銈娿伨銇欍��3銉舵湀銇儊銈с儍銈倐銇傘倞銇俱仚銆併亾銇撱仹鐒″姽銇仚銈嬫剰鍛炽亴銇傘倞銇俱仜銈�
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
+
+ if (confirm(Confirm_EstimateRefresh)) {
+ window.location.href="/apex/SelectAssetEstimate?copyid={!URLENCODE(targetEstimateId)}";
+ return true;
+ } else {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ // decide鍙兘銇牬鍚堛�佸垾閫攄ecide銇儊銈с儍銈亴蹇呰銆�
+ // 銉併偋銉冦偗寰屽啀搴︾敾闈efresh銇曘倢銈嬨仧銈併�乨ecide鍙兘銇牬鍚堛�乨ecide銉溿偪銉炽亴浣裤亪銈嬨倛銇嗐伀銇倞銇俱仚銆�
+ changeContractStartdate('{!estimate.Contract_Start_Date__c}');
+ }
+ return false;
+ }
+ }
+ }else{
+ createdDate = createdDate.setMonth(createdDate.getMonth() + 6);
+ // FIX liang JS銇檪闁撱仯銇� addMonths銇亜銇с仚銇嬶紵 銇濄亱銈� 1/1 銇倝銆� 4/1銈傘仩銈併仹銇欍倛銆�
+ if (createdDate < Date.parse(nowDate)) {
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("class", 'btnDisabled');
+
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("disabled", true);
+ // 鏈�鍒濄伅銆丏ecide銇悓鏅傘伀淇濆瓨銈傘亗銈娿伨銇欍�併仢銈屻倰闃层亹銇熴倎銆佷繚瀛樸仺Decide銈掑悓鏅傘伀鐒″姽銇仚銈�
+ // 鑰冦亪銇︺伩銈嬨仺銆併偗銉┿偣銇獶ecide銇垽鏂亴銇傘倞銆丏ecide銇檪鏄庣窗澶夋洿銉併偋銉冦偗銈傘亗銈娿伨銇欍��3銉舵湀銇儊銈с儍銈倐銇傘倞銇俱仚銆併亾銇撱仹鐒″姽銇仚銈嬫剰鍛炽亴銇傘倞銇俱仜銈�
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
+
+ if (confirm('宸茶秴杩囧垱寤烘棩6涓湀锛屾槸鍚︽洿鏂版姤浠凤紵')) {
+ window.location.href="/apex/SelectAssetEstimate?copyid={!URLENCODE(targetEstimateId)}";
+ return true;
+ } else {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ // decide鍙兘銇牬鍚堛�佸垾閫攄ecide銇儊銈с儍銈亴蹇呰銆�
+ // 銉併偋銉冦偗寰屽啀搴︾敾闈efresh銇曘倢銈嬨仧銈併�乨ecide鍙兘銇牬鍚堛�乨ecide銉溿偪銉炽亴浣裤亪銈嬨倛銇嗐伀銇倞銇俱仚銆�
+ changeContractStartdate('{!estimate.Contract_Start_Date__c}');
+ }
+ return false;
+ }
+ }
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).val(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
+ }
+}
+
+function checkAll(checker) {
+ var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ for (var i = 0; i < cnt; i++) {
+ if (j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox')).size() == 0) {
+ break;
+ }
+ document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox').checked = checker.checked;
+ }
+}
+
+function checkAll2(checker) {
+ var cnt2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection2:productCnt2')).val();
+ var outer = 0;
+ for (var i = 0; i < cnt2; i++) {
+ outer = Math.floor(i / 1000);
+ if (document.getElementById('allPage:allForm:allBlock:assetSection2:outassetTable2:' + outer +':assetTable2:' + (i-(1000*outer)) + ':assetRowCheckbox2').disabled == false) {
+ document.getElementById('allPage:allForm:allBlock:assetSection2:outassetTable2:' + outer +':assetTable2:' + (i-(1000*outer)) + ':assetRowCheckbox2').checked = checker.checked;
+ }
+ }
+}
+
+function checkPercentage(val) {
+ if (val == null || val == "") {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val(0.00);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).val(0.00);
+ return;
+ }
+ if (isNaN(parseInt(val))) {
+ alert("璇疯緭鍏ユ暟鍊�");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val(0.00);
+ return;
+ }
+ val = localParseFloat(val);
+ val = Math.round(val * 100) / 100;
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val(toNumComma(val));
+ //if (val> 100.00 || val < 0) {
+ // alert("璇疯緭鍏�0.00鍒�99.99涔嬮棿鐨勬暟鍊�");
+ // j$(escapeVfId('allPage:allForm:allBlock:disBlock:disPercent')).val("");
+ // return;
+ //}
+
+ makeRealPrice();
+}
+
+function checkDiscount(val) {
+ if (val == null || val == "") {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val(0.00);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).val(0.00);
+ return;
+ }
+ if (isNaN(parseInt(val))) {
+ alert("璇疯緭鍏ユ暟鍊�");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).val(0.00);
+ return;
+ }
+ val = localParseFloat(val);
+ val = Math.round(val * 100) / 100;
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).val(toNumComma(val));
+ //if (val < 0) {
+ // alert("浼樻儬浠锋牸涓嶈兘浣庝簬0鍏�");
+ // j$(escapeVfId('allPage:allForm:allBlock:disBlock:disMoney')).val("");
+ // return;
+ //}
+
+ makeRealPrice(1);
+}
+
+function checkContractRange(val, cnt) {
+ if (isNaN(parseInt(val))) {
+ alert("璇疯緭鍏ユ暟鍊�");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ if (val <= 0) {
+ alert("鍚堝悓鏈堟暟蹇呴』澶т簬0");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ // HWAG-BA73ZP
+ contractStartDateChange();
+ refreshAsset(cnt);
+}
+
+function checkContractEstiStartDate(val, cnt) {
+ if (val == null || val == "") {
+ return;
+ }
+ for (var i = 0; i < cnt; i++) {
+ var instaldate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':InstallDate')).text();
+ if (instaldate != null && instaldate != '') {
+ var listprice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ if (isnew == "true") {
+ listprice = listprice / {!isNewPriceAdj};
+ }
+ var startdate = new Date(val);
+ startdate.setMonth(startdate.getMonth() + isNewAddMonth);
+ instaldate = new Date(instaldate);
+ if (startdate < instaldate) {
+ listprice = listprice * {!isNewPriceAdj};
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(listprice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNew')).attr('checked',true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val('true');
+ } else {
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(listprice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNew')).attr('checked',false);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val('false');
+ }
+ }
+ }
+
+ refreshAsset(cnt);
+}
+
+function refreshAsset(cnt) {
+ // row閲戦鍚堣▓
+ var repairSum = 0;
+ var listSum = 0;
+ // 鍚堝悓鏈堟暟涔楃畻
+ var month = j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val();
+ if (month == undefined || month == "") {
+ month = 1;
+ }
+ var month2 = 0;
+ if (month > 12) {
+ month2 = month - 12;
+ month = 12;
+ }
+ for (var i = 0; i < cnt; i++) {
+ var strMoney = 0;
+ var repairMoney = 0;
+
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isnew == 'true') {
+ strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+ } else {
+ strMoney = month * strMoney + month2 * strMoney;
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+
+ repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+ } else {
+ // TODO 涓�鏅傜殑銇蹇溿�併仾銈撱仹鍒ヨ銇噾椤嶃儶銉曘儸銉冦偡銉ャ仌銈屻仧锛�
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val();
+ }
+ }
+ else {
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isnew == 'true') {
+ strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+ } else {
+ strMoney = month * strMoney + month2 * strMoney;
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+
+ repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+ }
+ repairSum = repairSum + localParseFloat(repairMoney);
+ listSum = listSum + localParseFloat(toNum(strMoney));
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
+ j$(escapeVfId('allPage:allForm:allBlock:assetListSumNum')).text(toNumComma(listSum));
+
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPrice')).text(toNumComma(listSum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPriceHidden')).val(toNum(listSum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text(toNumComma(repairSum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPriceHidden')).val(toNum(repairSum));
+
+ NotUseOxygenatedWaterAmount(1);
+ examinationPriceCal(cnt);
+}
+
+function NotUseOxygenatedWaterAmount(t) {
+ var sum = 1 * localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPrice')).text());
+ var sumAdj = 0;
+
+ if (document.getElementById('allPage:allForm:allBlock:appendCondition:notUseOxygen').checked == true) {
+ sumAdj = -1 * sum * oxygenPriceAdj;
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:NotUseOxygenatedWaterAmount')).text(toNumComma(sumAdj));
+
+ // 浠樺姞鏉′欢绶忛娆�
+ var examPrice = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationReal')).text());
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPrice')).text(toNumComma(sumAdj + examPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPriceHidden')).val(toNum(sumAdj + examPrice));
+
+ makeRealPrice(1);
+}
+
+function examinationPriceCal(cntWithKara) {
+ var examinationCount = localParseInt(j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).val());
+ var examinationCountStr = number_format_common(examinationCount, 0, ".", ",");
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).val(examinationCountStr);
+ var cnt = 0;
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+ cnt++;
+ }
+ }
+ else {
+ cnt++;
+ }
+ }
+ var examinationPrice = 0;
+// 浠婂緦寰╂椿銇嬨倐
+// var cntLot = Math.ceil(cnt / 20);
+// if (cntLot == 0) {
+// examinationPrice = 0;
+// }
+// else if (cntLot == 1) {
+// examinationPrice = 2000;
+// }
+// else if (cntLot == 2) {
+// examinationPrice = 3800;
+// }
+// else if (cntLot == 3) {
+// examinationPrice = 5400;
+// }
+// else if (cntLot == 4) {
+// examinationPrice = 6800;
+// }
+// else if (cntLot == 5) {
+// examinationPrice = 8000;
+// }
+// else if (cntLot >= 6) {
+// examinationPrice = 1600 * cntLot;
+// }
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationReal')).text(toNumComma(examinationPrice * examinationCount));
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationRealHidden')).val(toNum(examinationPrice * examinationCount));
+
+ // 浠樺姞鏉′欢绶忛娆�
+ var oxygenPrice = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:NotUseOxygenatedWaterAmount')).text());
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPrice')).text(toNumComma(oxygenPrice + examinationPrice * examinationCount));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPriceHidden')).val(toNum(oxygenPrice + examinationPrice * examinationCount));
+
+ makeRealPrice(1);
+}
+
+/*
+ * @param t 1: 閲戦銇倛銈婂壊寮�
+ */
+function makeRealPrice(t) {
+ // 瀹熼殯閲戦鍚堣▓
+ var sum1 = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPrice')).text();
+ var sum2 = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
+ var append = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPrice')).text();
+ var sum = localParseFloat(sum1) + localParseFloat(append);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSum2')).text(toNumComma(sum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSum2Hidden')).val(toNum(sum));
+
+ var disM = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).val());
+ var disMP = toNum(disM / sum * 100);
+ // 鍓插紩閲戦銇嬨倝鍓插紩鐜囥倰瑷堢畻
+ if (t == 1) {
+ var disP = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val();
+ if (disMP != disP) {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val(disMP);
+ }
+ }
+ // 鍓插紩鐜囥亱銈夊壊寮曢噾椤嶃倰瑷堢畻
+ else {
+ var disP = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).val();
+ if (disMP != disP) {
+ disM = sum * disP / 100;
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).val(toNum(disM));
+ }
+ }
+ sum = sum - disM;
+
+ // 淇悊绶忛銈掕▓涓�
+ sum = sum + localParseFloat(sum2);
+
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text(toNumComma(sum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteRealHidden')).val(toNum(sum));
+}
+
+function resetDealer() {
+ var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
+ var obj = document.getElementById('allPage:allForm:allBlock:contract:dealer');
+ var obj_lkwgt = document.getElementById('allPage:allForm:allBlock:contract:dealer_lkwgt');
+ if (target == '鍖婚櫌') {
+ obj.style.display = "none";
+ obj_lkwgt.style.display = "none";
+ } else {
+ obj.style.display = "block";
+ obj_lkwgt.style.display = "block";
+ }
+}
+
+function changeAllCheckResult(val) {
+ var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ for (var i = 0; i < cnt; i++) {
+ if (val == ' ') {
+ document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult').value = '';
+ } else {
+ document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult').value = val;
+ }
+ }
+}
+function alertMsg() {
+ // body...
+ if('{!isPaymentSet}' == 'false'){
+ alert('璇峰~鍐欎粯娆捐鍒�');
+ return false;
+ }else if('{!isPaymentSet}' == 'Denied'){
+ alert('浠樻璁″垝閲戦涓庡疄闄呬笉绗︼紝璇烽噸鏂板~鍐�');
+ return false;
+ }else{
+ return true;
+ }
+}
+function onclickCheckchangedAfterPrint(saveBtnDisabled, saveOrApproval) {
+ if(saveBtnDisabled == 'Pttrue'){
+ var rs = alertMsg();
+ if(rs){
+ }else {
+ return false;
+ }
+ }
+
+ var cntWithKara = {!productCount};
+ var alerts = 0;
+ var today = new Date();
+ today.setMonth(today.getMonth() - 3);
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var plkid = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert_lkid'));
+ var pid = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (plkid.size() > 0 && pid.size() > 0) {
+ if (pid.value() != '' && plkid.value() != pid.value().substring(0, 15)) {
+ alert('璇蜂娇鐢ㄤ骇鍝佹斁澶ч暅鎸夐挳璁惧畾鎵嬪姩浜у搧');
+ return false;
+ }
+ }
+ }
+ if (isManual == 'false') {
+ var strDate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':finalExaminationDate')).value();
+ strDate = strDate.replace(/(^\s*)|(\s*$)/g, "");
+ if (strDate == "" || Date.parse(strDate) < Date.parse(today)) {
+ alerts = 1;
+ }
+ }
+ }
+ if (alerts == 1) {
+ if (confirm("閫夋嫨鐨勪繚鏈夎澶嘯鏈�鍚庣偣妫�鏃涓虹┖鎴栧凡缁忚秴杩囦笁涓湀涔嬪墠锛屾槸鍚︾户缁紵")) {
+
+ } else {
+ return false;
+ }
+ }
+ blockme();
+ if (saveOrApproval == "true") {
+ if (saveBeforeCheckPriceChange()) {
+ if (confirm("琛屼俊鎭湁鍙樺寲(缁翠慨鍚堝悓浠锋牸)锛屾槸鍚︽洿鏂版姤浠凤紵")) {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('true');
+ } else {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('fasle');
+ unblockUI();
+ return false;
+ }
+ }
+ j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ }
+
+ return true;
+ // if ((saveBtnDisabled == "true"||saveBtnDisabled == "Pttrue" )&& checkchangedAfterPrint()) {
+ // if (confirm(Confirm_ChangedAfterPrint)) {
+ // if (saveOrApproval == "true") {
+ // j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ // }
+ // return true;
+ // } else {
+ // unblockUI();
+ // return false;
+ // }
+ // } else {
+ // if (saveOrApproval == "true") {
+ // j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ // }
+ // return true;
+ // }
+}
+
+function changeEstiStartdate(val) {
+ if ('{!SaveBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(val);
+ changeContractStartdate(val);
+ }
+}
+
+function changeContractStartdate(val) {
+ var oldDateStr = j$('#oldContractDate').value();
+ var oldDate = new Date();
+ if (oldDateStr != null && oldDateStr != '') {
+ oldDate = new Date(oldDateStr);
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ var monthStr = '00' + (oldDate.getMonth()+1);
+ monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ var dayStr = '00' + oldDate.getDate();
+ dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ var oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+ j$(escapeVfId('allPage:allForm:oldDecideContractDate')).val(oldDateVal);
+ if (saveBeforeCheckPriceChange()) {
+ blockme();
+ contractStartDateChange();
+ }
+ } else {
+ var cntWithKara = {!productCount};
+ var haveLine = 'false';
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert_lkid'));
+ if (a.size() > 0 && a.val() != "000000000000000") {
+ haveLine = 'true';
+ }
+ } else {
+ haveLine = 'true';
+ }
+ }
+
+ if (haveLine == 'false') {
+ return false;
+ }
+ var contractStartDate = new Date(val);
+ var strCreatedDate = '{!estimate.CreatedDate}';
+ var createDate = new Date();
+ if (strCreatedDate != '') {
+ createDate = new Date(strCreatedDate);
+ }
+ createDate = new Date(createDate.toDateString());
+ var threeMA = new Date(createDate.setMonth(createDate.getMonth() + 3));
+ var isnewMA = new Date(createDate.setMonth(createDate.getMonth() - 3 - isNewAddMonth));
+
+ if (oldDate >= isnewMA && contractStartDate >= isnewMA) {
+ return false;
+ }
+ if (oldDate < threeMA && contractStartDate < threeMA) {
+ return false;
+ }
+
+ if (contractStartDate >= isnewMA) {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖澶т簬鍒涘缓鏃�6涓湀锛屾墍鏈夊悎鍚屽璞¤澶囦笉閫傜敤鏂板搧浠锋牸銆俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ょ淮淇悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ } else if (contractStartDate >= threeMA) {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖澶т簬鍒涘缓鏃�3涓湀锛屾墍鏈夊悎鍚屽璞¤澶囦娇鐢ㄣ�愬悎鍚屽紑濮嬫棩銆戦噸鏂拌绠楃淮淇悎鍚屼环鏍笺�俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ょ淮淇悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ } else {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖鍦ㄥ垱寤烘棩3涓湀浠ュ唴锛屾墍鏈夊悎鍚屽璞¤澶囦娇鐢ㄣ�愬垱寤烘棩銆戦噸鏂拌绠楃淮淇悎鍚屼环鏍笺�俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ょ淮淇悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ }
+ j$('oldContractDate').val(val);
+ blockme();
+ contractStartDateChange();
+ }
+}
+function AlertPriceBtnJs(){
+
+ var VarAlert = j$(escapeVfId('allPage:allForm:alertStringValue')).val();
+ var VarAlert2 = j$(escapeVfId('allPage:allForm:alertStringValue2')).val();
+ var VarAlert3 = j$(escapeVfId('allPage:allForm:alertStringValue3')).val();
+ var PStatus = j$(escapeVfId('allPage:allForm:PriceStatus')).val();
+ blockme();
+
+ if(PStatus!='鐢宠涓�'&&PStatus!='鎵瑰噯'){
+ ComputeLTYRepair();
+ //ShowLTYRepair();
+ }else if(PStatus == '鐢宠涓�'||PStatus == '鎵瑰噯'){
+ ShowLTYRepair();
+ }
+
+}
+function ComputeLTY() {
+ var urlNameJs = j$(escapeVfId('allPage:allForm:urlName')).val();
+ urlNameJs = '{!$Label.ID_of_SelectAssetEstimate}'+urlNameJs ;
+ var w = window.open(encodeURI(urlNameJs),'杩囧幓涓ゅ勾淇悊瀹炵哗','menubar=no,height=720,width=986');
+ w.focus();
+}
+function recordNumChangeJs() {
+ recordNumChangeAction();
+}
+
+function checkDecideDate() {
+ var strSubmitDate = '{!estimate.Submit_quotation_day__c}';
+ var submitDate = new Date();
+ var nowDate = new Date();
+ /// 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
+ // 榛樿涓�3鏈堬紝鍏ㄦ槸浜у搧涓�6鏈堬紱
+ var monthGap = 6;
+ var cntWithKara = {!productCount};
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual != 'true') {
+ monthGap = 3;
+ break;
+ }
+ }
+ if (strSubmitDate != '') {
+ submitDate = new Date(strSubmitDate);
+ submitDate = new Date(submitDate.setMonth(submitDate.getMonth() + monthGap));
+ }
+ if (strSubmitDate != '' && nowDate > submitDate) {
+ alert('宸茶秴鍑烘姤浠风敵璇锋棩' + monthGap + '涓湀锛屼笉鍏佽DECIDE銆�');
+ return false;
+ }
+ return true;
+}
+function decideJs() {
+ if (checkDecideDate() == true) {
+ if (onclickCheckchangedAfterPrint('true','false') == true) {
+ var oldDate = j$(escapeVfId('allPage:allForm:oldDecideContractDate')).value();
+ var contractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ //var olDt = oldDate.getFullYear() + oldDate.getMonth() + oldDate.getDate();
+ var monthStr = '00' + (contractDate.getMonth()+1);
+ monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ var dayStr = '00' + contractDate.getDate();
+ dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ var contractDateStr = contractDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+
+ //var neDt = contractDate.getFullYear() + contractDate.getMonth() + contractDate.getDate();
+ //monthStr = '00' + (oldDate.getMonth()+1);
+ //monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ //dayStr = '00' + oldDate.getDate();
+ //dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ //oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+ if (oldDate == contractDateStr) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decide();
+ } else {
+ var oldp = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).value();
+ var newp = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
+
+ if (oldp != newp) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ if (confirm('鏈鍚堝悓寮�濮嬫棩鐨勪慨鏀瑰皢瀵艰嚧鍚堝悓閲戦鍙戠敓鍙樺寲锛岃鎮ㄧ‘璁ゆ槸鍚︿慨鏀癸紵')) {
+ decide();
+ } else {
+ alert('鍚堝悓寮�濮嬫棩鏈繘琛屽彉鏇达紝璇风‘璁ゅ叏閮ㄥ唴瀹瑰悗鐐瑰嚮Decide銆�');
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(oldDate);
+ j$(escapeVfId('allPage:allForm:oldDecideContractDate')).val('');
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decideCancle();
+ }
+ } else {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ if (confirm('鏈鍚堝悓寮�濮嬫棩鐨勪慨鏀逛笉浼氬鑷村悎鍚岄噾棰濆彂鐢熷彉鍖栵紝璇锋偍纭鏄惁淇敼锛�')) {
+ decide();
+ } else {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(oldDate);
+ alert('鍚堝悓寮�濮嬫棩鏈繘琛屽彉鏇达紝璇风‘璁ゅ叏閮ㄥ唴瀹瑰悗鐐瑰嚮Decide銆�');
+ unblockUI();
+ }
+ }
+ }
+ }
+ }
+}
+</script>
+<apex:form id="allForm">
+ <apex:inputHidden id="alertStringValue" value="{!alertString}" />
+ <apex:inputHidden id="alertStringValue2" value="{!alertString2}" />
+ <apex:inputHidden id="alertStringValue3" value="{!alertString3}" />
+ <apex:inputHidden id="PriceStatus" value="{!estimate.Process_Status__c}"/>
+ <apex:inputHidden id="urlName" value="{!estimate.Name}"/>
+ <apex:inputHidden id="changedAfterPrint" value="{!changedAfterPrint}"/>
+ <apex:inputHidden id="changedSubmitPrice" value="{!changedSubmitPrice}"/>
+ <apex:inputHidden id="isSaveOrApproval" value="{!isSaveOrApproval}"/>
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,assetSection2,pageMessages,allBlock" onComplete="unblockUI();"></apex:actionFunction>
+ <!-- HWAG-B4R3SS END 20181026-->
+ <apex:actionFunction name="ComputeLTYRepair" action="{!ComputeLTYRepair}" oncomplete="unblockUI();ComputeLTY();"/>
+ <apex:actionFunction name="ShowLTYRepair" action="{!ShowLTYRepair}" oncomplete="unblockUI();ComputeLTY();"/>
+ <apex:actionFunction name="decide" action="{!decide}" rerender="allForm" oncomplete="unblockUI();"/>
+ <apex:actionFunction name="decideCancle" action="{!decideCancle}" rerender="allForm" oncomplete="unblockUI();"/>
+ <apex:inputHidden id="oldDecideContractDate" value="{!OldContractStartDate}" />
+ <input type="hidden" id="oldContractDate" value="{!estimate.Contract_Start_Date__c}" />
+<script type="text/javascript">
+//j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+</script>
+ <apex:pageBlock title="缁翠慨鍚堝悓鎶ヤ环" id="allBlock">
+ <apex:pageBlockButtons id="blocktop" location="top">
+ <apex:commandButton id="savebtntop" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();"/>
+ <!-- <apex:commandButton id="LastTwoYearRepairShow" value="杩囧幓涓ゅ勾缁翠慨瀹炵哗Repaort" action="{!ShowLTYRepair}" rerender="alertStringValue,alertStringValue2,alertStringValue3" oncomplete="AlertPrice();"/> -->
+ <apex:commandButton id="LastTwoYearRepairComp" value="杩囧幓涓夊勾缁翠慨瀹炵哗璁$畻" rerender="PriceStatus" onclick="AlertPriceBtnJs()"/>
+ <apex:commandButton id="approvalbtntop" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();ComputeLTYRepair();"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
+ <apex:outputText style="color:red;font-size:20px" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
+ <apex:commandButton action="{!cancel}" value="涓嶄繚瀛橈紙杩斿洖锛�" style="float:right;" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/>
+ <apex:commandButton id="saveAndCancelBtn" action="{!saveAndCancel}" value="淇濆瓨锛堣繑鍥烇級" style="float:right;" rerender="allForm" oncomplete="unblockUI();" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" disabled="{!SaveBtnDisabled}"/>
+ </apex:pageBlockButtons>
+
+ <apex:pageMessages id="pageMessages"></apex:pageMessages>
+ <!-- update 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖� 娣诲姞鈥榓ssetSection鈥� fxk 2021/9/10 Star-->
+ <apex:actionFunction name="refreshProductData" action="{!refreshProductData}" rerender="pageMessages, assetListPrice, assetListPriceHidden, productCount3, assetSection" oncomplete="refreshAsset({!productCount});unblockUI();">
+ <apex:param assignTo="{!productIdx}" name="productIdx" value=""/>
+ </apex:actionFunction>
+ <!-- update 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖� 娣诲姞鈥榓ssetSection鈥� fxk 2021/9/10 End-->
+ <apex:actionFunction name="contractStartDateChange" action="{!contractStartDateChange}" rerender="allForm" oncomplete="unblockUI();">
+ </apex:actionFunction>
+
+ <apex:actionFunction name="recordNumChangeAction" action="{!recordNumChange}" rerender="allForm" oncomplete="unblockUI();">
+ </apex:actionFunction>
+
+ <apex:pageblocksection title="{!$ObjectType.Maintenance_Contract__c.label}" id="contract">
+ <apex:outputField value="{!estimate.Name}"/>
+ <apex:outputField value="{!contract.Management_Code__c}" />
+ <apex:outputField value="{!estimate.Process_Status__c}"/>
+ <apex:outputField value="{!contract.Status__c}"/>
+ <apex:outputField value="{!contract.Hospital__c}" />
+ <apex:inputField value="{!estimate.Department__c}" id="depart"/>
+ <apex:inputField value="{!estimate.Contract_Esti_Start_Date__c}" required="true" id="startdate" onchange="changeEstiStartdate(this.value);"/><!-- onchange="checkContractEstiStartDate(this.value, {!productCount})" -->
+ <apex:inputField value="{!estimate.Contract_Range__c}" required="true" id="monthRange" onchange="checkContractRange(this.value, {!productCount})"/>
+ <apex:outputField value="{!estimate.Contract_Esti_End_Date__c}"/>
+ <apex:outputField label="鍒跺畾鏃�" value="{!estimate.CreatedDate}" id="createDateShow"/>
+
+ <apex:outputPanel >
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鎻愪氦瀵硅薄</label>
+ <apex:inputField value="{!estimate.Estimate_Target__c}" id="estimateTarget" onchange="resetDealer()" style="margin-left:5px"/>
+
+ <apex:outputPanel rendered="{!DecideBtnDisabled==false}">
+ <input type="button" class="btn" value="鍙樻洿" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!DecideBtnDisabled==true}">
+ <input type="button" class="btnDisabled" value="鍙樻洿" disabled="true" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/>
+ </apex:outputPanel>
+ </apex:outputPanel>
+
+ <apex:inputField value="{!estimate.Dealer__c}" id="dealer" />
+ <script type="text/javascript">
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).children('option[value=]').remove();
+ resetDealer();
+ </script>
+ </apex:pageblocksection>
+
+ <apex:pageblocksection columns="1" title="鍚堝悓瀵硅薄璁惧" id="assetSection" >
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <input type="hidden" id="allPage:allForm:allBlock:assetSection:productCnt" value="{!productCount}" />
+ <table width="100%">
+ <tr>
+ <td> </td>
+ <td width="100px"><span>鍏�</span>
+ <select style="vertical-align:text-bottom" id="allCheckResult" size="1" onchange="changeAllCheckResult(this.value)">
+ <option value=" ">--鏃�--</option>
+ <option value="OK">OK</option>
+ <option value="NG">NG</option>
+ </select>
+ </td>
+ <td width="150px"> </td>
+ </tr>
+ </table>
+
+ <table class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
+ <tr class="headerRow" height="30px">
+ <th style="width:25px" class="headerRow booleanColumn"><input type='checkbox' onClick='checkAll(this)'/></th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Name.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
+ <!-- <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Installation_Site__c.label}</th> -->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Management_Code__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.InstallDate.label}</th>
+ <!-- <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price_All__c.label}</th>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star-->
+ <th style="width:70px" class="headerRow booleanColumn">
+ {!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Check_Object__c.label}</th>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end-->
+ <th style="width:40px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.IsNew__c.label}</th>
+ <!-- <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Last_inspection_day__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Check_Result__c.label}</th> -->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Comment__c.label}</th>
+ </tr>
+ </table>
+
+ <apex:outputPanel layout="block" styleClass="container">
+ <apex:variable value="{!1}" var="cnt" />
+ <table class="list" style="border-top-width: 0px; font-size:12px;" border="0" cellspacing="0" cellpadding="0">
+ <apex:repeat value="{!checkedAssets}" var="ar" id="assetTable">
+ <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
+ <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox" rendered="{!Not(ar.IsManual)}" disabled="{!PageDisabled}"/>
+ <apex:outputText value="{!ar.IsManual}" id="IsManual" style="display:none;" />
+ </td>
+ <td class="dataCell">
+ <apex:outputField value="{!ar.rec.Name}" id="assetName" rendered="{!Not(ar.IsManual)}" />
+ <apex:inputField value="{!ar.mcae.Product_Manual__c}" id="Assert" style="width:90%;" rendered="{!ar.IsManual}" onchange="blockme();refreshProductData({!ar.lineNo});"/>
+ <apex:inputText id="ProductId" value="{!ar.mcae.Product_Manual__c}" style="display:none;" disabled="true"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputLink value="/{!ar.recId}" rendered="{!Not(ar.IsManual)}" >{!ar.rec.SerialNumber}</apex:outputLink>
+ <apex:inputHidden id="AssetId" value="{!ar.recId}"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Department_Name__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Installation_Site__c}" rendered="{!Not(ar.IsManual)}" />
+ </td> -->
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Management_Code__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.CurrentContract_End_Date__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.InstallDate}" id="InstallDate" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_Owner__c}" rendered="{!Not(ar.IsManual)}" />
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Accumulation_Repair_Amount__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputText value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPrice" style="padding-right:3px;" />
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
+ </apex:outputPanel>
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.Estimate_List_Price__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetListPriceHidden"/>
+ </apex:outputPanel>
+ </td>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star-->
+ <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:inputCheckbox value="{!ar.mcae.Check_Object__c}" id="assetCheck" disabled="{!ar.CheckRows}"/>
+ </td>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end-->
+ <td class="dataCell" width="40px" style="text-align:center" >
+ <apex:inputCheckbox value="{!ar.mcae.IsNew__c}" id="assetNew" disabled="true"/>
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.IsNew__c}" id="assetNewHidden" />
+ </apex:outputPanel>
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.IsNew__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetNewHidden" />
+ </apex:outputPanel>
+ <apex:outputText value="{!ar.rec.Final_Examination_Date__c}" id="finalExaminationDate" rendered="{!Not(ar.IsManual)}" style="display:none"/>
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Final_Examination_Date__c}" id="finalExaminationDate" rendered="{!Not(ar.IsManual)}"/>
+ </td>
+ <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:inputField value="{!ar.mcae.Check_Result__c}" id="checkResult"/>
+ </td> -->
+ <td class="dataCell" width="70px" style="text-align:right" >
+ <apex:inputField value="{!ar.mcae.Repair_Price__c}" id="repairPrice" style="ime-mode: disabled; width:95%; text-align:right;" onchange="refreshAsset({!productCount});"/>
+ </td>
+ <td class="dataCell" width="70px" style="text-align:right" >
+ <apex:inputField value="{!ar.mcae.Comment__c}" id="comment" style="width:95%;"/>
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ </table>
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:outputPanel id="sumPanel" onkeydown="if(event.keyCode==13){searchJs(); return false;}">
+ <!-- HWAG-B4R3SS END 20181026-->
+ <table style="width:100%;">
+ <tr>
+
+ <td>
+ <apex:commandButton value="琛岃拷鍔�" action="{!addNewRows}" disabled="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable) || PageDisabled}"
+ style="margin-left:10px;float:left;" onclick="blockme();" oncomplete="unblockUI();" rerender="allForm" />
+ <apex:commandButton value="鍒锋柊閫変腑鐨勪繚鏈夎澶�" disabled="{!SaveBtnDisabled || productCount2==0}" action="{!exchangeAsset}" onclick="blockme();" oncomplete="unblockUI();" rerender="allForm" />
+
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:outputText value="閫夋嫨鏉′欢"/>
+
+ <apex:selectList value="{!text1}" id="text1" size="1" style="width:80px"><apex:selectOptions value="{!textOpts}"/>
+ </apex:selectList>
+
+ <apex:selectList value="{!cond1}" id="cond1" size="1" style="width:80px">
+ <apex:selectOptions value="{!equalOpts}"/>
+ </apex:selectList>
+
+
+ <!-- LJPH-BSS6E2 ---20200911 ---update by rentongxiao start -->
+ <!-- <apex:inputText value="{!val1}"
+ id="val1" style="width:100px"/> -->
+
+ <apex:inputText value="{!val1}"
+ id="val1" style="width:100px; background-color:{!IF(contr == '1','#e3f3ff','white')}"/>
+ <!-- LJPH-BSS6E2 ---20200911 ---update by rentongxiao end -->
+
+ <apex:commandButton value="妫�绱�" onclick="searchJs();" style="width:100px" rerender="dummy"/>
+
+ <apex:commandButton value="娓呴櫎鏉′欢" onclick="clearAndSearch();" style="width:100px" rerender="dummy"/>
+ <!-- HWAG-B4R3SS END 20181026-->
+ </td>
+
+ <th width="90px" style="text-align:right">璁惧鏁伴噺</th>
+ <td width="90px" style="text-align:right"><apex:outputtext value="{!productCount3}" id="productCount3"/></td>
+ <td width="25px"> </td>
+ <th width="90px" style="text-align:right">鎶ヤ环鎬婚</th>
+ <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetListSumNum" ></span></th>
+ <td width="25px"> </td>
+ <th width="90px" style="text-align:right">淇悊鎬婚</th>
+ <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetRepairSumNum" ></span></th>
+ <td width="95px"> </td>
+ </tr>
+
+ </table>
+ </apex:outputPanel>
+
+ <apex:pageblocksection columns="1" title="鏈�夋嫨鐨勪繚鏈夎澶�" id="assetSection2" >
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <input type="hidden" id="allPage:allForm:allBlock:assetSection2:productCnt2" value="{!productCount2}" />
+ <table class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
+ <tr class="headerRow" height="30px">
+ <th style="width:25px" class="headerRow booleanColumn"><input type='checkbox' onClick='checkAll2(this)'/></th>
+ <th style="width:29%" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Name.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
+ <!-- <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Installation_Site__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty__c.label}</th>
+
+ <!-- JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
+ <th style="width: 90px" class="headerRow booleanColumn">涓绘満/鑰楁潗</th>
+ <!-- JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
+
+ <th style="width:150px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Reson_Can_not_Warranty__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.InstallDate.label}</th>
+ <!-- <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price__c.label}</th>
+ </tr>
+ </table>
+
+ <apex:outputPanel layout="block" styleClass="container2" style="max-height: 404px; height: auto;">
+ <apex:variable value="{!1}" var="cnt" />
+ <table class="list" style="border-top-width: 0px; font-size:12px;" border="0" cellspacing="0" cellpadding="0">
+ <apex:repeat value="{!unCheckedAssetsView}" var="assetsView" id="outassetTable2">
+ <apex:repeat value="{!assetsView}" var="ar" id="assetTable2">
+ <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
+ <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty__c = '鍚�', 'true', 'false')}"/>
+ </td>
+ <td class="dataCell" width="30%">
+ <apex:outputField value="{!ar.rec.name}" id="assetName"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_situation__c}"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.SerialNumber}"/>
+ </td>
+ <td class="dataCell">
+ <apex:outputField value="{!ar.rec.Department_Name__c}"/>
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Installation_Site__c}"/>
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.IF_Warranty__c}"/>
+ </td>
+
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
+ <td class="dataCell" width="90px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.AssetMark__c}"/>
+ </td>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
+
+ <td class="dataCell" width="150px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.Reson_Can_not_Warranty__c}"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.InstallDate}"/>
+ </td>
+ <!-- <td class="dataCell" width="90px">
+ <apex:outputField value="{!ar.rec.Asset_Owner__c}"/>
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Accumulation_Repair_Amount__c}"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Maintenance_Price_Month__c}" />
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ </apex:repeat>
+ </table>
+ </apex:outputPanel>
+ <apex:outputPanel >
+ <dir align="right">
+ <table>
+ <tr>
+ <td>{!(currPage-1)*selctRecordNum} - {!IF(currPage*selctRecordNum > totalRecords, totalRecords, currPage*selctRecordNum)}</td>
+ <td> 鍏眥!totalRecords}涓�</td>
+ <td align="right" width="115px">鏄剧ず
+ <apex:selectList value="{!selRecordOption}" id="selRecordOption" size="1" onchange="blockme();recordNumChangeJs();" disabled="{!IF(totalRecords<10,true,false)}"><apex:selectOptions value="{!recordNum}"/></apex:selectList>鏉¤褰�
+ </td>
+ <td align="right" width="50px">绗瑊!currPage}椤�</td>
+ <td align="right" width="45px">
+ <apex:commandLink action="{!firstPage}" value="棣栭〉" id="firstPg" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(currPage==1,'display: none;','')}color: blue;"/>
+ <apex:outputText value="棣栭〉" style="{!IF(currPage!=1,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td align="right" width="40px">
+ <apex:commandLink action="{!previousPage}" value="涓婁竴椤�" id="previous" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(currPage==1,'display: none;','')}color: blue;"/>
+ <apex:outputText value="涓婁竴椤�" style="{!IF(currPage!=1,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td width="3px"></td>
+ <td align="left" width="40px">
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:commandLink action="{!nextPage}" value="涓嬩竴椤�" id="next" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(totalPage==currPage ||totalPage == 0,'display: none;','')}color: blue;"/>
+ <apex:outputText value="涓嬩竴椤�" style="{!IF(totalPage!=currPage && totalPage != 0,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td align="left" width="45px">
+ <apex:commandLink action="{!endPage}" value="灏鹃〉" id="endPg" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(totalPage==currPage||totalPage == 0,'display: none;','')}color: blue;"/>
+ <apex:outputText value="灏鹃〉" style="{!IF(totalPage!=currPage
+ && totalPage != 0,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <!-- HWAG-B4R3SS END 20181026-->
+ <td align="left">鍏眥!totalPage}椤�</td>
+ </tr>
+ </table>
+ </dir>
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+
+ <apex:pageblocksection columns="1" title="闄勫姞鏉′欢" id="appendCondition">
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <table style="width:100%">
+ <tr>
+ <th width="100" style="text-align:right">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.NotUse_Oxygenated_Water__c.label}</th>
+ <td width="100" style="text-align:center"><!-- <apex:inputField value="{!estimate.NotUse_Oxygenated_Water__c}" id="notUseOxygen" onclick="NotUseOxygenatedWaterAmount();"/> -->
+ <apex:inputCheckbox value="{!estimate.NotUse_Oxygenated_Water__c}" id="notUseOxygen" onclick="NotUseOxygenatedWaterAmount();" disabled="true"/>
+ </td>
+ <td width="100" style="text-align:right"><span id="allPage:allForm:allBlock:NotUseOxygenatedWaterAmount"></span></td>
+ <td width="100"> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <th style="text-align:right">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Service_contract_target_number__c.label}</th>
+ <td><apex:inputField value="{!estimate.Service_contract_target_number__c}" id="Examination_Count" style="ime-mode: disabled; text-align:right; width:100px" onchange="examinationPriceCal({!productCount})"/></td>
+ <th style="text-align:right;display:none;">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Examination_Price__c.label}</th>
+ <td style="text-align:right;display:none;">
+ <apex:outputField value="{!estimate.Examination_Price__c}" id="examinationReal" />
+ <apex:inputHidden value="{!estimate.Examination_Price__c}" id="examinationRealHidden"/>
+ </td>
+ <td> </td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+
+ <apex:pageblocksection title="鍚堝悓淇℃伅" columns="1" id="contractInfo">
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <table style="width:100%">
+ <tr>
+ <td width="15%"></td>
+ <td width="14%"></td>
+ <td width="15%"></td>
+ <td width="28%"></td>
+ <td width="14%"></td>
+ <td width="14%"></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">1.缁翠慨鍚堝悓璁惧鎶ヤ环鎬婚</th>
+ <th style="text-align: center">2.闄勫姞鏉′欢鎬婚</th>
+ <th style="text-align: center">3.姝ゆ鍚堝悓鎶ヤ环鎬婚</th>
+ <th style="text-align: center">4.浼樻儬鐜囷紙浠锋牸锛�</th>
+ <th style="text-align: center">5.淇悊鎬婚</th>
+ <th style="text-align: center">6.鍚堝悓浠锋牸</th>
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Asset_Sum_Price__c}" id="assetSumPrice" />
+ <apex:inputHidden value="{!estimate.Asset_Sum_Price__c}" id="assetSumPriceHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Append_Condition_Price__c}" id="appendPrice" />
+ <apex:inputHidden value="{!estimate.Append_Condition_Price__c}" id="appendPriceHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Estimate_Trial_Money__c}" id="assetSum2" />
+ <apex:inputHidden value="{!estimate.Estimate_Trial_Money__c}" id="assetSum2Hidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:inputField value="{!estimate.Discount_Percentage__c}" id="disPercent" style="ime-mode: disabled; text-align:right; width:100px" onchange="checkPercentage(this.value);"/><font style="font-weight: bold"> % 锛� </font>
+ <apex:inputField value="{!estimate.Discount_Price__c}" id="disMoney" style="ime-mode: disabled; text-align: right; width:100px" onchange="checkDiscount(this.value);"/><font style="font-weight: bold"> 锛�</font>
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPrice" />
+ <apex:inputHidden value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPriceHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal" />
+ <apex:inputHidden value="{!estimate.Maintenance_Price__c}" id="mainteRealHidden"/>
+ <apex:inputHidden value="{!OldMaintenancePrice}" id="oldMainteReal"/>
+ </td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Discount_reason__c.label}</th>
+ <td colspan="5"><apex:inputField value="{!estimate.Discount_reason__c}" id="discountReason" style="width:95%;height:50px;" /></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Improve_ConsumptionRate_Idea__c.label}</th>
+ <td colspan="5"><apex:inputField value="{!estimate.Improve_ConsumptionRate_Idea__c}" id="improveConsumptionRateIdea" style="width:95%;height:50px;" /></td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+
+ <script type="text/javascript">
+ refreshAsset({!productCount});
+ </script>
+ </apex:pageBlock>
+
+ <table width="100%" border="0">
+ <tr>
+ <!-- <td width="40%" style="text-align: right;"> -->
+ <td width="40%">
+ <table border="0" style="background-color:#ffd6c1;">
+ <tr>
+ <th width="70px">鎵撳嵃鎶ヤ环</th>
+ <td width="80px"><apex:inputCheckbox value="{!estimate.Print_ListPrice__c}"/>鎶ヤ环</td>
+ <td width="80px"><apex:inputCheckbox value="{!estimate.Print_RepairPrice__c}"/>淇悊閲戦</td>
+ <td width="80px"><apex:inputCheckbox value="{!estimate.Print_SumPrice__c}"/>鎶ヤ环鎬婚</td>
+ <td width="80px" style="display:none;"><apex:inputCheckbox value="{!estimate.Print_DiscountPercentage__c}"/>浼樻儬鎶樻墸</td>
+ <td width="80px" style="display:none;"><apex:inputCheckbox value="{!estimate.Print_DiscountPrice__c}"/>浼樻儬浠锋牸</td>
+ <td width="80px"><apex:inputCheckbox value="{!estimate.Print_MaintePrice__c}"/>鍚堝悓浠锋牸</td>
+
+ </tr>
+ <tr>
+ <th width="70px">鎵撳嵃鍚堝悓閰嶇疆</th>
+ <td width="80px">
+
+ <!-- 2018/10/26HWAG-B5C88S 鍖婚櫌鍜岀粡閿�鍟嗗悎鍚屼换浣曟椂鍊欓兘涓嶈兘閫夋嫨 start -->
+
+ <apex:outputPanel rendered="false">
+ <apex:inputCheckbox value="{!estimate.Print_Contract__c}" />
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 鍖婚櫌鍚堝悓
+ </td>
+ <!-- 2018/09/26 HWAG-B4SCR3 涓夋柟鍜屼唬鐞嗗晢鍚堝悓鍦ㄦ湭decide鍓嶄篃涓嶈兘閫夋嫨 start -->
+ <td width="70px">
+ <apex:outputPanel rendered="{!EnablePrintContract}">
+ <apex:inputCheckbox id="tripartite" value="{!estimate.Print_Tripartite__c}"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 涓夋柟鍗忚</td>
+ <td width="70px">
+ <apex:outputPanel rendered="false">
+ <apex:inputCheckbox id="agent" value="{!estimate.Print_Agent__c}"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 浠g悊鍟嗗悎鍚�</td>
+ <!-- 2018/09/26 HWAG-B4SCR3 涓夋柟鍜屼唬鐞嗗晢鍚堝悓鍦ㄦ湭decide鍓嶄篃涓嶈兘閫夋嫨 end -->
+ <!-- 2018/10/26 HWAG-B5C88S 鍖婚櫌鍜岀粡閿�鍟嗗悎鍚屼换浣曟椂鍊欓兘涓嶈兘閫夋嫨 end -->
+ <td colspan="3" style="text-align: right"><apex:commandButton action="{!print}" value="PDF鍗板埛" rerender="allBlock,pdfPrint" disabled="{!PrintBtnDisabled}" onclick="if (!onclickCheckchangedAfterPrint('Pt{!SaveBtnDisabled}','false')) return false;" oncomplete="unblockUI();ComputeLTYRepair()"/></td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table class="btntable" border="0">
+ <tr>
+ <td> </td>
+ <td> </td>
+ <td width="20px"> </td>
+ <td> </td>
+ <td> </td>
+ <td width="30px"> </td>
+ <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();"/></td>
+
+ <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();ComputeLTYRepair();"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
+ <apex:outputText style="color:red;font-size:20px;" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
+ </td>
+ </tr>
+ <tr>
+ <th>{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Contract_Start_Date__c.label}</th>
+ <td><apex:inputField value="{!estimate.Contract_Start_Date__c}" id="contractstartdate" onchange="changeContractStartdate(this.value);"/></td>
+ <td> </td>
+ <th> {!$ObjectType.Maintenance_Contract_Estimate__c.fields.Contract_End_Date__c.label}</th>
+ <td><apex:outputField value="{!estimate.Contract_End_Date__c}" id="contractenddate"/></td>
+ <td> </td>
+ <td><apex:commandButton id="decidebtn" value="{!$Label.QuoteDecision_Button}" disabled="{!DecideBtnDisabled}" onclick="decideJs(); return false;"/></td>
+ <td style="text-align:right"><apex:commandButton id="undecidebtn" action="{!undecide}" value="鍙栨秷{!$Label.QuoteDecision_Button}" disabled="{!UnDecideBtnDisabled}" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</apex:form>
+<apex:outputPanel id="pdfPrint">
+<script type="text/javascript">
+//j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+
+function saveBeforeCheckPriceChange() {
+ sforce.connection.sessionId = Session_ID;
+ var needClearId = false;
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ var assIds = "";
+ var proIds = "";
+ var priceMap = new Map();
+ var newProductMap = new Map();
+ var newProductCheck = false;
+ var nowDate = new Date();
+ var createdDate = null;
+ var createdDateShow = j$(escapeVfId('allPage:allForm:allBlock:contract:createDateShow')).text();
+ var contractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ if (createdDateShow.trim() != '') {
+ createdDate = new Date(createdDateShow);
+ newProductCheck = true;
+ } else {
+ createdDate = new Date();
+ }
+ var threeMonthAfter = new Date(createdDate.setMonth(createdDate.getMonth() + 3));
+ createdDate = new Date(createdDate.setMonth(createdDate.getMonth() - 3));
+ for (var i = 0; i < rowCnt; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ var price = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (a.size() > 0 && a.value() != "000000000000000000" && a.value() != "") {
+ if (proIds == "") {
+ proIds = "'" + a.value() + "'";
+ } else {
+ proIds = proIds + ",'" + a.value() + "'";
+ }
+ if (isnew == "true") {
+ priceMap.set(a.value(), price/{!isNewPriceAdj});
+ } else {
+ priceMap.set(a.value(), price);
+ }
+ newProductMap.set(a.value(), isnew);
+
+ } else {
+ continue;
+ }
+ }
+ else {
+ var aId = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetId')).value();
+ if (assIds == "") {
+ assIds = "'" + aId + "'";
+ } else {
+ assIds = assIds + ",'" + aId + "'";
+ }
+ if (isnew == "true") {
+ priceMap.set(aId, price/{!isNewPriceAdj});
+ } else {
+ priceMap.set(aId, price);
+ }
+ newProductMap.set(aId, isnew);
+ }
+ }
+ // 閫夋嫨璁惧鍚庝环鏍煎彉鏇碿heck
+ if (assIds.length > 0) {
+ var sql = "SELECT Id, Maintenance_Price_Month__c, Posting_Date__c, InstallDate from Asset where Id In(" + assIds + ")";
+ var rt = sforce.connection.query(sql);
+ var asList = rt.getArray("records");
+ if (asList != null) {
+ for(var i=0;i<asList.length;i++) {
+ var asvar = asList[i];
+ var asId = asvar["Id"];
+ var mprice = asvar["Maintenance_Price_Month__c"];
+ var ptDt = asvar["Posting_Date__c"];
+ var postingDate = null;
+ if (ptDt != null && ptDt != '') {
+ postingDate = new Date(ptDt);
+ }
+ var inDt = asvar["InstallDate"];
+ var installDate = null;
+ if (inDt != null && inDt != '') {
+ installDate = new Date(inDt);
+ }
+ var priceShow = priceMap.get(asId);
+ var isNew = newProductMap.get(asId);
+ if ('{!DecideBtnDisabled}' == 'true') {
+ if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
+ needClearId = true;
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ // 鏂板搧check
+ var sixCreateDate = new Date(createdDate.setMonth(createdDate.getMonth() + 6));
+ createdDate.setMonth(createdDate.getMonth() - 6);
+ if (contractDate >= sixCreateDate && newProductCheck) {
+ if (isNew=='true') {
+ needClearId = true;
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ } else {
+ var threeCreateDate = new Date(createdDate.setMonth(createdDate.getMonth() + 3));
+ createdDate = new Date(createdDate.setMonth(createdDate.getMonth() - 3));
+ if (newProductCheck) {
+ var isNewDate = null;
+ var isNewProduct = 'false';
+ if (contractDate >= threeMonthAfter) {
+ isNewDate = new Date(contractDate);
+ } else {
+ isNewDate = new Date(createdDate);
+ }
+ if (postingDate != null && postingDate != '' && (installDate == null || installDate == '')) {
+ if (new Date(isNewDate.setMonth(isNewDate.getMonth()-6)) < postingDate) {
+ isNewProduct = 'true';
+ }
+ } else if (postingDate != null && postingDate != '' && installDate != null && installDate != '') {
+ // alert('postingDate:'+postingDate+'/installDate:'+installDate);
+ if (new Date(postingDate.setMonth(postingDate.getMonth()+6)) >= installDate) {
+ var dt = new Date(isNewDate.setMonth(isNewDate.getMonth()-6));
+ if (dt < installDate) {
+ isNewProduct = 'true';
+ }
+ }
+ } else if ((postingDate == null || postingDate == '') && installDate != null && installDate != '') {
+ if (new Date(isNewDate.setMonth(isNewDate.getMonth()-6)) < installDate) {
+ isNewProduct = 'true';
+ }
+ // isNewDate.setMonth(isNewDate.getMonth()+6);
+ }
+ // alert('contract:'+contractDate+'/create:'+createdDate+'/install:'+installDate+'/date:'+isNewDate);
+ // alert('oldNew:'+isNew + 'isNew:'+isNewProduct);
+ if (isNew != isNewProduct) {
+ needClearId = true;
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (proIds.length > 0) {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ var oldDateStr = j$('#oldContractDate').value();
+ var oldDate = new Date();
+ if (oldDateStr != null && oldDateStr != '') {
+ oldDate = new Date(oldDateStr);
+ }
+ var crdt = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:createDateShow')).text());
+ var newContractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ var sixMonthAfter = new Date(crdt.setMonth(crdt.getMonth() + 6));
+ if ((newContractDate > sixMonthAfter && oldDate <= sixMonthAfter) || (newContractDate <= sixMonthAfter && oldDate > sixMonthAfter)) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return true;
+ }
+ } else {
+ var sql = "SELECT Id, Maintenance_Price_Month__c from Product2 where Id In(" + proIds + ")";
+ var rt = sforce.connection.query(sql);
+ var pdList = rt.getArray("records");
+ if (pdList != null) {
+ for(var i=0;i<pdList.length;i++) {
+ var pdvar = pdList[i];
+ var pdId = pdvar["Id"];
+ var mprice = pdvar["Maintenance_Price_Month__c"];
+ var priceShow = priceMap.get(pdId);
+ if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
+ needClearId = true;
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ }
+ }
+ }
+ // var changedPrice = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ // if (changedPrice=='true') {
+ // needClearId = true;
+ // }
+ return needClearId;
+}
+
+// SelectAssetEstimateController#checkchangedAfterPrint 銇ㄥ悓銇樸儹銈搞儍銈伀銇欍倠蹇呰銇屻亗銈娿伨銇欍��
+// true 澶夋洿銇傘倞銆乫alse 澶夋洿銇仐
+function checkchangedAfterPrint() {
+ sforce.connection.sessionId = Session_ID;
+ var needClearId = false;
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ var changedPrice = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ // 鏂拌銇牬鍚堛�乼argetEstimateId銇屻仾銇勩�佸垽鏂亜銈夈仾銇�
+ if ('{!targetEstimateId}' == '') return needClearId;
+ if ('{!estimate.Quote_Date__c}' != '' || '{!estimate.Process_Status__c}' != '鑽夋涓�') {
+ // xud 20140529 銇撱亾銇槑绱板鏇村垽鏂�
+ // xudan 20150729 銈姐兗銉堥爡鐩伀Id銈掕拷鍔�
+ var sql = "SELECT Id, Asset__c, Asset__r.SerialNumber, Check_Result__c, Product_Manual__c,"
+ + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c"
+ + " FROM Maintenance_Contract_Asset_Estimate__c"
+ + " WHERE Maintenance_Contract_Estimate__c = '{!targetEstimateId}'"
+ + " ORDER BY id,Asset__c,Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate";
+ var result = sforce.connection.query(sql);
+ var mcaeList = result.getArray("records");
+ var inputingList = [];
+ var finalPrice = 0;
+ // 鐢婚潰鍏ュ姏鍊ゃ倰鏁寸悊锛堛亜銈夈仾銇勩倐銇倰瀵捐薄澶栥伀銇欍倠锛�
+ var cntWithKara = {!productCount};
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (a.size() > 0 && a.value() != "000000000000000000" && a.value() != "") {
+ inputingList.push(
+ {'id' : '',
+ 'Product_Manual__c' : a.value(),
+ 'Check_Result__c' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult')).value(),
+ 'Repair_Price__c' : localParseFloat(j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value())),
+ 'Comment__c': j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).value()
+ }
+ );
+ } else {
+ continue;
+ }
+ }
+ else {
+ inputingList.push(
+ {'id' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetId')).value(),
+ 'Check_Result__c' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult')).value(),
+ 'Repair_Price__c' : localParseFloat(j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value())),
+ 'Comment__c': j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).value()
+ }
+ );
+ }
+ }
+ //閽堝inputingList鐨勯噸鏂版帓搴�
+ var arrayMap = [];
+ var ArrayOrderPMCnt = [];
+ for(var i=0;i<mcaeList.length;i++){
+ var mcaeVar = mcaeList[i];
+ var AssetIDOrPMC = mcaeVar["Asset__c"]!=null?mcaeVar["Asset__c"]:mcaeVar["Product_Manual__c"];
+ if(arrayMap[AssetIDOrPMC]!=null){
+ arrayMap[AssetIDOrPMC] = i;
+ ArrayOrderPMCnt[AssetIDOrPMC] = i;
+ }else{
+ // Product_Manual__c鐩稿悓鐨勮瘽鎬庝箞鍔�
+ if(ArrayOrderPMCnt[AssetIDOrPMC]==null){
+ ArrayOrderPMCnt[AssetIDOrPMC] = i;
+ }else{
+ var cacheArray = new Array();
+ cacheArray = ArrayOrderPMCnt[AssetIDOrPMC];
+ ArrayOrderPMCnt[AssetIDOrPMC] = cacheArray+','+i;
+ }
+
+ }
+
+ }
+ var inputingListCache = inputingList;
+ var cntLength = mcaeList.length>inputingListCache.length?mcaeList.length:inputingListCache.length;
+ if(mcaeList.length!=inputingListCache.length){
+ needClearId = true;
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ inputingList = new Array(cntLength);
+ var inputingListOut = new Array();
+ for(var i=0;i<inputingListCache.length;i++){
+ var InputIdOrPMc = inputingListCache[i].id!=""?inputingListCache[i].id:inputingListCache[i].Product_Manual__c;
+ var thisArray = ArrayOrderPMCnt[InputIdOrPMc];
+ if(thisArray.length!=null){
+ thisArray = thisArray.split(',');
+ var ORDERCnt = thisArray[0];
+ thisArray.shift();
+ thisArray = thisArray.join(',');
+ ArrayOrderPMCnt[InputIdOrPMc] = thisArray;
+ }else{
+ var ORDERCnt = thisArray;
+ }
+ if( ORDERCnt !=null){
+ inputingList[ORDERCnt] = inputingListCache[i];
+ }else{
+ inputingList[ORDERCnt] = inputingListCache[i];
+ inputingListOut.push(inputingListCache[i]);
+ }
+ }
+ if( inputingListOut.length>0){
+ for(var i = 0; i<inputingListOut.length;i++){
+ inputingList.push(inputingListOut[i]);
+ }
+ }
+ //20161122,娴嬭瘯鍙戠幇Check_Result__c宸插仠鐢紝鏁呰�屼慨鏀瑰搴旂殑Js鍒ゆ柇閮ㄥ垎
+ /*
+ && (((mcae["Check_Result__c"] == null || mcae["Check_Result__c"] == "")
+ && (inputing["Check_Result__c"] == null || inputing["Check_Result__c"] == "")
+ )
+ || mcae["Check_Result__c"] == inputing["Check_Result__c"]
+ )
+ //==================================================================================
+ && (((mcae["Check_Result__c"] == null || mcae["Check_Result__c"] == "")
+ && (inputing["Check_Result__c"] == null || inputing["Check_Result__c"] == "")
+ )
+ || mcae["Check_Result__c"] == inputing["Check_Result__c"]
+ )
+ */
+ //鍘熸槸浠g爜淇濈暀
+ if (inputingList.length == mcaeList.length && needClearId == false ) {
+ for (var i = 0; i < mcaeList.length; i++) {
+ var mcae = mcaeList[i];
+ finalPrice = mcae["Maintenance_Contract_Estimate__r"]["Maintenance_Price__c"];
+ var inputing = inputingList[i];
+ if (mcae["Asset__c"] != null && mcae["Asset__c"] != "") {
+ if (inputing["id"] != "" && mcae["Asset__c"] == inputing["id"]
+ && localParseFloat(mcae["Repair_Price__c"]) == inputing["Repair_Price__c"]
+
+ && (((mcae["Comment__c"] == null || mcae["Comment__c"] == "")
+ && (inputing["Comment__c"] == null || inputing["Comment__c"] == "")
+ )
+ || mcae["Comment__c"] == inputing["Comment__c"]
+ )
+ ) {
+ // 鍚屻仒
+ } else {
+ needClearId = true;
+ break;
+ }
+ } else {
+ if (inputing["id"] == "" && mcae["Product_Manual__c"] != null && mcae["Product_Manual__c"] != ""
+ && mcae["Product_Manual__c"] == inputing["Product_Manual__c"]
+
+ && localParseFloat(mcae["Repair_Price__c"]) == inputing["Repair_Price__c"]
+ && (((mcae["Comment__c"] == null || mcae["Comment__c"] == "")
+ && (inputing["Comment__c"] == null || inputing["Comment__c"] == "")
+ )
+ || mcae["Comment__c"] == inputing["Comment__c"]
+ )
+ ) {
+ // 鍚屻仒
+ } else {
+ needClearId = true;
+ break;
+ }
+ }
+ }
+ } else {
+ needClearId = true;
+ }
+
+ // xud 20140529 銇撱亾銇窂閲戦澶夋洿鍒ゆ柇锛堝壊寮曘倰澶夋洿銇椼仧銈夈伨銇氥亜锛�
+ var inputFinalPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteRealHidden')).value();
+ if (toNum(inputFinalPrice) != toNum(finalPrice)) {
+ needClearId = true;
+ }
+ if (changedPrice=='true') {
+ needClearId = true;
+ }
+ }
+ if (needClearId) {
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ }
+ return needClearId;
+}
+if ('{!printAsset}' == 'true') {
+ //鎵撳嵃淇濇湁瑷倷
+ window.open('/apex/MaintenanceContractEstimatePDF?id={!targetEstimateId}', 'MaintenanceContractEstimatePDF');
+} else if ('{!printContract}' == 'true') {
+ // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printContract', 'MceConfigPDF');
+} else if ('{!printTripartite}' == 'true') {
+ //鎵撳嵃涓夋柟鍚堝悓
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printTripartite', 'MceConfigPDF');
+} else if ('{!printAgent}' == 'true') {
+ //鎵撳嵃缁忛攢鍟嗗悎鍚�
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printAgent', 'MceConfigPDF');
+}else {}
+</script>
+</apex:outputPanel>
+</apex:page>
\ No newline at end of file
diff --git a/force-app/main/default/pages/SelectAssetEstimate.page-meta.xml b/force-app/main/default/pages/SelectAssetEstimate.page-meta.xml
new file mode 100644
index 0000000..cc36132
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimate.page-meta.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>31.0</apiVersion>
+ <availableInTouch>false</availableInTouch>
+ <confirmationTokenRequired>false</confirmationTokenRequired>
+ <label>SelectAssetEstimate</label>
+</ApexPage>
diff --git a/force-app/main/default/pages/SelectAssetEstimateJumpPage.page b/force-app/main/default/pages/SelectAssetEstimateJumpPage.page
new file mode 100644
index 0000000..5cf919b
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimateJumpPage.page
@@ -0,0 +1,22 @@
+<apex:page standardcontroller="Maintenance_Contract_Estimate__c" sidebar="false">
+ <!-- <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.apex20)}"/> -->
+ <script type="text/javascript">
+ var rdn = '{!Maintenance_Contract_Estimate__c.RecordType_DeveloperName__c}';
+ // 杩藉姞闄愭璺宠浆
+ var urf = '{!Maintenance_Contract_Estimate__c.URF_Contract__c}';
+ if(rdn == 'NewMaintenance_Quote'){
+
+ if (urf == 'true') {
+ window.open("/apex/SelectAssetEstimateURF?id={!URLENCODE(Maintenance_Contract_Estimate__c.Id)}", "_self")
+ }else{
+ window.open("/apex/SelectAssetEstimateVM?id={!URLENCODE(Maintenance_Contract_Estimate__c.Id)}", "_self");
+ }
+
+ }else{
+ window.open("/apex/SelectAssetEstimate?id={!URLENCODE(Maintenance_Contract_Estimate__c.Id)}", "_self");
+ }
+ </script>
+ <body>
+ </body>
+</apex:page>
\ No newline at end of file
diff --git a/force-app/main/default/pages/SelectAssetEstimateJumpPage.page-meta.xml b/force-app/main/default/pages/SelectAssetEstimateJumpPage.page-meta.xml
new file mode 100644
index 0000000..89893c4
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimateJumpPage.page-meta.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>41.0</apiVersion>
+ <availableInTouch>false</availableInTouch>
+ <confirmationTokenRequired>false</confirmationTokenRequired>
+ <label>SelectAssetEstimateJumpPage</label>
+</ApexPage>
diff --git a/force-app/main/default/pages/SelectAssetEstimateURF.page b/force-app/main/default/pages/SelectAssetEstimateURF.page
new file mode 100644
index 0000000..824561a
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimateURF.page
@@ -0,0 +1,2613 @@
+<apex:page controller="SelectAssetEstimateURFController" tabStyle="Maintenance_Contract_Estimate__c" sidebar="false" showHeader="true" id="allPage" action="{!init}" lightningStylesheets="true">
+<head>
+ <!-- <meta http-equiv="x-ua-compatible" content="ie=edge" /> -->
+ <!-- <meta name="viewport" content="width=device-width, initial-scale=1" /> -->
+ <!-- <apex:slds /> -->
+</head>
+ <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
+<style type="text/css">
+ table { border-collapse: collapse; }
+
+ .container {
+ overflow:auto;
+ width:100%;
+ height:304px;
+ }
+ .container2 {
+ overflow:auto;
+ width:100%;
+ height:404px;
+ }
+ .btntable.dateFormat {
+ display: none;
+ }
+</style>
+<script type="text/javascript">
+//add by rentx 2020-11-17 start 澶卞幓鐒︾偣
+function setFocusOnLoad() {}
+function bodyOnLoad(){setFocusOnLoad();}
+//add by rentx 2020-11-17 end 澶卞幓鐒︾偣
+
+var oxygenPriceAdj = {!oxygenPriceAdj};
+var approvalDate = '';
+var Session_ID = '{!$Api.Session_ID}';
+var Confirm_ChangedAfterPrint = '鎵撳嵃鍚庤淇℃伅鏈夊彉鍖栵紝鏄惁缁х画鎿嶄綔锛堟姤浠风紪鐮佷細鍙樻柊锛夛紵';
+var isNewAddMonth = {!isNewAddMonth};
+var Confirm_EstimateRefresh = '宸茶秴杩囧垱寤烘棩3涓湀锛屾槸鍚︽洿鏂版姤浠凤紵';
+window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });
+
+function approvalJs() {
+ approvalDate = new Date();
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ refreshAsset(rowCnt);
+}
+
+//add by gwy 2021-01-27 start 鎻愪氦鏃剁殑鎻愮ず妗�
+function KindsAndMonths() {
+ var months = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
+ var contrNew = document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML;
+ if(months>12 && months<60 && contrNew == '鏂板搧鍚堝悓'){
+ if(confirm("鏈鎮ㄦ彁浜ょ殑鎶ヤ环涓哄骞存湡鏂板搧鍚堝悓锛岃鎮ㄥ湪姝e紡鎻愪氦鎶ヤ环鍓嶅厛灏嗙粡閿�鍟嗕笌鍖婚櫌绛捐鐨勫骞存湡鍚堝悓閭欢鍙戦�佹湇鍔℃湰閮ㄦ姤浠风獥鍙c�傝嫢宸茬粡鎻愪氦璇风偣鍑荤‘瀹氾紝缁х画淇濆瓨鎻愪氦銆�")){
+ return true;
+ }else{
+ return false;
+ }
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ var FirstParagraphEnd = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
+ if(FirstParagraphEnd){
+ if (confirm('鏈绛剧害缁忛攢鍟嗘槸鍏堟瀵硅薄锛岃纭鏄惁鎻愪氦鎶ヤ环锛�')) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ return true;
+}
+//add by gwy 2021-01-27 end 鎻愪氦鏃剁殑鎻愮ず妗�
+
+
+
+
+
+function unblockUI(){
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+ // disable1();
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+ pageSetDisabled();
+ var isChange = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ if (isChange=='true') {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('false');
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ refreshAsset(rowCnt);
+ }
+ j$("#sbArea").fadeOut(500, function(){
+ j$("#sbArea").remove();
+ });
+}
+//<!-- HWAG-B4R3SS START 20181026-->
+function clearAndSearch() {
+ document.getElementById("allPage:allForm:allBlock:text1").value = "";
+ document.getElementById("allPage:allForm:allBlock:cond1").value = "equals";
+ document.getElementById("allPage:allForm:allBlock:val1").value = "";
+ blockme();
+ searchfunc();
+}
+function searchJs() {
+ blockme();
+ searchfunc();
+}
+
+//<!-- HWAG-B4R3SS END 20181026-->
+// 鍒濆鍖栬瀹氱敾闈㈤」鐩笉鍙敤
+function pageSetDisabled(){
+ var isDisabled = {!PageDisabled};
+ if (isDisabled) {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:depart')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:EndUserType')).attr("disabled", true);
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).attr("disabled", true);
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ var rowCnt = {!productCount};
+ for (var i = 0; i < rowCnt; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert'));
+ a.attr("disabled", true);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).attr("disabled", true);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discountReason')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:improveConsumptionRateIdea')).attr("disabled", true);
+
+
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:finalPriceDecideWay')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:Sales_incidental')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:mainTalksTime')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:talksStartDate')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:AgencyHos_Price')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:discountReason')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:improveConsumptionRateIdea')).attr("disabled", true);
+
+ j$(escapeVfId('allPage:allForm:contractstartdate')).attr("disabled", true);
+ var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
+ if (target != '鍖婚櫌') {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).attr("disabled", true);
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd')).attr("disabled", true);
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ }
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).attr("disabled", false);
+ }
+}
+// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+// function disable1(){
+// var isDisabled;
+// if(isDisabled){
+// var rowCnt = {!productCount};
+// for (var i = 0; i < rowCnt; i++) {
+// // 淇濇湁璁惧鍚�
+// var assN = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:'+ i +':assetName')).text();
+// var assN1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:'+ i +':Assert')).val();
+// // alert('1234567'+assN +'----'+assN1);
+// if(!assN1 && !assN){
+// // alert('23456789'+assN);
+// j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck' )).attr("disabled", true);
+// }else{
+// j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck' )).attr("disabled", false);
+// }
+// }
+// }
+// }
+// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+var winOpenObj;
+function closeWin(flg) {
+ winOpenObj.close();
+ if (flg==2) {
+ window.location.href="/{!URLENCODE(estimate.Id)}/e?completion=2";
+ }
+}
+function controlDisabled() {
+ winOpenObj = window.open("/apex/ChangeDealerApproval?eid=" + '{!URLENCODE(estimate.Id)}','ChangeDealerApproval','height=300,width=700,toolbar=no,menubar=no,left=20%,top=30%,scrollbars=yes,resizable=no,location=no,status=no');
+}
+// 瑕嬬銈傘倞浣滄垚寰屻�侊紦銉舵湀浠ュ唴銇с亗銈屻伆瑕嬬銈傘倞銇唴瀹广倰缍欑稓浣跨敤鍙兘
+function calonLoad() {
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+ // disable1();
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+ pageSetDisabled();
+ var createdDate = new Date('{!estimate.CreatedDate}');
+ // 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
+ var aLLManual = 'true';
+ var cntWithKara = {!productCount};
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual != 'true') {
+ aLLManual = 'false';
+ break;
+ }
+ }
+ var nowDate = new Date();
+ if (aLLManual == 'false') {
+ createdDate = createdDate.setMonth(createdDate.getMonth() + 3);
+ // FIX liang JS銇檪闁撱仯銇� addMonths銇亜銇с仚銇嬶紵 銇濄亱銈� 1/1 銇倝銆� 4/1銈傘仩銈併仹銇欍倛銆�
+ if (createdDate < Date.parse(nowDate)) {
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("disabled", true);
+ // 鏈�鍒濄伅銆丏ecide銇悓鏅傘伀淇濆瓨銈傘亗銈娿伨銇欍�併仢銈屻倰闃层亹銇熴倎銆佷繚瀛樸仺Decide銈掑悓鏅傘伀鐒″姽銇仚銈�
+ // 鑰冦亪銇︺伩銈嬨仺銆併偗銉┿偣銇獶ecide銇垽鏂亴銇傘倞銆丏ecide銇檪鏄庣窗澶夋洿銉併偋銉冦偗銈傘亗銈娿伨銇欍��3銉舵湀銇儊銈с儍銈倐銇傘倞銇俱仚銆併亾銇撱仹鐒″姽銇仚銈嬫剰鍛炽亴銇傘倞銇俱仜銈�
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
+
+ if (confirm(Confirm_EstimateRefresh)) {
+ window.location.href="/apex/SelectAssetEstimateURF?copyid={!URLENCODE(targetEstimateId)}";
+ return true;
+ } else {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ // decide鍙兘銇牬鍚堛�佸垾閫攄ecide銇儊銈с儍銈亴蹇呰銆�
+ // 銉併偋銉冦偗寰屽啀搴︾敾闈efresh銇曘倢銈嬨仧銈併�乨ecide鍙兘銇牬鍚堛�乨ecide銉溿偪銉炽亴浣裤亪銈嬨倛銇嗐伀銇倞銇俱仚銆�
+ changeContractStartdate('{!estimate.Contract_Start_Date__c}');
+ }
+ return false;
+ }
+ }
+ }else{
+ createdDate = createdDate.setMonth(createdDate.getMonth() + 6);
+ // FIX liang JS銇檪闁撱仯銇� addMonths銇亜銇с仚銇嬶紵 銇濄亱銈� 1/1 銇倝銆� 4/1銈傘仩銈併仹銇欍倛銆�
+ if (createdDate < Date.parse(nowDate)) {
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("class", 'btnDisabled');
+
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("disabled", true);
+ // 鏈�鍒濄伅銆丏ecide銇悓鏅傘伀淇濆瓨銈傘亗銈娿伨銇欍�併仢銈屻倰闃层亹銇熴倎銆佷繚瀛樸仺Decide銈掑悓鏅傘伀鐒″姽銇仚銈�
+ // 鑰冦亪銇︺伩銈嬨仺銆併偗銉┿偣銇獶ecide銇垽鏂亴銇傘倞銆丏ecide銇檪鏄庣窗澶夋洿銉併偋銉冦偗銈傘亗銈娿伨銇欍��3銉舵湀銇儊銈с儍銈倐銇傘倞銇俱仚銆併亾銇撱仹鐒″姽銇仚銈嬫剰鍛炽亴銇傘倞銇俱仜銈�
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
+
+ if (confirm('宸茶秴杩囧垱寤烘棩6涓湀锛屾槸鍚︽洿鏂版姤浠凤紵')) {
+ window.location.href="/apex/SelectAssetEstimateURF?copyid={!URLENCODE(targetEstimateId)}";
+ return true;
+ } else {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ // decide鍙兘銇牬鍚堛�佸垾閫攄ecide銇儊銈с儍銈亴蹇呰銆�
+ // 銉併偋銉冦偗寰屽啀搴︾敾闈efresh銇曘倢銈嬨仧銈併�乨ecide鍙兘銇牬鍚堛�乨ecide銉溿偪銉炽亴浣裤亪銈嬨倛銇嗐伀銇倞銇俱仚銆�
+ changeContractStartdate('{!estimate.Contract_Start_Date__c}');
+ }
+ return false;
+ }
+ }
+ }
+
+ if ('{!DecideBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).val(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
+ }
+}
+
+function checkAll(checker) {
+ var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ for (var i = 0; i < cnt; i++) {
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+ if (j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox')).size() == 0) {
+ continue;
+ }
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+ document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox').checked = checker.checked;
+ }
+}
+
+function checkAll2(checker) {
+ var cnt2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection2:productCnt2')).val();
+ var outer = 0;
+ for (var i = 0; i < cnt2; i++) {
+ outer = Math.floor(i / 1000);
+ if (document.getElementById('allPage:allForm:allBlock:assetSection2:outassetTable2:' + outer +':assetTable2:' + (i-(1000*outer)) + ':assetRowCheckbox2').disabled == false) {
+ document.getElementById('allPage:allForm:allBlock:assetSection2:outassetTable2:' + outer +':assetTable2:' + (i-(1000*outer)) + ':assetRowCheckbox2').checked = checker.checked;
+ }
+ }
+}
+
+function checkDiscount(val) {
+ if (val == null || val == "") {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val("");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_Rate')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_RateHidden')).val(0.00);
+ return;
+ }
+ if (isNaN(parseInt(val))) {
+ alert("璇疯緭鍏ユ暟鍊�");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(0.00);
+ return;
+ }
+ val = localParseFloat(val);
+ //val = Math.round(val * 100) / 100;
+ val = Math.round(val);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(toNumComma(val));
+ makeRealPrice(1);
+}
+
+function checkContractRange(val, cnt) {
+ if (isNaN(parseInt(val))) {
+ alert("蹇呴』杈撳叆鍚堝悓鏈堟暟!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ if (val <= 0) {
+ alert("鍚堝悓鏈堟暟蹇呴』澶т簬0");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ if (val > 60) {
+ alert("鍚堝悓鏈熸渶闀垮彧鑳介�夋嫨60涓湀锛�");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ // HWAG-BA73ZP
+ //contractStartDateChange();
+ refreshAsset(cnt);
+}
+//URF闄愭鍚堝悓2鏈� LY 20220811 start
+function checkVMaxRepairCount(val, cnt) {
+
+ var uRFSeriesMap =[];
+ for (var i = 0; i < cnt; i++) {
+ var uRFSeries = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uRFSeries')).text();
+ // var uRFSeries = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uRFSeries')).value();
+ uRFSeriesMap.push(uRFSeries);
+ }
+ if ((val == null || val == "" || val == "0") && uRFSeriesMap.includes('URF-V')){
+ alert("鍚堝悓瀵硅薄璁惧涓惈鏈塙RF-V绯诲垪锛屽繀椤婚�夋嫨URF-V鐨勬渶澶уぇ淇鏁�!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val("0");
+ return;
+ }
+ if ((val == "3") && uRFSeriesMap.includes('URF-V')){
+ alert("鍚堝悓瀵硅薄璁惧涓璘RF-V绯诲垪鐩墠涓嶈兘閫夋嫨3娆�!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val("0");
+ return;
+ }
+ if (uRFSeriesMap.includes('URF-V')==false) {
+ alert("鍚堝悓瀵硅薄璁惧涓笉鍚湁URF-V绯诲垪锛孶RF-V鐨勬渶澶уぇ淇鏁板繀椤婚�夋嫨/!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val("0");
+ }
+ refreshAsset(cnt);
+}
+function checkPMaxRepairCount(val, cnt) {
+ var uRFSeriesMap =[];
+ for (var i = 0; i < cnt; i++) {
+ var uRFSeries = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uRFSeries')).text();
+ uRFSeriesMap.push(uRFSeries);
+ }
+ if ((val == null || val == "" || val == "0") && uRFSeriesMap.includes('URF-P')){
+ alert("鍚堝悓瀵硅薄璁惧涓惈鏈塙RF-P绯诲垪锛孶RF-P鐨勬渶澶уぇ淇鏁板繀椤婚�夋嫨!");
+ //j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val("3");
+ }
+ if (uRFSeriesMap.includes('URF-P')==false) {
+ alert("鍚堝悓瀵硅薄璁惧涓笉鍚湁URF-P绯诲垪锛孶RF-P鐨勬渶澶уぇ淇鏁板繀椤婚�夋嫨/!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val("0");
+ }
+
+ refreshAsset(cnt);
+}
+//URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+function checkContractEstiStartDate(val, cnt) {
+ if (val == null || val == "") {
+ return;
+ }
+ for (var i = 0; i < cnt; i++) {
+ var instaldate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':InstallDate')).text();
+ if (instaldate != null && instaldate != '') {
+ var listprice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ if (isnew == "true") {
+ listprice = listprice / {!isNewPriceAdj};
+ }
+ var startdate = new Date(val);
+ startdate.setMonth(startdate.getMonth() + isNewAddMonth);
+ instaldate = new Date(instaldate);
+ if (startdate < instaldate) {
+ listprice = listprice * {!isNewPriceAdj};
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(listprice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNew')).attr('checked',true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val('true');
+ } else {
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(listprice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(listprice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNew')).attr('checked',false);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val('false');
+ }
+ }
+ }
+
+ refreshAsset(cnt);
+}
+
+function refreshAsset(cnt) {
+ // 鎻愪氦鍚庡氨椤甸潰涓嶈绠椾簡
+ var isDisabled = {!PageDisabled};
+ // 鍚堝悓鎬荤悊
+ var newCount = 0;
+ var oyearCount = 0;
+ var firstCCount = 0;
+ var conCCount = 0;
+ // row閲戦鍚堣▓
+ var repairSum = 0;
+ var listSum = 0;
+ // 鏂板搧鍚堝悓 鍒ゆ柇
+ var newCon = true;
+ var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+
+
+ // 棰勫畾寮�濮嬫棩
+ var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
+ // 棰勫畾寮�濮嬫棩-6涓湀
+ startdate.setMonth(startdate.getMonth() - 6);
+ // 鐢宠鏃� 褰撳墠鏃ユ湡
+ if(approvalDate != ''){
+ //鐢宠鏃�
+ approvalDate = new Date(approvalDate.toLocaleDateString());
+ if (Date.parse(approvalDate) < Date.parse(startdate)) {
+ newCon = false;
+ }
+
+ }
+
+ // 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+ var downPriceSum = 0;
+ var upPriceSum = 0;
+ // 鍚堝悓鏈堟暟涔楃畻
+ var month = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ var estimateURFVMaxRepairCount=localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val())
+ var estimateURFPMaxRepairCount=localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val())
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ var Contract_year = 0;
+ if (month == undefined || month == "" || month <= 12) {
+ Contract_year = 1;
+ } else{
+ Contract_year = Math.ceil(month / 12);
+ }
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ var month2 = 0;
+ if (month > 12) {
+ month2 = month - 12;
+ month = 12;
+ }
+ for (var i = 0; i < cnt; i++) {
+ var strMoney = 0;
+ var repairMoney = 0;
+ // 琛岄」鐩� 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+ // 缁浠锋牸鍙栬仈鍔ㄤ环鏍奸〉闈㈣绠楋紝棣栫鎴栦骇鍝佸彇 瀹為檯浠锋牸
+ // 涓嬬嚎浠锋牸
+ var downPrice = 0;
+ // 涓婄嚎浠锋牸
+ var upPrice = 0;
+
+ // 12涓湀鍚堝悓閲戦
+ var Price_YearTXT = 0;
+
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ var assetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+
+ // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+ //var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+ //isNewDate.setMonth(isNewDate.getMonth() + 6);
+ //if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+ // newCon = false;
+ //}
+
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ var uRFSeries= j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uRFSeries')).value();
+ if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==2) {
+ strMoneyMax = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMaxPrice')).val();
+ strMoneyMin = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMinPrice')).val();
+ }else if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==0) {
+ strMoneyMax = 0;
+ strMoneyMin = 0;
+ }else if (uRFSeries=='URF-P' && estimateURFPMaxRepairCount==0){
+ strMoneyMax = 0;
+ strMoneyMin = 0;
+ }else{
+ strMoneyMax = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMaxPrice3')).val();
+ strMoneyMin = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMinPrice3')).val();
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ // alert(strMoney);
+ Price_YearTXT = strMoney * 12;
+ if (isnew == 'true') {
+ newCount ++;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ strMoneyMin = Contract_year * strMoneyMin;
+ strMoneyMax = Contract_year * strMoneyMax;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ } else {
+ newCon = false;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ strMoneyMin = Contract_year * strMoneyMin;
+ strMoneyMax = Contract_year * strMoneyMax;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ }
+ var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+ var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+ if(b != ''){
+ conCCount ++;
+ // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+ // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+
+ var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ var lastContRange = 0;
+ if(LastMContractRecord == 'VM_Contract'){
+ newCount++;
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ lastContRange = 36;
+ }else{
+ lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+ }
+ //鏈�鍚庣粨鏉熸棩+1骞�
+ lastendDate.setMonth(lastendDate.getMonth() + 12);
+ if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+ oyearCount ++;
+ }
+ // 鍙栬仈鍔ㄤ环鏍�
+ // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+ //
+ var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+ var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+ var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+ //璁$畻鎯╃綒鐜�
+ var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+ if(Punish == 0){
+ return;
+ }
+ // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+ var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+ // if(Estimate_Num == 0){
+ // if(LastMContractRecord == 'VM_Contract'){
+ // //upPrice = (strMoney) * (1 + Adjustment_ratio_Upper/100);
+ // //downPrice = (strMoney) * (1 + Adjustment_ratio_Lower/100);
+ // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+ // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+ // }else{
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ upPrice = strMoneyMax;
+ // downPrice = strMoney * 0.8;
+ downPrice = strMoneyMin;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ // }
+ // }else{
+ // upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+ // downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+ // }
+ }else{
+ //firstCCount ++;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ upPrice = strMoneyMax;
+ // downPrice = strMoney * 0.8;
+ downPrice = strMoneyMin;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ }
+ // 涓婁笅闄愬洓鑸嶄簲鍏�
+ upPrice = upPrice.toFixed(2);
+ downPrice = downPrice.toFixed(2);
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+
+ repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+ } else {
+ // TODO 涓�鏅傜殑銇蹇溿�併仾銈撱仹鍒ヨ銇噾椤嶃儶銉曘儸銉冦偡銉ャ仌銈屻仧锛�
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val();
+
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text("");
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val();
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val();
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+ }
+ }
+ else {
+ // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+ var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+ isNewDate.setMonth(isNewDate.getMonth() + 6);
+ if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+ newCon = false;
+ }
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ var uRFSeries= j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uRFSeries')).value();
+ if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==2) {
+ strMoneyMax = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMaxPrice')).val();
+ strMoneyMin = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMinPrice')).val();
+ }else if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==0) {
+ strMoneyMax = 0;
+ strMoneyMin = 0;
+ }else if (uRFSeries=='URF-P' && estimateURFPMaxRepairCount==0){
+ strMoneyMax = 0;
+ strMoneyMin = 0;
+ }else{
+ strMoneyMax = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMaxPrice3')).val();
+ strMoneyMin = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uFRMinPrice3')).val();
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ Price_YearTXT = strMoney * 12;
+ if (isnew == 'true') {
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ strMoneyMin = Contract_year * strMoneyMin;
+ strMoneyMax = Contract_year * strMoneyMax;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ } else {
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ strMoneyMin = Contract_year * strMoneyMin;
+ strMoneyMax = Contract_year * strMoneyMax;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ }
+ var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+ var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+ if(b != ''){
+ conCCount ++;
+ // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+ // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+ var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ var lastContRange = 0;
+ if(LastMContractRecord == 'VM_Contract'){
+ newCount++;
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ lastContRange = 36;
+ }else{
+ lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+ }
+ //鏈�鍚庣粨鏉熸棩+1骞�
+ lastendDate.setMonth(lastendDate.getMonth() + 12);
+ if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+ oyearCount ++;
+ }
+ // 鍙栬仈鍔ㄤ环鏍�
+ // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+ //
+ var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+ var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+ var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+ //璁$畻鎯╃綒鐜�
+ var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+ if(Punish == 0){
+ return;
+ }
+ // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+ var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+ // if(Estimate_Num == 0){
+ // if(LastMContractRecord == 'VM_Contract'){
+ // //upPrice = (strMoney) * (1 + Adjustment_ratio_Upper/100);
+ // //downPrice = (strMoney) * (1 + Adjustment_ratio_Lower/100);
+ // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+ // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+ // }else{
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ upPrice = strMoneyMax;
+ // downPrice = strMoney * 0.8;
+ downPrice = strMoneyMin;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ // }
+ // }else{
+ // upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+ // downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+ // }
+ }else{
+ if (isnew == 'true') {
+ newCount ++;
+ } else {
+ newCon = false;
+ firstCCount ++;
+ }
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start
+ upPrice = strMoneyMax;
+ // downPrice = strMoney * 0.8;
+ downPrice = strMoneyMin;
+ // XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end
+ }
+ // 涓婁笅闄愬洓鑸嶄簲鍏�
+ upPrice = upPrice.toFixed(2);
+ downPrice = downPrice.toFixed(2);
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+ //
+ repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+ }
+ repairSum = repairSum + localParseFloat(repairMoney);
+ listSum = listSum + localParseFloat(toNum(strMoney));
+ downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
+ upPriceSum = upPriceSum + localParseFloat(toNum(upPrice));
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetListSumNum')).text(toNumComma(listSum));
+
+ //j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPrice')).text(toNumComma(listSum));
+ //j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPriceHidden')).val(toNum(listSum));
+ if (!isDisabled) {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text(toNumComma(Math.round(upPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val(toNum(Math.round(upPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text(toNumComma(Math.round(downPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val(toNum(Math.round(downPriceSum)));
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text(toNumComma(repairSum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPriceHidden')).val(toNum(repairSum));
+
+ var allcount = j$(escapeVfId('allPage:allForm:allBlock:productCount3')).value();
+ var result = '';
+ if (allcount == 0) {
+ result = null;
+ }else
+ if (newCount > 0 && newCount == allcount && newCon == true) {
+ result = '鏂板搧鍚堝悓';
+ }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
+ result = '棣栫鍚堝悓';
+ }else if(firstCCount > 0 && firstCCount == allcount){
+ result = '棣栫鍚堝悓';
+ // 20220328 ljh update LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+ // }else if(oyearCount > 0 && oyearCount == conCCount){
+ }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
+ // 20220328 ljh update LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+ result = '闈炵画绛惧悎鍚岋紙绌虹櫧鏈熶竴骞翠互涓婏級';
+ }else{
+ result = '缁鍚堝悓';
+ }
+ document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML = result;
+ document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXTHidden").value = result;
+ // 鍙栨秷閰稿寲姘�
+ //NotUseOxygenatedWaterAmount(1);
+ examinationPriceCal(cnt);
+ getLastContractRate();
+}
+
+
+
+function examinationPriceCal(cntWithKara) {
+ var examinationCount = localParseInt(j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).val());
+ var examinationCountStr = number_format_common(examinationCount, 0, ".", ",");
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).val(examinationCountStr);
+ var cnt = 0;
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+ cnt++;
+ }
+ }
+ else {
+ cnt++;
+ }
+ }
+ var examinationPrice = 0;
+// 浠婂緦寰╂椿銇嬨倐
+// var cntLot = Math.ceil(cnt / 20);
+// if (cntLot == 0) {
+// examinationPrice = 0;
+// }
+// else if (cntLot == 1) {
+// examinationPrice = 2000;
+// }
+// else if (cntLot == 2) {
+// examinationPrice = 3800;
+// }
+// else if (cntLot == 3) {
+// examinationPrice = 5400;
+// }
+// else if (cntLot == 4) {
+// examinationPrice = 6800;
+// }
+// else if (cntLot == 5) {
+// examinationPrice = 8000;
+// }
+// else if (cntLot >= 6) {
+// examinationPrice = 1600 * cntLot;
+// }
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationReal')).text(toNumComma(examinationPrice * examinationCount));
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationRealHidden')).val(toNum(examinationPrice * examinationCount));
+
+ // 浠樺姞鏉′欢绶忛娆�
+ // 20200108 鍘婚櫎闄勫姞鏉′欢鎬婚
+ // var oxygenPrice = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:NotUseOxygenatedWaterAmount')).text());
+ // j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPrice')).text(toNumComma(oxygenPrice + examinationPrice * examinationCount));
+ // j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPriceHidden')).val(toNum(oxygenPrice + examinationPrice * examinationCount));
+
+ makeRealPrice(1);
+}
+
+/*
+ * @param t 1: 閲戦銇倛銈婂壊寮�
+ */
+function makeRealPrice(t) {
+ // 瀹熼殯閲戦鍚堣▓
+ // 鐢宠鎶ヤ环閲戦
+ var sum1 = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val());
+ // 淇悊鎬婚
+ var sum2 = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
+ var sum1 = localParseFloat(sum1);
+ // 涓婇檺
+ var upPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text();
+ upPrice = localParseFloat(upPrice);
+ // 涓嬮檺
+ var downPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text();
+ downPrice = localParseFloat(downPrice);
+
+ // 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼 璁$畻
+ // 1锛夋爣鍑嗕环鏍艰寖鍥村唴鏃讹紝缁撴灉涓�0锛�
+ // 2锛夋瘮鏍囧噯浠锋牸浣庢椂锛岀粨鏋滄槸1-甯屾湜浠锋牸/鏍囧噯浠风殑鏈�浣庝环鏍�
+ // 3锛夋瘮鏍囧噯浠锋牸楂樻椂锛岀粨鏋滄槸1-甯屾湜浠锋牸/鏍囧噯浠风殑鏈�楂樹环鏍�
+ var disMP = 0.00;
+ var disP = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_RateHidden')).val();
+ if(sum1 < downPrice){
+ disMP = toNum((1 - sum1/downPrice) * 100);
+ }else if(sum1 >= downPrice && sum1 <= upPrice){
+ disMP = 0.00;
+ }else if(sum1 > upPrice){
+ disMP = toNum((1 - sum1/upPrice) * 100);
+ }
+
+
+ if (disMP != disP) {
+ disMP = '' + disMP + '%';
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_Rate')).text(disMP);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_RateHidden')).val(parseFloat(disMP));
+ }
+ // 淇悊绶忛銈掕▓涓�
+ sum = sum1 + localParseFloat(sum2);
+
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text(toNumComma(sum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteRealHidden')).val(toNum(sum));
+}
+
+function resetDealer() {
+ var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
+ var obj = document.getElementById('allPage:allForm:allBlock:contract:dealer');
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ var obj2 = document.getElementById('allPage:allForm:allBlock:contract:FirstParagraphEnd');
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ var obj_lkwgt = document.getElementById('allPage:allForm:allBlock:contract:dealer_lkwgt');
+ if (target == '鍖婚櫌') {
+ obj.style.display = "none";
+ obj_lkwgt.style.display = "none";
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ obj2.style.display = "none";
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ } else {
+ obj.style.display = "block";
+ obj_lkwgt.style.display = "block";
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ obj2.style.display = "block";
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ }
+}
+
+function alertMsg() {
+ // body...
+ if('{!isPaymentSet}' == 'false'){
+ alert('璇峰~鍐欎粯娆捐鍒�');
+ return false;
+ }else if('{!isPaymentSet}' == 'Denied'){
+ alert('浠樻璁″垝閲戦涓庡疄闄呬笉绗︼紝璇烽噸鏂板~鍐�');
+ return false;
+ }else{
+ return true;
+ }
+}
+function EGFlgconfim() {
+ getEstimateCost();
+ var cntWithKara = {!productCount};
+ // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 鏄惁鏀瑰彉
+ var alert1s = 0;
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var EGFlgtxt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':EquipmentGuaranteeFlg')).value();
+ var EGFlgnow = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':EGFlgassHidden')).value();
+ if (EGFlgtxt != EGFlgnow) {
+ alert1s = 1;
+ }
+ }
+ if (alert1s == 1) {
+ if (confirm("閫夋嫨鐨勪繚鏈夎澶嘯鏂板悎鍚屽鍝佺‘淇濇彁渚沒鍙戠敓鍙樺寲锛屾槸鍚︾户缁紵")) {
+
+ } else {
+ return false;
+ }
+ }
+ return onclickCheckchangedAfterPrint('true','true');
+}
+function onclickCheckchangedAfterPrint(saveBtnDisabled, saveOrApproval) {
+
+ //if(saveBtnDisabled == 'Pttrue'){
+ // var rs = alertMsg();
+ // if(rs){
+ // }else {
+ // return false;
+ // }
+ //}
+
+ var cntWithKara = {!productCount};
+ var alerts = 0;
+ // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 鏄惁鏀瑰彉
+ var alert1s = 0;
+ var today = new Date();
+ today.setMonth(today.getMonth() - 3);
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ var uRFSeriesMap =[];
+ var valURFV =j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val();
+ var valURFP =j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val();
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var plkid = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert_lkid'));
+ var pid = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (plkid.size() > 0 && pid.size() > 0) {
+ if (pid.value() != '' && plkid.value() != pid.value().substring(0, 15)) {
+ alert('璇蜂娇鐢ㄤ骇鍝佹斁澶ч暅鎸夐挳璁惧畾鎵嬪姩浜у搧');
+ return false;
+ }
+ }
+ }
+ if (isManual == 'false') {
+ var strDate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':finalExaminationDate')).value();
+ // var produ = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ //alert(EGFlgtxt + ':' + EGFlgnow);
+ strDate = strDate.replace(/(^\s*)|(\s*$)/g, "");
+ if (strDate == "" || Date.parse(strDate) < Date.parse(today)) {
+ alerts = 1;
+ }
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ var uRFSeries = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':uRFSeries')).text();
+ uRFSeriesMap.push(uRFSeries);
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ if ((valURFV == null || valURFV == "" || valURFV == "0") && uRFSeriesMap.includes('URF-V')){
+ alert("鍚堝悓瀵硅薄璁惧涓惈鏈塙RF-V绯诲垪锛屽繀椤婚�夋嫨URF-V鐨勬渶澶уぇ淇鏁�!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val("");
+ return;
+ }
+ if ((valURFP == null || valURFP == "" || valURFP == "0") && uRFSeriesMap.includes('URF-P')){
+ alert("鍚堝悓瀵硅薄璁惧涓惈鏈塙RF-P绯诲垪锛屽繀椤婚�夋嫨URF-P鐨勬渶澶уぇ淇鏁�!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val("0");
+ return;
+ }
+ if (uRFSeriesMap.includes('URF-V')==false) {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).val("0");
+ }
+ // if ((valURFP == null || valURFP == "" || valURFP == "0") && uRFSeriesMap.includes('URF-P')){
+ // j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val("3");
+ // }
+ if (uRFSeriesMap.includes('URF-P')==false) {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).val("0");
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ if (alerts == 1) {
+ if (confirm("閫夋嫨鐨勪繚鏈夎澶嘯鏈�鍚庣偣妫�鏃涓虹┖鎴栧凡缁忚秴杩囦笁涓湀涔嬪墠锛屾槸鍚︾户缁紵")) {
+
+ } else {
+ return false;
+ }
+ }
+ blockme();
+ if (saveOrApproval == "true") {
+ if (saveBeforeCheckPriceChange()) {
+ if (confirm("琛屼俊鎭湁鍙樺寲(鏈嶅姟鍚堝悓浠锋牸)锛屾槸鍚︽洿鏂版姤浠凤紵")) {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('true');
+ } else {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('fasle');
+ unblockUI();
+ return false;
+ }
+ }
+ j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ }
+
+
+ return true;
+ // if ((saveBtnDisabled == "true"||saveBtnDisabled == "Pttrue" )&& checkchangedAfterPrint()) {
+ // if (confirm(Confirm_ChangedAfterPrint)) {
+ // if (saveOrApproval == "true") {
+ // j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ // }
+ // return true;
+ // } else {
+ // unblockUI();
+ // return false;
+ // }
+ // } else {
+ // if (saveOrApproval == "true") {
+ // j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ // }
+ // return true;
+ // }
+}
+
+function changeEstiStartdate(val) {
+ if ('{!SaveBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(val);
+ changeContractStartdate(val);
+ }
+}
+
+function changeContractStartdate(val) {
+
+ var oldDateStr = j$('#oldContractDate').value();
+ var oldDate = new Date();
+ if (oldDateStr != null && oldDateStr != '') {
+ oldDate = new Date(oldDateStr);
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ var monthStr = '00' + (oldDate.getMonth()+1);
+ monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ var dayStr = '00' + oldDate.getDate();
+ dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ var oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+ j$(escapeVfId('allPage:allForm:oldDecideContractDate')).val(oldDateVal);
+ if (saveBeforeCheckPriceChange()) {
+ //blockme();
+ //contractStartDateChange();
+ //refreshAsset({!productCount});
+ }
+ refreshAsset({!productCount});
+ } else {
+ var cntWithKara = {!productCount};
+ var haveLine = 'false';
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert_lkid'));
+ if (a.size() > 0 && a.val() != "000000000000000") {
+ haveLine = 'true';
+ }
+ } else {
+ haveLine = 'true';
+ }
+ }
+
+ if (haveLine == 'false') {
+ return false;
+ }
+ var contractStartDate = new Date(val);
+ var strCreatedDate = '{!estimate.CreatedDate}';
+ var createDate = new Date();
+ if (strCreatedDate != '') {
+ createDate = new Date(strCreatedDate);
+ }
+ createDate = new Date(createDate.toDateString());
+ var threeMA = new Date(createDate.setMonth(createDate.getMonth() + 3));
+ var isnewMA = new Date(createDate.setMonth(createDate.getMonth() - 3 - isNewAddMonth));
+
+ /*if (oldDate >= isnewMA && contractStartDate >= isnewMA) {
+ return false;
+ }
+ if (oldDate < threeMA && contractStartDate < threeMA) {
+ return false;
+ }
+
+ if (contractStartDate >= isnewMA) {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖澶т簬鍒涘缓鏃�6涓湀锛屾墍鏈夊悎鍚屽璞¤澶囦笉閫傜敤鏂板搧浠锋牸銆俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ゆ湇鍔″悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ } else if (contractStartDate >= threeMA) {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖澶т簬鍒涘缓鏃�3涓湀锛屾墍鏈夊悎鍚屽璞¤澶囦娇鐢ㄣ�愬悎鍚屽紑濮嬫棩銆戦噸鏂拌绠楁湇鍔″悎鍚屼环鏍笺�俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ゆ湇鍔″悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ } else {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖鍦ㄥ垱寤烘棩3涓湀浠ュ唴锛屾墍鏈夊悎鍚屽璞¤澶囦娇鐢ㄣ�愬垱寤烘棩銆戦噸鏂拌绠楁湇鍔″悎鍚屼环鏍笺�俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ゆ湇鍔″悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ }*/
+ j$('oldContractDate').val(val);
+ //blockme();
+ //contractStartDateChange();
+ refreshAsset({!productCount});
+ }
+}
+function AlertPriceBtnJs(){
+
+ var VarAlert = j$(escapeVfId('allPage:allForm:alertStringValue')).val();
+ var VarAlert2 = j$(escapeVfId('allPage:allForm:alertStringValue2')).val();
+ var VarAlert3 = j$(escapeVfId('allPage:allForm:alertStringValue3')).val();
+ var PStatus = j$(escapeVfId('allPage:allForm:PriceStatus')).val();
+ blockme();
+
+ if(PStatus!='鐢宠涓�'&& PStatus!='鎵瑰噯'){
+ ComputeLTYRepair();
+ //ShowLTYRepair();
+ }else if(PStatus == '鐢宠涓�'||PStatus == '鎵瑰噯'){
+ ShowLTYRepair();
+ }
+
+}
+function ComputeLTY() {
+ var urlNameJs = j$(escapeVfId('allPage:allForm:urlName')).val();
+ urlNameJs = '{!$Label.ID_of_SelectAssetEstimate}'+urlNameJs ;
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ //var w = window.open(encodeURI(urlNameJs),'杩囧幓涓ゅ勾淇悊瀹炵哗','menubar=no,height=720,width=986');
+ //w.focus();
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+}
+function recordNumChangeJs() {
+ recordNumChangeAction();
+}
+
+function checkDecideDate() {
+ // 鎶ヤ环鏈夋晥鏈�
+ var strSubmitDate = '{!estimate.Submit_quotation_day__c}';
+ // 涓婃湡鍚堝悓缁撴潫鏃� 鍙栨渶鏅氱殑
+ var conEndDate = getLastContractendDate();
+ conEndDate = new Date(conEndDate);
+ // 浠婂ぉ
+ var submitDate = new Date();
+ var nowDate = new Date();
+ nowDate = new Date(nowDate.toLocaleDateString());
+ /// 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
+ // 榛樿涓�3鏈堬紝鍏ㄦ槸浜у搧涓�6鏈堬紱
+ var monthGap = 6;
+ var cntWithKara = {!productCount};
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual != 'true') {
+ monthGap = 3;
+ break;
+ }
+ }
+
+
+ //nowDate = new Date(nowDate.getYear(),nowDate.getYear(),nowDate.getYear());
+ if (strSubmitDate != '') {
+ submitDate = new Date(strSubmitDate);
+ submitDate = new Date(submitDate.setMonth(submitDate.getMonth() + monthGap));
+ if(Date.parse(conEndDate) > Date.parse(submitDate)){
+ submitDate = new Date(conEndDate);
+ }
+ }
+ //alert(nowDate + '=====' + submitDate);
+ if (strSubmitDate != '' && nowDate > submitDate) {
+ alert('宸茶秴鍑烘姤浠风敵璇锋棩'+ monthGap+'涓湀锛屼笉鍏佽DECIDE銆�');
+ return false;
+ }
+ return true;
+}
+
+function getLastContractendDate(){
+ var rowCnt = {!productCount};
+ var lastdate = null;
+ for (var i = 0; i < rowCnt; i++) {
+ var LastMContractID = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractID')).value();
+ if(!!LastMContractID){
+ var endDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ if(lastdate == null){
+ lastdate = new Date(endDate);
+ }else if(Date.parse(endDate) > Date.parse(lastdate)){
+ lastdate = new Date(endDate);
+ }
+ }
+ }
+ return lastdate;
+}
+
+
+function decideJs() {
+ if (checkDecideDate() == true) {
+ if (onclickCheckchangedAfterPrint('true','false') == true) {
+ var oldDate = j$(escapeVfId('allPage:allForm:oldDecideContractDate')).value();
+ var contractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ //var olDt = oldDate.getFullYear() + oldDate.getMonth() + oldDate.getDate();
+ var monthStr = '00' + (contractDate.getMonth()+1);
+ monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ var dayStr = '00' + contractDate.getDate();
+ dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ var contractDateStr = contractDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+
+ //var neDt = contractDate.getFullYear() + contractDate.getMonth() + contractDate.getDate();
+ //monthStr = '00' + (oldDate.getMonth()+1);
+ //monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ //dayStr = '00' + oldDate.getDate();
+ //dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ //oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+ if (oldDate == contractDateStr) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decide();
+ } else {
+ var oldp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).value());
+ var newp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
+
+ if (oldp != newp) {
+ // 20201106 楂樼珷浼� 鎻愰啋娑堟伅淇敼 start
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ if (confirm('鍚堝悓閲戦鍙戠敓鍙樺寲锛岃鎮ㄧ‘璁ゃ��')) {
+ decide();
+ } else {
+ alert('璇风‘璁ゅ叏閮ㄥ唴瀹瑰悗鐐瑰嚮Decide銆�');
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(oldDate);
+ j$(escapeVfId('allPage:allForm:oldDecideContractDate')).val('');
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decideCancle();
+ }
+ } else {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decide();
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ // if (confirm('鏈鍚堝悓寮�濮嬫棩鐨勪慨鏀逛笉浼氬鑷村悎鍚岄噾棰濆彂鐢熷彉鍖栵紝璇锋偍纭鏄惁淇敼锛�')) {
+ // decide();
+ // } else {
+ // j$(escapeVfId('allPage:allForm:contractstartdate')).val(oldDate);
+ // alert('鍚堝悓寮�濮嬫棩鏈繘琛屽彉鏇达紝璇风‘璁ゅ叏閮ㄥ唴瀹瑰悗鐐瑰嚮Decide銆�');
+ // unblockUI();
+ // }
+ }
+ // 20201106 楂樼珷浼� 鎻愰啋娑堟伅淇敼 end
+ }
+ }
+ }
+}
+// 鑾峰彇瀹為檯鎶ヤ环閲戦 鎸夌収涓婇檺姣斾緥绠�
+function getEstimateCost() {
+ // 琛屾暟
+ var rowcount = {!productCount};
+ // 6.鍚堝悓浠锋牸
+ var mainteReal = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
+ mainteReal = localParseFloat(mainteReal);
+ // 5.淇悊鎬婚
+ var assetRepairSumPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
+ assetRepairSumPrice = localParseFloat(assetRepairSumPrice);
+ // 璁$畻瀹為檯鎶ヤ环鎬婚噾棰�
+ var realprice = mainteReal - assetRepairSumPrice;
+ //URF闄愭鍚堝悓2鏈� LY 20221009 start
+ // 鏍囧噯浠锋牸鐨勬渶楂樹环鎬婚
+ var GuidePriceUp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val());
+ // //鏍囧噯浠锋牸鐨勬渶浣庝环鎬婚
+ var GuidePriceDown = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val());
+ GuidePriceUp = localParseFloat(GuidePriceUp);
+ GuidePriceDown = localParseFloat(GuidePriceDown);
+ for (var i = 0; i < rowcount; i++) {
+ // 鍘讳笂闄愪环鏍�
+ var assetListPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
+ // //鍙栦笅闄愪环鏍�
+ var assetLowerPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val();
+ assetListPrice = localParseFloat(assetListPrice);
+ var Estimate_Cost = 0;
+ if(realprice == GuidePriceUp){
+ Estimate_Cost = assetListPrice;
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_Cost')).val(0);
+ } else if (realprice == GuidePriceDown){
+ Estimate_Cost = assetLowerPrice;
+ }else{
+ Estimate_Cost = (realprice * (assetListPrice / GuidePriceUp)).toFixed(2);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_Cost')).val(Estimate_Cost);
+
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20221009 end
+}
+
+function getLastContractRate(){
+ var rowCnt = {!productCount};
+ var Contractrate = 0.00;
+ var count = 0;
+ for (var i = 0; i < rowCnt; i++) {
+ var LastMContractID = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractID')).value();
+ if(!!LastMContractID){
+ var tempContractrate = parseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).value().replace(/,/g,''));
+ if(!!tempContractrate){
+ Contractrate = Contractrate + tempContractrate;
+ }
+ count++;
+ }
+ }
+ var allContractRate = '' + 0.00 + '%';
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ // if( count > 0){
+ // allContractRate = '' + (Contractrate/count).toFixed(2) + '%';
+ // }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Combinedrate')).text(allContractRate);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:CombinedrateHidden')).val(parseFloat(allContractRate));
+
+ return allContractRate;
+}
+function calculateNtoMRatio(lastContRange, month ){
+ var lastContRangeYear = Math.ceil(localParseFloat(lastContRange)/12);
+ var currentMonthYear = Math.ceil(localParseFloat(month)/12);
+ //if(!lastendDate || currentMonthYear <= lastContRangeYear){
+ if(currentMonthYear == lastContRangeYear || currentMonthYear == 1){
+ return month;
+ }else if(month <= 24) {
+ return 12+ (month- 12) *1.1;
+ }else if(month <= 36) {
+ return 25.2 + (month- 24) *1.21;
+ }else if(month <= 48) {
+ return 39.72 + (month- 36) *1.331;
+ }else if(month <= 60) {
+ return 55.692 + (month- 48) *1.4641;
+ }else {
+ alert('鍚堝悓鏈熸渶闀垮彧鑳介�夋嫨60涓湀锛�');
+ return 0;
+ }
+}
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ //鑾峰彇缁忛攢鍟嗙殑鍏堟鏍囪瘑
+ function onChDealerUpdateJs(oBj){
+ //鑾峰彇 鎶ヤ环鎻愪氦瀵硅薄 鏄惁涓虹粡閿�鍟�
+ var estimateTarget = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget'))[0].value;
+ if(estimateTarget == '缁忛攢鍟�'){
+ //鍒ゆ柇缁忛攢鍟嗗悕鏄惁涓虹┖
+ var dealerValue = j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).val();
+ if(dealerValue != ''){
+ //鑾峰彇缁忛攢鍟嗗悕鐨刬d
+ var dealerId = j$(escapeVfId('allPage:allForm:allBlock:contract:dealer_lkid')).val();
+ //鐢变簬salesforce鐨勬煡鎵惧瓧娈垫槸鍙互杈撳叆鐨勶紝鎵�浠ュ垽鏂粬濡傛灉涓虹┖鎴栬�呬负 000000000000000 鐨勬椂鍊欙紝浼犵殑鍙傛暟灏变綅缁忛攢鍟嗕腑鏂囧悕锛屽叾浠栨儏鍐典紶id
+ if(dealerId != '' && dealerId != '000000000000000'){
+ onChDealerUpdate(dealerId);
+ }else{
+ onChDealerUpdate(dealerValue);
+ }
+ }else{
+ onChDealerUpdate('');
+ //j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked = false;
+ }
+ }
+ }
+ //濡傛灉閫夋嫨鐨勭粡閿�鍟嗕负鍏堟瀵硅薄锛岄偅涔堝仛涓�涓嬫彁绀�
+ function hintAccount(){
+ var xkChecked = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
+ if(xkChecked){
+ alert('璇锋敞鎰忥紝褰撳墠缁忛攢鍟嗕负鍏堟瀵硅薄銆�');
+ }
+ }
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+</script>
+<apex:form id="allForm">
+ <apex:inputHidden id="alertStringValue" value="{!alertString}" />
+ <apex:inputHidden id="alertStringValue2" value="{!alertString2}" />
+ <apex:inputHidden id="alertStringValue3" value="{!alertString3}" />
+ <apex:inputHidden id="PriceStatus" value="{!estimate.Process_Status__c}"/>
+ <apex:inputHidden id="urlName" value="{!estimate.Name}"/>
+ <apex:inputHidden id="changedAfterPrint" value="{!changedAfterPrint}"/>
+ <apex:inputHidden id="changedSubmitPrice" value="{!changedSubmitPrice}"/>
+ <apex:inputHidden id="isSaveOrApproval" value="{!isSaveOrApproval}"/>
+
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,assetSection2,pageMessages,allBlock" onComplete="unblockUI();"></apex:actionFunction>
+ <!-- HWAG-B4R3SS END 20181026-->
+ <apex:actionFunction name="ComputeLTYRepair" action="{!ComputeLTYRepair}" rerender="pageMessages" oncomplete="unblockUI();ComputeLTY();"/>
+ <apex:actionFunction name="ShowLTYRepair" action="{!ShowLTYRepair}" oncomplete="unblockUI();ComputeLTY();"/>
+ <apex:actionFunction name="decide" action="{!decide}" rerender="allForm" oncomplete="unblockUI();"/>
+ <apex:actionFunction name="decideCancle" action="{!decideCancle}" rerender="allForm" oncomplete="unblockUI();"/>
+ <apex:inputHidden id="oldDecideContractDate" value="{!OldContractStartDate}" />
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220920 start -->
+ <apex:actionFunction name="onChDealerUpdate" action="{!onChDealerUpdate}" rerender="contract" onComplete="hintAccount();">
+ <apex:param name="checkDealerId" assignTo="{!checkDealerId}" value="" />
+ </apex:actionFunction>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220920 end -->
+ <input type="hidden" id="oldContractDate" value="{!estimate.Contract_Start_Date__c}" />
+<script type="text/javascript">
+//j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+</script>
+ <apex:pageBlock title="鏈嶅姟鍚堝悓鎶ヤ环" id="allBlock">
+ <apex:pageBlockButtons id="blocktop" location="top">
+ <apex:commandButton id="savebtntop" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/>
+ <!-- <apex:commandButton id="LastTwoYearRepairShow" value="杩囧幓涓ゅ勾缁翠慨瀹炵哗Repaort" action="{!ShowLTYRepair}" rerender="alertStringValue,alertStringValue2,alertStringValue3" oncomplete="AlertPrice();"/> -->
+ <apex:commandButton id="LastTwoYearRepairComp" value="杩囧幓涓夊勾缁翠慨瀹炵哗璁$畻" rerender="PriceStatus" onclick="AlertPriceBtnJs()"/>
+ <apex:commandButton id="approvalbtntop" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
+ <apex:outputText style="color:red;font-size:20px" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
+ <apex:commandButton action="{!cancel}" value="涓嶄繚瀛橈紙杩斿洖锛�" style="float:right;" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/>
+ <apex:commandButton id="saveAndCancelBtn" action="{!saveAndCancel}" value="淇濆瓨锛堣繑鍥烇級" style="float:right;" rerender="allForm" oncomplete="unblockUI();" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" disabled="{!SaveBtnDisabled}"/>
+ </apex:pageBlockButtons>
+
+ <apex:pageMessages id="pageMessages"></apex:pageMessages>
+ <!-- update 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖� 娣诲姞鈥榓ssetSection鈥� fxk 2021/9/10 Star-->
+ <apex:actionFunction name="refreshProductData" action="{!refreshProductData}" rerender="pageMessages,EquipmentGuaranteeFlg,EGFlgassHidden,EquipmentGuaranteeFlgtxt, assetListPriceHidden, productCount3, assetSection, uFRMaxPrice, uFRMinPrice, uFRMaxPrice3, uFRMinPrice3,uRFSeries" oncomplete="refreshAsset({!productCount});unblockUI();">
+ <apex:param assignTo="{!productIdx}" name="productIdx" value=""/>
+ </apex:actionFunction>
+ <!-- update 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖� 娣诲姞鈥榓ssetSection鈥� fxk 2021/9/10 End-->
+ <!--<apex:actionFunction name="contractStartDateChange" action="{!contractStartDateChange}" rerender="allForm" oncomplete="unblockUI();">
+ </apex:actionFunction>-->
+
+ <apex:actionFunction name="recordNumChangeAction" action="{!recordNumChange}" rerender="allForm" oncomplete="unblockUI();">
+ </apex:actionFunction>
+
+ <!-- update by rentx 2020-11-17 -->
+ <!-- <apex:pageblocksection title="鏈嶅姟鍚堝悓" id="contract"> -->
+ <!-- <apex:outputField value="{!estimate.Name}"/> -->
+ <!-- <apex:outputField value="{!contract.Management_Code__c}" /> -->
+ <!-- <apex:outputField value="{!estimate.Process_Status__c}"/> -->
+ <!-- <apex:outputField value="{!contract.Status__c}"/> -->
+ <!-- <apex:outputField value="{!contract.Hospital__c}" /> -->
+ <!-- <apex:inputField value="{!estimate.Department__c}" id="depart"/> -->
+ <!-- <apex:inputField value="{!estimate.Contract_Esti_Start_Date__c}" required="true" id="startdate" onchange="changeEstiStartdate(this.value);"/>onchange="checkContractEstiStartDate(this.value, {!productCount})" -->
+ <!-- <apex:inputField value="{!estimate.Contract_Range__c}" required="true" id="monthRange" onchange="checkContractRange(this.value, {!productCount})"/> -->
+ <!-- <apex:inputField style="width:3px;height:15px;background-color:#cc0000; position:absolute;margin-right:5px;"> -->
+ <!-- <div><div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div></div> -->
+ <!-- <apex:inputField value="{!estimate.Contract_Range__c}" required="false" id="monthRange" onchange="checkContractRange(this.value, {!productCount})"/> -->
+ <!-- </apex:inputField> -->
+
+ <!-- <apex:outputField value="{!estimate.Contract_Esti_End_Date__c}"/> -->
+ <!-- <apex:outputField label="鍒跺畾鏃�" value="{!estimate.CreatedDate}" id="createDateShow"/> -->
+
+ <!-- <apex:outputPanel > -->
+ <!-- <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鎻愪氦瀵硅薄</label> -->
+ <!-- <apex:inputField value="{!estimate.Estimate_Target__c}" id="estimateTarget" onchange="resetDealer()" style="margin-left:5px"/> -->
+
+ <!-- <apex:outputPanel rendered="{!DecideBtnDisabled==false}"> -->
+ <!-- <input type="button" class="btn" value="鍙樻洿" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/> -->
+ <!-- </apex:outputPanel> -->
+ <!-- <apex:outputPanel rendered="{!DecideBtnDisabled==true}"> -->
+ <!-- <input type="button" class="btnDisabled" value="鍙樻洿" disabled="true" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/> -->
+ <!-- </apex:outputPanel> -->
+ <!-- </apex:outputPanel> -->
+
+ <!-- <apex:inputField value="{!estimate.Dealer__c}" id="dealer" /> -->
+ <!-- <apex:inputField value="{!estimate.EndUserType__c}" id="EndUserType" /> -->
+ <!-- <script type="text/javascript"> -->
+ <!-- j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).children('option[value=]').remove(); -->
+ <!-- resetDealer(); -->
+ <!-- </script> -->
+ <!-- </apex:pageblocksection> -->
+ <apex:pageBlockSection title="鏈嶅姟鍚堝悓" id="contract">
+ <!-- <apex:outputPanel/> -->
+ <apex:outputPanel >
+ <table align="center" width="100%" style="border-collapse:separate; border-spacing:0px 10px" >
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环缂栫爜</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!estimate.Name}"/> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鐘舵��</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!estimate.Process_Status__c}"/> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍖婚櫌</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!contract.Hospital__c}" /> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓寮�濮嬮璁㈡棩</label> </td>
+ <td width="50%" align="left"> <apex:inputField value="{!estimate.Contract_Esti_Start_Date__c}" required="true" id="startdate" onchange="changeEstiStartdate(this.value);"/>
+ </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"><label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓缁撴潫棰勮鏃�</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!estimate.Contract_Esti_End_Date__c}"/> </td>
+ </tr>
+ <tr>
+ <td align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鎻愪氦瀵硅薄</label>
+ <td>
+ <apex:outputPanel >
+ <apex:inputField value="{!estimate.Estimate_Target__c}" id="estimateTarget" onchange="resetDealer()" style="margin-left:5px"/>
+ <apex:outputPanel rendered="{!DecideBtnDisabled==false}">
+ <input type="button" class="btn" value="鍙樻洿" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!DecideBtnDisabled==true}">
+ <input type="button" class="btnDisabled" value="鍙樻洿" disabled="true" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/>
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </td>
+ </td>
+ </tr>
+ <tr>
+ <td align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%"> 鐢ㄦ埛绫诲瀷</label></td>
+ <td align="left">
+ <apex:outputField value="{!estimate.EndUserType__c}" id="EndUserType" />
+ </td>
+ <td> </td>
+ </tr>
+
+ </table>
+ </apex:outputPanel>
+ <apex:outputPanel >
+ <table align="center" width="100%" style="border-collapse:separate; border-spacing:0px 10px" >
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓璇环缂栫爜</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!contract.Management_Code__c}" /> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鐘舵��</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!contract.Status__c}"/> </td>
+ </tr>
+ <tr>
+
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">绉戝</label> </td>
+ <td width="50%" align="left"> <apex:inputField value="{!estimate.Department__c}" id="depart"/> </td>
+ </tr>
+ <tr>
+
+
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓鏈堟暟</label> </td>
+ <td width="50%" align="left">
+ <div style="width:3px;height:20px;background-color:#cc0000; position:absolute;margin-right:5px" />
+ <apex:inputField value="{!estimate.Contract_Range__c}" required="false" id="monthRange"
+ onchange="checkContractRange(this.value, {!productCount})"
+ />
+ </td>
+ </tr>
+ <tr>
+
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍒跺畾鏃�</label></td>
+ <td width="50%" align="left"> <apex:outputField label="鍒跺畾鏃�" value="{!estimate.CreatedDate}" id="createDateShow"/> </td>
+ </tr>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <tr>
+
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:30%"> 缁忛攢鍟嗗悕</label></td>
+ <td width="50%" align="left"> <apex:inputField value="{!estimate.Dealer__c}" id="dealer" onchange="onChDealerUpdateJs(this);return false;" style="float: left;"/> </td>
+ </tr>
+
+ <tr>
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:30%"> 鍏堟鏍囪瘑锛堢粡閿�鍟嗭級</label></td>
+ <td width="50%" align="left" > <apex:inputCheckbox value="{!estimate.Is_RecognitionModel__c}" id="FirstParagraphEnd" onClick="return false;" /> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">URF-V鏈�澶уぇ淇鏁�:</label></td>
+ <td>
+ <apex:inputField value="{!estimate.URF_V_MaxRepairCount__c}" required="false" id="estimateURFVMaxRepairCount" onchange="checkVMaxRepairCount(this.value,{!productCount})" style="margin-left:5px"/>娆�
+ </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:30%">URF-P鏈�澶уぇ淇鏁�:</label></td>
+ <td width="50%" align="left">
+ <apex:inputField value="{!estimate.URF_P_MaxRepairCount__c}" required="false" id="estimateURFPMaxRepairCount" onchange="checkPMaxRepairCount(this.value,{!productCount})" style="margin-left:5px"/>娆�
+ </td>
+
+ </tr>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ </table>
+ <script type="text/javascript">
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).children('option[value=]').remove();
+ resetDealer();
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFVMaxRepairCount')).children('option[value=]').remove();
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateURFPMaxRepairCount')).children('option[value=]').remove();
+ </script>
+ </apex:outputPanel>
+ </apex:pageBlockSection>
+
+ <!-- update by rentx 2020-11-17 end -->
+
+ <apex:pageblocksection columns="1" title="鍚堝悓瀵硅薄璁惧" id="assetSection" >
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <input type="hidden" id="allPage:allForm:allBlock:assetSection:productCnt" value="{!productCount}" />
+ <!-- <table width="100%">
+ <tr>
+ <td> </td>
+ <td width="100px"><span>鍏�</span>
+ <select style="vertical-align:text-bottom" id="allCheckResult" size="1" onchange="changeAllCheckResult(this.value)">
+ <option value=" ">--鏃�--</option>
+ <option value="OK">OK</option>
+ <option value="NG">NG</option>
+ </select>
+ </td>
+ <td width="150px"> </td>
+ </tr>
+ </table> -->
+ <!-- <div id = 'aaaa' class="slds-scrollable_x" style="width:450px">
+ <div class="slds-table--header-fixed_container" style="height:450px;width:850px">
+ <div class="slds-scrollable_y" style="height:100%;width:850px"> -->
+ <div style="width: 100%">
+ <table class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
+ <tr class="headerRow" height="30px">
+ <th style="width:25px" class="headerRow booleanColumn"><input type='checkbox' onClick='checkAll(this)'/></th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Name.label}</th>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <th style="width:35px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.URF_Series__c.label}
+ </th>
+ <!-- <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.URF_Maintenance_Contract__c.label}</th> -->
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.EGFlg_fromContract_asset__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.InstallDate.label}</th>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star-->
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <!-- <th style="width:70px" class="headerRow booleanColumn">
+ {!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Check_Object__c.label}</th> -->
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end-->
+ <th style="width:40px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.IsNew__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
+
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Management_Code__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}</th>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 start -->
+ <th style="width:35px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Upper_price__c.label}</th>
+ <th style="width:35px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Lower_price__c.label}</th>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 end -->
+ <!-- 闅愯棌鍚堝悓鏈堟暟
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract__c.fields.Contract_Range__c.label}</th>-->
+
+
+
+
+
+
+
+
+ <!-- <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price_All__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Maintenance_Price_YearTXT__c.label}</th>-->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Comment__c.label}</th>
+ </tr>
+
+ <apex:variable value="{!1}" var="cnt" />
+ <apex:repeat value="{!checkedAssets}" var="ar" id="assetTable">
+ <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
+ <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox" rendered="{!Not(ar.IsManual)}" disabled="{!PageDisabled}"/>
+ <apex:outputText value="{!ar.IsManual}" id="IsManual" style="display:none;" />
+ <!-- 鍒ゆ柇鏄惁鍙姤浠� -->
+ <!-- <input type="hidden" value="{!ar.estimateass}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:estimateass"/> -->
+ <!-- <apex:inputCheckbox value="{!ar.estimateass}" id="estimateass" style="display:none;" /> -->
+ </td>
+ <td class="dataCell">
+ <apex:outputField value="{!ar.rec.Name}" id="assetName" rendered="{!Not(ar.IsManual)}" />
+ <apex:inputField value="{!ar.mcae.Product_Manual__c}" id="Assert" style="width:90%;" rendered="{!ar.IsManual}" onchange="blockme();refreshProductData({!ar.lineNo});"/>
+ <apex:inputText id="ProductId" value="{!ar.mcae.Product_Manual__c}" style="display:none;" disabled="true"/>
+ </td>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <td class="dataCell" width="70px" >
+ <apex:outputText value="{!ar.uFRSerial}" id="uRFSeries"/>
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.URF_Maintenance_Contract__r.Management_Code__c}" rendered="{!Not(ar.IsManual)}" id="URF_Contract_No"/>
+ </td> -->
+
+ <apex:inputHidden value="{!ar.rec.URF_Maintenance_Contract__r.Management_Code__c}" rendered="{!Not(ar.IsManual)}" id="URF_Contract_No"/>
+
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputLink value="/{!ar.recId}" rendered="{!Not(ar.IsManual)}" >{!ar.rec.SerialNumber}</apex:outputLink>
+ <apex:inputHidden id="AssetId" value="{!ar.recId}"/>
+ <apex:inputField value="{!ar.rec.isNewDate_use__c}" id="isNewDate" style="display: none" showDatePicker="false"/>
+ </td>
+ <td class="dataCell" >
+ <apex:outputField value="{!ar.mcae.EquipmentGuaranteeFlgTxt__c}" id="EquipmentGuaranteeFlgtxt"/>
+ <apex:outputText value="{!ar.mcae.EquipmentGuaranteeFlgTxt__c}" id="EquipmentGuaranteeFlg" style="display:none;"/>
+ <apex:inputHidden id="EGFlgassHidden" value="{!ar.etGFlg}"/>
+ </td>
+ <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.InstallDate}" id="InstallDate" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star-->
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <!-- <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:inputCheckbox value="{!ar.mcae.Check_Object__c}" id="assetCheck" disabled="{!ar.CheckRows}"/>
+ </td> -->
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end-->
+ <td class="dataCell" width="40px" style="text-align:center" >
+ <apex:inputCheckbox value="{!ar.mcae.IsNew__c}" id="assetNew" disabled="true"/>
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.IsNew__c}" id="assetNewHidden" />
+ </apex:outputPanel>
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.IsNew__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetNewHidden" />
+ </apex:outputPanel>
+ <apex:outputText value="{!ar.rec.Final_Examination_Date__c}" id="finalExaminationDate" rendered="{!Not(ar.IsManual)}" style="display:none"/>
+ </td>
+ <td class="dataCell" width="70px" >
+ <apex:outputField value="{!ar.rec.Department_Name__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.CurrentContract_F__r.Maintenance_Contract_No_F__c}" rendered="{!Not(ar.IsManual)}" id="Contract_No"/>
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.RecordType_DeveloperName__c}" id="LastMContractRecord"/>
+ <apex:inputField value="{!ar.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c}" id="endDateGurantee_Text" style="display: none" showDatePicker="false"/>
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__c}" id="LastMContractID"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.mcae.Asset_Consumption_rate__c}" rendered="{!Not(ar.IsManual)}" id="Contractrate"/>
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Contract_Range__c}" id="lastContRange"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_End_Date__c}" rendered="{!(Not(ar.IsManual)&& ar.rec.CurrentContract_F__c != null)}" id="End_Date" />
+ </td>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 start -->
+ <td class="dataCell" width="35px">
+ <apex:outputText value="{!ar.mcae.Adjustment_Upper_price__c}" id="Adjustment_Upper_price"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_Upper_price__c}" id="Adjustment_Upper_priceHidden"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_ratio_Upper__c}" id="Adjustment_ratio_Upper"/>
+ </td>
+ <td class="dataCell" width="35px" >
+ <apex:outputText value="{!ar.mcae.Adjustment_Lower_price__c}" id="Adjustment_Lower_price"/>
+ <apex:inputHidden value="{!ar.mcae.LastMContract_Price__c}" id="LastMContract_Price"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_ratio_Lower__c}" id="Adjustment_ratio_Lower"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_Lower_price__c}" id="Adjustment_Lower_priceHidden"/>
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
+ <!-- XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 start -->
+ <apex:inputHidden value="{!ar.uFRMaxPrice}" id="uFRMaxPrice"/>
+ <apex:inputHidden value="{!ar.uFRMinPrice}" id="uFRMinPrice"/>
+ <!-- XLIU-CE7AVC銆愬鎵樸�慤RF闄愭淇悊鍚堝悓鐨勬渶楂樹环鏍间慨鏀� thh 20220509 end -->
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <apex:inputHidden value="{!ar.uFRMaxPrice3}" id="uFRMaxPrice3"/>
+ <apex:inputHidden value="{!ar.uFRMinPrice3}" id="uFRMinPrice3"/>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Estimate_Num__c}" id="Estimate_NumHidden" />
+ </apex:outputPanel>
+
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.Estimate_List_Price__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetListPriceHidden"/>
+ <input type="hidden" value="{!ar.rec.CurrentContract_F__r.Estimate_Num__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:Estimate_NumHidden"/>
+ </apex:outputPanel>
+ <!-- 20200103 Gzw 璁$畻瀹為檯鎶ヤ环閲戦 start -->
+ <apex:inputHidden value="{!ar.mcae.Estimate_Cost__c}" id="Estimate_Cost"/>
+ <!-- 20200103 Gzw 璁$畻瀹為檯鎶ヤ环閲戦 end -->
+
+ </td>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 end -->
+
+ <!-- 闅愯棌鍚堝悓鏈堟暟
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_Range__c}" rendered="{!Not(ar.IsManual)}" id="lastContRange" />
+ </td>-->
+
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_Owner__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Accumulation_Repair_Amount__c}" rendered="{!Not(ar.IsManual)}" />
+ </td> -->
+ <!--<td class="dataCell" width="90px" style="text-align:right" >-->
+ <!-- 闅愯棌鏈嶅姟鍚堝悓浠锋牸
+ <apex:outputText value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPrice" style="padding-right:3px;" />
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
+ </apex:outputPanel>
+
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.Estimate_List_Price__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetListPriceHidden"/>
+ </apex:outputPanel>-->
+ <!--</td>-->
+ <!--<td>
+ <apex:outputText value="{!ar.mcae.Maintenance_Price_YearTXT__c}" id="assetListPriceTXT" />
+ <apex:inputHidden value="{!ar.mcae.Maintenance_Price_YearTXT__c}" id="assetListPriceTXTHidden" />
+ </td>-->
+
+
+
+ <td class="dataCell" width="70px" style="text-align:right" >
+ <apex:inputField value="{!ar.mcae.Repair_Price__c}" id="repairPrice" style="ime-mode: disabled; width:95%; text-align:right;" onchange="refreshAsset({!productCount});"/>
+ </td>
+ <td class="dataCell" width="70px" style="text-align:right" >
+ <apex:inputField value="{!ar.mcae.Comment__c}" id="comment" style="width:95%;"/>
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+
+ </table>
+ </div>
+<!-- </div>
+ </div> -->
+ </apex:outputPanel>
+ </apex:pageblocksection>
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:outputPanel id="sumPanel" onkeydown="if(event.keyCode==13){searchJs(); return false;}">
+ <!-- HWAG-B4R3SS END 20181026-->
+ <table style="width:100%;">
+ <tr>
+
+ <td>
+ <apex:commandButton value="琛岃拷鍔�" action="{!addNewRows}" disabled="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable) || PageDisabled}"
+ style="margin-left:10px;float:left;" onclick="blockme();" oncomplete="unblockUI();" rerender="allForm" />
+ <apex:commandButton value="鍒锋柊閫変腑鐨勪繚鏈夎澶�" disabled="{!SaveBtnDisabled || productCount2==0}" action="{!exchangeAsset}" onclick="blockme();" oncomplete="unblockUI();refreshAsset({!productCount});" rerender="allForm" />
+
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:outputText value="閫夋嫨鏉′欢"/>
+
+ <apex:selectList value="{!text1}" id="text1" size="1" style="width:80px"><apex:selectOptions value="{!textOpts}"/>
+ </apex:selectList>
+
+ <apex:selectList value="{!cond1}" id="cond1" size="1" style="width:80px">
+ <apex:selectOptions value="{!equalOpts}"/>
+ </apex:selectList>
+
+ <!-- LJPH-BSS6E2 ---20200911 ---update by rentongxiao start -->
+
+ <apex:inputText value="{!val1}"
+ id="val1" style="width:100px; background-color:{!IF(contr == '1','#e3f3ff','white')}"/>
+ <!-- LJPH-BSS6E2 ---20200911 ---update by rentongxiao end -->
+
+ <apex:commandButton value="妫�绱�" onclick="searchJs();" style="width:100px" rerender="dummy"/>
+
+ <apex:commandButton value="娓呴櫎鏉′欢" onclick="clearAndSearch();" style="width:100px" rerender="dummy"/>
+ <!-- HWAG-B4R3SS END 20181026-->
+ </td>
+ <th width="90px" style="text-align:right"></th>
+ <th width="90px" style="text-align:right"></th>
+
+ <th width="90px" style="text-align:right">璁惧鏁伴噺</th>
+ <td width="90px" style="text-align:right"><apex:outputtext value="{!productCount3}" id="productCount3"/></td>
+ <td width="25px"> </td>
+ <!--<th width="90px" style="text-align:right">鎶ヤ环鎬婚</th>
+ <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetListSumNum" ></span></th>-->
+ <td width="25px"> </td>
+ <th width="90px" style="text-align:right">淇悊鎬婚</th>
+ <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetRepairSumNum" ></span></th>
+ <td width="95px"> </td>
+ </tr>
+
+ </table>
+ </apex:outputPanel>
+
+ <apex:pageblocksection columns="1" title="鏈�夋嫨鐨勪繚鏈夎澶�" id="assetSection2" >
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <input type="hidden" id="allPage:allForm:allBlock:assetSection2:productCnt2" value="{!productCount2}" />
+ <table class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
+ <tr class="headerRow" height="30px">
+ <th style="width:25px" class="headerRow booleanColumn"><input type='checkbox' onClick='checkAll2(this)'/></th>
+ <th style="width:25%" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Name.label}</th>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <th style="width:90px" class="headerRow booleanColumn">闄愭绯诲垪<!-- {!$ObjectType.Asset.fields.Product2.ProductURF__r.URFLimitSerial__c.label} --></th>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
+ <!-- <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Installation_Site__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty__c.label}</th>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
+ <th style="width:90px" class="headerRow booleanColumn">涓绘満/鑰楁潗</th>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
+
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.EGFlg_fromContract_asset__c.label}</th>
+ <th style="width:150px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Reson_Can_not_Warranty__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.InstallDate.label}</th>
+ <!-- <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price__c.label}</th>
+ </tr>
+
+ <apex:variable value="{!1}" var="cnt" />
+ <apex:repeat value="{!unCheckedAssetsView}" var="assetsView" id="outassetTable2">
+ <apex:repeat value="{!assetsView}" var="ar" id="assetTable2">
+ <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
+ <!-- <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.uFRPrice == 0 || ar.rec.IF_Warranty__c = '鍚�', 'true', 'false')}"/>
+ </td> -->
+ <!-- gzw update 20220823 -->
+ <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF( ar.rec.IF_Warranty__c = '鍚�', 'true', 'false')}"/>
+ </td>
+ <td class="dataCell" width="25%">
+ <apex:outputField value="{!ar.rec.name}" id="assetName"/>
+ </td>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+ <td class="dataCell" width="90px">
+ <!-- <apex:outputField value="{!ar.rec.Product2.ProductURF__r.URFLimitSerial__c}"/> --><apex:outputText value="{!ar.uFRSerial}"/>
+ </td>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_situation__c}"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.SerialNumber}"/>
+ </td>
+ <td class="dataCell">
+ <apex:outputField value="{!ar.rec.Department_Name__c}"/>
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Installation_Site__c}"/>
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.IF_Warranty__c}"/>
+ </td>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
+ <td class="dataCell" width="90px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.AssetMark__c}"/>
+ </td>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
+ <td class="dataCell" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.EquipmentGuaranteeFlg__c}"/>
+ </td>
+ <td class="dataCell" width="150px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.Reson_Can_not_Warranty__c}"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.InstallDate}"/>
+ </td>
+ <!-- <td class="dataCell" width="90px">
+ <apex:outputField value="{!ar.rec.Asset_Owner__c}"/>
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Accumulation_Repair_Amount__c}"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <!-- <apex:outputField value="{!ar.rec.Maintenance_Price_Month__c}" /> -->
+ <apex:outputText value="{!ar.uFRPrice}" />
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ </apex:repeat>
+ </table>
+ <apex:outputPanel >
+ <dir align="right">
+ <table>
+ <tr>
+ <td>{!(currPage-1)*selctRecordNum} - {!IF(currPage*selctRecordNum > totalRecords, totalRecords, currPage*selctRecordNum)}</td>
+ <td> 鍏眥!totalRecords}涓�</td>
+ <td align="right" width="115px">鏄剧ず
+ <apex:selectList value="{!selRecordOption}" id="selRecordOption" size="1" onchange="blockme();recordNumChangeJs();" disabled="{!IF(totalRecords<10,true,false)}"><apex:selectOptions value="{!recordNum}"/></apex:selectList>鏉¤褰�
+ </td>
+ <td align="right" width="50px">绗瑊!currPage}椤�</td>
+ <td align="right" width="45px">
+ <apex:commandLink action="{!firstPage}" value="棣栭〉" id="firstPg" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(currPage==1,'display: none;','')}color: blue;"/>
+ <apex:outputText value="棣栭〉" style="{!IF(currPage!=1,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td align="right" width="40px">
+ <apex:commandLink action="{!previousPage}" value="涓婁竴椤�" id="previous" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(currPage==1,'display: none;','')}color: blue;"/>
+ <apex:outputText value="涓婁竴椤�" style="{!IF(currPage!=1,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td width="3px"></td>
+ <td align="left" width="40px">
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:commandLink action="{!nextPage}" value="涓嬩竴椤�" id="next" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(totalPage==currPage ||totalPage == 0,'display: none;','')}color: blue;"/>
+ <apex:outputText value="涓嬩竴椤�" style="{!IF(totalPage!=currPage && totalPage != 0,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td align="left" width="45px">
+ <apex:commandLink action="{!endPage}" value="灏鹃〉" id="endPg" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(totalPage==currPage||totalPage == 0,'display: none;','')}color: blue;"/>
+ <apex:outputText value="灏鹃〉" style="{!IF(totalPage!=currPage
+ && totalPage != 0,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <!-- HWAG-B4R3SS END 20181026-->
+ <td align="left">鍏眥!totalPage}椤�</td>
+ </tr>
+ </table>
+ </dir>
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+ <apex:pageblocksection title="鍚堝悓淇℃伅" columns="1" id="contractInfo">
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <table style="width:100%">
+ <tr>
+ <td width="22%"></td>
+ <!-- <td width="14%"></td> -->
+ <td width="22%"></td>
+ <td width="28%"></td>
+ <td width="14%"></td>
+ <td width="14%"></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.GuidePrice_Down__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.GuidePrice_Up__c.label}</th>
+ <th style="text-align: center">鐢宠鎶ヤ环閲戦</th>
+ <th style="text-align: center">鍚堝悓璁惧淇悊鎬婚</th>
+ <th style="text-align: center">鍚堝悓鎬婚噾棰�</th>
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.GuidePrice_Down__c}" id="GuidePriceDown" />
+ <apex:inputHidden value="{!estimate.GuidePrice_Down__c}" id="GuidePriceDownHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUp" />
+ <apex:inputHidden value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUpHidden" />
+ </td>
+ <td style="text-align: center">
+ <!--<apex:inputField value="{!estimate.Request_quotation_Amount__c}" id="quotation_Amount" />-->
+ <apex:inputField value="{!estimate.Request_quotation_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="quotation_Amount" onchange="checkDiscount(this.value);"/>
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPrice" />
+ <apex:inputHidden value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPriceHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal" />
+ <apex:inputHidden value="{!estimate.Maintenance_Price__c}" id="mainteRealHidden"/>
+ <apex:inputHidden value="{!OldMaintenancePrice}" id="oldMainteReal"/>
+ </td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Service_discount_Rate__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.New_Contract_Type_TxT__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Combined_rate__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Consumption_rate_Forecast__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Estimate_Price_range__c.label}</th>
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Service_discount_Rate__c}" id="discount_Rate"/>
+ <apex:inputHidden value="{!estimate.Service_discount_Rate__c}" id="discount_RateHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputText value="{!estimate.New_Contract_Type_TxT__c}" id="Contract_TypeTXT" />
+ <apex:inputHidden value="{!typeresult}" id="Contract_TypeTXTHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Combined_rate__c}" id="Combinedrate" />
+ <apex:inputHidden value="{!estimate.Combined_rate__c}" id="CombinedrateHidden" />
+ </td>
+ <td style="text-align: center">
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220920 start -->
+ <!-- <apex:outputField value="{!estimate.Consumption_rate_Forecast__c}" /> -->
+ -
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220920 end -->
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Estimate_Price_range__c}" />
+ </td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.ContractPriceType__c.label}</th>
+ <th style="text-align: center"></th>
+ <th style="text-align: center"></th>
+ <th style="text-align: center"></th>
+ <th style="text-align: center"></th>
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.ContractPriceType__c}"/>
+ </td>
+ <td style="text-align: center"></td>
+ <td style="text-align: center"></td>
+ <td style="text-align: center"></td>
+ <td style="text-align: center"></td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+
+ <apex:pageblocksection title="鐢宠鑳屾櫙" columns="1" id="Appbackground">
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <table style="width:100%">
+ <tr>
+ <td width="10%"></td>
+ <td width="30%"></td>
+ <td width="10%"></td>
+ <td width="50%"></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.finalPriceDecideWay__c.label}</th>
+ <td><apex:inputField value="{!estimate.finalPriceDecideWay__c}" id="finalPriceDecideWay" style="width:50%;" /></td>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Sales_incidental__c.label}</th>
+ <td><apex:inputField value="{!estimate.Sales_incidental__c}" id="Sales_incidental" style="width: 20px;height: 20px;" /></td>
+ <!-- lighting鍗囩骇 20230210 lt 澶嶉�夋澶у皬寮傚父闂 style="width:50%;" == style="width: 20px;height: 20px;" -->
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.mainTalksTime__c.label}</th>
+ <td ><apex:inputField value="{!estimate.mainTalksTime__c}" style="width:50%;" id="mainTalksTime"/></td>
+ <th>{!$ObjectType.Maintenance_Contract_Estimate__c.fields.talksStartDate__c.label}</th>
+ <td><apex:inputField value="{!estimate.talksStartDate__c}" id="talksStartDate" style="width:50%;" /></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.AgencyHos_Price__c.label}</th>
+ <td ><apex:inputField value="{!estimate.AgencyHos_Price__c}" style="width:50%;" id="AgencyHos_Price"/></td>
+ <th style="text-align: center"></th>
+ <td ></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Discount_reason__c.label}</th>
+ <td colspan="3"><apex:inputField value="{!estimate.Discount_reason__c}" id="discountReason" style="width:95%;height:50px;" /></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Improve_ConsumptionRate_Idea__c.label}</th>
+ <td colspan="3"><apex:inputField value="{!estimate.Improve_ConsumptionRate_Idea__c}" id="improveConsumptionRateIdea" style="width:95%;height:50px;" /></td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ <script type="text/javascript">
+ //var applyType = j$(escapeVfId('allPage:allForm:allBlock:Appbackground:applyType')).val();
+ //var obj = document.getElementById('allPage:allForm:allBlock:Appbackground:TypeOther');
+ //if (applyType == '鍏朵粬') {
+ // obj.style.display = "block";
+ //} else {
+ // obj.style.display = "none";
+ //}
+ //resetapplyType();
+ </script>
+ </apex:pageblocksection>
+
+ <script type="text/javascript">
+ var isDisabled = {!PageDisabled};
+ if(!isDisabled){
+ refreshAsset({!productCount});
+ }
+ </script>
+ </apex:pageBlock>
+
+
+
+ <table width="100%" border="0">
+ <tr>
+ <!-- <td width="40%" style="text-align: right;"> -->
+ <td width="50%">
+ <table border="0" style="background-color:#ffd6c1;" width="100%">
+ <tr>
+ <th width="50px">鎵撳嵃鎶ヤ环</th>
+ <td width="90px"><apex:inputCheckbox id="check0" onchange="hideSimplify(0);" value="{!estimate.Print_ListPrice__c}" />瀹屾暣鐗�+鎶樻墸鍓�</td>
+ <td width="90px"><apex:inputCheckbox id="check1" onchange="hideSimplify(1);" value="{!estimate.Print_Simplify__c}" />瀹屾暣鐗�+鎶樻墸鍚�</td>
+
+ <td width="80px"><apex:inputCheckbox id="check2" onchange="hideSimplify(2);" value="{!estimate.Print_RepairPrice__c}"/>绠�鍖栫増+鎶樻墸鍓�</td>
+ <td width="80px"><apex:inputCheckbox id="check3" onchange="hideSimplify(3);" value="{!estimate.Print_SumPrice__c}"/>绠�鍖栫増+鎶樻墸鍚�</td>
+ </tr>
+ <tr>
+ <th width="70px">鎵撳嵃鍚堝悓閰嶇疆</th>
+ <td width="60px">
+
+ <!-- 2018/10/26HWAG-B5C88S 鍖婚櫌鍜岀粡閿�鍟嗗悎鍚屼换浣曟椂鍊欓兘涓嶈兘閫夋嫨 start -->
+
+ <apex:outputPanel rendered="false">
+ <apex:inputCheckbox value="{!estimate.Print_Contract__c}" />
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 鍖婚櫌鍚堝悓
+ </td>
+ <!-- 2018/09/26 HWAG-B4SCR3 涓夋柟鍜屼唬鐞嗗晢鍚堝悓鍦ㄦ湭decide鍓嶄篃涓嶈兘閫夋嫨 start -->
+ <td width="60px">
+ <apex:outputPanel rendered="{!EnablePrintContract}">
+ <apex:inputCheckbox id="tripartite" value="{!estimate.Print_Tripartite__c}"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 涓夋柟鍗忚</td>
+ <td width="85px">
+ <apex:outputPanel rendered="false">
+ <apex:inputCheckbox id="agent" value="{!estimate.Print_Agent__c}"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 浠g悊鍟嗗悎鍚�</td>
+ <!-- 2018/09/26 HWAG-B4SCR3 涓夋柟鍜屼唬鐞嗗晢鍚堝悓鍦ㄦ湭decide鍓嶄篃涓嶈兘閫夋嫨 end -->
+ <!-- 2018/10/26 HWAG-B5C88S 鍖婚櫌鍜岀粡閿�鍟嗗悎鍚屼换浣曟椂鍊欓兘涓嶈兘閫夋嫨 end -->
+
+ <td colspan="3" style="text-align: right"><apex:commandButton action="{!print}" value="PDF鍗板埛" rerender="allBlock,pdfPrint" onclick="if (!onclickCheckchangedAfterPrint('Pt{!SaveBtnDisabled}','false')) return false;" oncomplete="unblockUI();ComputeLTYRepair()"/></td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table class="btntable" border="0">
+ <tr>
+ <td> </td>
+ <td> </td>
+ <td width="20px"> </td>
+ <td> </td>
+ <td> </td>
+ <td width="30px"> </td>
+ <!-- <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();"/></td> -->
+ <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/></td>
+
+ <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
+ <apex:outputText style="color:red;font-size:20px;" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
+ </td>
+ </tr>
+ <tr>
+ <th>{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Contract_Start_Date__c.label}</th>
+ <td><apex:inputField value="{!estimate.Contract_Start_Date__c}" id="contractstartdate" onchange="changeContractStartdate(this.value);"/></td>
+ <td> </td>
+ <th> {!$ObjectType.Maintenance_Contract_Estimate__c.fields.Contract_End_Date__c.label}</th>
+ <td><apex:outputField value="{!estimate.Contract_End_Date__c}" id="contractenddate"/></td>
+ <td> </td>
+ <td><apex:commandButton id="decidebtn" value="{!$Label.QuoteDecision_Button}" disabled="{!DecideBtnDisabled}" onclick="decideJs(); return false;"/></td>
+ <td style="text-align:right"><apex:commandButton id="undecidebtn" action="{!undecide}" value="鍙栨秷{!$Label.QuoteDecision_Button}" disabled="{!UnDecideBtnDisabled}" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</apex:form>
+<apex:outputPanel id="pdfPrint">
+<script type="text/javascript">
+//j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+function saveBeforeCheckPriceChange() {
+ sforce.connection.sessionId = Session_ID;
+ var needClearId = false;
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ var assIds = "";
+ var proIds = "";
+ var priceMap = new Map();
+ var newProductMap = new Map();
+ var newProductCheck = false;
+ var nowDate = new Date();
+ var createdDate = null;
+ var createdDateShow = j$(escapeVfId('allPage:allForm:allBlock:contract:createDateShow')).text();
+ var contractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ if (createdDateShow.trim() != '') {
+ createdDate = new Date(createdDateShow);
+ newProductCheck = true;
+ } else {
+ createdDate = new Date();
+ }
+ var threeMonthAfter = new Date(createdDate.setMonth(createdDate.getMonth() + 3));
+ createdDate = new Date(createdDate.setMonth(createdDate.getMonth() - 3));
+ for (var i = 0; i < rowCnt; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ var price = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (a.size() > 0 && a.value() != "000000000000000000" && a.value() != "") {
+ if (proIds == "") {
+ proIds = "'" + a.value() + "'";
+ } else {
+ proIds = proIds + ",'" + a.value() + "'";
+ }
+ if (isnew == "true") {
+ priceMap.set(a.value(), price/{!isNewPriceAdj});
+ } else {
+ priceMap.set(a.value(), price);
+ }
+ newProductMap.set(a.value(), isnew);
+
+ } else {
+ continue;
+ }
+ }
+ else {
+ var aId = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetId')).value();
+ if (assIds == "") {
+ assIds = "'" + aId + "'";
+ } else {
+ assIds = assIds + ",'" + aId + "'";
+ }
+ if (isnew == "true") {
+ priceMap.set(aId, price/{!isNewPriceAdj});
+ } else {
+ priceMap.set(aId, price);
+ }
+ newProductMap.set(aId, isnew);
+ }
+ }
+ // 閫夋嫨璁惧鍚庝环鏍煎彉鏇碿heck
+ if (assIds.length > 0) {
+ // alert('222222222222' + assIds);
+ var sql = "SELECT Id, Maintenance_Price_Month__c,Product2.UFR_Maintenance_Price_Month__c, Posting_Date__c, InstallDate,Product2.UFR_Maintenance_Price_Month_3__c from Asset where Id In(" + assIds + ")";
+ var rt = sforce.connection.query(sql);
+ var asList = rt.getArray("records");
+ if (asList != null) {
+ for(var i=0;i<asList.length;i++) {
+ var asvar = asList[i];
+ // alert('asvar' + asvar);
+ var asId = asvar["Id"];
+ // alert('asvar++++' + asvar["Product2"].["ProductURF__r"].["UFR_Maintenance_Price_Month__c"]);
+ // var mprice = asvar["Maintenance_Price_Month__c"];
+ //URF闄愭鍚堝悓2鏈� LY 20220811 start
+ //var mprice = asvar["Product2"].UFR_Maintenance_Price_Month__c;
+ var mprice = asvar["Product2"].UFR_Maintenance_Price_Month_3__c;
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ var ptDt = asvar["Posting_Date__c"];
+ var postingDate = null;
+ if (ptDt != null && ptDt != '') {
+ postingDate = new Date(ptDt);
+ }
+ var inDt = asvar["InstallDate"];
+ var installDate = null;
+ if (inDt != null && inDt != '') {
+ installDate = new Date(inDt);
+ }
+ var priceShow = priceMap.get(asId);
+ var isNew = newProductMap.get(asId);
+ if ('{!DecideBtnDisabled}' == 'true') {
+ if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
+ needClearId = true;
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ }
+ }
+ }
+ if (proIds.length > 0) {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ var oldDateStr = j$('#oldContractDate').value();
+ var oldDate = new Date();
+ if (oldDateStr != null && oldDateStr != '') {
+ oldDate = new Date(oldDateStr);
+ }
+ var crdt = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:createDateShow')).text());
+ var newContractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ var sixMonthAfter = new Date(crdt.setMonth(crdt.getMonth() + 6));
+ if ((newContractDate > sixMonthAfter && oldDate <= sixMonthAfter) || (newContractDate <= sixMonthAfter && oldDate > sixMonthAfter)) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return true;
+ }
+ } else {
+ var sql = "SELECT Id, Maintenance_Price_Month__c,UFR_Maintenance_Price_Month__c,UFR_Maintenance_Price_Month_3__c from Product2 where Id In(" + proIds + ")";
+ var rt = sforce.connection.query(sql);
+ var pdList = rt.getArray("records");
+ if (pdList != null) {
+ for(var i=0;i<pdList.length;i++) {
+ var pdvar = pdList[i];
+ var pdId = pdvar["Id"];
+ // var mprice = pdvar["Maintenance_Price_Month__c"];
+ //URF闄愭鍚堝悓2鏈� LY 20220811 strat
+ //var mprice = pdvar["UFR_Maintenance_Price_Month__c"];
+ var mprice = pdvar["UFR_Maintenance_Price_Month_3__c"];
+ //URF闄愭鍚堝悓2鏈� LY 20220811 end
+ var priceShow = priceMap.get(pdId);
+ if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
+ needClearId = true;
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ }
+ }
+ }
+ // var changedPrice = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ // if (changedPrice=='true') {
+ // needClearId = true;
+ // }
+ return needClearId;
+}
+
+// SelectAssetEstimateController#checkchangedAfterPrint 銇ㄥ悓銇樸儹銈搞儍銈伀銇欍倠蹇呰銇屻亗銈娿伨銇欍��
+// true 澶夋洿銇傘倞銆乫alse 澶夋洿銇仐
+function checkchangedAfterPrint() {
+ sforce.connection.sessionId = Session_ID;
+ var needClearId = false;
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ var changedPrice = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ // 鏂拌銇牬鍚堛�乼argetEstimateId銇屻仾銇勩�佸垽鏂亜銈夈仾銇�
+ if ('{!targetEstimateId}' == '') return needClearId;
+ if ('{!estimate.Quote_Date__c}' != '' || '{!estimate.Process_Status__c}' != '鑽夋涓�') {
+ // xud 20140529 銇撱亾銇槑绱板鏇村垽鏂�
+ // xudan 20150729 銈姐兗銉堥爡鐩伀Id銈掕拷鍔�
+ var sql = "SELECT Id, Asset__c, Asset__r.SerialNumber, Check_Result__c, Product_Manual__c,"
+ + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c"
+ + " FROM Maintenance_Contract_Asset_Estimate__c"
+ + " WHERE Maintenance_Contract_Estimate__c = '{!targetEstimateId}'"
+ + " ORDER BY id,Asset__c,Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate";
+ var result = sforce.connection.query(sql);
+ var mcaeList = result.getArray("records");
+ var inputingList = [];
+ var finalPrice = 0;
+ // 鐢婚潰鍏ュ姏鍊ゃ倰鏁寸悊锛堛亜銈夈仾銇勩倐銇倰瀵捐薄澶栥伀銇欍倠锛�
+ var cntWithKara = {!productCount};
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (a.size() > 0 && a.value() != "000000000000000000" && a.value() != "") {
+ inputingList.push(
+ {'id' : '',
+ 'Product_Manual__c' : a.value(),
+ 'Check_Result__c' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult')).value(),
+ 'Repair_Price__c' : localParseFloat(j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value())),
+ 'Comment__c': j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).value()
+ }
+ );
+ } else {
+ continue;
+ }
+ }
+ else {
+ inputingList.push(
+ {'id' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetId')).value(),
+ 'Check_Result__c' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult')).value(),
+ 'Repair_Price__c' : localParseFloat(j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value())),
+ 'Comment__c': j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).value()
+ }
+ );
+ }
+ }
+ //閽堝inputingList鐨勯噸鏂版帓搴�
+ var arrayMap = [];
+ var ArrayOrderPMCnt = [];
+ for(var i=0;i<mcaeList.length;i++){
+ var mcaeVar = mcaeList[i];
+ var AssetIDOrPMC = mcaeVar["Asset__c"]!=null?mcaeVar["Asset__c"]:mcaeVar["Product_Manual__c"];
+ if(arrayMap[AssetIDOrPMC]!=null){
+ arrayMap[AssetIDOrPMC] = i;
+ ArrayOrderPMCnt[AssetIDOrPMC] = i;
+ }else{
+ // Product_Manual__c鐩稿悓鐨勮瘽鎬庝箞鍔�
+ if(ArrayOrderPMCnt[AssetIDOrPMC]==null){
+ ArrayOrderPMCnt[AssetIDOrPMC] = i;
+ }else{
+ var cacheArray = new Array();
+ cacheArray = ArrayOrderPMCnt[AssetIDOrPMC];
+ ArrayOrderPMCnt[AssetIDOrPMC] = cacheArray+','+i;
+ }
+
+ }
+
+ }
+ var inputingListCache = inputingList;
+ var cntLength = mcaeList.length>inputingListCache.length?mcaeList.length:inputingListCache.length;
+ if(mcaeList.length!=inputingListCache.length){
+ needClearId = true;
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ inputingList = new Array(cntLength);
+ var inputingListOut = new Array();
+ for(var i=0;i<inputingListCache.length;i++){
+ var InputIdOrPMc = inputingListCache[i].id!=""?inputingListCache[i].id:inputingListCache[i].Product_Manual__c;
+ var thisArray = ArrayOrderPMCnt[InputIdOrPMc];
+ if(thisArray.length!=null){
+ thisArray = thisArray.split(',');
+ var ORDERCnt = thisArray[0];
+ thisArray.shift();
+ thisArray = thisArray.join(',');
+ ArrayOrderPMCnt[InputIdOrPMc] = thisArray;
+ }else{
+ var ORDERCnt = thisArray;
+ }
+ if( ORDERCnt !=null){
+ inputingList[ORDERCnt] = inputingListCache[i];
+ }else{
+ inputingList[ORDERCnt] = inputingListCache[i];
+ inputingListOut.push(inputingListCache[i]);
+ }
+ }
+ if( inputingListOut.length>0){
+ for(var i = 0; i<inputingListOut.length;i++){
+ inputingList.push(inputingListOut[i]);
+ }
+ }
+ //20161122,娴嬭瘯鍙戠幇Check_Result__c宸插仠鐢紝鏁呰�屼慨鏀瑰搴旂殑Js鍒ゆ柇閮ㄥ垎
+ /*
+ && (((mcae["Check_Result__c"] == null || mcae["Check_Result__c"] == "")
+ && (inputing["Check_Result__c"] == null || inputing["Check_Result__c"] == "")
+ )
+ || mcae["Check_Result__c"] == inputing["Check_Result__c"]
+ )
+ //==================================================================================
+ && (((mcae["Check_Result__c"] == null || mcae["Check_Result__c"] == "")
+ && (inputing["Check_Result__c"] == null || inputing["Check_Result__c"] == "")
+ )
+ || mcae["Check_Result__c"] == inputing["Check_Result__c"]
+ )
+ */
+ //鍘熸槸浠g爜淇濈暀
+ if (inputingList.length == mcaeList.length && needClearId == false ) {
+ for (var i = 0; i < mcaeList.length; i++) {
+ var mcae = mcaeList[i];
+ finalPrice = mcae["Maintenance_Contract_Estimate__r"]["Maintenance_Price__c"];
+ var inputing = inputingList[i];
+ if (mcae["Asset__c"] != null && mcae["Asset__c"] != "") {
+ if (inputing["id"] != "" && mcae["Asset__c"] == inputing["id"]
+ && localParseFloat(mcae["Repair_Price__c"]) == inputing["Repair_Price__c"]
+
+ && (((mcae["Comment__c"] == null || mcae["Comment__c"] == "")
+ && (inputing["Comment__c"] == null || inputing["Comment__c"] == "")
+ )
+ || mcae["Comment__c"] == inputing["Comment__c"]
+ )
+ ) {
+ // 鍚屻仒
+ } else {
+ needClearId = true;
+ break;
+ }
+ } else {
+ if (inputing["id"] == "" && mcae["Product_Manual__c"] != null && mcae["Product_Manual__c"] != ""
+ && mcae["Product_Manual__c"] == inputing["Product_Manual__c"]
+
+ && localParseFloat(mcae["Repair_Price__c"]) == inputing["Repair_Price__c"]
+ && (((mcae["Comment__c"] == null || mcae["Comment__c"] == "")
+ && (inputing["Comment__c"] == null || inputing["Comment__c"] == "")
+ )
+ || mcae["Comment__c"] == inputing["Comment__c"]
+ )
+ ) {
+ // 鍚屻仒
+ } else {
+ needClearId = true;
+ break;
+ }
+ }
+ }
+ } else {
+ needClearId = true;
+ }
+
+ // xud 20140529 銇撱亾銇窂閲戦澶夋洿鍒ゆ柇锛堝壊寮曘倰澶夋洿銇椼仧銈夈伨銇氥亜锛�
+ var inputFinalPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteRealHidden')).value();
+ if (toNum(inputFinalPrice) != toNum(finalPrice)) {
+ needClearId = true;
+ }
+ if (changedPrice=='true') {
+ needClearId = true;
+ }
+ }
+ if (needClearId) {
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ }
+ return needClearId;
+}
+
+if ('{!printAsset}' == 'true') {
+ //鎵撳嵃淇濇湁瑷倷
+ // //蹇呴』閫夋嫨鎵撳嵃鎶ヤ环(璇︾粏杩樻槸绠�鍖�)
+ var con = 0;
+ for (j = 0; j < 4; j++) {
+ if (j$(escapeVfId('allPage:allForm:check' + j)).attr('checked')) {
+ con ++;
+ }
+ }
+ if(con != 1){
+ alert('璇锋偍鍕鹃�夋墦鍗版姤浠风増鏈紝鍙兘鍕鹃�変竴涓��');
+ }else{
+ window.open('/apex/MaintenanceContractEstimateVMPDF?id={!targetEstimateId}', 'MaintenanceContractEstimateVMPDF');
+ }
+
+} else if ('{!printContract}' == 'true') {
+ // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printContract', 'MceConfigPDF');
+} else if ('{!printTripartite}' == 'true') {
+ //鎵撳嵃涓夋柟鍚堝悓
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printTripartite', 'MceConfigPDF');
+} else if ('{!printAgent}' == 'true') {
+ //鎵撳嵃缁忛攢鍟嗗悎鍚�
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printAgent', 'MceConfigPDF');
+}else {}
+//褰撻�夋嫨鎶ヤ环鍗曪紙璇︾粏鐗堬級鐨勬椂鍊欓殣钘忔姤浠峰崟锛堢畝鍖栫増锛�
+// 4涓�夐」鍙彲浠ラ�変竴涓�
+function hideSimplify(cb){
+ for (j = 0; j < 4; j++) {
+ if (j$(escapeVfId('allPage:allForm:check' + j)).attr('checked')) {
+ j$(escapeVfId('allPage:allForm:check' + j)).attr('checked',false);
+ if (j == cb) {
+ j$(escapeVfId('allPage:allForm:check' + j)).attr('checked',true);
+ }
+ }
+ }
+
+}
+var isDisabled = {!PageDisabled};
+if(!isDisabled){
+ refreshAsset({!productCount});
+}
+</script>
+</apex:outputPanel>
+</apex:page>
\ No newline at end of file
diff --git a/force-app/main/default/pages/SelectAssetEstimateURF.page-meta.xml b/force-app/main/default/pages/SelectAssetEstimateURF.page-meta.xml
new file mode 100644
index 0000000..b99bd85
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimateURF.page-meta.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>41.0</apiVersion>
+ <availableInTouch>false</availableInTouch>
+ <confirmationTokenRequired>false</confirmationTokenRequired>
+ <label>SelectAssetEstimateURF</label>
+</ApexPage>
diff --git a/force-app/main/default/pages/SelectAssetEstimateVM.page b/force-app/main/default/pages/SelectAssetEstimateVM.page
new file mode 100644
index 0000000..7b4bc32
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimateVM.page
@@ -0,0 +1,3017 @@
+<apex:page controller="SelectAssetEstimateVMController" tabStyle="Maintenance_Contract_Estimate__c" lightningStylesheets="true" sidebar="false" showHeader="true" id="allPage" action="{!init}">
+<head>
+ <!-- <meta http-equiv="x-ua-compatible" content="ie=edge" /> -->
+ <!-- <meta name="viewport" content="width=device-width, initial-scale=1" /> -->
+ <!-- <apex:slds /> -->
+</head>
+ <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
+ <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
+<style type="text/css">
+ table { border-collapse: collapse; }
+
+ .container {
+ overflow:auto;
+ width:100%;
+ height:304px;
+ }
+ .container2 {
+ overflow:auto;
+ width:100%;
+ height:404px;
+ }
+ .btntable.dateFormat {
+ display: none;
+ }
+</style>
+<script type="text/javascript">
+//add by rentx 2020-11-17 start 澶卞幓鐒︾偣
+function setFocusOnLoad() {}
+function bodyOnLoad(){setFocusOnLoad();}
+//add by rentx 2020-11-17 end 澶卞幓鐒︾偣
+
+var oxygenPriceAdj = {!oxygenPriceAdj};
+var approvalDate = '';
+var Session_ID = '{!$Api.Session_ID}';
+var Confirm_ChangedAfterPrint = '鎵撳嵃鍚庤淇℃伅鏈夊彉鍖栵紝鏄惁缁х画鎿嶄綔锛堟姤浠风紪鐮佷細鍙樻柊锛夛紵';
+var isNewAddMonth = {!isNewAddMonth};
+var Confirm_EstimateRefresh = '宸茶秴杩囧垱寤烘棩3涓湀锛屾槸鍚︽洿鏂版姤浠凤紵';
+window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });
+
+var RCbottonChanged = 0;
+
+// 2022鏁呴殰鍝佸姞璐� start
+// var RCButtonDisable = document.getElementById("emailSend");
+// RCButtonDisable.style.display = "none";
+// 2022鏁呴殰鍝佸姞璐� end
+
+var hasSendEmail = {!hasSendEmail};
+console.log('***hasSendEmail',hasSendEmail);
+// if(hasSendEmail == true){
+// j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+// j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+// console.log('宸叉彁浜C 鎸夐挳涓嶅彲瑙�');
+// }
+
+function approvalJs() {
+ approvalDate = new Date();
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ refreshAsset(rowCnt);
+}
+//鏁呴殰鍝佸姞璐� RC 鐐瑰嚮鍚庝笉鍙
+function rcJs() {
+ hasSendEmail = true;
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+ console.log('鐐瑰嚮RC 鎸夐挳涓嶅彲瑙乭asSendEmail' +hasSendEmail);
+}
+//add by gwy 2021-01-27 start 鎻愪氦鏃剁殑鎻愮ず妗�
+function KindsAndMonths() {
+ // 鏁呴殰鍝佸姞璐� 绯荤粺妫�鏌ヤ慨鐞嗗噺浠峰鎵瑰畬鎴� Start
+ ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+ console.log('鐐瑰嚮鎻愪氦寰呭鎵规椂 鏄惁瀹℃壒閫氳繃='+ISReduced);
+ if( ISReduced == '瀹℃壒涓�' || ISReduced == '鏈夊叓鎶樹互涓嬪緟瀹℃壒'){
+ alert('璇烽�氳繃淇悊鍑忎环瀹℃壒鍐嶆彁浜�');
+ // approvalbtntop1.style.display = "none";
+ return false;
+ }
+
+ // 鏁呴殰鍝佸姞璐� 绯荤粺妫�鏌ヤ慨鐞嗗噺浠峰鎵瑰畬鎴� end
+ var months = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
+ var contrNew = document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML;
+ if(months>12 && months<60 && contrNew == '鏂板搧鍚堝悓'){
+ if(confirm("鏈鎮ㄦ彁浜ょ殑鎶ヤ环涓哄骞存湡鏂板搧鍚堝悓锛岃鎮ㄥ湪姝e紡鎻愪氦鎶ヤ环鍓嶅厛灏嗙粡閿�鍟嗕笌鍖婚櫌绛捐鐨勫骞存湡鍚堝悓閭欢鍙戦�佹湇鍔℃湰閮ㄦ姤浠风獥鍙c�傝嫢宸茬粡鎻愪氦璇风偣鍑荤‘瀹氾紝缁х画淇濆瓨鎻愪氦銆�")){
+ return true;
+ }else{
+ return false;
+ }
+ }
+ // 鍏堟鍚庝慨-鎻愪氦鎶ヤ环鏃跺鏋滄槸鍏堟瀵硅薄杩涜鎻愮ず thh 20220408 start
+ var FirstParagraphEnd = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
+ if(FirstParagraphEnd){
+ if (confirm('鏈绛剧害缁忛攢鍟嗘槸鍏堟瀵硅薄锛岃纭鏄惁鎻愪氦鎶ヤ环锛�')) {
+ return true;
+ }else{
+ return false;
+ }
+ }
+ // 鍏堟鍚庝慨-鎻愪氦鎶ヤ环鏃跺鏋滄槸鍏堟瀵硅薄杩涜鎻愮ず thh 20220408 end
+ return true;
+}
+//add by gwy 2021-01-27 end 鎻愪氦鏃剁殑鎻愮ず妗�
+
+
+
+
+
+function unblockUI(){
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+ // disable1();
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+ pageSetDisabled();
+ var isChange = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ if (isChange=='true') {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('false');
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ refreshAsset(rowCnt);
+ }
+ j$("#sbArea").fadeOut(500, function(){
+ j$("#sbArea").remove();
+ });
+
+ console.log('鍙戦�侀偖浠舵垚鍔�');
+
+}
+//<!-- HWAG-B4R3SS START 20181026-->
+function clearAndSearch() {
+ document.getElementById("allPage:allForm:allBlock:text1").value = "";
+ document.getElementById("allPage:allForm:allBlock:cond1").value = "equals";
+ document.getElementById("allPage:allForm:allBlock:val1").value = "";
+ blockme();
+ searchfunc();
+}
+function searchJs() {
+ blockme();
+ searchfunc();
+}
+//<!-- HWAG-B4R3SS END 20181026-->
+// 鍒濆鍖栬瀹氱敾闈㈤」鐩笉鍙敤
+function pageSetDisabled(){
+ // if (RCbottonChanged == 0) {
+ // console.log('test鍒濆鍖�');
+ // 鏁呴殰鍝佸姞璐� 鎻愪氦RC鎸夐挳涓嶅彲瑙� start
+ // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+ // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+ // 鏁呴殰鍝佸姞璐� 鎻愪氦RC鎸夐挳涓嶅彲瑙� end
+ // }
+ // 鏁呴殰鍝佸姞璐� start
+ var hasSendEmail ={!hasSendEmail};
+ console.log('page hasSendEmail',hasSendEmail);
+ if(hasSendEmail == true){
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+ console.log('宸叉彁浜C 鎸夐挳涓嶅彲瑙� page set');
+ }
+
+ //鏁呴殰鍝佸姞璐� end
+ var isDisabled = {!PageDisabled};
+ // ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
+ // if(!ResonCannotWarranty.contains("寮冧慨")){
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).attr("display", none);
+ // }
+ if (isDisabled) {
+
+ j$(escapeVfId('allPage:allForm:allBlock:contract:depart')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:EndUserType')).attr("disabled", true);
+ var rowCnt = {!productCount};
+ for (var i = 0; i < rowCnt; i++) {
+ // alert(11111111111111 +rowCnt);
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert'));
+ a.attr("disabled", true);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Third_Party_Return__c')).attr("disabled", true);
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disMoney')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discountReason')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:improveConsumptionRateIdea')).attr("disabled", true);
+
+
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:finalPriceDecideWay')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:Sales_incidental')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:mainTalksTime')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:talksStartDate')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:AgencyHos_Price')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:discountReason')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:Appbackground:improveConsumptionRateIdea')).attr("disabled", true);
+
+ j$(escapeVfId('allPage:allForm:contractstartdate')).attr("disabled", true);
+ var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
+ if (target != '鍖婚櫌') {
+ j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd')).attr("disabled", true);
+ }
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).attr("disabled", false);
+ }
+}
+// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+
+// function disable1(){
+// // alert(12312);
+// // addNewRows();
+// var isDisabled ;
+// var rowCnt = {!productCount}+{!productCount2};
+// if(isDisabled){
+
+// // alert(22222 + '444' +rowCnt);
+// for (var i = 0; i < rowCnt; i++) {
+// // 淇濇湁璁惧鍚�
+// var assN = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:'+ i +':assetName')).text();
+// var assN1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:'+ i +':Assert')).val();
+// // alert('1234567'+assN +'----'+assN1);
+// if(!assN1 && !assN){
+// // alert('23456789'+assN);
+// j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck' )).attr("disabled", true);
+// }else{
+// j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck' )).attr("disabled", false);
+// }
+// }
+// }
+// }
+// 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+var winOpenObj;
+function closeWin(flg) {
+ winOpenObj.close();
+ if (flg==2) {
+ window.location.href="/{!URLENCODE(estimate.Id)}/e?completion=2";
+ }
+}
+function controlDisabled() {
+ winOpenObj = window.open("/apex/ChangeDealerApproval?eid=" + '{!URLENCODE(estimate.Id)}','ChangeDealerApproval','height=300,width=700,toolbar=no,menubar=no,left=20%,top=30%,scrollbars=yes,resizable=no,location=no,status=no');
+}
+// 瑕嬬銈傘倞浣滄垚寰屻�侊紦銉舵湀浠ュ唴銇с亗銈屻伆瑕嬬銈傘倞銇唴瀹广倰缍欑稓浣跨敤鍙兘
+function calonLoad() {
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
+ // disable1();
+ // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+ console.log('ApprovalBtnDisabled=='+{!ApprovalBtnDisabled});
+ pageSetDisabled();
+ var createdDate = new Date('{!estimate.CreatedDate}');
+ // 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
+ var aLLManual = 'true';
+ var cntWithKara = {!productCount};
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual != 'true') {
+ aLLManual = 'false';
+ break;
+ }
+ }
+ var nowDate = new Date();
+ if (aLLManual == 'false') {
+ createdDate = createdDate.setMonth(createdDate.getMonth() + 3);
+ // FIX liang JS銇檪闁撱仯銇� addMonths銇亜銇с仚銇嬶紵 銇濄亱銈� 1/1 銇倝銆� 4/1銈傘仩銈併仹銇欍倛銆�
+ if (createdDate < Date.parse(nowDate)) {
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("disabled", true);
+ // 鏈�鍒濄伅銆丏ecide銇悓鏅傘伀淇濆瓨銈傘亗銈娿伨銇欍�併仢銈屻倰闃层亹銇熴倎銆佷繚瀛樸仺Decide銈掑悓鏅傘伀鐒″姽銇仚銈�
+ // 鑰冦亪銇︺伩銈嬨仺銆併偗銉┿偣銇獶ecide銇垽鏂亴銇傘倞銆丏ecide銇檪鏄庣窗澶夋洿銉併偋銉冦偗銈傘亗銈娿伨銇欍��3銉舵湀銇儊銈с儍銈倐銇傘倞銇俱仚銆併亾銇撱仹鐒″姽銇仚銈嬫剰鍛炽亴銇傘倞銇俱仜銈�
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+
+ //鏁呴殰鍝佸姞璐� RC鎸夐挳
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
+
+ if (confirm(Confirm_EstimateRefresh)) {
+ window.location.href="/apex/SelectAssetEstimateVM?copyid={!URLENCODE(targetEstimateId)}";
+ return true;
+ } else {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ // decide鍙兘銇牬鍚堛�佸垾閫攄ecide銇儊銈с儍銈亴蹇呰銆�
+ // 銉併偋銉冦偗寰屽啀搴︾敾闈efresh銇曘倢銈嬨仧銈併�乨ecide鍙兘銇牬鍚堛�乨ecide銉溿偪銉炽亴浣裤亪銈嬨倛銇嗐伀銇倞銇俱仚銆�
+ changeContractStartdate('{!estimate.Contract_Start_Date__c}');
+ }
+ return false;
+ }
+ }
+ }else{
+ createdDate = createdDate.setMonth(createdDate.getMonth() + 6);
+ // FIX liang JS銇檪闁撱仯銇� addMonths銇亜銇с仚銇嬶紵 銇濄亱銈� 1/1 銇倝銆� 4/1銈傘仩銈併仹銇欍倛銆�
+ if (createdDate < Date.parse(nowDate)) {
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:savebtntop')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:saveAndCancelBtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:allBlock:blocktop:approvalbtntop')).attr("class", 'btnDisabled');
+
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("disabled", true);
+ // 鏈�鍒濄伅銆丏ecide銇悓鏅傘伀淇濆瓨銈傘亗銈娿伨銇欍�併仢銈屻倰闃层亹銇熴倎銆佷繚瀛樸仺Decide銈掑悓鏅傘伀鐒″姽銇仚銈�
+ // 鑰冦亪銇︺伩銈嬨仺銆併偗銉┿偣銇獶ecide銇垽鏂亴銇傘倞銆丏ecide銇檪鏄庣窗澶夋洿銉併偋銉冦偗銈傘亗銈娿伨銇欍��3銉舵湀銇儊銈с儍銈倐銇傘倞銇俱仚銆併亾銇撱仹鐒″姽銇仚銈嬫剰鍛炽亴銇傘倞銇俱仜銈�
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
+ j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+
+ //鏁呴殰鍝佸姞璐筊C鎸夐挳
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+ j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+ //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
+
+ if (confirm('宸茶秴杩囧垱寤烘棩6涓湀锛屾槸鍚︽洿鏂版姤浠凤紵')) {
+ window.location.href="/apex/SelectAssetEstimateVM?copyid={!URLENCODE(targetEstimateId)}";
+ return true;
+ } else {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ // decide鍙兘銇牬鍚堛�佸垾閫攄ecide銇儊銈с儍銈亴蹇呰銆�
+ // 銉併偋銉冦偗寰屽啀搴︾敾闈efresh銇曘倢銈嬨仧銈併�乨ecide鍙兘銇牬鍚堛�乨ecide銉溿偪銉炽亴浣裤亪銈嬨倛銇嗐伀銇倞銇俱仚銆�
+ changeContractStartdate('{!estimate.Contract_Start_Date__c}');
+ }
+ return false;
+ }
+ }
+ }
+
+ if ('{!DecideBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).val(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
+ }
+}
+
+function checkAll(checker) {
+ var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ debugger;
+ for (var i = 0; i < cnt; i++) {
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+ if (j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox')).size() == 0) {
+ continue;
+ }else{
+ document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox').checked = checker.checked;
+ }
+ //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+ }
+}
+
+function checkAll2(checker) {
+ var cnt2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection2:productCnt2')).val();
+ var outer = 0;
+ for (var i = 0; i < cnt2; i++) {
+ outer = Math.floor(i / 1000);
+ if (document.getElementById('allPage:allForm:allBlock:assetSection2:outassetTable2:' + outer +':assetTable2:' + (i-(1000*outer)) + ':assetRowCheckbox2').disabled == false) {
+ document.getElementById('allPage:allForm:allBlock:assetSection2:outassetTable2:' + outer +':assetTable2:' + (i-(1000*outer)) + ':assetRowCheckbox2').checked = checker.checked;
+ }
+ }
+}
+
+function checkDiscount(val) {
+ if (val == null || val == "") {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val("");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_Rate')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_RateHidden')).val(0.00);
+ return;
+ }
+ if (isNaN(parseInt(val))) {
+ alert("璇疯緭鍏ユ暟鍊�");
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(0.00);
+ return;
+ }
+ val = localParseFloat(val);
+ //val = Math.round(val * 100) / 100;
+ val = Math.round(val);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(toNumComma(val));
+ makeRealPrice(1);
+}
+
+function checkContractRange(val, cnt) {
+ if (isNaN(parseInt(val))) {
+ alert("蹇呴』杈撳叆鍚堝悓鏈堟暟!");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ if (val <= 0) {
+ alert("鍚堝悓鏈堟暟蹇呴』澶т簬0");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ if (val > 60) {
+ alert("鍚堝悓鏈熸渶闀垮彧鑳介�夋嫨60涓湀锛�");
+ j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val("");
+ return;
+ }
+ // HWAG-BA73ZP
+ //contractStartDateChange();
+ refreshAsset(cnt);
+}
+function toChange1(){
+ tochange();
+ ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+ console.log('鏂规硶1鏄惁瀹℃壒閫氳繃=='+ISReducedpriceapproval+'====================');
+}
+function toChange2(){
+ tochange2();
+ ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+ console.log('鏂规硶2鏄惁瀹℃壒閫氳繃=='+ISReducedpriceapproval+'==============');
+}
+function refreshAsset(cnt) {
+ // alert(cnt);
+ // 鎻愪氦鍚庡氨椤甸潰涓嶈绠椾簡
+ var isDisabled = {!PageDisabled};
+ // 鍚堝悓鎬荤悊
+ var newCount = 0;
+ var isresduce = 0;
+ var oyearCount = 0;
+ var firstCCount = 0;
+ var conCCount = 0;
+ // row閲戦鍚堣▓
+ var repairSum = 0;
+ var listSum = 0;
+ // 鏂板搧鍚堝悓 鍒ゆ柇
+ var newCon = true;
+ var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ //涓婇檺鍚堝悓 20230103 LY start
+ // var mainteReal = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
+ // Limit_Price_Amount = localParseFloat(mainteReal)*1.3;
+ // console.log('Limit_Price_Amount'+Limit_Price_Amount);
+ // j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
+
+ //涓婇檺鍚堝悓 20230103 LY end
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 start
+ var GuranteeCount = 0;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 end
+
+ //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� 鏄惁涓篎SE start
+ var isFSE = {!isFSE};
+ // var isFSE = true;
+ console.log('***isFSE',isFSE);
+ //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� end
+
+ // 棰勫畾寮�濮嬫棩
+ var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
+ // 棰勫畾寮�濮嬫棩-6涓湀
+ startdate.setMonth(startdate.getMonth() - 6);
+ // 鐢宠鏃� 褰撳墠鏃ユ湡
+ if(approvalDate != ''){
+ //鐢宠鏃�
+ approvalDate = new Date(approvalDate.toLocaleDateString());
+ if (Date.parse(approvalDate) < Date.parse(startdate)) {
+ newCon = false;
+ }
+
+ }
+
+ // 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+ var downPriceSum = 0;
+ var upPriceSum = 0;
+ // 鍚堝悓鏈堟暟涔楃畻
+ var month = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
+ if (month == undefined || month == "") {
+ month = 1;
+ }
+ var month2 = 0;
+ if (month > 12) {
+ month2 = month - 12;
+ month = 12;
+ }
+ for (var i = 0; i < cnt; i++) {
+ var strMoney = 0;
+ var repairMoney = 0;
+ // 琛岄」鐩� 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+ // 缁浠锋牸鍙栬仈鍔ㄤ环鏍奸〉闈㈣绠楋紝棣栫鎴栦骇鍝佸彇 瀹為檯浠锋牸
+ // 涓嬬嚎浠锋牸
+ var downPrice = 0;
+ // 涓婄嚎浠锋牸
+ var upPrice = 0;
+
+ // 12涓湀鍚堝悓閲戦
+ var Price_YearTXT = 0;
+
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ var assetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+ // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+ //var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+ //isNewDate.setMonth(isNewDate.getMonth() + 6);
+ //if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+ // newCon = false;
+ //}
+
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ // alert(strMoney);
+ Price_YearTXT = strMoney * 12;
+ if (isnew == 'true') {
+ newCount ++;
+ strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+ } else {
+ newCon = false;
+ strMoney = month * strMoney + month2 * strMoney;
+ }
+ var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+ var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+ if(b != ''){
+ conCCount ++;
+ // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+ // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+
+ var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ var lastContRange = 0;
+ if(LastMContractRecord == 'VM_Contract'){
+ newCount++;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+ GuranteeCount++;
+ newCon = false;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ lastContRange = 36;
+ }else{
+ lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+ }
+ //鏈�鍚庣粨鏉熸棩+1骞�
+ lastendDate.setMonth(lastendDate.getMonth() + 12);
+ if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
+ oyearCount ++;
+ }
+ // 鍙栬仈鍔ㄤ环鏍�
+ // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+ //
+ var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+ var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+ var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+ //璁$畻鎯╃綒鐜�
+ var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+ if(Punish == 0){
+ return;
+ }
+ // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+ var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+ if(Estimate_Num == 0){
+ if(LastMContractRecord == 'VM_Contract'){
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ var nowdate = new Date();
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+ if(nowdate < Date.parse(lastendDate)){
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }else{
+ upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ }else{
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ }else{
+ upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ }else{
+ //firstCCount ++;
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ // 涓婁笅闄愬洓鑸嶄簲鍏�
+ upPrice = upPrice.toFixed(2);
+ downPrice = downPrice.toFixed(2);
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+
+ repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+ } else {
+ // TODO 涓�鏅傜殑銇蹇溿�併仾銈撱仹鍒ヨ銇噾椤嶃儶銉曘儸銉冦偡銉ャ仌銈屻仧锛�
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val();
+
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text("");
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val();
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val();
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+ }
+ }
+ else {
+ // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+ var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+ isNewDate.setMonth(isNewDate.getMonth() + 6);
+ if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+ newCon = false;
+ }
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ Price_YearTXT = strMoney * 12;
+ if (isnew == 'true') {
+ strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+ } else {
+ strMoney = month * strMoney + month2 * strMoney;
+ }
+ var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+ var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+ if(b != ''){
+ conCCount ++;
+ // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+ // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+ var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ var lastContRange = 0;
+ if(LastMContractRecord == 'VM_Contract'){
+ newCount++;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+ GuranteeCount++;
+ newCon = false;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ lastContRange = 36;
+ }else{
+ lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+ }
+ //鏈�鍚庣粨鏉熸棩+1骞�
+ lastendDate.setMonth(lastendDate.getMonth() + 12);
+ // alert('+++++++++--------' + lastendDate);
+ // alert('+++++++++--------' + Date.parse(contractStartDate) + '77777' + Date.parse(lastendDate));
+ if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+ oyearCount ++;
+ }
+ // 鍙栬仈鍔ㄤ环鏍�
+ // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+ //
+ var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+ var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+ var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+ //璁$畻鎯╃綒鐜�
+ var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+ if(Punish == 0){
+ return;
+ }
+ // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+ var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+ if(Estimate_Num == 0){
+ if(LastMContractRecord == 'VM_Contract'){
+ // alert('11111');
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ var nowdate = new Date();
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+ if(nowdate < Date.parse(lastendDate)){
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }else{
+ upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ }else{
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ }else{
+ upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ }else{
+ if (isnew == 'true') {
+ newCount ++;
+ } else {
+ newCon = false;
+ firstCCount ++;
+ }
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ // 涓婁笅闄愬洓鑸嶄簲鍏�
+ upPrice = upPrice.toFixed(2);
+ downPrice = downPrice.toFixed(2);
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+ //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->
+
+ Repair_Price_AutoPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto'));
+ Repair_Price_Auto = Repair_Price_AutoPrice.value();
+ repairMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
+ Repair_Price_pass = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val();
+ console.log((i+1)+'鍙穜epairMoney='+repairMoney);
+ console.log((i+1)+'鍙稲epair_Price_Auto='+Repair_Price_Auto);
+ if ((repairMoney+1)==1) {
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_Auto);
+ console.log('repairMoney淇敼鎴愬姛');
+ }
+ if ((Repair_Price_pass+1)==1) {
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val(Repair_Price_Auto);
+ console.log('Repair_Price_pass淇敼鎴愬姛');
+ }
+ repairMoney1 = localParseFloat(repairMoney);
+ ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+ console.log('ISReducedpriceapproval=='+ISReducedpriceapproval);
+ if (ISReducedpriceapproval =='鏈夊叓鎶樹互涓嬪緟瀹℃壒' || ISReducedpriceapproval =='鏄�') {
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
+ }else{
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", false);
+ }
+ ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
+ ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+ if (repairMoney1> 0 && (repairMoney1 <Repair_Price_Auto*0.80)) {
+
+ isresduce = isresduce+1;
+ }
+
+ console.log('鍒濆鍖杋sresduce='+isresduce);
+
+ ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
+ rppa = document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto');
+ situation = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_situation')).value();
+ // Agreed_Date = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Agreed_Date')).value();
+
+ console.log('situation='+situation);
+ // console.log('Agreed_Date1='+Agreed_Date);
+ if(!(ResonCannotWarranty.indexOf("寮冧慨") != -1)&&(repairMoney+1)==1){
+ rppa.style.display = "none";
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val('');
+ console.log('###淇敼鎴愬姛');
+ }
+ console.log('鍒ゆ柇1'+(situation.indexOf("淇悊涓�")!=-1));
+ // console.log('鍒ゆ柇'+(Agreed_Date.indexOf("涓嶄负绌�")!=-1));
+ // if ((situation.indexOf("淇悊涓�")!=-1)&& (Agreed_Date.indexOf("涓嶄负绌�")!=-1)) {
+ // console.log('寮�濮嬫搷浣�2');
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).val(0);
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(0);
+ // }
+ //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
+ }
+
+ repairSum = repairSum + localParseFloat(repairMoney);
+ listSum = listSum + localParseFloat(toNum(strMoney));
+ downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
+ upPriceSum = upPriceSum + localParseFloat(toNum(upPrice));
+ }
+
+
+ j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetListSumNum')).text(toNumComma(listSum));
+
+ //j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPrice')).text(toNumComma(listSum));
+ //j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPriceHidden')).val(toNum(listSum));
+ if (!isDisabled) {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text(toNumComma(Math.round(upPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val(toNum(Math.round(upPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text(toNumComma(Math.round(downPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val(toNum(Math.round(downPriceSum)));
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text(toNumComma(repairSum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPriceHidden')).val(toNum(repairSum));
+
+ var allcount = j$(escapeVfId('allPage:allForm:allBlock:productCount3')).value();
+ var result = '';
+ if (allcount == 0) {
+ result = null;
+ //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 start
+ }else if(GuranteeCount > 0 && GuranteeCount == allcount){
+ result = '甯傚満澶氬勾淇濈画绛惧悎鍚�';
+ //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 end
+ }else if (newCount > 0 && newCount == allcount && newCon == true) {
+ result = '鏂板搧鍚堝悓';
+ }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
+ result = '棣栫鍚堝悓';
+ }else if(firstCCount > 0 && firstCCount == allcount){
+ result = '棣栫鍚堝悓';
+ // 20220328 ljh update LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+ // }else if(oyearCount > 0 && oyearCount == conCCount){
+ }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
+ // 20220328 ljh update LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+ result = '闈炵画绛惧悎鍚岋紙绌虹櫧鏈熶竴骞翠互涓婏級';
+ }else{
+ result = '缁鍚堝悓';
+ }
+ console.log(result);
+ document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML = result;
+ document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXTHidden").value = result;
+
+ // 鍙栨秷閰稿寲姘�
+ //NotUseOxygenatedWaterAmount(1);
+ examinationPriceCal(cnt);
+ getLastContractRate();
+}
+function changeAsset(cnt) {
+ // alert(cnt);
+ // 鎻愪氦鍚庡氨椤甸潰涓嶈绠椾簡
+ var isDisabled = {!PageDisabled};
+ // 鍚堝悓鎬荤悊
+ var newCount = 0;
+ var isresduce = 0;
+ var oyearCount = 0;
+ var firstCCount = 0;
+ var conCCount = 0;
+ // row閲戦鍚堣▓
+ var repairSum = 0;
+ var listSum = 0;
+ // 鏂板搧鍚堝悓 鍒ゆ柇
+ var newCon = true;
+ var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 start
+ var GuranteeCount = 0;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 end
+
+ //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� 鏄惁涓篎SE start
+ var isFSE = {!isFSE};
+ // var hasSendEmail = {!hasSendEmail};
+
+ // var isFSE = true;
+ console.log('***isFSE',isFSE);
+ // console.log('***hasSendEmail',hasSendEmail);
+ // if(hasSendEmail == true){
+ // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+ // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+ // console.log('8鎶樹互涓嬫彁浜C鍙 ');
+ // }
+
+
+ //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� end
+
+ // 棰勫畾寮�濮嬫棩
+ var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
+ // 棰勫畾寮�濮嬫棩-6涓湀
+ startdate.setMonth(startdate.getMonth() - 6);
+ // 鐢宠鏃� 褰撳墠鏃ユ湡
+ if(approvalDate != ''){
+ //鐢宠鏃�
+ approvalDate = new Date(approvalDate.toLocaleDateString());
+ if (Date.parse(approvalDate) < Date.parse(startdate)) {
+ newCon = false;
+ }
+
+ }
+
+ // 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+ var downPriceSum = 0;
+ var upPriceSum = 0;
+ // 鍚堝悓鏈堟暟涔楃畻
+ var month = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
+ if (month == undefined || month == "") {
+ month = 1;
+ }
+ var month2 = 0;
+ if (month > 12) {
+ month2 = month - 12;
+ month = 12;
+ }
+ for (var i = 0; i < cnt; i++) {
+ var strMoney = 0;
+ var repairMoney = 0;
+ // 琛岄」鐩� 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+ // 缁浠锋牸鍙栬仈鍔ㄤ环鏍奸〉闈㈣绠楋紝棣栫鎴栦骇鍝佸彇 瀹為檯浠锋牸
+ // 涓嬬嚎浠锋牸
+ var downPrice = 0;
+ // 涓婄嚎浠锋牸
+ var upPrice = 0;
+
+ // 12涓湀鍚堝悓閲戦
+ var Price_YearTXT = 0;
+
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ var assetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+ // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+ //var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+ //isNewDate.setMonth(isNewDate.getMonth() + 6);
+ //if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+ // newCon = false;
+ //}
+
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ // alert(strMoney);
+ Price_YearTXT = strMoney * 12;
+ if (isnew == 'true') {
+ newCount ++;
+ strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+ } else {
+ newCon = false;
+ strMoney = month * strMoney + month2 * strMoney;
+ }
+ var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+ var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+ if(b != ''){
+ conCCount ++;
+ // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+ // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+
+ var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ var lastContRange = 0;
+ if(LastMContractRecord == 'VM_Contract'){
+ newCount++;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+ GuranteeCount++;
+ newCon = false;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ lastContRange = 36;
+ }else{
+ lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+ }
+ //鏈�鍚庣粨鏉熸棩+1骞�
+ lastendDate.setMonth(lastendDate.getMonth() + 12);
+ if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
+ oyearCount ++;
+ }
+ // 鍙栬仈鍔ㄤ环鏍�
+ // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+ //
+ var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+ var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+ var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+ //璁$畻鎯╃綒鐜�
+ var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+ if(Punish == 0){
+ return;
+ }
+ // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+ var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+ if(Estimate_Num == 0){
+ if(LastMContractRecord == 'VM_Contract'){
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ var nowdate = new Date();
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+ if(nowdate < Date.parse(lastendDate)){
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }else{
+ upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ }else{
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ }else{
+ upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ }else{
+ //firstCCount ++;
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ // 涓婁笅闄愬洓鑸嶄簲鍏�
+ upPrice = upPrice.toFixed(2);
+ downPrice = downPrice.toFixed(2);
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+
+ repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+ } else {
+ // TODO 涓�鏅傜殑銇蹇溿�併仾銈撱仹鍒ヨ銇噾椤嶃儶銉曘儸銉冦偡銉ャ仌銈屻仧锛�
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val();
+
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text("");
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val();
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val();
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text("");
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+ }
+ }
+ else {
+ // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+ var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+ isNewDate.setMonth(isNewDate.getMonth() + 6);
+ if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+ newCon = false;
+ }
+ strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ Price_YearTXT = strMoney * 12;
+ if (isnew == 'true') {
+ strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+ } else {
+ strMoney = month * strMoney + month2 * strMoney;
+ }
+ var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+ var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+ if(b != ''){
+ conCCount ++;
+ // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+ // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+ var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ var lastContRange = 0;
+ if(LastMContractRecord == 'VM_Contract'){
+ newCount++;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+ GuranteeCount++;
+ newCon = false;
+ //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ lastContRange = 36;
+ }else{
+ lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+ }
+ //鏈�鍚庣粨鏉熸棩+1骞�
+ lastendDate.setMonth(lastendDate.getMonth() + 12);
+ // alert('+++++++++--------' + lastendDate);
+ // alert('+++++++++--------' + Date.parse(contractStartDate) + '77777' + Date.parse(lastendDate));
+ if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+ oyearCount ++;
+ }
+ // 鍙栬仈鍔ㄤ环鏍�
+ // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+ //
+ var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+ var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+ var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+ //璁$畻鎯╃綒鐜�
+ var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+ if(Punish == 0){
+ return;
+ }
+ // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+ var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+ if(Estimate_Num == 0){
+ if(LastMContractRecord == 'VM_Contract'){
+ // alert('11111');
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ var nowdate = new Date();
+ lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+ nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+ if(nowdate < Date.parse(lastendDate)){
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }else{
+ upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ // gzw 20220630 瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+ }else{
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ }else{
+ upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+ downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+ }
+ }else{
+ if (isnew == 'true') {
+ newCount ++;
+ } else {
+ newCon = false;
+ firstCCount ++;
+ }
+ upPrice = strMoney;
+ downPrice = strMoney * 0.8;
+ }
+ // 涓婁笅闄愬洓鑸嶄簲鍏�
+ upPrice = upPrice.toFixed(2);
+ downPrice = downPrice.toFixed(2);
+ // 12涓湀鍚堝悓閲戦
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+ if (!isDisabled) {
+ // 瀹為檯鑱斿姩浠锋牸 start
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+ // 瀹為檯鑱斿姩浠锋牸 end
+ }
+ //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+ //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->
+
+ Repair_Price_AutoPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto'));
+ Repair_Price_Auto = Repair_Price_AutoPrice.value();
+ repairMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
+ // console.log('repairMoney='+repairMoney);
+ repairMoney1 = localParseFloat(repairMoney);
+ ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
+ ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+ console.log('ISReduced='+ISReduced);
+
+ console.log('Repair_Price_Auto='+Repair_Price_Auto);
+ console.log('绗�'+(i+1)+'涓澶嘔SReducedpriceapproval1='+ISReducedpriceapproval1);
+ console.log('repairMoney1='+repairMoney1);
+
+ Repair_Price_pass1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val();
+ Repair_Price_pass2 = localParseFloat(Repair_Price_pass1);
+ console.log('缁撴灉='+(repairMoney1<Repair_Price_pass2));
+ console.log('Repair_Price_pass2='+Repair_Price_pass2);
+ if (repairMoney1> 0 && repairMoney1<(Repair_Price_Auto*0.80) && Repair_Price_Auto != null && isFSE == true) {
+ if (Repair_Price_pass1!=null && repairMoney1<Repair_Price_pass2) {
+ alert('鐢变簬瀛樺湪鎶樻墸鐜囪秴杩�20%浠ヤ笂鐨勪慨鐞嗗姞璐瑰噺浠风敵璇凤紝璇峰厛鐐瑰嚮鈥滄彁浜C璇勪及鈥濇寜閽紝寰匯C璇勪及鍚庢湇鍔$鐞嗛儴浼氭帹杩涘鎵�');
+ // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", false);
+ // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btn');
+
+ // RCbottonChanged = 1;
+
+ // var change_cancel = document.getElementById("emailSend");
+ // change_cancel.style.display = "block";
+ repairMoney = Repair_Price_pass2;
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_pass2);
+ }
+ }
+
+ repairMoney2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
+ // console.log('repairMoney='+repairMoney);
+ repairMoney3 = localParseFloat(repairMoney2);
+ if (repairMoney3> 0 && (repairMoney3 <Repair_Price_Auto*0.80)) {
+ if (Repair_Price_pass1!=null && repairMoney3<Repair_Price_pass2) {
+ isresduce = isresduce+1;
+ }
+ }
+ ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
+ rppa = document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto');
+ situation = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_situation')).value();
+ // Agreed_Date = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Agreed_Date')).value();
+
+ console.log('situation='+situation);
+ // console.log('Agreed_Date1='+Agreed_Date);
+ //if(ResonCannotWarranty!=null&&!(ResonCannotWarranty.indexOf("寮冧慨") != -1)){
+ // rppa.style.display = "none";
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val('');
+ // console.log('###淇敼鎴愬姛');
+ // }
+ // if ((situation.indexOf("淇悊涓�")!=-1)&& (Agreed_Date.indexOf("涓虹┖")!=-1)) {
+ // console.log('寮�濮嬫搷浣�1');
+ // rppa.style.display = "none";
+ // }
+ // if ((situation.indexOf("淇悊涓�")!=-1)&& (Agreed_Date.indexOf("涓嶄负绌�")!=-1)) {
+ // console.log('寮�濮嬫搷浣�2');
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).val(0);
+ // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(0);
+ // }
+ //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
+ }
+
+ repairSum = repairSum + localParseFloat(repairMoney);
+ listSum = listSum + localParseFloat(toNum(strMoney));
+ downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
+ upPriceSum = upPriceSum + localParseFloat(toNum(upPrice));
+ }
+ console.log('鏀瑰彉閲戦isresduce='+isresduce);
+ if (isresduce!=0) {
+ toChange1();
+ }else{
+ if(ISReduced !='' ){
+ toChange2();
+ }
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
+ if (!isDisabled) {
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text(toNumComma(Math.round(upPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val(toNum(Math.round(upPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text(toNumComma(Math.round(downPriceSum)));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val(toNum(Math.round(downPriceSum)));
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text(toNumComma(repairSum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPriceHidden')).val(toNum(repairSum));
+
+ var allcount = j$(escapeVfId('allPage:allForm:allBlock:productCount3')).value();
+ var result = '';
+ if (allcount == 0) {
+ result = null;
+ //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 start
+ }else if(GuranteeCount > 0 && GuranteeCount == allcount){
+ result = '甯傚満澶氬勾淇濈画绛惧悎鍚�';
+ //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 end
+ }else if (newCount > 0 && newCount == allcount && newCon == true) {
+ result = '鏂板搧鍚堝悓';
+ }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
+ result = '棣栫鍚堝悓';
+ }else if(firstCCount > 0 && firstCCount == allcount){
+ result = '棣栫鍚堝悓';
+ // 20220328 ljh update LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+ // }else if(oyearCount > 0 && oyearCount == conCCount){
+ }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
+ // 20220328 ljh update LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+ result = '闈炵画绛惧悎鍚岋紙绌虹櫧鏈熶竴骞翠互涓婏級';
+ }else{
+ result = '缁鍚堝悓';
+ }
+ document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML = result;
+ document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXTHidden").value = result;
+
+ examinationPriceCal(cnt);
+ getLastContractRate();
+}
+
+
+function examinationPriceCal(cntWithKara) {
+ var examinationCount = localParseInt(j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).val());
+ var examinationCountStr = number_format_common(examinationCount, 0, ".", ",");
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).val(examinationCountStr);
+ var cnt = 0;
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ if (a != '') {
+ cnt++;
+ }
+ }
+ else {
+ cnt++;
+ }
+ }
+ var examinationPrice = 0;
+// 浠婂緦寰╂椿銇嬨倐
+// var cntLot = Math.ceil(cnt / 20);
+// if (cntLot == 0) {
+// examinationPrice = 0;
+// }
+// else if (cntLot == 1) {
+// examinationPrice = 2000;
+// }
+// else if (cntLot == 2) {
+// examinationPrice = 3800;
+// }
+// else if (cntLot == 3) {
+// examinationPrice = 5400;
+// }
+// else if (cntLot == 4) {
+// examinationPrice = 6800;
+// }
+// else if (cntLot == 5) {
+// examinationPrice = 8000;
+// }
+// else if (cntLot >= 6) {
+// examinationPrice = 1600 * cntLot;
+// }
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationReal')).text(toNumComma(examinationPrice * examinationCount));
+ j$(escapeVfId('allPage:allForm:allBlock:appendCondition:examinationRealHidden')).val(toNum(examinationPrice * examinationCount));
+
+ // 浠樺姞鏉′欢绶忛娆�
+ // 20200108 鍘婚櫎闄勫姞鏉′欢鎬婚
+ // var oxygenPrice = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:NotUseOxygenatedWaterAmount')).text());
+ // j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPrice')).text(toNumComma(oxygenPrice + examinationPrice * examinationCount));
+ // j$(escapeVfId('allPage:allForm:allBlock:contractInfo:appendPriceHidden')).val(toNum(oxygenPrice + examinationPrice * examinationCount));
+
+ makeRealPrice(1);
+}
+
+/*
+ * @param t 1: 閲戦銇倛銈婂壊寮�
+ */
+function makeRealPrice(t) {
+ // 瀹熼殯閲戦鍚堣▓
+ // 鐢宠鎶ヤ环閲戦
+ var sum1 = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val());
+ // 淇悊鎬婚
+ var sum2 = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
+ var sum1 = localParseFloat(sum1);
+ // 涓婇檺
+ var upPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text();
+ upPrice = localParseFloat(upPrice);
+ // 涓嬮檺
+ var downPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text();
+ downPrice = localParseFloat(downPrice);
+
+ // 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼 璁$畻
+ // 1锛夋爣鍑嗕环鏍艰寖鍥村唴鏃讹紝缁撴灉涓�0锛�
+ // 2锛夋瘮鏍囧噯浠锋牸浣庢椂锛岀粨鏋滄槸1-甯屾湜浠锋牸/鏍囧噯浠风殑鏈�浣庝环鏍�
+ // 3锛夋瘮鏍囧噯浠锋牸楂樻椂锛岀粨鏋滄槸1-甯屾湜浠锋牸/鏍囧噯浠风殑鏈�楂樹环鏍�
+ var disMP = 0.00;
+ var disP = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_RateHidden')).val();
+ if(sum1 < downPrice){
+ disMP = toNum((1 - sum1/downPrice) * 100);
+ }else if(sum1 >= downPrice && sum1 <= upPrice){
+ disMP = 0.00;
+ }else if(sum1 > upPrice){
+ disMP = toNum((1 - sum1/upPrice) * 100);
+ }
+
+
+ if (disMP != disP) {
+ disMP = '' + disMP + '%';
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_Rate')).text(disMP);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_RateHidden')).val(parseFloat(disMP));
+ }
+ // 淇悊绶忛銈掕▓涓�
+ sum = sum1 + localParseFloat(sum2);
+
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text(toNumComma(sum));
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteRealHidden')).val(toNum(sum));
+}
+
+function resetDealer() {
+ var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
+ var obj = document.getElementById('allPage:allForm:allBlock:contract:dealer');
+ var obj2 = document.getElementById('allPage:allForm:allBlock:contract:FirstParagraphEnd');
+ var obj_lkwgt = document.getElementById('allPage:allForm:allBlock:contract:dealer_lkwgt');
+ if (target == '鍖婚櫌') {
+ obj.style.display = "none";
+ obj2.style.display = "none";
+ obj_lkwgt.style.display = "none";
+ } else {
+ obj.style.display = "block";
+ obj_lkwgt.style.display = "block";
+ obj2.style.display = "block";
+ }
+}
+
+function alertMsg() {
+ // body...
+ if('{!isPaymentSet}' == 'false'){
+ alert('璇峰~鍐欎粯娆捐鍒�');
+ return false;
+ }else if('{!isPaymentSet}' == 'Denied'){
+ alert('浠樻璁″垝閲戦涓庡疄闄呬笉绗︼紝璇烽噸鏂板~鍐�');
+ return false;
+ }else{
+ return true;
+ }
+}
+function EGFlgconfim() {
+ getEstimateCost();
+ var cntWithKara = {!productCount};
+ // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 鏄惁鏀瑰彉
+ var alert1s = 0;
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var EGFlgtxt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':EquipmentGuaranteeFlg')).value();
+ var EGFlgnow = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':EGFlgassHidden')).value();
+ if (EGFlgtxt != EGFlgnow) {
+ alert1s = 1;
+ }
+ }
+ if (alert1s == 1) {
+ if (confirm("閫夋嫨鐨勪繚鏈夎澶嘯鏂板悎鍚屽鍝佺‘淇濇彁渚沒鍙戠敓鍙樺寲锛屾槸鍚︾户缁紵")) {
+
+ } else {
+ return false;
+ }
+ }
+ return onclickCheckchangedAfterPrint('true','true');
+}
+function onclickCheckchangedAfterPrint(saveBtnDisabled, saveOrApproval) {
+
+ //if(saveBtnDisabled == 'Pttrue'){
+ // var rs = alertMsg();
+ // if(rs){
+ // }else {
+ // return false;
+ // }
+ //}
+
+ var cntWithKara = {!productCount};
+ var alerts = 0;
+ // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 鏄惁鏀瑰彉
+ var alert1s = 0;
+ var today = new Date();
+ today.setMonth(today.getMonth() - 3);
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var plkid = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert_lkid'));
+ var pid = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (plkid.size() > 0 && pid.size() > 0) {
+ if (pid.value() != '' && plkid.value() != pid.value().substring(0, 15)) {
+ alert('璇蜂娇鐢ㄤ骇鍝佹斁澶ч暅鎸夐挳璁惧畾鎵嬪姩浜у搧');
+ return false;
+ }
+ }
+ }
+ if (isManual == 'false') {
+ var strDate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':finalExaminationDate')).value();
+ // var produ = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+ //alert(EGFlgtxt + ':' + EGFlgnow);
+ strDate = strDate.replace(/(^\s*)|(\s*$)/g, "");
+ if (strDate == "" || Date.parse(strDate) < Date.parse(today)) {
+ alerts = 1;
+ }
+ }
+ }
+ if (alerts == 1) {
+ if (confirm("閫夋嫨鐨勪繚鏈夎澶嘯鏈�鍚庣偣妫�鏃涓虹┖鎴栧凡缁忚秴杩囦笁涓湀涔嬪墠锛屾槸鍚︾户缁紵")) {
+
+ } else {
+ return false;
+ }
+ }
+ blockme();
+ if (saveOrApproval == "true") {
+ if (saveBeforeCheckPriceChange()) {
+ if (confirm("琛屼俊鎭湁鍙樺寲(鏈嶅姟鍚堝悓浠锋牸)锛屾槸鍚︽洿鏂版姤浠凤紵")) {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('true');
+ } else {
+ j$(escapeVfId('allPage:allForm:changedSubmitPrice')).val('fasle');
+ unblockUI();
+ return false;
+ }
+ }
+ j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ }
+
+
+ return true;
+ // if ((saveBtnDisabled == "true"||saveBtnDisabled == "Pttrue" )&& checkchangedAfterPrint()) {
+ // if (confirm(Confirm_ChangedAfterPrint)) {
+ // if (saveOrApproval == "true") {
+ // j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ // }
+ // return true;
+ // } else {
+ // unblockUI();
+ // return false;
+ // }
+ // } else {
+ // if (saveOrApproval == "true") {
+ // j$(escapeVfId('allPage:allForm:isSaveOrApproval')).val('true');
+ // }
+ // return true;
+ // }
+}
+
+function changeEstiStartdate(val) {
+ if ('{!SaveBtnDisabled}' == 'false') {
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(val);
+ changeContractStartdate(val);
+ }
+}
+
+function changeContractStartdate(val) {
+
+ var oldDateStr = j$('#oldContractDate').value();
+ var oldDate = new Date();
+ if (oldDateStr != null && oldDateStr != '') {
+ oldDate = new Date(oldDateStr);
+ }
+ if ('{!DecideBtnDisabled}' == 'false') {
+ var monthStr = '00' + (oldDate.getMonth()+1);
+ monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ var dayStr = '00' + oldDate.getDate();
+ dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ var oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+ j$(escapeVfId('allPage:allForm:oldDecideContractDate')).val(oldDateVal);
+ if (saveBeforeCheckPriceChange()) {
+ //blockme();
+ //contractStartDateChange();
+ //refreshAsset({!productCount});
+ }
+ refreshAsset({!productCount});
+ } else {
+ var cntWithKara = {!productCount};
+ var haveLine = 'false';
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert_lkid'));
+ if (a.size() > 0 && a.val() != "000000000000000") {
+ haveLine = 'true';
+ }
+ } else {
+ haveLine = 'true';
+ }
+ }
+
+ if (haveLine == 'false') {
+ return false;
+ }
+ var contractStartDate = new Date(val);
+ var strCreatedDate = '{!estimate.CreatedDate}';
+ var createDate = new Date();
+ if (strCreatedDate != '') {
+ createDate = new Date(strCreatedDate);
+ }
+ createDate = new Date(createDate.toDateString());
+ var threeMA = new Date(createDate.setMonth(createDate.getMonth() + 3));
+ var isnewMA = new Date(createDate.setMonth(createDate.getMonth() - 3 - isNewAddMonth));
+
+ /*if (oldDate >= isnewMA && contractStartDate >= isnewMA) {
+ return false;
+ }
+ if (oldDate < threeMA && contractStartDate < threeMA) {
+ return false;
+ }
+
+ if (contractStartDate >= isnewMA) {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖澶т簬鍒涘缓鏃�6涓湀锛屾墍鏈夊悎鍚屽璞¤澶囦笉閫傜敤鏂板搧浠锋牸銆俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ゆ湇鍔″悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ } else if (contractStartDate >= threeMA) {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖澶т簬鍒涘缓鏃�3涓湀锛屾墍鏈夊悎鍚屽璞¤澶囦娇鐢ㄣ�愬悎鍚屽紑濮嬫棩銆戦噸鏂拌绠楁湇鍔″悎鍚屼环鏍笺�俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ゆ湇鍔″悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ } else {
+ alert('鍚堝悓寮�濮嬮瀹氭棩鎴栧悎鍚屽紑濮嬫棩鍙戠敓鍙樺寲骞朵笖鍦ㄥ垱寤烘棩3涓湀浠ュ唴锛屾墍鏈夊悎鍚屽璞¤澶囦娇鐢ㄣ�愬垱寤烘棩銆戦噸鏂拌绠楁湇鍔″悎鍚屼环鏍笺�俓n璇峰湪鐢婚潰鍒锋柊鍚庣‘璁ゆ湇鍔″悎鍚屼环鏍硷紝鍐嶇户缁叾浠栨搷浣溿��');
+ }*/
+ j$('oldContractDate').val(val);
+ //blockme();
+ //contractStartDateChange();
+ refreshAsset({!productCount});
+ }
+}
+function AlertPriceBtnJs(){
+
+ var VarAlert = j$(escapeVfId('allPage:allForm:alertStringValue')).val();
+ var VarAlert2 = j$(escapeVfId('allPage:allForm:alertStringValue2')).val();
+ var VarAlert3 = j$(escapeVfId('allPage:allForm:alertStringValue3')).val();
+ var PStatus = j$(escapeVfId('allPage:allForm:PriceStatus')).val();
+ blockme();
+
+ if(PStatus!='鐢宠涓�'&& PStatus!='鎵瑰噯'){
+ ComputeLTYRepair();
+ //ShowLTYRepair();
+ }else if(PStatus == '鐢宠涓�'||PStatus == '鎵瑰噯'){
+ ShowLTYRepair();
+ }
+
+}
+function ComputeLTY() {
+ var urlNameJs = j$(escapeVfId('allPage:allForm:urlName')).val();
+ urlNameJs = '{!$Label.ID_of_SelectAssetEstimate}'+urlNameJs ;
+ //URF闄愭鍚堝悓2鏈� LY 20220920 start
+ // var w = window.open(encodeURI(urlNameJs),'杩囧幓涓ゅ勾淇悊瀹炵哗','menubar=no,height=720,width=986');
+ // w.focus();
+ //URF闄愭鍚堝悓2鏈� LY 20220920 end
+}
+function recordNumChangeJs() {
+ recordNumChangeAction();
+}
+
+function checkDecideDate() {
+ // 鎶ヤ环鏈夋晥鏈�
+ var strSubmitDate = '{!estimate.Submit_quotation_day__c}';
+ // 涓婃湡鍚堝悓缁撴潫鏃� 鍙栨渶鏅氱殑
+ var conEndDate = getLastContractendDate();
+ conEndDate = new Date(conEndDate);
+ // 浠婂ぉ
+ var submitDate = new Date();
+ var nowDate = new Date();
+ nowDate = new Date(nowDate.toLocaleDateString());
+ /// 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
+ // 榛樿涓�3鏈堬紝鍏ㄦ槸浜у搧涓�6鏈堬紱
+ var monthGap = 6;
+ var cntWithKara = {!productCount};
+
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual != 'true') {
+ monthGap = 3;
+ break;
+ }
+ }
+
+
+ //nowDate = new Date(nowDate.getYear(),nowDate.getYear(),nowDate.getYear());
+ if (strSubmitDate != '') {
+ submitDate = new Date(strSubmitDate);
+ submitDate = new Date(submitDate.setMonth(submitDate.getMonth() + monthGap));
+ if(Date.parse(conEndDate) > Date.parse(submitDate)){
+ submitDate = new Date(conEndDate);
+ }
+ }
+ //alert(nowDate + '=====' + submitDate);
+ if (strSubmitDate != '' && nowDate > submitDate) {
+ alert('宸茶秴鍑烘姤浠风敵璇锋棩'+ monthGap+'涓湀锛屼笉鍏佽DECIDE銆�');
+ return false;
+ }
+ return true;
+}
+
+function getLastContractendDate(){
+ var rowCnt = {!productCount};
+ var lastdate = null;
+ for (var i = 0; i < rowCnt; i++) {
+ var LastMContractID = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractID')).value();
+ if(!!LastMContractID){
+ var endDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+ if(lastdate == null){
+ lastdate = new Date(endDate);
+ }else if(Date.parse(endDate) > Date.parse(lastdate)){
+ lastdate = new Date(endDate);
+ }
+ }
+ }
+ return lastdate;
+}
+
+
+function decideJs() {
+ if (checkDecideDate() == true) {
+ if (onclickCheckchangedAfterPrint('true','false') == true) {
+ var oldDate = j$(escapeVfId('allPage:allForm:oldDecideContractDate')).value();
+ var contractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ //var olDt = oldDate.getFullYear() + oldDate.getMonth() + oldDate.getDate();
+ var monthStr = '00' + (contractDate.getMonth()+1);
+ monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ var dayStr = '00' + contractDate.getDate();
+ dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ var contractDateStr = contractDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+
+ //var neDt = contractDate.getFullYear() + contractDate.getMonth() + contractDate.getDate();
+ //monthStr = '00' + (oldDate.getMonth()+1);
+ //monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
+ //dayStr = '00' + oldDate.getDate();
+ //dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
+ //oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
+ if (oldDate == contractDateStr) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decide();
+ } else {
+ var oldp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).value());
+ var newp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
+
+ if (oldp != newp) {
+ // 20201106 楂樼珷浼� 鎻愰啋娑堟伅淇敼 start
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ if (confirm('鍚堝悓閲戦鍙戠敓鍙樺寲锛岃鎮ㄧ‘璁ゃ��')) {
+ decide();
+ } else {
+ alert('璇风‘璁ゅ叏閮ㄥ唴瀹瑰悗鐐瑰嚮Decide銆�');
+ j$(escapeVfId('allPage:allForm:contractstartdate')).val(oldDate);
+ j$(escapeVfId('allPage:allForm:oldDecideContractDate')).val('');
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decideCancle();
+ }
+ } else {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ decide();
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ // if (confirm('鏈鍚堝悓寮�濮嬫棩鐨勪慨鏀逛笉浼氬鑷村悎鍚岄噾棰濆彂鐢熷彉鍖栵紝璇锋偍纭鏄惁淇敼锛�')) {
+ // decide();
+ // } else {
+ // j$(escapeVfId('allPage:allForm:contractstartdate')).val(oldDate);
+ // alert('鍚堝悓寮�濮嬫棩鏈繘琛屽彉鏇达紝璇风‘璁ゅ叏閮ㄥ唴瀹瑰悗鐐瑰嚮Decide銆�');
+ // unblockUI();
+ // }
+ }
+ // 20201106 楂樼珷浼� 鎻愰啋娑堟伅淇敼 end
+ }
+ }
+ }
+}
+// 鑾峰彇瀹為檯鎶ヤ环閲戦 鎸夌収涓婇檺姣斾緥绠�
+function getEstimateCost() {
+ // 琛屾暟
+ var rowcount = {!productCount};
+ // 6.鍚堝悓浠锋牸
+ var mainteReal = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
+ mainteReal = localParseFloat(mainteReal);
+ // 5.淇悊鎬婚
+ var assetRepairSumPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
+ assetRepairSumPrice = localParseFloat(assetRepairSumPrice);
+ // 璁$畻瀹為檯鎶ヤ环鎬婚噾棰�
+ var realprice = mainteReal - assetRepairSumPrice;
+ // 鏍囧噯浠锋牸鐨勬渶楂樹环鎬婚
+ var GuidePriceUp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val());
+ GuidePriceUp = localParseFloat(GuidePriceUp);
+ for (var i = 0; i < rowcount; i++) {
+ // 鍘讳笂闄愪环鏍�
+ var assetListPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
+ assetListPrice = localParseFloat(assetListPrice);
+ if(GuidePriceUp == 0){
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_Cost')).val(0);
+ }else{
+ var Estimate_Cost = (realprice * (assetListPrice / GuidePriceUp)).toFixed(2);
+ j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_Cost')).val(Estimate_Cost);
+ }
+
+
+ }
+}
+
+function getLastContractRate(){
+ var rowCnt = {!productCount};
+ var Contractrate = 0.00;
+ var count = 0;
+ for (var i = 0; i < rowCnt; i++) {
+ var LastMContractID = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractID')).value();
+ if(!!LastMContractID){
+ var tempContractrate = parseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).value().replace(/,/g,''));
+ if(!!tempContractrate){
+ Contractrate = Contractrate + tempContractrate;
+ }
+ count++;
+ }
+ }
+ var allContractRate = '' + 0.00 + '%';
+ if( count > 0){
+ allContractRate = '' + (Contractrate/count).toFixed(2) + '%';
+ }
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Combinedrate')).text(allContractRate);
+ j$(escapeVfId('allPage:allForm:allBlock:contractInfo:CombinedrateHidden')).val(parseFloat(allContractRate));
+
+ return allContractRate;
+}
+function calculateNtoMRatio(lastContRange, month ){
+ var lastContRangeYear = Math.ceil(localParseFloat(lastContRange)/12);
+ var currentMonthYear = Math.ceil(localParseFloat(month)/12);
+ //if(!lastendDate || currentMonthYear <= lastContRangeYear){
+ if(currentMonthYear == lastContRangeYear || currentMonthYear == 1){
+ return month;
+ }else if(month <= 24) {
+ return 12+ (month- 12) *1.1;
+ }else if(month <= 36) {
+ return 25.2 + (month- 24) *1.21;
+ }else if(month <= 48) {
+ return 39.72 + (month- 36) *1.331;
+ }else if(month <= 60) {
+ return 55.692 + (month- 48) *1.4641;
+ }else {
+ alert('鍚堝悓鏈熸渶闀垮彧鑳介�夋嫨60涓湀锛�');
+ return 0;
+ }
+
+}
+
+ //鑾峰彇缁忛攢鍟嗙殑鍏堟鏍囪瘑
+ function onChDealerUpdateJs(oBj){
+ //鑾峰彇 鎶ヤ环鎻愪氦瀵硅薄 鏄惁涓虹粡閿�鍟�
+ var estimateTarget = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget'))[0].value;
+ if(estimateTarget == '缁忛攢鍟�'){
+ //鍒ゆ柇缁忛攢鍟嗗悕鏄惁涓虹┖
+ var dealerValue = j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).val();
+ if(dealerValue != ''){
+ //鑾峰彇缁忛攢鍟嗗悕鐨刬d
+ var dealerId = j$(escapeVfId('allPage:allForm:allBlock:contract:dealer_lkid')).val();
+ //鐢变簬salesforce鐨勬煡鎵惧瓧娈垫槸鍙互杈撳叆鐨勶紝鎵�浠ュ垽鏂粬濡傛灉涓虹┖鎴栬�呬负 000000000000000 鐨勬椂鍊欙紝浼犵殑鍙傛暟灏变綅缁忛攢鍟嗕腑鏂囧悕锛屽叾浠栨儏鍐典紶id
+ if(dealerId != '' && dealerId != '000000000000000'){
+ onChDealerUpdate(dealerId);
+ }else{
+ onChDealerUpdate(dealerValue);
+ }
+ }else{
+ onChDealerUpdate('');
+ //j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked = false;
+ }
+ }
+ }
+ //濡傛灉閫夋嫨鐨勭粡閿�鍟嗕负鍏堟瀵硅薄锛岄偅涔堝仛涓�涓嬫彁绀�
+ function hintAccount(){
+ var xkChecked = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
+ if(xkChecked){
+ alert('璇锋敞鎰忥紝褰撳墠缁忛攢鍟嗕负鍏堟瀵硅薄銆�');
+ }
+ }
+
+//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋 lt 20211221 start
+//鍚堝悓寮�濮嬫棩棰勫畾鏃ラ粯璁や负涓婃湡鍚堝悓1缁撴潫鏃ョ殑绗�2澶�
+// function DefaultStartDate(){
+// //涓婃湡鍚堝悓1缁撴潫鏃�
+// var LastContractEndDate;
+// var LastContractEndDate2; //鏃ユ湡鏍煎紡
+// var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+// for (var i = 0; i < cnt; i++){
+// LastContractEndDate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value();
+// //鎴栬�呮崲闅愯棌鏍囩Maintenance_Contract__r.Past_Contract_end_day__c
+// LastContractEndDate2 = LastContractEndDate;
+// if(LastContractEndDate != null && LastContractEndDate != ''){
+// break;
+// }
+// }
+
+// if(LastContractEndDate != null && LastContractEndDate != ''){
+// //涓婃湡鍚堝悓1缁撴潫鏃ョ殑绗�2澶�
+// LastContractEndDate += " 00:00:00";//璁剧疆涓哄綋澶╁噷鏅�12鐐�
+// LastContractEndDate = Date.parse(new Date(LastContractEndDate))/1000;//杞崲涓烘椂闂存埑
+// LastContractEndDate += (86400) * 1;//淇敼鍚庣殑鏃堕棿鎴�
+// var newDate = new Date(parseInt(LastContractEndDate) * 1000);//杞崲涓烘椂闂�
+// var LastContractEndDate1 = newDate.getFullYear() + '/' + (newDate.getMonth() + 1) + '/' + newDate.getDate();;
+
+// //鑾峰彇褰撳墠鏃ユ湡(currentdate)
+// var date1 = new Date();
+// var seperator = "/";
+// var year = date1.getFullYear();
+// var month = date1.getMonth() + 1;
+// var day = date1.getDate();
+// if (month >= 1 && month <= 9) {
+// month = "0" + month;
+// }
+// if (day >= 0 && day <= 9) {
+// day = "0" + day;
+// }
+// var currentdate = year + seperator + month + seperator + day;
+
+// //涓婃湡鍚堝悓灏氭湭缁撴潫 , 寮�濮嬮瀹氭棩
+// if(currentdate < LastContractEndDate2){
+// document.getElementById("allPage:allForm:allBlock:contract:startdate").value = LastContractEndDate1;
+// }
+// }
+
+// }
+//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋 lt 20211221 end
+
+</script>
+<apex:form id="allForm">
+ <apex:inputHidden id="alertStringValue" value="{!alertString}" />
+ <apex:inputHidden id="alertStringValue2" value="{!alertString2}" />
+ <apex:inputHidden id="alertStringValue3" value="{!alertString3}" />
+ <apex:inputHidden id="PriceStatus" value="{!estimate.Process_Status__c}"/>
+ <apex:inputHidden id="urlName" value="{!estimate.Name}"/>
+ <apex:inputHidden id="changedAfterPrint" value="{!changedAfterPrint}"/>
+ <apex:inputHidden id="changedSubmitPrice" value="{!changedSubmitPrice}"/>
+ <apex:inputHidden id="isSaveOrApproval" value="{!isSaveOrApproval}"/>
+
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,assetSection2,pageMessages,allBlock" onComplete="unblockUI();"></apex:actionFunction>
+ <apex:actionfunction action="{!tochange}" name="tochange" rerender="ISReducedpriceapproval" oncomplete="unblockUI();">
+ </apex:actionfunction>
+ <apex:actionfunction action="{!tochange2}" name="tochange2" rerender="ISReducedpriceapproval" oncomplete="unblockUI();">
+ </apex:actionfunction>
+ <!-- HWAG-B4R3SS END 20181026-->
+ <apex:actionFunction name="ComputeLTYRepair" action="{!ComputeLTYRepair}" rerender="pageMessages" oncomplete="unblockUI();ComputeLTY();"/>
+ <apex:actionFunction name="ShowLTYRepair" action="{!ShowLTYRepair}" oncomplete="unblockUI();ComputeLTY();"/>
+ <apex:actionFunction name="decide" action="{!decide}" rerender="allForm" oncomplete="unblockUI();"/>
+ <apex:actionFunction name="decideCancle" action="{!decideCancle}" rerender="allForm" oncomplete="unblockUI();"/>
+ <apex:inputHidden id="oldDecideContractDate" value="{!OldContractStartDate}" />
+ <!-- 缁忛攢鍟嗗彂鐢熷彉鍖栫殑change鏃堕棿 -->
+ <apex:actionFunction name="onChDealerUpdate" action="{!onChDealerUpdate}" rerender="contract" onComplete="hintAccount();">
+ <apex:param name="checkDealerId" assignTo="{!checkDealerId}" value="" />
+ </apex:actionFunction>
+ <input type="hidden" id="oldContractDate" value="{!estimate.Contract_Start_Date__c}" />
+<script type="text/javascript">
+//j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+</script>
+ <apex:pageBlock title="鏈嶅姟鍚堝悓鎶ヤ环" id="allBlock">
+ <apex:pageBlockButtons id="blocktop" location="top">
+ <apex:commandButton id="savebtntop" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/>
+ <!-- <apex:commandButton id="LastTwoYearRepairShow" value="杩囧幓涓ゅ勾缁翠慨瀹炵哗Repaort" action="{!ShowLTYRepair}" rerender="alertStringValue,alertStringValue2,alertStringValue3" oncomplete="AlertPrice();"/> -->
+ <apex:commandButton id="LastTwoYearRepairComp" value="杩囧幓涓夊勾缁翠慨瀹炵哗璁$畻" rerender="PriceStatus" onclick="AlertPriceBtnJs()"/>
+ <apex:commandButton id="approvalbtntop" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
+ <apex:outputText style="color:red;font-size:20px" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
+ <apex:commandButton action="{!cancel}" value="涓嶄繚瀛橈紙杩斿洖锛�" style="float:right;" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/>
+ <apex:commandButton id="saveAndCancelBtn" action="{!saveAndCancel}" value="淇濆瓨锛堣繑鍥烇級" style="float:right;" rerender="allForm" oncomplete="unblockUI();" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" disabled="{!SaveBtnDisabled}"/>
+ </apex:pageBlockButtons>
+
+ <apex:pageMessages id="pageMessages"></apex:pageMessages>
+ <!-- update 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖� 娣诲姞鈥榓ssetSection鈥� fxk 2021/9/10 Star-->
+ <apex:actionFunction name="refreshProductData" action="{!refreshProductData}" rerender="pageMessages,EquipmentGuaranteeFlg,EGFlgassHidden,EquipmentGuaranteeFlgtxt, assetListPriceHidden, productCount3,assetSection" oncomplete="refreshAsset({!productCount});unblockUI();">
+ <apex:param assignTo="{!productIdx}" name="productIdx" value=""/>
+ </apex:actionFunction>
+ <!-- update 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖� 娣诲姞鈥榓ssetSection鈥� fxk 2021/9/10 End-->
+ <!--<apex:actionFunction name="contractStartDateChange" action="{!contractStartDateChange}" rerender="allForm" oncomplete="unblockUI();">
+ </apex:actionFunction>-->
+
+ <apex:actionFunction name="recordNumChangeAction" action="{!recordNumChange}" rerender="allForm" oncomplete="unblockUI();">
+ </apex:actionFunction>
+
+ <!-- update by rentx 2020-11-17 -->
+ <!-- <apex:pageblocksection title="鏈嶅姟鍚堝悓" id="contract"> -->
+ <!-- <apex:outputField value="{!estimate.Name}"/> -->
+ <!-- <apex:outputField value="{!contract.Management_Code__c}" /> -->
+ <!-- <apex:outputField value="{!estimate.Process_Status__c}"/> -->
+ <!-- <apex:outputField value="{!contract.Status__c}"/> -->
+ <!-- <apex:outputField value="{!contract.Hospital__c}" /> -->
+ <!-- <apex:inputField value="{!estimate.Department__c}" id="depart"/> -->
+ <!-- <apex:inputField value="{!estimate.Contract_Esti_Start_Date__c}" required="true" id="startdate" onchange="changeEstiStartdate(this.value);"/>onchange="checkContractEstiStartDate(this.value, {!productCount})" -->
+ <!-- <apex:inputField value="{!estimate.Contract_Range__c}" required="true" id="monthRange" onchange="checkContractRange(this.value, {!productCount})"/> -->
+ <!-- <apex:inputField style="width:3px;height:15px;background-color:#cc0000; position:absolute;margin-right:5px;"> -->
+ <!-- <div><div style="width:2px;height:20px;background-color:red; position:absolute;margin-right:5px;"></div></div> -->
+ <!-- <apex:inputField value="{!estimate.Contract_Range__c}" required="false" id="monthRange" onchange="checkContractRange(this.value, {!productCount})"/> -->
+ <!-- </apex:inputField> -->
+
+ <!-- <apex:outputField value="{!estimate.Contract_Esti_End_Date__c}"/> -->
+ <!-- <apex:outputField label="鍒跺畾鏃�" value="{!estimate.CreatedDate}" id="createDateShow"/> -->
+
+ <!-- <apex:outputPanel > -->
+ <!-- <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鎻愪氦瀵硅薄</label> -->
+ <!-- <apex:inputField value="{!estimate.Estimate_Target__c}" id="estimateTarget" onchange="resetDealer()" style="margin-left:5px"/> -->
+
+ <!-- <apex:outputPanel rendered="{!DecideBtnDisabled==false}"> -->
+ <!-- <input type="button" class="btn" value="鍙樻洿" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/> -->
+ <!-- </apex:outputPanel> -->
+ <!-- <apex:outputPanel rendered="{!DecideBtnDisabled==true}"> -->
+ <!-- <input type="button" class="btnDisabled" value="鍙樻洿" disabled="true" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/> -->
+ <!-- </apex:outputPanel> -->
+ <!-- </apex:outputPanel> -->
+
+ <!-- <apex:inputField value="{!estimate.Dealer__c}" id="dealer" /> -->
+ <!-- <apex:inputField value="{!estimate.EndUserType__c}" id="EndUserType" /> -->
+ <!-- <script type="text/javascript"> -->
+ <!-- j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).children('option[value=]').remove(); -->
+ <!-- resetDealer(); -->
+ <!-- </script> -->
+ <!-- </apex:pageblocksection> -->
+ <apex:pageBlockSection title="鏈嶅姟鍚堝悓" id="contract">
+ <!-- <apex:outputPanel/> -->
+ <apex:outputPanel >
+ <table align="center" width="100%" style="border-collapse:separate; border-spacing:0px 10px" >
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环缂栫爜</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!estimate.Name}"/> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鐘舵��</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!estimate.Process_Status__c}"/> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍖婚櫌</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!contract.Hospital__c}" /> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓寮�濮嬮璁㈡棩</label> </td>
+ <td width="50%" align="left"> <apex:inputField value="{!estimate.Contract_Esti_Start_Date__c}" required="true" id="startdate" onchange="changeEstiStartdate(this.value);"/>
+ </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"><label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓缁撴潫棰勮鏃�</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!estimate.Contract_Esti_End_Date__c}"/> </td>
+ </tr>
+ <tr>
+ <td align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鎶ヤ环鎻愪氦瀵硅薄</label>
+ <td>
+ <apex:outputPanel >
+ <apex:inputField value="{!estimate.Estimate_Target__c}" id="estimateTarget" onchange="resetDealer()" style="margin-left:5px"/>
+ <apex:outputPanel rendered="{!DecideBtnDisabled==false}">
+ <input type="button" class="btn" value="鍙樻洿" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!DecideBtnDisabled==true}">
+ <input type="button" class="btnDisabled" value="鍙樻洿" disabled="true" onclick="controlDisabled()" style="margin-left:20px;width:40px;padding:0 0;"/>
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </td>
+ </td>
+ </tr>
+ <tr>
+ <td align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%"> 鐢ㄦ埛绫诲瀷</label></td>
+ <td align="left">
+ <apex:outputField value="{!estimate.EndUserType__c}" id="EndUserType" />
+ </td>
+ <td> </td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ <apex:outputPanel >
+
+ <table align="center" width="100%" style="border-collapse:separate; border-spacing:0px 10px" >
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓璇环缂栫爜</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!contract.Management_Code__c}" /> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鐘舵��</label> </td>
+ <td width="50%" align="left"> <apex:outputField value="{!contract.Status__c}"/> </td>
+ </tr>
+ <tr>
+
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">绉戝</label> </td>
+ <td width="50%" align="left"> <apex:inputField value="{!estimate.Department__c}" id="depart"/> </td>
+ </tr>
+ <tr>
+
+
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓鏈堟暟</label> </td>
+ <td width="50%" align="left">
+ <div style="width:3px;height:20px;background-color:#cc0000; position:absolute;margin-right:5px" />
+ <apex:inputField value="{!estimate.Contract_Range__c}" required="false" id="monthRange"
+ onchange="checkContractRange(this.value, {!productCount})"
+ />
+ </td>
+ </tr>
+ <tr>
+
+ <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍒跺畾鏃�</label></td>
+ <td width="50%" align="left"> <apex:outputField label="鍒跺畾鏃�" value="{!estimate.CreatedDate}" id="createDateShow"/> </td>
+ </tr>
+ <tr>
+
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:30%"> 缁忛攢鍟嗗悕</label></td>
+ <!-- update wangweipeng 2021/12/04 start -->
+ <td width="50%" align="left"> <apex:inputField value="{!estimate.Dealer__c}" id="dealer" onchange="onChDealerUpdateJs(this);return false;" style="float: left;"/> </td>
+ </tr>
+ <tr>
+ <td width="50%" align="right">
+ <label class="labelCol vfLabelColTextWrap " style="margin-left:30%"> 鍏堟鏍囪瘑锛堢粡閿�鍟嗭級</label></td>
+ <td width="50%" align="left" > <apex:inputCheckbox value="{!estimate.Is_RecognitionModel__c}" id="FirstParagraphEnd" onClick="return false;" /> </td>
+ </tr>
+ <!-- update wangweipeng 2021/12/04 end -->
+ </table>
+ <script type="text/javascript">
+ j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).children('option[value=]').remove();
+ resetDealer();
+ </script>
+ </apex:outputPanel>
+ </apex:pageBlockSection>
+
+ <!-- update by rentx 2020-11-17 end -->
+
+ <apex:pageblocksection columns="1" title="鍚堝悓瀵硅薄璁惧" id="assetSection" >
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <input type="hidden" id="allPage:allForm:allBlock:assetSection:productCnt" value="{!productCount}" />
+ <!-- <table width="100%">
+ <tr>
+ <td> </td>
+ <td width="100px"><span>鍏�</span>
+ <select style="vertical-align:text-bottom" id="allCheckResult" size="1" onchange="changeAllCheckResult(this.value)">
+ <option value=" ">--鏃�--</option>
+ <option value="OK">OK</option>
+ <option value="NG">NG</option>
+ </select>
+ </td>
+ <td width="150px"> </td>
+ </tr>
+ </table> -->
+ <!-- <div id = 'aaaa' class="slds-scrollable_x" style="width:450px">
+ <div class="slds-table--header-fixed_container" style="height:450px;width:850px">
+ <div class="slds-scrollable_y" style="height:100%;width:850px"> -->
+ <div style="width: 100%">
+ <table class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
+ <tr class="headerRow" height="30px">
+ <th style="width:25px" class="headerRow booleanColumn"><input type='checkbox' onClick='checkAll(this)'/></th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Name.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.EGFlg_fromContract_asset__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.InstallDate.label}</th>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star-->
+ <th style="width:70px" class="headerRow booleanColumn">
+ {!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Check_Object__c.label}</th>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end-->
+ <th style="width:40px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.IsNew__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
+
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Management_Code__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}</th>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 start -->
+ <th style="width:35px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Upper_price__c.label}</th>
+ <th style="width:35px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Lower_price__c.label}</th>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 end -->
+ <!-- 闅愯棌鍚堝悓鏈堟暟
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract__c.fields.Contract_Range__c.label}</th>-->
+
+
+
+
+
+
+
+
+ <!-- <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price_All__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Maintenance_Price_YearTXT__c.label}</th>-->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price__c.label}</th>
+ <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->
+
+ <th style="width:70px" class="headerRow ">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price_Auto__c.label}</th>
+
+ <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Comment__c.label}</th>
+
+ <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� -->
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Third_Party_Return__c.label}</th>
+ </tr>
+
+ <apex:variable value="{!1}" var="cnt" />
+ <apex:repeat value="{!checkedAssets}" var="ar" id="assetTable">
+ <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
+ <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox" rendered="{!Not(ar.IsManual)}" disabled="{!PageDisabled}"/>
+ <apex:outputText value="{!ar.IsManual}" id="IsManual" style="display:none;" />
+ <!-- 鍒ゆ柇鏄惁鍙姤浠� -->
+ <!-- <input type="hidden" value="{!ar.estimateass}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:estimateass"/> -->
+ <!-- <apex:inputCheckbox value="{!ar.estimateass}" id="estimateass" style="display:none;" /> -->
+ </td>
+ <td class="dataCell">
+ <apex:outputField value="{!ar.rec.Name}" id="assetName" rendered="{!Not(ar.IsManual)}" />
+ <apex:inputField value="{!ar.mcae.Product_Manual__c}" id="Assert" style="width:90%;" rendered="{!ar.IsManual}" onchange="blockme();refreshProductData({!ar.lineNo});"/>
+ <apex:inputText id="ProductId" value="{!ar.mcae.Product_Manual__c}" style="display:none;" disabled="true"/>
+ </td>
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+
+ <apex:inputHidden value="{!ar.rec.URF_Maintenance_Contract__r.Management_Code__c}" rendered="{!Not(ar.IsManual)}" id="URF_Contract_No"/>
+
+ <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" id="Asset_situation"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputLink value="/{!ar.recId}" rendered="{!Not(ar.IsManual)}" >{!ar.rec.SerialNumber}</apex:outputLink>
+ <apex:inputHidden id="AssetId" value="{!ar.recId}"/>
+ <apex:inputField value="{!ar.rec.isNewDate_use__c}" id="isNewDate" style="display: none" showDatePicker="false"/>
+ </td>
+ <td class="dataCell" >
+ <apex:outputField value="{!ar.mcae.EquipmentGuaranteeFlgTxt__c}" id="EquipmentGuaranteeFlgtxt"/>
+ <apex:outputText value="{!ar.mcae.EquipmentGuaranteeFlgTxt__c}" id="EquipmentGuaranteeFlg" style="display:none;"/>
+ <apex:inputHidden id="EGFlgassHidden" value="{!ar.etGFlg}"/>
+ </td>
+ <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.InstallDate}" id="InstallDate" rendered="{!Not(ar.IsManual)}" />
+ </td>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star-->
+ <td class="dataCell" width="70px" style="text-align:center" >
+ <apex:inputCheckbox value="{!ar.mcae.Check_Object__c}" id="assetCheck" disabled="{!ar.CheckRows}"/>
+ </td>
+ <!--add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end-->
+ <td class="dataCell" width="40px" style="text-align:center" >
+ <apex:inputCheckbox value="{!ar.mcae.IsNew__c}" id="assetNew" disabled="true"/>
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.IsNew__c}" id="assetNewHidden" />
+ </apex:outputPanel>
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.IsNew__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetNewHidden" />
+ </apex:outputPanel>
+ <apex:outputText value="{!ar.rec.Final_Examination_Date__c}" id="finalExaminationDate" rendered="{!Not(ar.IsManual)}" style="display:none"/>
+ </td>
+ <td class="dataCell" width="70px" >
+ <apex:outputField value="{!ar.rec.Department_Name__c}" rendered="{!Not(ar.IsManual)}" />
+ </td>
+
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.CurrentContract_F__r.Maintenance_Contract_No_F__c}" rendered="{!Not(ar.IsManual)}" id="Contract_No"/>
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.RecordType_DeveloperName__c}" id="LastMContractRecord"/>
+ <apex:inputField value="{!ar.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c}" id="endDateGurantee_Text" style="display: none" showDatePicker="false"/>
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__c}" id="LastMContractID"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.mcae.Asset_Consumption_rate__c}" rendered="{!Not(ar.IsManual)}" id="Contractrate"/>
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Contract_Range__c}" id="lastContRange"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_End_Date__c}" rendered="{!(Not(ar.IsManual)&& ar.rec.CurrentContract_F__c != null)}" id="End_Date" />
+ </td>
+ <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 start -->
+ <td class="dataCell" width="35px">
+ <apex:outputText value="{!ar.mcae.Adjustment_Upper_price__c}" id="Adjustment_Upper_price"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_Upper_price__c}" id="Adjustment_Upper_priceHidden"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_ratio_Upper__c}" id="Adjustment_ratio_Upper"/>
+ </td>
+ <td class="dataCell" width="35px" >
+ <apex:outputText value="{!ar.mcae.Adjustment_Lower_price__c}" id="Adjustment_Lower_price"/>
+ <apex:inputHidden value="{!ar.mcae.LastMContract_Price__c}" id="LastMContract_Price"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_ratio_Lower__c}" id="Adjustment_ratio_Lower"/>
+ <apex:inputHidden value="{!ar.mcae.Adjustment_Lower_price__c}" id="Adjustment_Lower_priceHidden"/>
+ <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
+ <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
+ <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Estimate_Num__c}" id="Estimate_NumHidden" />
+
+ </apex:outputPanel>
+
+ <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
+ <input type="hidden" value="{!ar.mcae.Estimate_List_Price__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetListPriceHidden"/>
+ <input type="hidden" value="{!ar.rec.CurrentContract_F__r.Estimate_Num__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:Estimate_NumHidden"/>
+ </apex:outputPanel>
+ <!-- 20200103 Gzw 璁$畻瀹為檯鎶ヤ环閲戦 start -->
+ <apex:inputHidden value="{!ar.mcae.Estimate_Cost__c}" id="Estimate_Cost"/>
+ <!-- 20200103 Gzw 璁$畻瀹為檯鎶ヤ环閲戦 end -->
+
+ </td>
+ <td class="dataCell" width="35px" style="text-align:right" >
+ <apex:inputField value="{!ar.mcae.Repair_Price__c}" id="repairPrice" style="ime-mode: disabled; width:95%; text-align:right;" onchange="changeAsset({!productCount})"/>
+ </td>
+ <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->
+ <td class="dataCell" width="35px" style="text-align:right" >
+ <apex:outputText value="{!ar.Repair_Price_Auto}" id="Repair_Price_Auto" style="width:95%; disabled:disabled;"/>
+ <!-- <apex:inputHiddenalue="{!ar.rec.Reson_Can_not_Warranty__c}" id="ResonCannotWarranty"/> -->
+ <!-- <apex:outputText value="{!ar.Agreed_Date}" id="Agreed_Date" style="width:95%;display: none;"/> -->
+ <apex:inputField value="{!ar.mcae.Repair_Price_pass__c}" id="Repair_Price_pass" style="width:95%;display: none;"/>
+ <apex:inputHidden value="{!ar.mcae.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval1"/>
+ <apex:outputText value="{!ar.rec.Reson_Can_not_Warranty__c}" id="ResonCannotWarranty" style="display:none;" rendered="{!Not(ar.IsManual)}" />
+ </td>
+
+ <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
+ <td class="dataCell" width="70px" style="text-align:right" >
+ <apex:inputField value="{!ar.mcae.Comment__c}" id="comment" style="width:95%;"/>
+ </td>
+ <!--(2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� -->
+ <td class="dataCell" width="40px" style="text-align:center;" >
+ <apex:inputCheckbox value="{!ar.mcae.Third_Party_Return__c}" id="Third_Party_Return__c"/>
+ </td>
+ </tr>
+
+ <!-- LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋 lt 20211221 start -->
+ <!-- <script>
+ DefaultStartDate();
+ </script> -->
+ <!-- LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋 lt 20211221 end -->
+
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+
+ </table>
+ </div>
+<!-- </div>
+ </div> -->
+ </apex:outputPanel>
+ </apex:pageblocksection>
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:outputPanel id="sumPanel" onkeydown="if(event.keyCode==13){searchJs(); return false;}">
+ <!-- HWAG-B4R3SS END 20181026-->
+ <table style="width:100%;">
+ <tr>
+
+ <td>
+ <apex:commandButton value="琛岃拷鍔�" action="{!addNewRows}" disabled="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable) || PageDisabled}"
+ style="margin-left:10px;float:left;" onclick="blockme();" oncomplete="unblockUI();" rerender="allForm" />
+ <apex:commandButton value="鍒锋柊閫変腑鐨勪繚鏈夎澶�" disabled="{!SaveBtnDisabled || productCount2==0}" action="{!exchangeAsset}" onclick="blockme();" oncomplete="unblockUI();refreshAsset({!productCount});" rerender="allForm" />
+
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:outputText value="閫夋嫨鏉′欢"/>
+
+ <apex:selectList value="{!text1}" id="text1" size="1" style="width:80px"><apex:selectOptions value="{!textOpts}"/>
+ </apex:selectList>
+
+ <apex:selectList value="{!cond1}" id="cond1" size="1" style="width:80px">
+ <apex:selectOptions value="{!equalOpts}"/>
+ </apex:selectList>
+
+ <!-- LJPH-BSS6E2 ---20200911 ---update by rentongxiao start -->
+
+ <apex:inputText value="{!val1}"
+ id="val1" style="width:100px; background-color:{!IF(contr == '1','#e3f3ff','white')}"/>
+ <!-- LJPH-BSS6E2 ---20200911 ---update by rentongxiao end -->
+
+ <apex:commandButton value="妫�绱�" onclick="searchJs();" style="width:100px" rerender="dummy"/>
+
+ <apex:commandButton value="娓呴櫎鏉′欢" onclick="clearAndSearch();" style="width:100px" rerender="dummy"/>
+ <!-- HWAG-B4R3SS END 20181026-->
+ </td>
+ <th width="90px" style="text-align:right"></th>
+ <th width="90px" style="text-align:right"></th>
+
+ <th width="90px" style="text-align:right">璁惧鏁伴噺</th>
+ <td width="90px" style="text-align:right"><apex:outputtext value="{!productCount3}" id="productCount3"/></td>
+ <td width="25px"> </td>
+ <th width="90px" style="text-align:right">
+ <apex:inputField value="{!estimate.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval" style="display:none"/></th>
+ <!-- <apex:inputField value="{!estimate.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval"/></th> -->
+ <td width="25px"> </td>
+ <!--<th width="90px" style="text-align:right">鎶ヤ环鎬婚</th>
+ <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetListSumNum" ></span></th>-->
+ <th width="90px" style="text-align:right">淇悊鎬婚</th>
+ <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetRepairSumNum" ></span></th>
+ <td width="95px"> </td>
+ </tr>
+
+ </table>
+ </apex:outputPanel>
+
+ <apex:pageblocksection columns="1" title="鏈�夋嫨鐨勪繚鏈夎澶�" id="assetSection2" >
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <input type="hidden" id="allPage:allForm:allBlock:assetSection2:productCnt2" value="{!productCount2}" />
+ <table class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
+ <tr class="headerRow" height="30px">
+ <th style="width:25px" class="headerRow booleanColumn"><input type='checkbox' onClick='checkAll2(this)'/></th>
+ <th style="width:25%" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Name.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
+ <th style="width:70px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
+ <!-- <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Installation_Site__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty_Service__c.label}</th>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
+ <th style="width:90px" class="headerRow booleanColumn">涓绘満/鑰楁潗</th>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
+
+ <th class="headerRow booleanColumn">{!$ObjectType.Asset.fields.EGFlg_fromContract_asset__c.label}</th>
+ <th style="width:150px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Reson_Can_not_Warranty__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.InstallDate.label}</th>
+ <!-- <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th> -->
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
+ <th style="width:90px" class="headerRow booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price__c.label}</th>
+ </tr>
+
+ <apex:variable value="{!1}" var="cnt" />
+ <apex:repeat value="{!unCheckedAssetsView}" var="assetsView" id="outassetTable2">
+ <apex:repeat value="{!assetsView}" var="ar" id="assetTable2">
+ <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
+ <td class="dataCell" width="25px">
+ <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty_Service__c = '鍚�', 'true', 'false')}"/>
+ </td>
+ <td class="dataCell" width="25%">
+ <apex:outputField value="{!ar.rec.name}" id="assetName"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Asset_situation__c}"/>
+ </td>
+ <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.SerialNumber}"/>
+ </td>
+ <td class="dataCell">
+ <apex:outputField value="{!ar.rec.Department_Name__c}"/>
+ </td>
+ <!-- <td class="dataCell" width="70px">
+ <apex:outputField value="{!ar.rec.Installation_Site__c}"/>
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.IF_Warranty_Service__c}"/>
+ </td>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
+ <td class="dataCell" width="90px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.AssetMark__c}"/>
+ </td>
+ <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
+ <td class="dataCell" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.EquipmentGuaranteeFlg__c}"/>
+ </td>
+ <td class="dataCell" width="150px" style="text-align:center">
+ <apex:outputField value="{!ar.rec.Reson_Can_not_Warranty__c}"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:center" >
+ <apex:outputField value="{!ar.rec.InstallDate}"/>
+ </td>
+ <!-- <td class="dataCell" width="90px">
+ <apex:outputField value="{!ar.rec.Asset_Owner__c}"/>
+ </td> -->
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Accumulation_Repair_Amount__c}"/>
+ </td>
+ <td class="dataCell" width="90px" style="text-align:right" >
+ <apex:outputField value="{!ar.rec.Maintenance_Price_Month__c}" />
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ </apex:repeat>
+ </table>
+ <apex:outputPanel >
+ <dir align="right">
+ <table>
+ <tr>
+ <td>{!(currPage-1)*selctRecordNum} - {!IF(currPage*selctRecordNum > totalRecords, totalRecords, currPage*selctRecordNum)}</td>
+ <td> 鍏眥!totalRecords}涓�</td>
+ <td align="right" width="115px">鏄剧ず
+ <apex:selectList value="{!selRecordOption}" id="selRecordOption" size="1" onchange="blockme();recordNumChangeJs();" disabled="{!IF(totalRecords<10,true,false)}"><apex:selectOptions value="{!recordNum}"/></apex:selectList>鏉¤褰�
+ </td>
+ <td align="right" width="50px">绗瑊!currPage}椤�</td>
+ <td align="right" width="45px">
+ <apex:commandLink action="{!firstPage}" value="棣栭〉" id="firstPg" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(currPage==1,'display: none;','')}color: blue;"/>
+ <apex:outputText value="棣栭〉" style="{!IF(currPage!=1,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td align="right" width="40px">
+ <apex:commandLink action="{!previousPage}" value="涓婁竴椤�" id="previous" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(currPage==1,'display: none;','')}color: blue;"/>
+ <apex:outputText value="涓婁竴椤�" style="{!IF(currPage!=1,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td width="3px"></td>
+ <td align="left" width="40px">
+ <!-- HWAG-B4R3SS START 20181026-->
+ <apex:commandLink action="{!nextPage}" value="涓嬩竴椤�" id="next" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(totalPage==currPage ||totalPage == 0,'display: none;','')}color: blue;"/>
+ <apex:outputText value="涓嬩竴椤�" style="{!IF(totalPage!=currPage && totalPage != 0,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <td align="left" width="45px">
+ <apex:commandLink action="{!endPage}" value="灏鹃〉" id="endPg" onclick="blockme();" oncomplete="unblockUI();" reRender="allForm" style="{!IF(totalPage==currPage||totalPage == 0,'display: none;','')}color: blue;"/>
+ <apex:outputText value="灏鹃〉" style="{!IF(totalPage!=currPage
+ && totalPage != 0,'display: none;','')}color: gray;"></apex:outputText>
+ </td>
+ <!-- HWAG-B4R3SS END 20181026-->
+ <td align="left">鍏眥!totalPage}椤�</td>
+ </tr>
+ </table>
+ </dir>
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+ <apex:pageblocksection title="鍚堝悓淇℃伅" columns="1" id="contractInfo">
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <table style="width:100%">
+ <tr>
+ <td width="22%"></td>
+ <!-- <td width="14%"></td> -->
+ <td width="22%"></td>
+ <td width="28%"></td>
+ <td width="14%"></td>
+ <td width="14%"></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.GuidePrice_Down__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.GuidePrice_Up__c.label}</th>
+ <th style="text-align: center">鐢宠鎶ヤ环閲戦</th>
+ <th style="text-align: center">鍚堝悓璁惧淇悊鎬婚</th>
+ <th style="text-align: center">鍚堝悓鎬婚噾棰�</th>
+ <!-- 涓婇檺鍚堝悓 20230103 LY start -->
+ <!-- <th style="text-align: center">涓婇檺閲戦</th> -->
+ <!-- 涓婇檺鍚堝悓 20230103 LY end -->
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.GuidePrice_Down__c}" id="GuidePriceDown" />
+ <apex:inputHidden value="{!estimate.GuidePrice_Down__c}" id="GuidePriceDownHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUp" />
+ <apex:inputHidden value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUpHidden" />
+ </td>
+
+ <td style="text-align: center">
+ <!--<apex:inputField value="{!estimate.Request_quotation_Amount__c}" id="quotation_Amount" />-->
+ <apex:inputField value="{!estimate.Request_quotation_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="quotation_Amount" onchange="checkDiscount(this.value);"/>
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPrice" />
+ <apex:inputHidden value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPriceHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal" />
+ <apex:inputHidden value="{!estimate.Maintenance_Price__c}" id="mainteRealHidden"/>
+ <apex:inputHidden value="{!OldMaintenancePrice}" id="oldMainteReal"/>
+ </td>
+ <!-- 涓婇檺鍚堝悓 20230103 LY start -->
+ <!-- <td style="text-align: center">
+ <apex:inputField value="{!estimate.Limit_Price_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="Limit_Price_Amount" />
+ </td> -->
+ <!-- 涓婇檺鍚堝悓 20230103 LY end -->
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Service_discount_Rate__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.New_Contract_Type_TxT__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Combined_rate__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Consumption_rate_Forecast__c.label}</th>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Estimate_Price_range__c.label}</th>
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Service_discount_Rate__c}" id="discount_Rate"/>
+ <apex:inputHidden value="{!estimate.Service_discount_Rate__c}" id="discount_RateHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputText value="{!estimate.New_Contract_Type_TxT__c}" id="Contract_TypeTXT" />
+ <apex:inputHidden value="{!typeresult}" id="Contract_TypeTXTHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Combined_rate__c}" id="Combinedrate" />
+ <apex:inputHidden value="{!estimate.Combined_rate__c}" id="CombinedrateHidden" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Consumption_rate_Forecast__c}" />
+ </td>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.Estimate_Price_range__c}" />
+ </td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.ContractPriceType__c.label}</th>
+ <th style="text-align: center"></th>
+ <th style="text-align: center"></th>
+ <th style="text-align: center"></th>
+ <th style="text-align: center"></th>
+ </tr>
+ <tr>
+ <td style="text-align: center">
+ <apex:outputField value="{!estimate.ContractPriceType__c}"/>
+ </td>
+ <td style="text-align: center"></td>
+ <td style="text-align: center"></td>
+ <td style="text-align: center"></td>
+ <td style="text-align: center"></td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+
+ <apex:pageblocksection title="鐢宠鑳屾櫙" columns="1" id="Appbackground">
+ <apex:outputLabel />
+ <apex:outputPanel >
+ <table style="width:100%">
+ <tr>
+ <td width="10%"></td>
+ <td width="30%"></td>
+ <td width="10%"></td>
+ <td width="50%"></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.finalPriceDecideWay__c.label}</th>
+ <td><apex:inputField value="{!estimate.finalPriceDecideWay__c}" id="finalPriceDecideWay" style="width:50%;" /></td>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Sales_incidental__c.label}</th>
+ <td><apex:inputField value="{!estimate.Sales_incidental__c}" id="Sales_incidental" style="width:50%;" /></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.mainTalksTime__c.label}</th>
+ <td ><apex:inputField value="{!estimate.mainTalksTime__c}" style="width:50%;" id="mainTalksTime"/></td>
+ <th>{!$ObjectType.Maintenance_Contract_Estimate__c.fields.talksStartDate__c.label}</th>
+ <td><apex:inputField value="{!estimate.talksStartDate__c}" id="talksStartDate" style="width:50%;" /></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.AgencyHos_Price__c.label}</th>
+ <td ><apex:inputField value="{!estimate.AgencyHos_Price__c}" style="width:50%;" id="AgencyHos_Price"/></td>
+ <th style="text-align: center"></th>
+ <td ></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Discount_reason__c.label}</th>
+ <td colspan="3"><apex:inputField value="{!estimate.Discount_reason__c}" id="discountReason" style="width:95%;height:50px;" /></td>
+ </tr>
+ <tr>
+ <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Improve_ConsumptionRate_Idea__c.label}</th>
+ <td colspan="3"><apex:inputField value="{!estimate.Improve_ConsumptionRate_Idea__c}" id="improveConsumptionRateIdea" style="width:95%;height:50px;" /></td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ <script type="text/javascript">
+ //var applyType = j$(escapeVfId('allPage:allForm:allBlock:Appbackground:applyType')).val();
+ //var obj = document.getElementById('allPage:allForm:allBlock:Appbackground:TypeOther');
+ //if (applyType == '鍏朵粬') {
+ // obj.style.display = "block";
+ //} else {
+ // obj.style.display = "none";
+ //}
+ //resetapplyType();
+ </script>
+ </apex:pageblocksection>
+
+ <script type="text/javascript">
+ var isDisabled = {!PageDisabled};
+ if(!isDisabled){
+ refreshAsset({!productCount});
+ }
+ </script>
+ </apex:pageBlock>
+
+
+
+ <table width="100%" border="0">
+ <tr>
+ <!-- <td width="40%" style="text-align: right;"> -->
+ <td width="50%">
+ <table border="0" style="background-color:#ffd6c1;" width="100%">
+ <tr>
+ <th width="50px">鎵撳嵃鎶ヤ环</th>
+ <td width="90px"><apex:inputCheckbox id="check0" onchange="hideSimplify(0);" value="{!estimate.Print_ListPrice__c}" />瀹屾暣鐗�+鎶樻墸鍓�</td>
+ <td width="90px"><apex:inputCheckbox id="check1" onchange="hideSimplify(1);" value="{!estimate.Print_Simplify__c}" />瀹屾暣鐗�+鎶樻墸鍚�</td>
+
+ <td width="80px"><apex:inputCheckbox id="check2" onchange="hideSimplify(2);" value="{!estimate.Print_RepairPrice__c}"/>绠�鍖栫増+鎶樻墸鍓�</td>
+ <td width="80px"><apex:inputCheckbox id="check3" onchange="hideSimplify(3);" value="{!estimate.Print_SumPrice__c}"/>绠�鍖栫増+鎶樻墸鍚�</td>
+ </tr>
+ <tr>
+ <th width="70px">鎵撳嵃鍚堝悓閰嶇疆</th>
+ <td width="60px">
+
+ <!-- 2018/10/26HWAG-B5C88S 鍖婚櫌鍜岀粡閿�鍟嗗悎鍚屼换浣曟椂鍊欓兘涓嶈兘閫夋嫨 start -->
+
+ <apex:outputPanel rendered="false">
+ <apex:inputCheckbox value="{!estimate.Print_Contract__c}" />
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 鍖婚櫌鍚堝悓
+ </td>
+ <!-- 2018/09/26 HWAG-B4SCR3 涓夋柟鍜屼唬鐞嗗晢鍚堝悓鍦ㄦ湭decide鍓嶄篃涓嶈兘閫夋嫨 start -->
+ <td width="60px">
+ <apex:outputPanel rendered="{!EnablePrintContract}">
+ <apex:inputCheckbox id="tripartite" value="{!estimate.Print_Tripartite__c}"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 涓夋柟鍗忚</td>
+ <td width="85px">
+ <apex:outputPanel rendered="false">
+ <apex:inputCheckbox id="agent" value="{!estimate.Print_Agent__c}"/>
+ </apex:outputPanel>
+ <apex:outputPanel rendered="{!Not(EnablePrintContract)}">
+
+ </apex:outputPanel>
+ 浠g悊鍟嗗悎鍚�</td>
+ <!-- 2018/09/26 HWAG-B4SCR3 涓夋柟鍜屼唬鐞嗗晢鍚堝悓鍦ㄦ湭decide鍓嶄篃涓嶈兘閫夋嫨 end -->
+ <!-- 2018/10/26 HWAG-B5C88S 鍖婚櫌鍜岀粡閿�鍟嗗悎鍚屼换浣曟椂鍊欓兘涓嶈兘閫夋嫨 end -->
+
+ <td colspan="3" style="text-align: right"><apex:commandButton action="{!print}" value="PDF鍗板埛" rerender="allBlock,pdfPrint" onclick="if (!onclickCheckchangedAfterPrint('Pt{!SaveBtnDisabled}','false')) return false;" oncomplete="unblockUI();ComputeLTYRepair()"/></td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table class="btntable" border="0">
+ <tr>
+ <td> </td>
+ <td> </td>
+ <td width="20px"> </td>
+ <td> </td>
+ <td> </td>
+ <td width="30px"> </td>
+ <!-- <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();"/></td> -->
+ <!-- 鏁呴殰淇悊璐� 娣诲姞鎻愪氦淇悊鍑忎环鎸夐挳 disabled="true" -->
+ <td><apex:commandButton id="emailSend" action="{!sendEmail}" value="鎻愪氦RC璇勪及" rerender="allForm" disabled="{!SendEmailBtnDisabled}" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/></td>
+ <td>
+ <apex:commandButton id="approvalbtn1" action="{!toApprovalProcess}" value="鎻愪氦淇悊鍑忎环瀹℃壒" disabled="{!ApprovalBtnNewDisabled}" />
+ </td>
+ <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();toApprovalProcess();"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
+ <apex:outputText style="color:red;font-size:20px;" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
+ <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
+ </td>
+ </tr>
+ <tr>
+ <th>{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Contract_Start_Date__c.label}</th>
+ <td><apex:inputField value="{!estimate.Contract_Start_Date__c}" id="contractstartdate" onchange="changeContractStartdate(this.value);"/></td>
+ <td> </td>
+ <th> {!$ObjectType.Maintenance_Contract_Estimate__c.fields.Contract_End_Date__c.label}</th>
+ <td><apex:outputField value="{!estimate.Contract_End_Date__c}" id="contractenddate"/></td>
+ <td> </td>
+ <td><apex:commandButton id="decidebtn" value="{!$Label.QuoteDecision_Button}" disabled="{!DecideBtnDisabled}" onclick="decideJs(); return false;"/></td>
+ <td> <apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/>
+ </td>
+ <!-- <td><apex:commandButton id="decidebtn1" value="{!$Label.QuoteDecision_Button}" action="{!dosomething}"/></td> -->
+ <td style="text-align:right"><apex:commandButton id="undecidebtn" action="{!undecide}" value="鍙栨秷{!$Label.QuoteDecision_Button}" disabled="{!UnDecideBtnDisabled}" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</apex:form>
+<apex:outputPanel id="pdfPrint">
+<script type="text/javascript">
+//j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+function saveBeforeCheckPriceChange() {
+ sforce.connection.sessionId = Session_ID;
+ var needClearId = false;
+ var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+ var assIds = "";
+ var proIds = "";
+ var priceMap = new Map();
+ var newProductMap = new Map();
+ var newProductCheck = false;
+ var nowDate = new Date();
+ var createdDate = null;
+ var createdDateShow = j$(escapeVfId('allPage:allForm:allBlock:contract:createDateShow')).text();
+ var contractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ if (createdDateShow.trim() != '') {
+ createdDate = new Date(createdDateShow);
+ newProductCheck = true;
+ } else {
+ createdDate = new Date();
+ }
+ var threeMonthAfter = new Date(createdDate.setMonth(createdDate.getMonth() + 3));
+ createdDate = new Date(createdDate.setMonth(createdDate.getMonth() - 3));
+ for (var i = 0; i < rowCnt; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+ var price = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (a.size() > 0 && a.value() != "000000000000000000" && a.value() != "") {
+ if (proIds == "") {
+ proIds = "'" + a.value() + "'";
+ } else {
+ proIds = proIds + ",'" + a.value() + "'";
+ }
+ if (isnew == "true") {
+ priceMap.set(a.value(), price/{!isNewPriceAdj});
+ } else {
+ priceMap.set(a.value(), price);
+ }
+ newProductMap.set(a.value(), isnew);
+
+ } else {
+ continue;
+ }
+ }
+ else {
+ var aId = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetId')).value();
+ if (assIds == "") {
+ assIds = "'" + aId + "'";
+ } else {
+ assIds = assIds + ",'" + aId + "'";
+ }
+ if (isnew == "true") {
+ priceMap.set(aId, price/{!isNewPriceAdj});
+ } else {
+ priceMap.set(aId, price);
+ }
+ newProductMap.set(aId, isnew);
+ }
+ }
+ // 閫夋嫨璁惧鍚庝环鏍煎彉鏇碿heck
+ if (assIds.length > 0) {
+ var sql = "SELECT Id, Maintenance_Price_Month__c, Posting_Date__c, InstallDate from Asset where Id In(" + assIds + ")";
+ var rt = sforce.connection.query(sql);
+ var asList = rt.getArray("records");
+ if (asList != null) {
+ for(var i=0;i<asList.length;i++) {
+ var asvar = asList[i];
+ var asId = asvar["Id"];
+ var mprice = asvar["Maintenance_Price_Month__c"];
+ var ptDt = asvar["Posting_Date__c"];
+ var postingDate = null;
+ if (ptDt != null && ptDt != '') {
+ postingDate = new Date(ptDt);
+ }
+ var inDt = asvar["InstallDate"];
+ var installDate = null;
+ if (inDt != null && inDt != '') {
+ installDate = new Date(inDt);
+ }
+ var priceShow = priceMap.get(asId);
+ var isNew = newProductMap.get(asId);
+ if ('{!DecideBtnDisabled}' == 'true') {
+ if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
+ needClearId = true;
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ }
+ }
+ }
+ if (proIds.length > 0) {
+ if ('{!DecideBtnDisabled}' == 'false') {
+ var oldDateStr = j$('#oldContractDate').value();
+ var oldDate = new Date();
+ if (oldDateStr != null && oldDateStr != '') {
+ oldDate = new Date(oldDateStr);
+ }
+ var crdt = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:createDateShow')).text());
+ var newContractDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+ var sixMonthAfter = new Date(crdt.setMonth(crdt.getMonth() + 6));
+ if ((newContractDate > sixMonthAfter && oldDate <= sixMonthAfter) || (newContractDate <= sixMonthAfter && oldDate > sixMonthAfter)) {
+ j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return true;
+ }
+ } else {
+ var sql = "SELECT Id, Maintenance_Price_Month__c from Product2 where Id In(" + proIds + ")";
+ var rt = sforce.connection.query(sql);
+ var pdList = rt.getArray("records");
+ if (pdList != null) {
+ for(var i=0;i<pdList.length;i++) {
+ var pdvar = pdList[i];
+ var pdId = pdvar["Id"];
+ var mprice = pdvar["Maintenance_Price_Month__c"];
+ var priceShow = priceMap.get(pdId);
+ if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
+ needClearId = true;
+ // j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ }
+ }
+ }
+ }
+ // var changedPrice = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ // if (changedPrice=='true') {
+ // needClearId = true;
+ // }
+ return needClearId;
+}
+
+// SelectAssetEstimateController#checkchangedAfterPrint 銇ㄥ悓銇樸儹銈搞儍銈伀銇欍倠蹇呰銇屻亗銈娿伨銇欍��
+// true 澶夋洿銇傘倞銆乫alse 澶夋洿銇仐
+function checkchangedAfterPrint() {
+ sforce.connection.sessionId = Session_ID;
+ var needClearId = false;
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
+ var changedPrice = j$(escapeVfId('allPage:allForm:changedSubmitPrice')).value();
+ // 鏂拌銇牬鍚堛�乼argetEstimateId銇屻仾銇勩�佸垽鏂亜銈夈仾銇�
+ if ('{!targetEstimateId}' == '') return needClearId;
+ if ('{!estimate.Quote_Date__c}' != '' || '{!estimate.Process_Status__c}' != '鑽夋涓�') {
+ // xud 20140529 銇撱亾銇槑绱板鏇村垽鏂�
+ // xudan 20150729 銈姐兗銉堥爡鐩伀Id銈掕拷鍔�
+ var sql = "SELECT Id, Asset__c, Asset__r.SerialNumber, Check_Result__c, Product_Manual__c,"
+ + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c,Third_Party_Return__c"
+ + " FROM Maintenance_Contract_Asset_Estimate__c"
+ + " WHERE Maintenance_Contract_Estimate__c = '{!targetEstimateId}'"
+ + " ORDER BY id,Asset__c,Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate";
+ var result = sforce.connection.query(sql);
+ var mcaeList = result.getArray("records");
+ var inputingList = [];
+ var finalPrice = 0;
+ // 鐢婚潰鍏ュ姏鍊ゃ倰鏁寸悊锛堛亜銈夈仾銇勩倐銇倰瀵捐薄澶栥伀銇欍倠锛�
+ var cntWithKara = {!productCount};
+ for (var i = 0; i < cntWithKara; i++) {
+ var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+ if (isManual == 'true') {
+ var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ProductId'));
+ if (a.size() > 0 && a.value() != "000000000000000000" && a.value() != "") {
+ inputingList.push(
+ {'id' : '',
+ 'Product_Manual__c' : a.value(),
+ 'Check_Result__c' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult')).value(),
+ 'Repair_Price__c' : localParseFloat(j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value())),
+ 'Comment__c': j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).value()
+ }
+ );
+ } else {
+ continue;
+ }
+ }
+ else {
+ inputingList.push(
+ {'id' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetId')).value(),
+ 'Check_Result__c' : j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':checkResult')).value(),
+ 'Repair_Price__c' : localParseFloat(j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value())),
+ 'Comment__c': j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).value()
+ }
+ );
+ }
+ }
+ //閽堝inputingList鐨勯噸鏂版帓搴�
+ var arrayMap = [];
+ var ArrayOrderPMCnt = [];
+ for(var i=0;i<mcaeList.length;i++){
+ var mcaeVar = mcaeList[i];
+ var AssetIDOrPMC = mcaeVar["Asset__c"]!=null?mcaeVar["Asset__c"]:mcaeVar["Product_Manual__c"];
+ if(arrayMap[AssetIDOrPMC]!=null){
+ arrayMap[AssetIDOrPMC] = i;
+ ArrayOrderPMCnt[AssetIDOrPMC] = i;
+ }else{
+ // Product_Manual__c鐩稿悓鐨勮瘽鎬庝箞鍔�
+ if(ArrayOrderPMCnt[AssetIDOrPMC]==null){
+ ArrayOrderPMCnt[AssetIDOrPMC] = i;
+ }else{
+ var cacheArray = new Array();
+ cacheArray = ArrayOrderPMCnt[AssetIDOrPMC];
+ ArrayOrderPMCnt[AssetIDOrPMC] = cacheArray+','+i;
+ }
+
+ }
+
+ }
+ var inputingListCache = inputingList;
+ var cntLength = mcaeList.length>inputingListCache.length?mcaeList.length:inputingListCache.length;
+ if(mcaeList.length!=inputingListCache.length){
+ needClearId = true;
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ return needClearId;
+ }
+ inputingList = new Array(cntLength);
+ var inputingListOut = new Array();
+ for(var i=0;i<inputingListCache.length;i++){
+ var InputIdOrPMc = inputingListCache[i].id!=""?inputingListCache[i].id:inputingListCache[i].Product_Manual__c;
+ var thisArray = ArrayOrderPMCnt[InputIdOrPMc];
+ if(thisArray.length!=null){
+ thisArray = thisArray.split(',');
+ var ORDERCnt = thisArray[0];
+ thisArray.shift();
+ thisArray = thisArray.join(',');
+ ArrayOrderPMCnt[InputIdOrPMc] = thisArray;
+ }else{
+ var ORDERCnt = thisArray;
+ }
+ if( ORDERCnt !=null){
+ inputingList[ORDERCnt] = inputingListCache[i];
+ }else{
+ inputingList[ORDERCnt] = inputingListCache[i];
+ inputingListOut.push(inputingListCache[i]);
+ }
+ }
+ if( inputingListOut.length>0){
+ for(var i = 0; i<inputingListOut.length;i++){
+ inputingList.push(inputingListOut[i]);
+ }
+ }
+ //20161122,娴嬭瘯鍙戠幇Check_Result__c宸插仠鐢紝鏁呰�屼慨鏀瑰搴旂殑Js鍒ゆ柇閮ㄥ垎
+ /*
+ && (((mcae["Check_Result__c"] == null || mcae["Check_Result__c"] == "")
+ && (inputing["Check_Result__c"] == null || inputing["Check_Result__c"] == "")
+ )
+ || mcae["Check_Result__c"] == inputing["Check_Result__c"]
+ )
+ //==================================================================================
+ && (((mcae["Check_Result__c"] == null || mcae["Check_Result__c"] == "")
+ && (inputing["Check_Result__c"] == null || inputing["Check_Result__c"] == "")
+ )
+ || mcae["Check_Result__c"] == inputing["Check_Result__c"]
+ )
+ */
+ //鍘熸槸浠g爜淇濈暀
+ if (inputingList.length == mcaeList.length && needClearId == false ) {
+ for (var i = 0; i < mcaeList.length; i++) {
+ var mcae = mcaeList[i];
+ finalPrice = mcae["Maintenance_Contract_Estimate__r"]["Maintenance_Price__c"];
+ var inputing = inputingList[i];
+ if (mcae["Asset__c"] != null && mcae["Asset__c"] != "") {
+ if (inputing["id"] != "" && mcae["Asset__c"] == inputing["id"]
+ && localParseFloat(mcae["Repair_Price__c"]) == inputing["Repair_Price__c"]
+
+ && (((mcae["Comment__c"] == null || mcae["Comment__c"] == "")
+ && (inputing["Comment__c"] == null || inputing["Comment__c"] == "")
+ )
+ || mcae["Comment__c"] == inputing["Comment__c"]
+ )
+ ) {
+ // 鍚屻仒
+ } else {
+ needClearId = true;
+ break;
+ }
+ } else {
+ if (inputing["id"] == "" && mcae["Product_Manual__c"] != null && mcae["Product_Manual__c"] != ""
+ && mcae["Product_Manual__c"] == inputing["Product_Manual__c"]
+
+ && localParseFloat(mcae["Repair_Price__c"]) == inputing["Repair_Price__c"]
+ && (((mcae["Comment__c"] == null || mcae["Comment__c"] == "")
+ && (inputing["Comment__c"] == null || inputing["Comment__c"] == "")
+ )
+ || mcae["Comment__c"] == inputing["Comment__c"]
+ )
+ ) {
+ // 鍚屻仒
+ } else {
+ needClearId = true;
+ break;
+ }
+ }
+ }
+ } else {
+ needClearId = true;
+ }
+
+ // xud 20140529 銇撱亾銇窂閲戦澶夋洿鍒ゆ柇锛堝壊寮曘倰澶夋洿銇椼仧銈夈伨銇氥亜锛�
+ var inputFinalPrice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteRealHidden')).value();
+ if (toNum(inputFinalPrice) != toNum(finalPrice)) {
+ needClearId = true;
+ }
+ if (changedPrice=='true') {
+ needClearId = true;
+ }
+ }
+ if (needClearId) {
+ //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
+ }
+ return needClearId;
+}
+
+if ('{!printAsset}' == 'true') {
+ //鎵撳嵃淇濇湁瑷倷
+ // //蹇呴』閫夋嫨鎵撳嵃鎶ヤ环(璇︾粏杩樻槸绠�鍖�)
+ var con = 0;
+ for (j = 0; j < 4; j++) {
+ if (j$(escapeVfId('allPage:allForm:check' + j)).attr('checked')) {
+ con ++;
+ }
+ }
+ if(con != 1){
+ alert('璇锋偍鍕鹃�夋墦鍗版姤浠风増鏈紝鍙兘鍕鹃�変竴涓��');
+ }else{
+ window.open('/apex/MaintenanceContractEstimateVMPDF?id={!targetEstimateId}', 'MaintenanceContractEstimateVMPDF');
+ }
+
+} else if ('{!printContract}' == 'true') {
+ // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printContract', 'MceConfigPDF');
+} else if ('{!printTripartite}' == 'true') {
+ //鎵撳嵃涓夋柟鍚堝悓
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printTripartite', 'MceConfigPDF');
+} else if ('{!printAgent}' == 'true') {
+ //鎵撳嵃缁忛攢鍟嗗悎鍚�
+ window.open('/apex/MceConfigPDF?id={!targetEstimateId}&flag=printAgent', 'MceConfigPDF');
+}else {}
+//褰撻�夋嫨鎶ヤ环鍗曪紙璇︾粏鐗堬級鐨勬椂鍊欓殣钘忔姤浠峰崟锛堢畝鍖栫増锛�
+// 4涓�夐」鍙彲浠ラ�変竴涓�
+function hideSimplify(cb){
+ for (j = 0; j < 4; j++) {
+ if (j$(escapeVfId('allPage:allForm:check' + j)).attr('checked')) {
+ j$(escapeVfId('allPage:allForm:check' + j)).attr('checked',false);
+ if (j == cb) {
+ j$(escapeVfId('allPage:allForm:check' + j)).attr('checked',true);
+ }
+ }
+ }
+
+}
+var isDisabled = {!PageDisabled};
+if(!isDisabled){
+ refreshAsset({!productCount});
+}
+</script>
+</apex:outputPanel>
+</apex:page>
\ No newline at end of file
diff --git a/force-app/main/default/pages/SelectAssetEstimateVM.page-meta.xml b/force-app/main/default/pages/SelectAssetEstimateVM.page-meta.xml
new file mode 100644
index 0000000..e6b0b15
--- /dev/null
+++ b/force-app/main/default/pages/SelectAssetEstimateVM.page-meta.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>41.0</apiVersion>
+ <availableInTouch>false</availableInTouch>
+ <confirmationTokenRequired>false</confirmationTokenRequired>
+ <label>SelectAssetEstimateVM</label>
+</ApexPage>
--
Gitblit v1.9.1