From 36d15f189de2e83ce2576715dac30c3c260388dd Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 14 七月 2023 14:47:50 +0800
Subject: [PATCH] fixconflict

---
 force-app/main/default/classes/LexConInvoiceViewController.cls |  173 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 140 insertions(+), 33 deletions(-)

diff --git a/force-app/main/default/classes/LexConInvoiceViewController.cls b/force-app/main/default/classes/LexConInvoiceViewController.cls
index 0173b6c..b67d39d 100644
--- a/force-app/main/default/classes/LexConInvoiceViewController.cls
+++ b/force-app/main/default/classes/LexConInvoiceViewController.cls
@@ -102,6 +102,32 @@
         }
         userId = UserInfo.getUserId();
         List<user> Useracc = new List<user>();
+<<<<<<< HEAD
+        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;
+        if (String.isBlank(Useracc[0].UserPro_Type__c)) {
+            agencyProType = 'ET';
+        }
+        coc = new Consumable_order__c();
+
+        Dealerelationship = [
+            SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
+            FROM Dealer_elationship__c
+            WHERE Dealer_principal__c = :accountid
+        ];
+        List<Agency_Hospital_Link__c> AgencyHospitalLink = new List<Agency_Hospital_Link__c>();
+        AgencyHospitalLink = [
+            SELECT Id, Name, Hospital__c, Hospital__r.Id, Hospital__r.Name, Agency__c
+            FROM Agency_Hospital_Link__c
+            WHERE Agency__c = :accountId
+        ];
+=======
         Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
         accountid = Useracc[0].accountid;
         userWorkLocation = Useracc[0].Work_Location__c;
@@ -122,6 +148,7 @@
             FROM Agency_Hospital_Link__c
             WHERE Agency__c = :accountId
         ];
+>>>>>>> LEXCommunityLiJun
         // 鏂拌
         if (invoiceId == null || invoiceId == '') {
             if (deliveryId == null || deliveryId == '') {
@@ -388,12 +415,46 @@
         //         attachmentRecoeds.add(new InvoiceOrderInfo(attachmentinfo[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]));
+<<<<<<< HEAD
+        List<ContentDocumentLink> links = [
+            SELECT Id, ContentDocumentId
+            FROM ContentDocumentLink
+            WHERE LinkedEntityId = :invoiceId
+        ];
+=======
+        List<ContentDocumentLink> links = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :invoiceId];
+>>>>>>> LEXCommunityLiJun
+        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
+            ];
+<<<<<<< HEAD
+
+=======
+            
+>>>>>>> LEXCommunityLiJun
+            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) {
@@ -415,17 +476,16 @@
         data.put('done', getdone());
         data.put('invoiceOrderdetail1Recoeds', invoiceOrderdetail1Recoeds);
         data.put('accountid', accountid);
-        data.put('invoiceOrderRecoedschange',invoiceOrderRecoedschange);
-        data.put('attachmentRecoeds',attachmentRecoeds);
-        data.put('outOrderStringList',outOrderStringList);
-        data.put('outordercountMap',outordercountMap);
+        data.put('invoiceOrderRecoedschange', invoiceOrderRecoedschange);
+        data.put('attachmentRecoeds', attachmentRecoeds);
+        data.put('outOrderStringList', outOrderStringList);
+        data.put('outordercountMap', outordercountMap);
         res.status = 'Success';
         res.code = 200;
         System.debug('res = ' + res);
         return res;
     }
 
-    
     //淇濆瓨
     @AuraEnabled
     public static ResponseBodyLWC save(
@@ -453,12 +513,12 @@
         SecondDealer = SecondDealerLwc;
         errorMsg = '';
         deliveryId = deliveryIdLwc;
-        invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class);
+        invoiceOrderRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class);
         invoiceId = invoiceIdLwc;
         accountid = accountidLwc;
         agencyProType = agencyProTypeLwc;
         reopen = reopenLwc;
-        invoiceOrderRecoedschange = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedschangeLwc, List<InvoiceOrderInfo>.class);
+        invoiceOrderRecoedschange = (List<InvoiceOrderInfo>) JSON.deserialize(invoiceOrderRecoedschangeLwc, List<InvoiceOrderInfo>.class);
 
         List<String> chukudanID = new List<String>();
         if (coc.Name == '' || coc.Name == null) {
@@ -533,7 +593,6 @@
                 }
             } else {
                 if (HospitalInfo != null && HospitalInfo != '') {
-                    
                     System.debug('++++++++++++' + ass.esd.Order_ForHospital__c + '   ' + shipmentAccountString);
                     if (ass.esd.Order_ForHospital__c != shipmentAccountString) {
                         System.debug('HospitalInfo != null ass.esd.Order_ForHospital__c != shipmentAccountString');
@@ -552,7 +611,9 @@
                         (ass.esd.Order_ForDealerText__c != null || ass.esd.Order_ForDealerText__c != '') &&
                         ass.esd.ShipmentAccount__c != shipmentAccountString
                     ) {
-                        System.debug('HospitalInfo == null && ass.esd.Order_ForDealerText__c != null ass.esd.ShipmentAccount__c != shipmentAccountString');
+                        System.debug(
+                            'HospitalInfo == null && ass.esd.Order_ForDealerText__c != null ass.esd.ShipmentAccount__c != shipmentAccountString'
+                        );
                         invoiceOrderAccountList.add(ass.esd.Name);
                     }
                 }
@@ -607,9 +668,15 @@
                     invoiceHead.Order_ForDealer__c = SecondDealer;
                 }
                 invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
-
+<<<<<<< HEAD
+                if (Test.isRunningTest()) {
+                    invoiceHead.Order_ForHospital__c = null;
+=======
+                if(Test.isRunningTest()){
+                    invoiceHead.Order_ForHospital__c  = null;
+>>>>>>> LEXCommunityLiJun
+                }
                 insert invoiceHead;
-
                 invoiceId = invoiceHead.Id;
                 List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
                 cocinfo = [
@@ -693,12 +760,12 @@
                 invoiceHead.Order_ProType__c = agencyProType;
                 invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
                 //if (deliveryId != null) {
-                    if (String.isNotBlank(deliveryId)) {
+                if (String.isNotBlank(deliveryId)) {
                     invoiceHead.Outbound_order__c = deliveryId;
                 }
                 invoiceHead.RecordTypeid = System.Label.RT_ConOrder_Invoice;
                 //if (SecondDealer == null) {
-                    if (String.isBlank(SecondDealer)) {
+                if (String.isBlank(SecondDealer)) {
                     if (HospitalInfo != null && HospitalInfo != '') {
                         invoiceHead.Order_ForHospital__c = HospitalInfo;
                     }
@@ -706,6 +773,14 @@
                     invoiceHead.Order_ForDealer__c = SecondDealer;
                 }
                 invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+<<<<<<< HEAD
+                if (Test.isRunningTest()) {
+                    invoiceHead.Order_ForHospital__c = null;
+=======
+                if(Test.isRunningTest()){
+                    invoiceHead.Order_ForHospital__c  = null;
+>>>>>>> LEXCommunityLiJun
+                }
                 insert invoiceHead;
                 System.debug('invoiceHead = ' + invoiceHead);
 
@@ -849,6 +924,8 @@
                     delete invoiceLinkdetList;
                 }
                 //鏂板缓鍙戠エ鏄庣粏1
+                System.debug('===>' + chukudanID);
+                System.debug('===>' + chukudanID.size());
                 if (chukudanID.size() > 0) {
                     newinvoicedetails1(chukudanID);
                 }
@@ -883,7 +960,7 @@
                 if (cocinfo.size() > 0) {
                     invoiceHead = cocinfo[0];
                 }
-                if (String.isNotBlank(deliveryId)) { 
+                if (String.isNotBlank(deliveryId)) {
                     for (InvoiceOrderInfo ass : invoiceOrderRecoedschange) {
                         insertDetMap.put(ass.esd.Id, invoiceHead.Id);
                     }
@@ -1267,13 +1344,13 @@
 
     // 淇濆瓨闄勪欢
     @AuraEnabled
-    public static ResponseBodyLWC saveAttachment(String attachmentRecoedsLwc,String invoiceId) {
+    public static ResponseBodyLWC saveAttachment(String attachmentRecoedsLwc, String invoiceId) {
         System.debug('杩涘叆 saveAttachment');
         ResponseBodyLWC res = new ResponseBodyLWC();
         Map<String, object> data = new Map<String, object>();
         res.entity = data;
         invoiceId = invoiceId;
-        attachmentRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(attachmentRecoedsLwc, List<InvoiceOrderInfo>.class);
+        attachmentRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(attachmentRecoedsLwc, List<InvoiceOrderInfo>.class);
         System.debug('attachmentRecoeds = ' + attachmentRecoeds);
         try {
             Consumable_accessories_invoice__c attachmentdetails = new Consumable_accessories_invoice__c();
@@ -1299,7 +1376,16 @@
 
     // 妫�绱�(鏈紑鍙戠エ鍑哄簱鍗�)
     @AuraEnabled
-    public static ResponseBodyLWC InvoiceorderSearch(Consumable_order__c cocLwc,String invoiceIdLwc,String accountidLwc,String userWorkLocationLwc,String agencyProTypeLwc,String HospitalInfoLwc,String SecondDealerLwc,String invoiceOrderRecoedsLwc) {
+    public static ResponseBodyLWC InvoiceorderSearch(
+        Consumable_order__c cocLwc,
+        String invoiceIdLwc,
+        String accountidLwc,
+        String userWorkLocationLwc,
+        String agencyProTypeLwc,
+        String HospitalInfoLwc,
+        String SecondDealerLwc,
+        String invoiceOrderRecoedsLwc
+    ) {
         System.debug('杩涘叆 InvoiceorderSearch');
         ResponseBodyLWC res = new ResponseBodyLWC();
         Map<String, object> data = new Map<String, object>();
@@ -1309,12 +1395,12 @@
         HospitalInfo = HospitalInfoLwc;
         SecondDealer = SecondDealerLwc;
         errorMsg = '';
-        invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class);
+        invoiceOrderRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class);
         invoiceId = invoiceIdLwc;
         accountid = accountidLwc;
         agencyProType = agencyProTypeLwc;
         userWorkLocation = userWorkLocationLwc;
-        
+
         Map<String, String> invoiceOrderMap = new Map<String, String>();
         String msoql = '';
         List<InvoiceOrderInfo> invoiceOrderdetailMid = new List<InvoiceOrderInfo>();
@@ -1340,7 +1426,7 @@
                 invoiceOrderMap.put(invoiceOrderList[i].Name, invoiceOrderList[i].Name);
             }
         }
-        data.put('invoiceOrderRecoeds',invoiceOrderRecoeds);
+        data.put('invoiceOrderRecoeds', invoiceOrderRecoeds);
         res.status = 'Success';
         res.code = 200;
         System.debug('res = ' + res);
@@ -1396,7 +1482,7 @@
 
     // 鍒犻櫎鎸夐挳
     @AuraEnabled
-    public static ResponseBodyLWC deleteButton(String invoiceIdLwc,Consumable_order__c cocLwc) {
+    public static ResponseBodyLWC deleteButton(String invoiceIdLwc, Consumable_order__c cocLwc) {
         System.debug('杩涘叆 deleteButton');
         ResponseBodyLWC res = new ResponseBodyLWC();
         Map<String, object> data = new Map<String, object>();
@@ -1429,7 +1515,11 @@
 
     // 鎻愪氦鎸夐挳
     @AuraEnabled
-    public static ResponseBodyLWC approval(List<String> outOrderStringListLwc,Map<String, Consumable_Orderdetails__c> outordercountMapLwc,String invoiceIdLwc) {
+    public static ResponseBodyLWC approval(
+        List<String> outOrderStringListLwc,
+        Map<String, Consumable_Orderdetails__c> outordercountMapLwc,
+        String invoiceIdLwc
+    ) {
         System.debug('杩涘叆 approval');
         ResponseBodyLWC res = new ResponseBodyLWC();
         Map<String, object> data = new Map<String, object>();
@@ -1437,7 +1527,7 @@
 
         outOrderStringList = outOrderStringListLwc;
         outordercountMap = outordercountMapLwc;
-        invoiceId= invoiceIdLwc;
+        invoiceId = invoiceIdLwc;
         //鏇存柊鍙戠エ鏄庣粏2閾炬帴
         Consumable_order__c P = new Consumable_order__c();
         List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
@@ -1501,6 +1591,8 @@
                         outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c
                     )
                     .Invoice_Unitprice__c;
+                System.debug('====>procount' + invoiceUpdte1.Invoiced_Procount__c);
+                System.debug('===>RMB' + outOrderdet1List[i].Delivery_List_RMB__c);
                 invoiceUpdte1.InvoicedProCost_RMB__c = invoiceUpdte1.Invoiced_Procount__c * outOrderdet1List[i].Delivery_List_RMB__c;
 
                 Decimal invoicedProcount = 0;
@@ -1521,6 +1613,8 @@
                     invoicedProcount = outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)
                         .Invoiced_Count__c;
                 }
+                System.debug('鍙戠エ鏁伴噺===>' + outOrderdet1List[i].InvoiceProNot_count__c);
+                System.debug('杩樻病鍙戠エ鏁伴噺===>' + invoicedProcount);
 
                 if (outOrderdet1List[i].InvoiceProNot_count__c < invoicedProcount) {
                     // ApexPages.addmessage(
@@ -1534,7 +1628,16 @@
                     //     )
                     // );
                     // return null;
-                    return new ResponseBodyLWC('Error', 500, '鍑哄簱鍗�' + outOrderdet1List[i].Consumable_order__r.Name + '涓紝' + outOrderdet1List[i].Asset_Model_No__c + '杩樻病寮�绁ㄦ暟閲忓皬浜庡彂绁ㄦ暟閲忥紝璇风‘璁ゆ槸鍚︽湁杩斿搧', '');
+                    return new ResponseBodyLWC(
+                        'Error',
+                        500,
+                        '鍑哄簱鍗�' +
+                            outOrderdet1List[i].Consumable_order__r.Name +
+                            '涓紝' +
+                            outOrderdet1List[i].Asset_Model_No__c +
+                            '杩樻病寮�绁ㄦ暟閲忓皬浜庡彂绁ㄦ暟閲忥紝璇风‘璁ゆ槸鍚︽湁杩斿搧',
+                        ''
+                    );
                 }
 
                 outOrderdetUp1List.add(invoiceUpdte1);
@@ -1570,7 +1673,7 @@
         System.debug('res = ' + res);
         return res;
     }
-
+    @TestVisible
     class InvoiceOrderInfo implements Comparable {
         @AuraEnabled
         public Boolean check { get; set; }
@@ -1583,12 +1686,12 @@
         @AuraEnabled
         public Attachment attach { get; set; }
         @AuraEnabled
-        public ContentVersion cvInfo{ get; set; }
+        public ContentVersion cvInfo { get; set; }
         @AuraEnabled
         public String mailSelectOptsin { get; set; }
         public List<SelectOption> mailSelectOpts { get; set; }
         @AuraEnabled
-        public Map<String,String> mailSelectOptsMap { get; set; }
+        public Map<String, String> mailSelectOptsMap { get; set; }
         @AuraEnabled
         public String invoiceOrderId { get; set; }
         @AuraEnabled
@@ -1616,7 +1719,7 @@
         //ContentVersion
         public InvoiceOrderInfo(ContentVersion cv) {
             cvInfo = cv;
-            mailSelectOptsMap = new Map<String,String>();
+            mailSelectOptsMap = new Map<String, String>();
             mailSelectOptsMap.put('鍙戠エ鍜屾槑缁�', '鍙戠エ鍜屾槑缁�');
             mailSelectOptsMap.put('鍙戠エ', '鍙戠エ');
             mailSelectOptsMap.put('鏄庣粏', '鏄庣粏');
@@ -1626,4 +1729,8 @@
             return null;
         }
     }
-}
\ No newline at end of file
+<<<<<<< HEAD
+}
+=======
+}
+>>>>>>> LEXCommunityLiJun

--
Gitblit v1.9.1