From aa7cab63bcc29d8a1cb4667bc982814fc28970e5 Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期一, 07 八月 2023 16:17:20 +0800
Subject: [PATCH] hql20230807lightning提交更新

---
 force-app/main/default/pages/QLMAttachmentPreview.page                   |    3 
 force-app/main/default/lwc/lexChoiceAsset/lexChoiceAsset.js              |    2 
 force-app/main/default/classes/LexChoiceAssetController.cls              |  201 ++++++++++++++++++++++++++++
 force-app/main/default/classes/LexChoiceAssetControllerTest.cls          |  124 +++++++++++++++++
 force-app/main/default/classes/NewPaymentPlanLoadController.cls          |   38 +++++
 force-app/main/default/classes/LexChoiceAssetControllerTest.cls-meta.xml |    5 
 6 files changed, 369 insertions(+), 4 deletions(-)

diff --git a/force-app/main/default/classes/LexChoiceAssetController.cls b/force-app/main/default/classes/LexChoiceAssetController.cls
new file mode 100644
index 0000000..72c21da
--- /dev/null
+++ b/force-app/main/default/classes/LexChoiceAssetController.cls
@@ -0,0 +1,201 @@
+public with sharing class LexChoiceAssetController {
+    public class SSPLine {
+        @AuraEnabled
+        public Boolean isSelected;
+        @AuraEnabled
+        public String setProductid ;
+        @AuraEnabled
+        public String Assetid;
+        @AuraEnabled
+        public String Accountid;
+        @AuraEnabled
+        public String Hospital;
+         @AuraEnabled
+        public String WorkLocation;
+        @AuraEnabled
+        public Asset theObject;
+        @AuraEnabled
+        public String Name;      
+        @AuraEnabled
+        public String SerialNumber;
+        @AuraEnabled
+        public String HP_Name;
+        @AuraEnabled
+        public String Department_Name;
+        @AuraEnabled
+        public Date Posting_Date;
+        @AuraEnabled
+        public Date Extend_Gurantee_DateTo;
+        @AuraEnabled
+        public Date CurrentContract_End_Date;
+
+
+        public SSPLine(Asset psl) {
+          isSelected = false;
+          setProductid = psl.id;
+            setProductid = setProductid.substring(0,15);
+            Assetid = psl.id;
+            if (psl.Account.id !=null) {
+                Accountid = psl.Account.id;
+            }
+            Name = psl.Name;
+            Hospital = psl.Hospital__r.id;
+            if (psl.Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c !=null) {
+                WorkLocation = psl.Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c;
+            }
+            SerialNumber= psl.SerialNumber;
+            HP_Name = psl.HP_Name__c;
+            Department_Name = psl.Department_Name__c;
+            Posting_Date = psl.Posting_Date__c;
+            Extend_Gurantee_DateTo = psl.Extend_Gurantee_DateTo__c;
+            CurrentContract_End_Date = psl.CurrentContract_End_Date__c;
+        }
+    }
+    public class InitData{
+        @AuraEnabled
+        public String Id;
+        @AuraEnabled
+        public String StatusC;
+        @AuraEnabled
+        public String OwnerId;
+        @AuraEnabled
+        public String Repair_Detail;
+        @AuraEnabled
+        public Date FaultTime;
+        @AuraEnabled
+        public String RepairApplicantName;
+        @AuraEnabled
+        public String HPname;
+        @AuraEnabled
+        public String DepName;
+        @AuraEnabled
+        public Date RepairsReportDate;
+        @AuraEnabled
+        public Date ReceiverTime;
+        @AuraEnabled
+        public Date PlannedVisitDay;
+        @AuraEnabled
+        public Date ActualVisitDateFirst;
+         @AuraEnabled
+        public Date ActualVisitDateSecon;
+         @AuraEnabled
+        public Date ActualVisitDateThird;
+         @AuraEnabled
+        public Date ApplicationTime;
+     }
+
+     public class AssData{
+        @AuraEnabled
+        public String canRepair;
+     }
+
+     @AuraEnabled
+    public static AssData searchAss(String recordId){
+        AssData res = new AssData();
+        List<Asset> ass = [select id,Product_ID__c from Asset where ID = :recordId];
+        List<Product2> p2 = [select id,Name,Can_Repair__c 
+                        from Product2 where 
+                        ID = :ass[0].Product_ID__c];
+        if (p2[0].Can_Repair__c != null) {
+            res.canRepair = p2[0].Can_Repair__c;
+        }
+        return res;
+    }
+    @AuraEnabled
+    public static InitData init(String recordId){
+        InitData res = new initData();
+        try{
+            RepairSubOrder__c report =  [SELECT Id,ApplicationTime__c,ActualVisitDateThird__c,ActualVisitDateSecon__c,ActualVisitDateFirst__c,PlannedVisitDay__c,ReceiverTime__c,RepairsReportDate__c,Status__c,Department__r.Name,Hospital__r.name,RepairApplicantName__c,OwnerId,ResponseResultDesc__c,FaultTime__c FROM RepairSubOrder__c WHERE Id =: recordId LIMIT 1];
+            System.debug(LoggingLevel.INFO, '*** opp: ' + report);
+            res.Id = report.Id;
+            res.StatusC = report.Status__c;
+            res.OwnerId = report.OwnerId;
+            res.Repair_Detail = report.ResponseResultDesc__c;
+            if (report.FaultTime__c!=null) {
+                res.FaultTime = report.FaultTime__c.date();
+            }
+            res.RepairApplicantName = report.RepairApplicantName__c;
+            if (report.Hospital__r.name!=null) {
+                res.HPname = report.Hospital__r.name;
+            }
+            if (report.Department__r.Name!=null) {
+                res.DepName = report.Department__r.Name;
+            }
+            res.RepairsReportDate = report.RepairsReportDate__c;
+            if (report.ReceiverTime__c!=null) {
+                res.ReceiverTime = report.ReceiverTime__c.date();
+            }
+            if (report.PlannedVisitDay__c!=null) {
+                res.PlannedVisitDay = report.PlannedVisitDay__c.date();
+            }
+            res.ActualVisitDateFirst = report.ActualVisitDateFirst__c;
+            res.ActualVisitDateSecon = report.ActualVisitDateSecon__c;
+            res.ActualVisitDateThird = report.ActualVisitDateThird__c;
+            if (report.ApplicationTime__c!=null) {
+                  res.ApplicationTime = report.ApplicationTime__c.date();
+            }
+            System.debug(LoggingLevel.INFO, '*** res: ' + res);
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }  
+
+    @AuraEnabled
+    public static String getNeedParm1(){
+        String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
+        return baseUrl;
+    }
+
+  //   @AuraEnabled
+  //   public static String init(){
+  //       String reportid;
+  //       Report r = new Report();
+  //       List<Report> rs = new List<Report>();
+  //       rs=[Select id,DeveloperName,Name,NamespacePrefix from Report Where DeveloperName='Set_Product_Detail'];
+  //       if (rs.size()>0){
+  //           //system.debug('DeveloperName=' + rs[0].DeveloperName);
+  //           //system.debug('Name=' + rs[0].Name);
+  //           //system.debug('NamespacePrefix=' + rs[0].NamespacePrefix);
+  //           reportid = rs[0].id;
+  //           reportid = reportid.substring(0,15);
+  //       }
+  //       return reportid;
+  // }
+
+  @AuraEnabled
+  public static List<SSPLine> getData(String SearchName , String SearchNo , String SearchSN){
+    String searchSql = 'Select id, name,Account.id,Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c,Hospital__r.id, SerialNumber,HP_Name__c,Department_Name__c,Posting_Date__c,Extend_Gurantee_DateTo__c,CurrentContract_End_Date__c from Asset ';
+    String whereStr = 'Where  id !=null  ';
+    String whereSql = '';
+
+    if(SearchName != null && SearchName != ''){
+      whereSql += 'and HP_Name__c Like ' + '\'%' + SearchName + '%\' ';
+    }
+
+    if(SearchNo != null && SearchNo != ''){
+      whereSql += 'and OwnershipMachine_No__c =\'' + SearchNo + '\'';
+    }
+
+    if(SearchSN != null && SearchSN != ''){
+      whereSql += 'and SerialNumber like ' + '\'%' + SearchSN + '%\' ';
+    }
+    searchSql = searchSql + whereStr + whereSql;
+
+    searchSql += ' order by Posting_Date__c limit 100';
+
+    List<Asset> cl = new List<Asset>();
+
+    cl = Database.query(searchSql);
+    List<SSPLine> activities = New List<SSPLine>();
+
+    for(Asset psl : cl){
+        SSPLine a = new SSPLine(psl);
+        activities.add(a);
+        
+    }
+    return activities;
+  }
+
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexChoiceAssetControllerTest.cls b/force-app/main/default/classes/LexChoiceAssetControllerTest.cls
new file mode 100644
index 0000000..b0d733e
--- /dev/null
+++ b/force-app/main/default/classes/LexChoiceAssetControllerTest.cls
@@ -0,0 +1,124 @@
+@isTest
+private class LexChoiceAssetControllerTest {
+
+     @testSetup
+static void setupTestData() {
+        Oly_TriggerHandler.bypass('ContactTriggerHandler');
+        ControllerUtil.EscapeNFM001Trigger = true;
+        // 鐪�
+        Address_Level__c al = new Address_Level__c();
+        al.Name = '鏉变含';
+        al.Level1_Code__c = 'CN-99';
+        al.Level1_Sys_No__c = '999999';
+        insert al;
+        // 甯�
+        Address_Level2__c al2 = new Address_Level2__c();
+        al2.Level1_Code__c = 'CN-99';
+        al2.Level1_Sys_No__c = '999999';
+        al2.Level1_Name__c = '鏉变含';
+        al2.Name = '娓嬭胺鍖�';
+        al2.Level2_Code__c = 'CN-9999';
+        al2.Level2_Sys_No__c = '9999999';
+        al2.Address_Level__c = al.id;
+        insert al2;
+
+        // 鐥呴櫌銈掍綔銈�
+        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 = '鏈夊姽';
+        hospital.Attribute_Type__c = '鍗敓閮�';
+        hospital.Speciality_Type__c = '缁煎悎鍖婚櫌';
+        hospital.Grade__c = '涓�绾�';
+        hospital.OCM_Category__c = 'SLTV';
+        hospital.Is_Medical__c = '鍖荤枟鏈烘瀯';
+        hospital.State_Master__c = al.id;
+        hospital.City_Master__c = al2.id;
+        hospital.Town__c = '涓滀含';
+        insert hospital;
+
+        // 鎴︾暐绉戝銈掑緱銈�
+        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
+        // 瑷虹檪绉戙倰浣溿倠
+        Account dep = new Account();
+        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
+        dep.Name = 'test dep';
+        dep.AgentCode_Ext__c = '9999998';
+        dep.ParentId = strategicDep[0].Id;
+        dep.Department_Class__c = strategicDep[0].Id;
+        dep.Hospital__c = hospital.Id;
+        insert dep;
+
+        Contact contact2 = new Contact();
+        contact2.AccountId = dep.Id;
+        contact2.FirstName = '璨换鑰�';
+        contact2.LastName = 'test1缁忛攢鍟�';
+        insert contact2;
+
+        // 浜у搧
+        Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP',
+                Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
+                Fixture_Model_No_T__c = 'n05',
+                ProductCode_Ext__c='pc05',Manual_Entry__c=false,Can_Repair__c='鍙�');
+        insert pro5;
+
+        Asset assetC1 = new Asset(Asset_Owner__c = 'Olympus');
+        assetC1.RecordTypeId = System.Label.Asset_RecordType;
+        assetC1.SerialNumber = 'assetC1';
+        assetC1.Name = 'assetC1';
+        assetC1.AccountId = dep.Id;
+        assetC1.Department_Class__c = strategicDep[0].Id;
+        assetC1.Hospital__c = hospital.Id;
+        assetC1.Product2Id = pro5.Id;
+        assetC1.Quantity = 1;
+        assetC1.Status = '鏈夊簱瀛�';
+        assetC1.Manage_type__c = '涓綋绠$悊';
+        assetC1.Internal_asset_location__c = '鍖椾含 澶囧搧涓績';
+        assetC1.Loaner_accsessary__c = true;
+        assetC1.Delete_Flag__c = false;
+        assetC1.Freeze_sign__c = false;
+        assetC1.Out_of_wh__c = 0;
+        // 淇濇湁璁惧
+        Asset asset = new Asset(Asset_Owner__c = 'Olympus');
+        asset.RecordTypeId = System.Label.Asset_RecordType;
+        asset.SerialNumber = 'asset';
+        asset.Name = 'asset';
+        asset.AccountId = dep.Id;
+        asset.Department_Class__c = strategicDep[0].Id;
+        asset.Hospital__c = hospital.Id;
+        asset.Product2Id = pro5.Id;
+        asset.Quantity = 1;
+        asset.Status = '鏈夊簱瀛�';
+        asset.Manage_type__c = '涓綋绠$悊';
+        asset.Internal_asset_location__c = '鍖椾含 澶囧搧涓績';
+        asset.Loaner_accsessary__c = true;
+        asset.Delete_Flag__c = false;
+        asset.Freeze_sign__c = false;
+        asset.Out_of_wh__c = 0;
+        insert new Asset[] {assetC1, asset};
+
+        
+    }
+    static testMethod void testMethod1() {
+          
+        RepairSubOrder__c subOrder = new RepairSubOrder__c();
+        subOrder.AttachmentDownload__c = true;
+        subOrder.AttachmentLink__c = 'https://albsylfw.s3.cn-northwest-1.amazonaws.com.cn/20211220/14/11/30/lessthan12/5e8cb69e-f935-48f5-825e-b8344d60f6d4.zip';
+        subOrder.AttachmentName__c = '娴嬭瘯闄勪欢涓嬭浇';
+        subOrder.FaultTime__c = Date.today();
+        subOrder.PlannedVisitDay__c = Date.today();
+        subOrder.ReceiverTime__c = Date.today();
+        subOrder.ApplicationTime__c = Date.today();
+        Account acc = [select id from account where name = 'test hospital' limit 1]; 
+        Account dep = [select id from account where AgentCode_Ext__c = '9999998' limit 1]; 
+        subOrder.Hospital__c = acc.id;
+        subOrder.Department__c = dep.id;
+        insert subOrder;
+        Asset ass = [select id,Account.id,Name,Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c,Hospital__r.id,SerialNumber,HP_Name__c,Department_Name__c,Posting_Date__c,Extend_Gurantee_DateTo__c,CurrentContract_End_Date__c from Asset limit 1];
+        LexChoiceAssetController.init(subOrder.id);
+        LexChoiceAssetController.searchAss(ass.id);
+        LexChoiceAssetController.getNeedParm1();
+         new LexChoiceAssetController.SSPLine(ass);
+        LexChoiceAssetController.getData('assetC1',null,null);
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexChoiceAssetControllerTest.cls-meta.xml b/force-app/main/default/classes/LexChoiceAssetControllerTest.cls-meta.xml
new file mode 100644
index 0000000..9662499
--- /dev/null
+++ b/force-app/main/default/classes/LexChoiceAssetControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>50.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
\ No newline at end of file
diff --git a/force-app/main/default/classes/NewPaymentPlanLoadController.cls b/force-app/main/default/classes/NewPaymentPlanLoadController.cls
index d06c9ca..eb5a437 100644
--- a/force-app/main/default/classes/NewPaymentPlanLoadController.cls
+++ b/force-app/main/default/classes/NewPaymentPlanLoadController.cls
@@ -8,6 +8,7 @@
 	public Boolean printAgent { get; private set; }
 	//HWAG-BHT7XX 2019/11/26 START
 	public Boolean agreeUpperLimit { get; private set; }
+	public Boolean isPrint { get;  set; }
 	//HWAG-BHT7XX 2019/11/26 END
 	// fxk 2021/8/31 鐐规娆℃暟蹇呴』濉� Star
 	// public boolean saveErrorflag { get; private set; }
@@ -16,10 +17,17 @@
 	public Integer Contract_validMonth {get; set;}
 	// 鏂板鐐规鎬绘鏁帮紙鍙湪椤甸潰涓樉绀猴級fxk 2021/9/2 End
 
+	// WKX START
+	public Maintenance_Contract_Estimate__c estimate { get; set; }
+	public String targetEstimateId { get; private set; }
+	public Boolean EnablePrintContract {get; set;}
+	// WKX END
+
 	public NewPaymentPlanLoadController() {
-		idl = ApexPages.currentPage().getParameters().get('id');
+		idl = ApexPages.currentPage().getParameters().get('id');	
 	}
 	public void init() {
+		isPrint = false;
 		statusSave = 'Fin';
 		testDateTime = system.now();
 		//
@@ -91,6 +99,11 @@
 		                                        //URF闄愭鍚堝悓2鏈� LY 20220811 star
 		                                        ,URF_Contract__c
 		                                        //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+		                                        // WKX 2023/7/25 DB202306182573 START
+		                                        ,Estimation_Id__r.id
+												// WKX 2023/7/25 DB202306182573 END
+
 		                                        from
 		                                        Maintenance_Contract__c
 		                                        where
@@ -150,6 +163,22 @@
 		}
 		//fxk 鏂板姞鐐规鎬绘鏁� 2021.9.2 End
 	}
+
+	// WKX START
+	private void setThisEstimate() {
+        this.estimate = [SELECT Id
+						,Print_RepairPrice__c
+						,Print_Agent__c
+						,Print_ListPrice__c
+						,Print_SumPrice__c
+						,Print_Tripartite__c
+						,Print_Simplify__c
+                        FROM Maintenance_Contract_Estimate__c 
+                        WHERE Id = :PageMCEElement.Estimation_Id__r.id];
+        this.EnablePrintContract = true;
+    }
+
+	// WKX END
 
 	public List<SelectOption> getSmall_Repair_Time() {
 		List<SelectOption> options = new List<SelectOption>();
@@ -516,6 +545,7 @@
 						ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,
 						                     '浠樻鎬婚噾棰濅笌鍚堝悓閲戦涓嶇銆�'));
 						statusSave = 'Denied';
+						return null;
 					}
 
 				}
@@ -563,6 +593,9 @@
 			PageMCEElement.MainLeaderManager__c = PageMCEElement.Service_Contract_Staff__r.JingliApprovalManager__c;
 			update PageMCEElement;
 			statusSave = 'Fin';
+			if(isPrint == false) {
+				ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '淇濆瓨鎴愬姛'));
+			}
 			return null;
 		} catch (exception ex) {
 			statusSave = 'Denied';
@@ -573,8 +606,9 @@
 	}
 	public void print() {
 		System.debug('print start');
+		this.isPrint = true;
 		save();
-
+		this.isPrint = false;
 		if (PageMCEElement.Decided_Estimation__c == null) {
 			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,
 			                     '鎶ヤ环鍗曟病鏈夊喅瀹氫箣鍓嶄笉鑳芥墦鍗板悎鍚屾枃鏈�!'));
diff --git a/force-app/main/default/lwc/lexChoiceAsset/lexChoiceAsset.js b/force-app/main/default/lwc/lexChoiceAsset/lexChoiceAsset.js
index a556a20..b3beb40 100644
--- a/force-app/main/default/lwc/lexChoiceAsset/lexChoiceAsset.js
+++ b/force-app/main/default/lwc/lexChoiceAsset/lexChoiceAsset.js
@@ -242,7 +242,7 @@
                     var status = this.StatusC;
                     if (status != '寰呭鐞�') {
                         const evt = new ShowToastEvent({
-                                title : '淇瓙鍗曠殑鐘舵�佷笉鏄� 寰呭鐞� 鏃犳硶鐢宠淇悊',
+                                title : '鎶ヤ慨瀛愬崟鐨勭姸鎬佷笉鏄� 寰呭鐞� 鏃犳硶鐢宠淇悊',
                                 message: '',
                                 variant: 'error'
                             });
diff --git a/force-app/main/default/pages/QLMAttachmentPreview.page b/force-app/main/default/pages/QLMAttachmentPreview.page
index 91b4c3c..eb68f3d 100644
--- a/force-app/main/default/pages/QLMAttachmentPreview.page
+++ b/force-app/main/default/pages/QLMAttachmentPreview.page
@@ -1,6 +1,7 @@
 <apex:page action="{!init}" id="Page"  controller="QLMAttachmentPreviewController" showheader="false" sidebar="false" lightningStylesheets="true">
 
     <!-- 鏂囦欢鍒楄〃 鐐瑰嚮琛岄」鐩� 棰勮鍥剧墖 闈炲浘鐗囨牸寮忕偣鍑讳笅杞�  -->
+    <apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/>
     <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}">
     </apex:stylesheet>
     <apex:includescript value="{!URLFOR($Resource.jquery183minjs)}">
@@ -109,7 +110,7 @@
     // 杩斿洖鎸夐挳鏍规嵁浼爄d杩斿洖涓婁竴绾ф搷浣�
         function test(){
         var queryVal=GetQueryValue('parentId');
-        // var url='https://ocsm--stagefull.my.salesforce.com/'+queryVal;
+        // var url='https://ocsm--partial--c.sandbox.vf.force.com/'+queryVal;
         var url='https://ocsm.my.salesforce.com/'+queryVal;
         window.location.href=url;
         }

--
Gitblit v1.9.1