From 3962c2bb0435484b60a3e408e4738d792e249a53 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 05 六月 2023 11:09:55 +0800
Subject: [PATCH] LEX CommunityNewCmp

---
 force-app/main/default/classes/LexConInvoiceList.cls |  156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 156 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/LexConInvoiceList.cls b/force-app/main/default/classes/LexConInvoiceList.cls
new file mode 100644
index 0000000..3f488ef
--- /dev/null
+++ b/force-app/main/default/classes/LexConInvoiceList.cls
@@ -0,0 +1,156 @@
+public with sharing class LexConInvoiceList {
+    public static Consumable_order__c coc { get; set; }
+    public static String agencyProType { get; set; }
+    public static String category1 { get; set; }
+    public static String category2 { get; set; }
+    //鍙戠エ寮�濮嬨�佺粨鏉熸棩鏈�
+    private static Date cate1 { get; set; }
+    private static Date cate2 { get; set; }
+    // 鐧诲綍鐢ㄦ埛 ID
+    private static String userinfoId { get; set; }
+    private static String invoiceStatus { get; set; }
+    //缁忛攢鍟唅d
+    private static String accountid { get; set; }
+    // 鐢婚潰鏄剧ず鏁版嵁
+    public static List<Consumable_order__c> raesList { get; private set; }
+    //鎺掑簭浣跨敤
+    private static String[] orderby = new List<String>{ 'Invoice_Date__c', 'Name', 'ShipmentAccount__c' };
+    public static String sortKey { get; set; }
+    public static String preSortKey { get; private set; }
+    public static Boolean sortOrderAsc { get; private set; }
+    public static String[] sortOrder { get; private set; }
+    // 鐧诲綍鑰呭伐浣滃湴
+    private static String userWorkLocation { get; set; }
+    public static Map<String, String> statusMap { get; set; }
+
+    @AuraEnabled
+    public static ResponseBodyLWC init() {
+        ResponseBodyLWC res = new ResponseBodyLWC();
+        Map<String, object> data = new Map<String, object>();
+        res.entity = data;
+
+        statusMap = new Map<String, String>();
+        raesList = new List<Consumable_order__c>();
+        coc = new Consumable_order__c();
+        cate1 = coc.Order_date__c;
+        cate2 = coc.Deliver_date__c;
+        userinfoId = UserInfo.getUserId();
+        List<user> Useracc = new List<user>();
+        Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userinfoId];
+        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';
+        }
+        invoiceStatus = coc.Invoice_status__c;
+        String soql = makeSoql(category1, category2, invoiceStatus);
+        raesList = Database.query(soql);
+
+        statusMap = getPicklistValues('Consumable_order__c', 'Invoice_status__c');
+
+        data.put('userinfoId', userinfoId);
+        data.put('accountid', accountid);
+        data.put('userWorkLocation', userWorkLocation);
+        data.put('agencyProType', agencyProType);
+        data.put('raesList', raesList);
+        data.put('statusMap', statusMap);
+        res.status = 'Success';
+        res.code = 200;
+        System.debug('res = ' + res);
+        return res;
+    }
+
+    // 鍙戠エ鍗曟绱�
+    @AuraEnabled
+    public static ResponseBodyLWC invoiceCodeSearch(
+        Date orderDateLwc,
+        Date deliverDateLwc,
+        String invoiceStatusLwc,
+        String category1Lwc,
+        String category2Lwc,
+        String accountidLwc,
+        String userWorkLocationLwc,
+        String agencyProTypeLwc
+    ) {
+        ResponseBodyLWC res = new ResponseBodyLWC();
+        Map<String, object> data = new Map<String, object>();
+        res.entity = data;
+
+        cate1 = orderDateLwc;
+        cate2 = deliverDateLwc;
+        invoiceStatus = invoiceStatusLwc;
+        category1 = category1Lwc;
+        category2 = category2Lwc;
+        accountid = accountidLwc;
+        userWorkLocation = userWorkLocationLwc;
+        agencyProType = agencyProTypeLwc;
+        // 鑾峰緱鍙戠エ涓�瑙�
+        raesList = new List<Consumable_order__c>();
+        String soql = makeSoql(category1, category2, invoiceStatus);
+        raesList = Database.query(soql);
+        // if(raesList.size()>0){
+        //     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨绱㈠埌' + raesList.size() + '涓彂绁�'));
+        // }else{
+        //     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '娌℃湁鎼滅储鍒扮浉鍏冲彂绁ㄣ��'));
+        // }
+        data.put('raesList', raesList);
+        data.put('raesListSize', raesList.size());
+        res.status = 'Success';
+        res.code = 200;
+        System.debug('res = ' + res);
+        return res;
+    }
+
+    // 鍋氭垚妫�绱QL鏂�
+    private static String makeSoql(String invoiceCode, String accountName, String invoiceStatus) {
+        String soql = 'SELECT Id, Name,Invoice_Date__c,ShipmentAccount__c,Shipment_total_amount__c,RrturnPro_total_amount__c,Invoice_status__c, ';
+        soql += ' InvoicedPro_total_amount__c,InvoiceNotPro_total_amount__c,Invoice_total_amount__c,Invoice_attachment__c,Invoicedet_attachment__c FROM Consumable_order__c ';
+        soql += ' WHERE Dealer_Info__c = \'' + accountid + '\'';
+        soql += ' AND Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
+        soql += ' and Order_ProType__c =\'' + agencyProType + '\' ';
+        soql += ' AND recordtypeid = \'' + System.Label.RT_ConOrder_Invoice + '\'';
+        if (cate1 != null) {
+            soql += ' AND Invoice_Date__c >= :cate1 ';
+        }
+        if (cate2 != null) {
+            soql += ' AND Invoice_Date__c <= :cate2 ';
+        }
+        if (!String.isBlank(invoiceCode)) {
+            soql += ' AND Name like \'%' + String.escapeSingleQuotes(invoiceCode.replaceAll('%', '\\%')) + '%\' ';
+        }
+        if (!String.isBlank(accountName)) {
+            soql += ' AND ShipmentAccount__c like \'%' + String.escapeSingleQuotes(accountName.replaceAll('%', '\\%')) + '%\' ';
+        }
+        if (!String.isBlank(invoiceStatus)) {
+            soql += ' AND Invoice_status__c =\'' + invoiceStatus + '\' ';
+        }
+        System.debug('soql+++++' + soql);
+        return soql;
+    }
+
+    /*
+    閫氳繃sObjectName鍜屾寚瀹氬瓧娈佃幏鍙朠ickList鐨剉alue鍊�
+    */
+    public static Map<String, String> getPicklistValues(String sObjectName, String sFieldName) {
+        Map<String, String> picValues = new Map<String, String>();
+        picValues.put('-鏃�-', '');
+        Map<String, Schema.SObjectType> sObjectDescribeMap = Schema.getGlobalDescribe();
+        if (sObjectDescribeMap.containsKey(sObjectName)) {
+            Map<String, Schema.SobjectField> sObjectFieldsMap = sObjectDescribeMap.get(sObjectName).getDescribe().fields.getMap();
+            if (sObjectFieldsMap.containsKey(sFieldName)) {
+                Schema.DescribeFieldResult sObjectFieldDescribe = sObjectFieldsMap.get(sFieldName).getDescribe();
+                List<Schema.PicklistEntry> lPickEntryList = sObjectFieldDescribe.getPicklistValues();
+                //tPicklistEntry.isDefaultValue()
+                for (Schema.PicklistEntry tPicklistEntry : lPickEntryList) {
+                    picValues.put(tPicklistEntry.getLabel(), tPicklistEntry.getValue());
+                }
+            } else {
+                //TODO 涓嶅瓨鍦ㄦ瀛楁鐨勬墽琛�
+            }
+        } else {
+            // TODO 涓嶅瓨鍦ㄦsObject鐨勬墽琛�
+        }
+        return picValues;
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1