binxie
2023-06-26 b5c5eb130ca0848124f9d136af4be142ad5aac07
force-app/main/default/classes/LexTopPageController.cls
@@ -39,9 +39,9 @@
    public static List<Consumable_order__c> raesList;
    /*****************一周未到货订单一览对应end******************/
    //排序使用
    private static String[] orderby = new List<String>{ 'Product2__c.Name__c' };
    private static String[] orderby = new String[]{ 'Product2__c.Name__c'};
    //产品上下限
    public static String[] proLimitAndDate = new List<String>{};
    public static String[] proLimitAndDate =new String[]{};
    public static String product_Limit;
    //库存产品最早有效期限
    private static Map<String, Date> productkucun = new Map<String, Date>();
@@ -79,35 +79,18 @@
            User useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :UserInfo.getUserId()];
            accountid = useracc.accountid;
            List<Account> accList = new List<Account>();
            accList = [
                SELECT
                    Name,
                    Ban_On_Use_Reason__c,
                    Deposit_Price__c,
                    Medical_Equipment_Num__c,
                    Medical_Equipment_Expiration_Date__c,
                    Ban_On_Use_Date__c,
                    Tax_Practice_No__c,
                    Tax_Practice_Expiration_Date__c,
                    Business_Authorization_No__c,
                    Business_Paper_Expiration_Date__c,
                    Credit_Check_No__c,
                    Dealer_discount__c,
                    Phone,
                    Address_Together__c,
                    Is_Active_Formula__c,
                    Management_Code__c,
                    Sales_Shop_Class__c,
                    Postal_Code__c,
                    Fax,
                    Address__c,
                    Deposit_Receipt_Finished__c,
            accList = [SELECT Name,Ban_On_Use_Reason__c,Deposit_Price__c,
                    Medical_Equipment_Num__c,Medical_Equipment_Expiration_Date__c,
                    Ban_On_Use_Date__c,Tax_Practice_No__c,Tax_Practice_Expiration_Date__c,
                    Business_Authorization_No__c,Business_Paper_Expiration_Date__c,
                    Credit_Check_No__c,Dealer_discount__c,
                    Phone,Address_Together__c,Is_Active_Formula__c,
                    Management_Code__c,Sales_Shop_Class__c,Postal_Code__c,
                    Fax,Address__c,Deposit_Receipt_Finished__c,
                    Deposit_Receipt_Completion_Day__c,
                    Product_Limit_Date__c,
                    Product_Limit_DateENG__c
                FROM account
                WHERE id = :accountid
            ];
                    FROM account WHERE id =:accountid];
            if (accList.size() == 1) {
                accountInfo = accList[0];
            } else {
@@ -155,35 +138,18 @@
            }
            //经销商·基本信息获取
            List<Account> accList = new List<Account>();
            accList = [
                SELECT
                    Name,
                    Ban_On_Use_Reason__c,
                    Deposit_Price__c,
                    Medical_Equipment_Num__c,
                    Medical_Equipment_Expiration_Date__c,
                    Ban_On_Use_Date__c,
                    Tax_Practice_No__c,
                    Tax_Practice_Expiration_Date__c,
                    Business_Authorization_No__c,
                    Business_Paper_Expiration_Date__c,
                    Credit_Check_No__c,
                    Dealer_discount__c,
                    Phone,
                    Address_Together__c,
                    Is_Active_Formula__c,
                    Management_Code__c,
                    Sales_Shop_Class__c,
                    Postal_Code__c,
                    Fax,
                    Address__c,
                    Deposit_Receipt_Finished__c,
            accList = [SELECT Name,Ban_On_Use_Reason__c,Deposit_Price__c,
                    Medical_Equipment_Num__c,Medical_Equipment_Expiration_Date__c,
                    Ban_On_Use_Date__c,Tax_Practice_No__c,Tax_Practice_Expiration_Date__c,
                    Business_Authorization_No__c,Business_Paper_Expiration_Date__c,
                    Credit_Check_No__c,Dealer_discount__c,
                    Phone,Address_Together__c,Is_Active_Formula__c,
                    Management_Code__c,Sales_Shop_Class__c,Postal_Code__c,
                    Fax,Address__c,Deposit_Receipt_Finished__c,
                    Deposit_Receipt_Completion_Day__c,
                    Product_Limit_Date__c,
                    Product_Limit_DateENG__c
                FROM account
                WHERE id = :accountid
            ];
                    FROM account WHERE id =:accountid];
            if (accList.size() == 1) {
                accountInfo = accList[0];
            } else {
@@ -203,30 +169,25 @@
            List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
            //库存明细取得
            orderDetZaikuList = new List<String>();
            List<AggregateResult> orderDetZaiku = [
                SELECT count(Id), Consumable_Product__c
            List<AggregateResult>  orderDetZaiku = [SELECT count(Id),
                                                        Consumable_Product__c
                FROM Consumable_order_details2__c
                WHERE
                    Dealer_Arrive__c = TRUE
                    AND Dealer_Shipment__c = FALSE
                    AND Dealer_Saled__c = FALSE
                    AND Lose_Flag__c = FALSE
                    AND Dealer_Returned__c = FALSE
                    AND Cancellation_Flag__c = FALSE
                    AND Bar_Code__c != NULL
                    AND Product_Type__c LIKE :userPro_Typestr
                                                    WHERE Dealer_Arrive__c = true
                                                    AND Dealer_Shipment__c = false
                                                    AND Dealer_Saled__c = false
                                                    AND Lose_Flag__c = false
                                                    AND Dealer_Returned__c = false
                                                    AND Cancellation_Flag__c = false
                                                    AND Bar_Code__c !=null
                                                    AND Product_Type__c like : userPro_Typestr
                    AND Dealer_Info_text__c = :accountName
                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
                GROUP BY Consumable_Product__c
            ];
                                                    group by Consumable_Product__c];
            for (AggregateResult zaikuId : orderDetZaiku) {
                orderDetZaikuList.add(String.valueOf(zaikuId.get('Consumable_Product__c')));
            }
            Map<String, Product2__c> MidMap = new Map<String, Product2__c>();
            List<Product2__c> product2Selected = [
                SELECT
                    Id,
                    Name,
            List<Product2__c> product2Selected = [SELECT Id, Name,
                    Name__c,
                    Asset_Model_No__c,
                    Category3__c,
@@ -237,16 +198,14 @@
                    Product2__r.SFDA_Expiration_Date__c,
                    Product2__r.Packing_list_manual__c
                FROM Product2__c
                WHERE Id IN :orderDetZaikuList
                                WHERE Id in :orderDetZaikuList
            ];
            for (Integer i = 0; i < product2Selected.size(); i++) {
                MidMap.put(product2Selected[i].Id, product2Selected[i]);
            }
            //返品库存统计
            List<Consumable_order_details2__c> CountDel = [
                SELECT
                    Id,
            List<Consumable_order_details2__c> CountDel = [SELECT Id,
                    Bar_Code__c,
                    Name,
                    Inventory_date__c,
@@ -257,18 +216,16 @@
                    Box_Piece__c,
                    hospitalSpecialOffer__c
                FROM Consumable_order_details2__c
                WHERE
                    Dealer_Arrive__c = TRUE
                    AND Dealer_Shipment__c = FALSE
                    AND Dealer_Saled__c = FALSE
                    AND Dealer_Returned__c = FALSE
                    AND Lose_Flag__c = FALSE
                    AND Cancellation_Flag__c = FALSE
                    AND Bar_Code__c != NULL
                    AND Product_Type__c LIKE :userPro_Typestr
                WHERE  Dealer_Arrive__c = true
                AND Dealer_Shipment__c = false
                AND Dealer_Saled__c = false
                AND Dealer_Returned__c = false
                AND Lose_Flag__c = false
                AND Cancellation_Flag__c = false
                AND Bar_Code__c !=null
                AND Product_Type__c like : userPro_Typestr
                    AND Dealer_Info_text__c = :accountName
                    AND Arrive_Owner_Work_Location__c = :userWorkLocation
            ];
                AND Arrive_Owner_Work_Location__c = :userWorkLocation];
            Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
            Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
            Map<String, ConsumableorderdetailsInfo> newHosMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
@@ -281,10 +238,7 @@
                        tex = 'B';
                    }
                    if (newMidBoxMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
                        ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(
                                CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex
                            )
                            .clone();
                        ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c + tex).clone();
                        Jstage.allnumber = Jstage.allnumber + 1;
                        if (CountDel[i].Isoverdue__c == 1) {
                            Jstage.limitCount = Jstage.limitCount + 1;
@@ -312,10 +266,7 @@
                        tex = 'B';
                    }
                    if (newMidPieceMap.containsKey(CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex)) {
                        ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
                                CountDel[i].Consumable_Product__c + CountDel[i].Box_Piece__c + tex
                            )
                            .clone();
                        ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(CountDel[i].Consumable_Product__c+CountDel[i].Box_Piece__c+ tex).clone();
                        Jstage.allnumber = Jstage.allnumber + 1;
                        if (CountDel[i].Isoverdue__c == 1) {
                            Jstage.limitCount = Jstage.limitCount + 1;
@@ -411,6 +362,7 @@
                if (bss.hospitalSpecialOffer) {
                    ishos = ishos + 1;
                }
            }
            if (ishos > 0) {
                hasHos = true;
@@ -484,15 +436,13 @@
        //over_view = false;
        Date orderdate = Date.today().addDays(-7);
        List<Consumable_order_details2__c> orderdetails = [
            SELECT Id, Name, Consumable_order_minor__c
        List<Consumable_order_details2__c> orderdetails = [SELECT Id,Name,Consumable_order_minor__c
            FROM Consumable_order_details2__c
            WHERE
                Deliver_date__c < :orderdate
                AND Consumable_order_minor__c != NULL
                AND Dealer_Info_text__c = :accountName
                                                            WHERE Deliver_date__c < :orderdate
                                                            and Consumable_order_minor__c !=null
                                                            and Dealer_Info_text__c = :accountName
                AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
                AND Dealer_Arrive__c = FALSE
                                                            AND Dealer_Arrive__c = false
        ];
        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'userPro_Type——————' + userPro_Type));
        Map<String, String> notarriveorderMap = new Map<String, String>();
@@ -527,14 +477,7 @@
        for (String s : column) {
            soql += ',' + s;
        }
        soql +=
            ' from Consumable_order__c where Order_type__c = \'' +
            '订单' +
            '\' and  recordtypeid =\'' +
            System.Label.RT_ConOrder_Delivery +
            '\' and Dealer_Info__c =\'' +
            accountid +
            '\'  and  Delivery_detail_count__c > 0 and showFalseNotshowTrue__c = false  ';
        soql += ' from Consumable_order__c where Order_type__c = \''+'订单'+'\' and  recordtypeid =\'' + System.Label.RT_ConOrder_Delivery + '\' and Dealer_Info__c =\'' + accountid +'\'  and  Delivery_detail_count__c > 0 and showFalseNotshowTrue__c = false  ';
        soql += ' and Order_ProType__c = \'' + userPro_Type + '\' ';
        soql += ' and Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
@@ -583,12 +526,8 @@
        }
        for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
            if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
                ass.lowerlimit = decimal.valueOf(
                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|'))
                );
                ass.upperlimit = decimal.valueOf(
                    productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1)
                );
                ass.lowerlimit = decimal.valueOf(productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf( '|')));
                ass.upperlimit = decimal.valueOf(productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf( '|')+1));
            }
        }
    }
@@ -596,29 +535,20 @@
    public static void datelimitSearch() {
        Set<String> barcodekucun = new Set<String>();
        //--------UpdateStart-----XHL--------------20180929-------------
        List<Consumable_order_details2__c> orderkucun = [
            SELECT
                Id,
                Bar_Code__c,
                Name,
                Consumable_Product__c,
                Recordtypeid,
                Guarantee_period_for_products__c,
                Sterilization_limit__c,
                Box_Piece__c
         List<Consumable_order_details2__c> orderkucun = [SELECT Id,Bar_Code__c, Name,Consumable_Product__c,
                                                        Recordtypeid,Guarantee_period_for_products__c,
                                                        Sterilization_limit__c,Box_Piece__c
            FROM Consumable_order_details2__c
            WHERE
                Dealer_Arrive__c = TRUE
                AND Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                AND Bar_Code__c != NULL
                AND Product_Type__c LIKE :userPro_Typestr
                                                        WHERE Dealer_Arrive__c = true
                                                        AND Dealer_Shipment__c = false
                                                        AND Dealer_Saled__c = false
                                                        AND Dealer_Returned__c = false
                                                        AND Lose_Flag__c = false
                                                        AND Bar_Code__c !=null
                                                        AND Product_Type__c like :userPro_Typestr
                AND Dealer_Info_text__c = :accountName
                AND Arrive_Owner_Work_Location__c = :userWorkLocation
            ORDER BY Consumable_Product__c, Sterilization_limit__c ASC
        ];
                                                        ORDER BY Consumable_Product__c, Sterilization_limit__c asc ];
        //--------UpdateEnd-----XHL--------------20180929-------------
        for (Integer i = 0; i < orderkucun.size(); i++) {
            if (productkucun.containsKey(orderkucun[i].Consumable_Product__c)) {
@@ -637,19 +567,17 @@
                }
            }
        }
        List<AggregateResult> overlimitdatedetails = [
            SELECT Asset_Model_No__c prodName, Box_Piece__c BoxPiece, count(id) countid
        List<AggregateResult>  overlimitdatedetails = [SELECT Asset_Model_No__c prodName ,
                                            Box_Piece__c BoxPiece,count(id) countid
            FROM Consumable_order_details2__c
            WHERE
                Bar_Code__c IN :barcodekucun
                AND Dealer_Arrive__c = TRUE
                AND Dealer_Shipment__c = FALSE
                AND Dealer_Saled__c = FALSE
                AND Dealer_Returned__c = FALSE
                AND Lose_Flag__c = FALSE
                                        WHERE Bar_Code__c in :barcodekucun
                                        AND Dealer_Arrive__c = true
                                        AND Dealer_Shipment__c = false
                                        AND Dealer_Saled__c = false
                                        AND Dealer_Returned__c = false
                                        AND Lose_Flag__c = false
            GROUP BY Asset_Model_No__c, Box_Piece__c
            ORDER BY Asset_Model_No__c, Box_Piece__c
        ];
                                        ORDER BY Asset_Model_No__c,Box_Piece__c];
        for (Integer i = 0; i < overlimitdatedetails.size(); i++) {
            overlimitdateorderdetails.add(new ConsumableorderdetailsInfo(overlimitdatedetails[i]));
        }
@@ -744,6 +672,7 @@
            allnumber = 0;
            limitCount = 0;
            overlimitCount = 0;
        }
        public ConsumableorderdetailsInfo(AggregateResult e) {
@@ -809,5 +738,7 @@
        public List<ConsumableorderdetailsInfo> pageCodeRecords;
        @AuraEnabled
        public PaginatedAccounts paginatedAccounts;
    }
}