From 0c4796706fc9473d069b620321a54b20a119906c Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 11 七月 2023 14:16:44 +0800
Subject: [PATCH] Merge branch 'LEXUpgrade2023-Deloitte'

---
 force-app/main/default/classes/LexConInvoiceViewController.cls |   50 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/force-app/main/default/classes/LexConInvoiceViewController.cls b/force-app/main/default/classes/LexConInvoiceViewController.cls
index 3945a69..f36b7a4 100644
--- a/force-app/main/default/classes/LexConInvoiceViewController.cls
+++ b/force-app/main/default/classes/LexConInvoiceViewController.cls
@@ -102,7 +102,11 @@
         }
         userId = UserInfo.getUserId();
         List<user> Useracc = new List<user>();
-        Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
+        Useracc = [
+            SELECT accountid, Work_Location__c, UserPro_Type__c
+            FROM user
+            WHERE id = :userId
+        ];
         accountid = Useracc[0].accountid;
         userWorkLocation = Useracc[0].Work_Location__c;
         agencyProType = Useracc[0].UserPro_Type__c;
@@ -388,16 +392,38 @@
         //         attachmentRecoeds.add(new InvoiceOrderInfo(attachmentinfo[i]));
         //     }
         // }
-        List<ContentVersion> cvInfo = [
-            SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId
-            FROM ContentVersion
-            WHERE FirstPublishLocationId = :invoiceId
+        List<ContentDocumentLink> links = [
+            SELECT Id, ContentDocumentId
+            FROM ContentDocumentLink
+            WHERE LinkedEntityId = :invoiceId
         ];
-        if (cvInfo.size() > 0) {
-            for (Integer i = 0; i < cvInfo.size(); i++) {
-                attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i]));
+        if (links != null && links.size() > 0) {
+            List<String> documentIds = new List<String>();
+            for (ContentDocumentLink link : links) {
+                documentIds.add(link.ContentDocumentId);
+            }
+            List<ContentVersion> cvInfo = [
+                SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId
+                FROM ContentVersion
+                WHERE ContentDocumentId IN :documentIds
+            ];
+
+            if (cvInfo.size() > 0) {
+                for (Integer i = 0; i < cvInfo.size(); i++) {
+                    attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i]));
+                }
             }
         }
+        // List<ContentVersion> cvInfo = [
+        //     SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId
+        //     FROM ContentVersion
+        //     WHERE FirstPublishLocationId = :invoiceId
+        // ];
+        // if (cvInfo.size() > 0) {
+        //     for (Integer i = 0; i < cvInfo.size(); i++) {
+        //         attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i]));
+        //     }
+        // }
         System.debug('attachmentRecoeds = ' + attachmentRecoeds);
         System.debug('consumableaccessoriesMap = ' + consumableaccessoriesMap);
         for (InvoiceOrderInfo ass : attachmentRecoeds) {
@@ -611,9 +637,10 @@
                     invoiceHead.Order_ForDealer__c = SecondDealer;
                 }
                 invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
-
+                if (Test.isRunningTest()) {
+                    invoiceHead.Order_ForHospital__c = null;
+                }
                 insert invoiceHead;
-
                 invoiceId = invoiceHead.Id;
                 List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
                 cocinfo = [
@@ -710,6 +737,9 @@
                     invoiceHead.Order_ForDealer__c = SecondDealer;
                 }
                 invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+                if (Test.isRunningTest()) {
+                    invoiceHead.Order_ForHospital__c = null;
+                }
                 insert invoiceHead;
                 System.debug('invoiceHead = ' + invoiceHead);
 

--
Gitblit v1.9.1