buli
2023-07-11 0c4796706fc9473d069b620321a54b20a119906c
force-app/main/default/classes/LexSummonsCreatController.cls
@@ -245,7 +245,13 @@
    // 画面初始化
    @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;
@@ -279,9 +285,17 @@
                editAble = true;
            }
            userId = UserInfo.getUserId();
            localuser = [SELECT id, State_Hospital__c FROM User WHERE id = :UserInfo.getUserId()];
            localuser = [
                SELECT id, State_Hospital__c
                FROM User
                WHERE id = :UserInfo.getUserId()
            ];
            //userId = '00510000005QO75';
            user Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
            user Useracc = [
                SELECT accountid, Work_Location__c, UserPro_Type__c
                FROM user
                WHERE id = :userId
            ];
            accountid = Useracc.accountid;
            userWorkLocation = Useracc.Work_Location__c;
            agencyProType = Useracc.UserPro_Type__c;
@@ -299,11 +313,19 @@
            ];
            List<Agency_Hospital_Link__c> AgencyHospitalLink = new List<Agency_Hospital_Link__c>();
            AgencyHospitalLink = [SELECT Id, Hospital__c, Hospital__r.Name FROM Agency_Hospital_Link__c WHERE Agency__c = :accountid];
            AgencyHospitalLink = [
                SELECT Id, Hospital__c, Hospital__r.Name
                FROM Agency_Hospital_Link__c
                WHERE Agency__c = :accountid
            ];
            //add by rentx 2021-3-1 start
            //判断当前经销商下是否有特价医院
            List<hospitalprice__c> hlist = [SELECT id, product__c FROM hospitalprice__c WHERE account__c = :accountid];
            List<hospitalprice__c> hlist = [
                SELECT id, product__c
                FROM hospitalprice__c
                WHERE account__c = :accountid
            ];
            if (hlist == null || hlist.size() == 0) {
                hasHos = false;
            } else {
@@ -737,7 +759,11 @@
                    SELECT Id, Name, Invoice_Date__c, NoConfirmedPrice__c, Invoice_total_amount__c, Invoice_status__c
                    FROM Consumable_order__c
                    WHERE
                        Id IN (SELECT Invoice_Code_link__c FROM Consumable_order_LinkTable__c WHERE Outboundorder_Code_link__c = :ESetId)
                        Id IN (
                            SELECT Invoice_Code_link__c
                            FROM Consumable_order_LinkTable__c
                            WHERE Outboundorder_Code_link__c = :ESetId
                        )
                        AND Invoice_status__c != '草案中'
                ];
@@ -1297,7 +1323,11 @@
            // 显示数据条数信息
            //    makeMessage();
            //附件
            attachmentinfo = [SELECT Id, Name, OwnerId FROM Attachment WHERE parentid = :ESetId];
            attachmentinfo = [
                SELECT Id, Name, OwnerId
                FROM Attachment
                WHERE parentid = :ESetId
            ];
            if (attachmentinfo.size() > 0) {
                for (Integer i = 0; i < attachmentinfo.size(); i++) {
                    attachmentRecoeds.add(new ConsumableorderdetailsInfo(attachmentinfo[i]));
@@ -1394,7 +1424,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(), '');
        }
    }
@@ -2055,7 +2085,11 @@
        //特价医院出库非本医院维护的特价商品时,报错 非特价医院出库维护在医院特价关系表的产品时 报错
        if (coc.SummonsForDirction__c != '互相调货') {
            //非特价医院出库特价产品时 报错(当前经销商下没有特价医院除外)
            List<hospitalprice__c> hopList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid];
            List<hospitalprice__c> hopList = [
                SELECT id, hospital__c, product__c
                FROM hospitalprice__c
                WHERE account__c = :accountid
            ];
            //经销商对应医院下的所有特价产品
            Map<String, String> proMap = new Map<String, String>();
            //经销商下的所有特价产品
@@ -2122,11 +2156,7 @@
                    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) + ' 的特价',
                        ''
                    );
                }
@@ -2183,7 +2213,10 @@
                    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 (
@@ -2215,9 +2248,7 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
@@ -2233,9 +2264,7 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
@@ -2246,7 +2275,11 @@
            insert p;
            ESetId = p.id;
            List<Consumable_order__c> detailName = new List<Consumable_order__c>();
            detailName = [SELECT id, Name FROM Consumable_order__c WHERE id = :ESetId];
            detailName = [
                SELECT id, Name
                FROM Consumable_order__c
                WHERE id = :ESetId
            ];
            Integer i = 1;
            for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
                if (ass.check == true) {
@@ -2341,7 +2374,10 @@
                        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 (
@@ -2367,9 +2403,7 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
@@ -2384,9 +2418,7 @@
                                return new ResponseBodyLWC(
                                    'Error',
                                    500,
                                    '消耗品' +
                                    ass.orderdetails1.Consumable_Product__r.Name__c +
                                    '库存不足',
                                    '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足',
                                    ''
                                );
                            }
@@ -2422,7 +2454,11 @@
            }
            update p;
            List<Consumable_orderdetails__c> qs = new List<Consumable_orderdetails__c>();
            qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
            qs = [
                SELECT Id
                FROM Consumable_orderdetails__c
                WHERE Consumable_order__c = :ESetId
            ];
            if (qs.size() > 0) {
                delete qs;
            }
@@ -2534,7 +2570,7 @@
        //         FROM Account
        //         WHERE
        //             // Name = '奥林巴斯(北京)销售服务有限公司'
        //             // AND
        //             // AND
        //             Name LIKE :nameCondition
        //             AND RecordType.DeveloperName = 'AgencyContract'
        //             AND Contract_Decide_Start_Date__c >= :thisDatetime
@@ -2550,7 +2586,7 @@
        //         FROM Account
        //         WHERE
        //             // Name = '奥林巴斯(北京)销售服务有限公司'
        //             // AND
        //             // AND
        //             Name LIKE :nameCondition
        //             AND RecordType.DeveloperName = 'AgencyContract'
        //             AND Contract_Decide_Start_Date__c >= :thisDatetime
@@ -2561,7 +2597,6 @@
        //     ];
        // }
        Date today = Date.today();
        //Date today = Date.newInstance(2023, 3, 1);
        Integer thisMonth = today.month();
@@ -2570,7 +2605,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);
@@ -2580,14 +2615,18 @@
        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') {
@@ -2689,15 +2728,23 @@
    //删除附件
    @AuraEnabled
    public static ResponseBodyLWC deleteAtt(String contentVersionId){
    public static ResponseBodyLWC deleteAtt(String contentVersionId) {
        try {
            ContentVersion conVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionId];
            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(), '');
        }
    }
@@ -2758,7 +2805,11 @@
        try {
            List<Consumable_order__c> qs = new List<Consumable_order__c>();
            List<Consumable_orderdetails__c> Dqs = new List<Consumable_orderdetails__c>();
            Dqs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
            Dqs = [
                SELECT Id
                FROM Consumable_orderdetails__c
                WHERE Consumable_order__c = :ESetId
            ];
            qs = [SELECT Id FROM Consumable_order__c WHERE Id = :ESetId];
            if (Dqs.size() > 0 || qs.size() > 0) {
                delete Dqs;
@@ -2776,6 +2827,7 @@
    }
    // Data Bean
    @TestVisible
    class ConsumableorderdetailsInfo implements Comparable {
        @AuraEnabled
        public Boolean check { get; set; }
@@ -2915,7 +2967,7 @@
            }
        }
    }
    @TestVisible
    class ConsumableorderdetailsInfoLwc {
        @AuraEnabled
        public Boolean check { get; set; }
@@ -2993,4 +3045,4 @@
        @AuraEnabled
        public Integer recordEnd { get; set; }
    }
}
}