buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
force-app/main/default/classes/LexSummonsCreatController.cls
@@ -245,13 +245,7 @@
    // 画面初始化
    @AuraEnabled
    public static ResponseBodyLWC init(
        String ESetidJs,
        String statusEdit,
        Integer pageSizeLWC,
        Integer pageTokenLWC,
        String arriveorderLWC
    ) {
    public static ResponseBodyLWC init(String ESetidJs, String statusEdit, Integer pageSizeLWC, Integer pageTokenLWC,String arriveorderLWC) {
        try {
            firstInit(ESetidJs);
            statusEdit = statusEdit;
@@ -349,6 +343,7 @@
            for (AggregateResult orderdetail : orderdetailCount) {
                zaikuId.add(String.valueOf(orderdetail.get('cpc')));
            }
            System.debug('orderdetailCount = ' + orderdetailCount);
            System.debug('sqlagencyProType = ' + sqlagencyProType);
            System.debug('userWorkLocation = ' + userWorkLocation);
            System.debug('accountName = ' + accountName);
@@ -392,6 +387,7 @@
                    for (Integer i = 0; i < product2Selected.size(); i++) {
                        MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
                    }
                    System.debug('MidMap = ' + MidMap);
                    for (Integer i = 0; i < CountDel.size(); i++) {
                        String str = '';
                        if (CountDel[i].hospitalSpecialOffer__c) {
@@ -399,6 +395,8 @@
                        } else {
                            str = 'notHos';
                        }
                        System.debug('CountDel[i].Consumable_Product__c= ' + CountDel[i].Consumable_Product__c);
                        System.debug('CountDel[i].Consumable_Product__c + str= ' + CountDel[i].Consumable_Product__c + str);
                        //明细2对应的产品存在于MidMap中
                        if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
                            //设置map中key的后缀 用于区分医院特价和非医院特价
@@ -1400,7 +1398,7 @@
            System.debug('res = ' + res);
            return res;
        } catch (Exception e) {
            return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
            return new ResponseBodyLWC('Error',500, e.getMessage() + e.getLineNumber(), '');
        }
    }
@@ -1417,6 +1415,7 @@
            WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
            GROUP BY Category4_text__c
        ];
        System.debug('category4List ' + category4List);
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String, String>();
@@ -1434,6 +1433,7 @@
            GROUP BY Category5_text__c
        ];
        System.debug('category5List ' + category5List);
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String, String>();
@@ -1465,6 +1465,7 @@
            WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
            GROUP BY Category4_text__c
        ];
        System.debug('category4List ' + category4List);
        category4OptionList = new List<SelectOption>();
        category4OptionList.add(new SelectOption('', '-无-'));
        category4OptionMap = new Map<String, String>();
@@ -1482,6 +1483,7 @@
            GROUP BY Category5_text__c
        ];
        System.debug('category5List ' + category5List);
        category5OptionList = new List<SelectOption>();
        category5OptionList.add(new SelectOption('', '-无-'));
        category5OptionMap = new Map<String, String>();
@@ -1549,6 +1551,8 @@
                AND Arrive_Owner_Work_Location__c = :userWorkLocationLwc
            GROUP BY Consumable_Product__c, Box_Piece__c
        ];
        System.debug('orderdetailCount = ' + orderdetailCount);
        for (AggregateResult orderdetail : orderdetailCount) {
            zaikuId.add(String.valueOf(orderdetail.get('cpc')));
        }
@@ -2128,7 +2132,11 @@
                    return new ResponseBodyLWC(
                        'Error',
                        500,
                        '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0, proStr.length() - 1) + ' 的特价',
                        '经销商:' +
                        coc.Order_ForDealerText__c +
                        ' 没有消耗品:' +
                        proStr.substring(0, proStr.length() - 1) +
                        ' 的特价',
                        ''
                    );
                }
@@ -2185,10 +2193,7 @@
                    if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '医院试用') {
                        return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)', '');
                    }
                    if (
                        (ass.orderdetails1.Delivery_List_RMB__c == null || ass.orderdetails1.Delivery_List_RMB__c == 0) &&
                        coc.SummonsForDirction__c != '医院试用'
                    ) {
                    if ((ass.orderdetails1.Delivery_List_RMB__c == null || ass.orderdetails1.Delivery_List_RMB__c == 0) && coc.SummonsForDirction__c != '医院试用') {
                        return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)', '');
                    }
                    if (
@@ -2220,7 +2225,9 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    ''
                                );
                            }
@@ -2236,7 +2243,9 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    ''
                                );
                            }
@@ -2342,10 +2351,7 @@
                        return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)', '');
                    }
                    Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
                    if (
                        (ass.orderdetails1.Delivery_List_RMB__c == null || ass.orderdetails1.Delivery_List_RMB__c == 0) &&
                        coc.SummonsForDirction__c != '医院试用'
                    ) {
                    if ((ass.orderdetails1.Delivery_List_RMB__c == null || ass.orderdetails1.Delivery_List_RMB__c == 0) && coc.SummonsForDirction__c != '医院试用') {
                        return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)', '');
                    }
                    if (
@@ -2371,7 +2377,9 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    ''
                                );
                            }
@@ -2386,7 +2394,9 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    ''
                                );
                            }
@@ -2404,6 +2414,7 @@
                        InsAfterDel.Name = p.name + '-' + str;
                        InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
                        InsAfterDel.Consumable_order__c = ESetId;
                        System.debug('ass.Prod.id:' + ass.Prod.id);
                        InsAfterDel.Consumable_Product__c = ass.Prod.id;
                        InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
                        InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
@@ -2534,7 +2545,7 @@
        //         FROM Account
        //         WHERE
        //             // Name = '奥林巴斯(北京)销售服务有限公司'
        //             // AND
        //             // AND
        //             Name LIKE :nameCondition
        //             AND RecordType.DeveloperName = 'AgencyContract'
        //             AND Contract_Decide_Start_Date__c >= :thisDatetime
@@ -2550,7 +2561,7 @@
        //         FROM Account
        //         WHERE
        //             // Name = '奥林巴斯(北京)销售服务有限公司'
        //             // AND
        //             // AND
        //             Name LIKE :nameCondition
        //             AND RecordType.DeveloperName = 'AgencyContract'
        //             AND Contract_Decide_Start_Date__c >= :thisDatetime
@@ -2561,6 +2572,7 @@
        //     ];
        // }
        Date today = Date.today();
        //Date today = Date.newInstance(2023, 3, 1);
        Integer thisMonth = today.month();
@@ -2569,7 +2581,7 @@
        Integer lastYear = today.year() - 1;
        Integer thisYear = today.year();
        Integer nextYear = today.year() + 1;
        Date lastDatetime = Date.newInstance(lastYear, 4, 1);
        Date thisDatetime = Date.newInstance(thisYear, 4, 1);
        Date thisDatetime2 = Date.newInstance(thisYear, 7, 1);
@@ -2579,14 +2591,14 @@
        System.debug('thisDatetime2 = ' + thisDatetime2);
        System.debug('nextDatetime = ' + nextDatetime);
        System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId());
        User UserProTypecTemp = [SELECT UserPro_Type__c FROM User WHERE id = :UserInfo.getUserId()];
        User UserProTypecTemp = [select UserPro_Type__c from User where id =: UserInfo.getUserId()];
        String sql = 'SELECT id, Parentid FROM Account WHERE Parent.Name LIKE :nameCondition ';
        if (thisMonth < 4) {
        if(thisMonth < 4){
            sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :thisDatetime2 ';
        } else if (thisMonth >= 4 && thisMonth <= 6) {
        }else if(thisMonth >= 4 && thisMonth <= 6){
            sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :nextDatetime ';
        } else {
        }else{
            sql += 'AND Contract_Decide_Start_Date__c >= :thisDatetime AND Contract_Decide_End_Date__c < :nextDatetime ';
        }
        if (UserProTypecTemp.UserPro_Type__c == 'ENG') {
@@ -2674,11 +2686,30 @@
        ResponseBodyLWC res = new ResponseBodyLWC();
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        List<ContentVersion> cvList = [
            SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate, ContentDocumentId
            FROM ContentVersion
            WHERE FirstPublishLocationId = :recordId
        ];
        List<ContentVersion> cvList = new List<ContentVersion>();
        List<ContentDocumentLink> links = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :recordId];
        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++) {
                    cvList.add(cvInfo[i]);
                }
            }
        }
        // List<ContentVersion> cvList = [
        //     SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate, ContentDocumentId
        //     FROM ContentVersion
        //     WHERE FirstPublishLocationId = :recordId
        // ];
        data.put('cvList', cvList);
        res.status = 'Success';
        res.code = 200;
@@ -2688,15 +2719,15 @@
    //删除附件
    @AuraEnabled
    public static ResponseBodyLWC deleteAtt(String contentVersionId) {
    public static ResponseBodyLWC deleteAtt(String contentVersionId){
        try {
            ContentVersion conVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionId];
            String contentDocumentId = conVersion.ContentDocumentId;
            ContentDocument conDocument = [SELECT Id FROM ContentDocument WHERE Id = :contentDocumentId];
            ContentDocument conDocument =  [SELECT Id FROM ContentDocument where Id = :contentDocumentId];
            delete conDocument;
            return new ResponseBodyLWC('Success', 200, '', '');
            return new ResponseBodyLWC('Success',200,'','');
        } catch (Exception e) {
            return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
            return new ResponseBodyLWC('Error',500, e.getMessage() + e.getLineNumber(), '');
        }
    }
@@ -2863,8 +2894,9 @@
            hospitalSpecialOffer = false;
            hosPro = false;
        }
        //附件
        @TestVisible
        public ConsumableorderdetailsInfo(Attachment e) {
            concc = e;
            hospitalSpecialOffer = false;
@@ -2915,7 +2947,6 @@
            }
        }
    }
    @TestVisible
    class ConsumableorderdetailsInfoLwc {
        @AuraEnabled