binxie
2023-06-26 b5c5eb130ca0848124f9d136af4be142ad5aac07
force-app/main/default/classes/LexConInvoiceViewController.cls
@@ -388,11 +388,7 @@
        //         attachmentRecoeds.add(new InvoiceOrderInfo(attachmentinfo[i]));
        //     }
        // }
        List<ContentVersion> cvInfo = [
            SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId
            FROM ContentVersion
            WHERE FirstPublishLocationId = :invoiceId
        ];
        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]));
@@ -419,16 +415,17 @@
        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(
@@ -456,12 +453,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) {
@@ -536,6 +533,7 @@
                }
            } 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');
@@ -554,9 +552,7 @@
                        (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);
                    }
                }
@@ -697,12 +693,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;
                    }
@@ -853,8 +849,6 @@
                    delete invoiceLinkdetList;
                }
                //新建发票明细1
                System.debug('===>' + chukudanID);
                System.debug('===>' + chukudanID.size());
                if (chukudanID.size() > 0) {
                    newinvoicedetails1(chukudanID);
                }
@@ -889,7 +883,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);
                    }
@@ -1273,13 +1267,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();
@@ -1305,16 +1299,7 @@
    // 检索(未开发票出库单)
    @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>();
@@ -1324,12 +1309,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>();
@@ -1355,7 +1340,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);
@@ -1411,7 +1396,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>();
@@ -1444,11 +1429,7 @@
    // 提交按钮
    @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>();
@@ -1456,7 +1437,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>();
@@ -1520,8 +1501,6 @@
                        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;
@@ -1542,8 +1521,6 @@
                    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(
@@ -1557,16 +1534,7 @@
                    //     )
                    // );
                    // 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);
@@ -1602,7 +1570,7 @@
        System.debug('res = ' + res);
        return res;
    }
    @TestVisible
    class InvoiceOrderInfo implements Comparable {
        @AuraEnabled
        public Boolean check { get; set; }
@@ -1615,12 +1583,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
@@ -1648,7 +1616,7 @@
        //ContentVersion
        public InvoiceOrderInfo(ContentVersion cv) {
            cvInfo = cv;
            mailSelectOptsMap = new Map<String, String>();
            mailSelectOptsMap = new Map<String,String>();
            mailSelectOptsMap.put('发票和明细', '发票和明细');
            mailSelectOptsMap.put('发票', '发票');
            mailSelectOptsMap.put('明细', '明细');