// xudan 20160106 Arrival_wh_time__c -> Arrival_wh_time2__c（回库はSet単位なので、積み上げ項目使わず）
//RentalFixtureManage5Test
public without sharing class EquipmentSetShippmentReceived1Controller {
    public Rental_Apply_Equipment_Set__c es { get; set; }
    public List<EsdInfo> esdList { get; set; }
    
    public Boolean saveBtnDisabled { get; private set; }
    public boolean ReturnRefuse {get;private set;}
    public String ErrorMessage {get; set;}
    public String CDSFinished {get;set;}
    public boolean LostFlg {get;set;}
    public String SR_status { get; private set; }
    public String Step_status { get; private set; }
    public Boolean needCDS { get; private set; }
    public String open_type { get; private set; }
    public Boolean done_flg { get; set; }
    public String Raid {get;set;}
    private String Id;
    //20231127 sx 贸易合规二期 add
    public Boolean trade_fag {get; set;}
    public String trade_String {get; set;}
    
    public Integer getEsdListSize() {
        return esdList.size();
    }
    
    public EquipmentSetShippmentReceived1Controller() {
//        Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
        Id = ApexPages.currentPage().getParameters().get('id');
        if (SR_status == null) {
            SR_status = ApexPages.currentPage().getParameters().get('type');
        }
        if (Step_status == null) {
            Step_status = ApexPages.currentPage().getParameters().get('step');
        }
        if (open_type == null) {
            open_type = ApexPages.currentPage().getParameters().get('open');
        }
    }
    
    // 画面初始化
    public PageReference init() {
        es = new Rental_Apply_Equipment_Set__c();
        esdList = new List<EsdInfo>();
        done_flg = false;
        //20231127 sx 贸易合规二期 add
        trade_fag = false;
        Set<Id> esIds = new Set<Id>();
        saveBtnDisabled = false;
        ReturnRefuse = true;
        ErrorMessage = '';
        if (Id != null) {
            //一览id分割
            List<String> ids = Id.split(',');
            // 当前User
            String userid = Userinfo.getUserId();
            User user = [select Id,Name from User where Id = :userid];
            // 备品set
            List<Rental_Apply_Equipment_Set__c> esList = [select Yi_StockDown__c, Cancel_Select__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c
                                            from Rental_Apply_Equipment_Set__c
                                           where (Rental_Apply__r.Name in :ids or Id in :Ids)
                                             //AND Cancel_Select__c = False
                                            ];

            //List<Fixture_Set__c> esList = [select Id, Name, CDS_staff__c, Shippment_loaner_time__c, Received_loaner_time__c, 
            //                                       delivery_company__c, Return_to_wh_staff__c, Return_to_wh_staff__r.Name, Fedex_number__c, Distributor_method__c,
            //                                       Return_delivery_company__c,Return_wh_chenk_staff__c, Received_confirmation_staff__c, Received_confirmation_staff__r.Name, Return_Fedex_number__c, Return_Distributor_method__c,
            //                                       Arrival_wh_time2__c, Asset_return_time__c,
            //                                       CDS_complete__c, Arrival_in_wh__c, StockDown__c,
            //                                       Lost_item_check_time__c,Last_Reserve_Rental_Apply_Fixture_Set__c,
            //                                       StockDown_time__c
            //                                  from Fixture_Set__c where Name = :Id];
            if (esList.size() > 0) {
                //es = esList[0];
                for (Rental_Apply_Equipment_Set__c raes : esList) {
                    if (raes.Yi_StockDown__c > 0 || raes.Cancel_Select__c == false) {
                        esIds.add(raes.Id);
                        Raid = raes.Rental_Apply__c;
                    }
                }
            } else {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '备品不存在'));
                saveBtnDisabled = true;
                return null;
            }
            //检查验证规则修理最终检测日
            /*   todo
            List<Rental_Apply_Equipment_Set__c> CheckRAES = [select id,Name,RAES_Status__c,Rental_Apply__c,Rental_Apply__r.Repair__c,Cancel_Date__c,Fixture_Set__c 
                    from Rental_Apply_Equipment_Set__c where id=:es.Last_Reserve_Rental_Apply_Equipment_Set__c];
            Rental_Apply_Equipment_Set__c Ra_c = new Rental_Apply_Equipment_Set__c();
            Rental_Apply__c Rac = new Rental_Apply__c();
            if(CheckRAES.size()>0){
                Ra_c = CheckRAES[0];
                Raid = Ra_c.Rental_Apply__c;
            }
            system.debug(Ra_c.Rental_Apply__r.Repair__c );
            List<Rental_Apply__c> CheckError = new List<Rental_Apply__c>();
            CheckError = [Select id,name,repair__c,repair__r.Return_Without_Repair_Date__c,repair__r.Repair_Final_Inspection_Date__c,repair__r.Repair_Shipped_Date__c,
                                Campaign__c,Campaign__r.Status
                                            from Rental_Apply__c where id=:Ra_c.Rental_Apply__c
                                            and RA_Status__c !='取消'
                                            and RA_Status__c !='删除'];
            if(CheckError.size()>0){
                Rac = CheckError[0];
            }
            */
            
            //system.debug('All::::'+Rac.repair__r.Repair_Final_Inspection_Date__c);
            // system.debug('All::::'+Rac.repair__c);
            //  system.debug('All::::'+Ra_c.RAES_Status__c);
            // 本番暂不上线该功能，启用后不能入库操作感觉不对
            
        }

        // 备品set明细
        List<Rental_Apply_Equipment_Set_Detail__c> eList = [
                select SerialNumber_F__c, FSD_Is_OneToOne__c, OneToOne_Flag__c, Is_Body__c, FSD_OneToOneAccessory_Cnt__c, Pre_After_Inspection_elapsed_days__c, Asset__r.WH_location__c, Shipment_request_time2__c, Fixture_Name_F__c, Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name, Fixture_QRCode_F__c, Rental_Apply_Equipment_Set__r.Name, Pre_inspection_time__c, StockDown__c, StockDown_time__c, Id, Name, Asset__c, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product_Serial_No__c,
                       Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c,
                       Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c,
                       Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
                       Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c
                  from Rental_Apply_Equipment_Set_Detail__c
                 where Rental_Apply_Equipment_Set__c in :esIds
                   AND Cancel_Select__c = False
                 order by Rental_Apply_Equipment_Set__r.Name, Rental_Apply_Equipment_Set__c, Name
        ];
        
        for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
            EsdInfo ei = new EsdInfo(esd);
            if (esd.Inspection_result__c == null && esd.Shipment_request_time2__c != null) ei.editable = true;
            esdList.add(ei);
            if (SR_status == 'Received') {
                if (esd.Loaner_CDS_Info__c == '需要清洗') {
                    needCDS = true;
                    break;
                }
            }
        }

        //两个sql文检索的话，顺序会乱
        /*
        List<Rental_Apply_Equipment_Set_Detail__c> eList2 = [
                select Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name, Fixture_QRCode_F__c, Rental_Apply_Equipment_Set__r.Name, Pre_inspection_time__c, StockDown__c, StockDown_time__c, Id, Name, Asset__c, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product_Serial_No__c,
                       Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c,
                       Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c,
                       Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
                       Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c
                  from Rental_Apply_Equipment_Set_Detail__c
                 where Rental_Apply_Equipment_Set__c in :esIds and Shipment_request_time2__c <> null and Id not in :esdIds
                 order by Rental_Apply_Equipment_Set__c, Name
        ];
        for (Rental_Apply_Equipment_Set_Detail__c esd : eList2) {
            esdIds.add(esd.Id);
            EsdInfo esi = new EsdInfo(esd);
            esi.editable = false;
            esdList.add(esi);
        }
        */

        Step_status = '下架';
        if (esdList.size() <= 0) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '没有备品set明细'));
            saveBtnDisabled = true;
            return null;
        }
        system.debug('=====' + Step_status);
        system.debug('=====' + open_type);

        return null;
    }

    // Step 切り替えボタン、发货前-检测
    public PageReference Shippment1() {
        Step_status = '发货前';
        return new PageReference('/apex/EquipmentSetShippmentReceived2?id=' + this.Id + '&type=' + this.SR_status + '&step=' + this.Step_status + '&open=' + this.open_type);
    }

    //20231127 sx start 贸易合规二期
    public PageReference tradeComplianceTWO(){
        trade_string = System.Label.IFTradeComplianceAlert2;
        //在保存之前先校验一下保有设备是否合规
        List<Rental_Apply_Equipment_Set_Detail__c> eList = new List<Rental_Apply_Equipment_Set_Detail__c>();
        List<String> engleList = new List<String>();        //20240201 sx 二期邮件发送 add
        Map<Id, Boolean> stockDownMap = new Map<Id, Boolean>();
        for (EsdInfo esdInfo : esdList) {
            if (!esdInfo.editable) continue;
            Rental_Apply_Equipment_Set_Detail__c esd = esdInfo.rec;
            eList.add(esd);
        }
        List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [select Id, Rental_Apply__r.AccDealerBlacklist__c, Asset__r.Product2.ProTradeComplianceStatus__c FROM Rental_Apply_Equipment_Set_Detail__c WHERE Id IN :eList];

        if(raesdList.size()>0){
            //选中的一览明细 取出所有的产品 进行合规校验
            if(System.Label.TradeComplianceStatusFlagBP =='true' && raesdList[0].Rental_Apply__r.AccDealerBlacklist__c == '2'){
                System.debug('===进来了====');
                for(Rental_Apply_Equipment_Set_Detail__c upd : raesdList){
                    System.debug('===upd.Asset__r.Product2.ProTradeComplianceStatus__c====' + upd.Asset__r.Product2.ProTradeComplianceStatus__c);
                    //接口返回值为0时，代表不合规
                    if(upd.Asset__r.Product2.ProTradeComplianceStatus__c == '0'){
                        engleList.add(upd.Id + '');     //20240201 sx 二期邮件发送 add
                        trade_fag = true;
                    }
                }
            }
        }
        if(engleList.size()>0){
            SendEmailUtil.tradeTempleSend(Raid, '下架', null, engleList);     //20240201 sx 二期邮件发送 add 
        }
        return null;
    }
    //20231127  sx  end  贸易合规二期

    // 保存按钮
    public PageReference save() {

        List<String> statusList = System.Label.StatusProcessState.split(',');

        //检查是否可以继续
        Rental_Apply__c RaTar = [select Name,Campaign__c,
                                        Repair__c,
                                        next_action__c,
                                        QIS_number__r.ReplaceDeliveryDate__c,
                                        demo_purpose2__c,
                                        Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,
                                        Campaign__r.Status,
                                        repair__r.Return_Without_Repair_Date__c,Repair__r.Repair_Final_Inspection_Date__c,Repair__r.Repair_Shipped_Date__c,
                                        Campaign__r.IF_Approved__c,
                                        Campaign__r.Meeting_Approved_No__c,
                                        AccDealerBlacklist__c,//贸易合规 you
                                        //EquipmentGuaranteeFlg__c,//贸易合规 you
                                        Hospital__r.IFTradeComplianceIntercept2__c,// WYL 贸易合规2期 add
                                        Campaign__r.Approved_Status__c      //20220315 sx obpm备品决裁状态相关修改
                                    from Rental_Apply__c 
                                    where id=:Raid];

        // 20230215 ljh DB202301265636 学会取消申请也拦截 start
        // if( RaTar.Campaign__r.Status == '取消'){
        //         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '学会已取消，不能继续操作了'));
        //贸易合规 you
        // && RaTar.EquipmentGuaranteeFlg__c==false
        if (RaTar.Hospital__r.IFTradeComplianceIntercept2__c == 'intercept') {
            SendEmailUtil.tradeTempleSend(Raid, '下架', null, null);      //20240201 sx 邮件发送 add
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '医院在黑名单中，存在贸易合规风险，无法下架，有问题请联系法务部贸易合规窗口'+System.Label.IFTradeComplianceAlertName+'。'));
            return null;
        }else if (RaTar.Hospital__r.IFTradeComplianceIntercept2__c == 'Freeze'){
            SendEmailUtil.tradeTempleSend(Raid, '下架', null, null);      //20240201 sx 邮件发送 add
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '医院在冻结清单中,可能存在贸易合规风险，目前正在评估中（一般需5-10个工作日），暂时无法下架，有问题请联系法务部贸易合规窗口'+System.Label.IFTradeComplianceAlertName+'。'));
                return null;
        }else if(System.Label.TradeComplianceStatusFlagBP =='true' && RaTar.AccDealerBlacklist__c == '1'){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, System.Label.IFTradeComplianceAlertBP));
            return null; 
        }else if( RaTar.Campaign__r.Status == '取消' || RaTar.Campaign__r.Status == '取消申请中' ){
            String tempS = '';
            if(RaTar.Campaign__r.Status == '取消'){
                tempS = '已取消';
            }else{
                tempS = '申请取消中';
            }
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '学会'+tempS+'，不能继续操作了'));
        // 20230215 ljh DB202301265636 学会取消申请也拦截 end
            return null;
            
        }else if(   RaTar.Repair__r.Repair_Final_Inspection_Date__c!=null){
            
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '存在修理最终检测日，不能继续了'));
                return null;
        }else if(   RaTar.repair__r.Return_Without_Repair_Date__c!=null&&RaTar.repair__c!=null ){
            
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '未修理归还日不为空，不能出库'));
                return null;
        }else if(   RaTar.Repair__r.Repair_Shipped_Date__c!=null){
           
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '存在RC修理返送日，不能继续了'));
                return null;
        }
        //1822 yc 20211025 start
        else if(RaTar.demo_purpose2__c=='已购待货' && RaTar.Follow_UP_Opp__r.Shipping_Finished_Day_Func__c!= null){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '已购待货目的，新品已有发货日，不能继续了'));
                return null;
        }else if(RaTar.demo_purpose2__c=='索赔QIS' && RaTar.next_action__c=='无偿更换' && RaTar.QIS_number__r.ReplaceDeliveryDate__c!= null){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '索赔QIS目的，QIS已有新品发货日，不能继续了'));
                return null;
        }
        //1822 yc 20211025 end
        
        //20220225 sx start obpm 下架增加 是否申请决裁勾着没有决裁编号不能进行操作
        else if ( RaTar.Campaign__c!= null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c == null){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '已申请决裁但决裁编码为空'));
            return null;
        }
        //20220225 sx end 下架增加判断

        //20220315 sx start obpm obpm备品决裁状态相关修改
        else if ( RaTar.Campaign__c!= null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(RaTar.Campaign__r.Approved_Status__c) ){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '已申请决裁但决裁状态不符合条件'));
            return null;
        }
        //20220315 sx end obpm obpm备品决裁状态相关修改

        String userid = Userinfo.getUserId();
        List<Rental_Apply_Equipment_Set_Detail__c> eList = new List<Rental_Apply_Equipment_Set_Detail__c>();
        Map<Id, Boolean> stockDownMap = new Map<Id, Boolean>();
        for (EsdInfo esdInfo : esdList) {
            if (!esdInfo.editable) continue;
            Rental_Apply_Equipment_Set_Detail__c esd = esdInfo.rec;
            eList.add(esd);
            stockDownMap.put(esd.Id, esd.StockDown__c);
        }
        Boolean needSaveSet = false;
        Boolean needSaveDetail = false;

        List<Rental_Apply_Equipment_Set_Detail__c> updateList = [select Id, Shipment_request_time2__c from Rental_Apply_Equipment_Set_Detail__c where Id in :eList for update];
        for (Rental_Apply_Equipment_Set_Detail__c upd : updateList) {
            if (upd.Shipment_request_time2__c == null && stockDownMap.get(upd.Id)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '出库指示时间为空，不能下架'));
                break;
            }
        }
        if (ApexPages.hasMessages(ApexPages.severity.Error)) {
            done_flg = false;
            return null;
        }
        
        // TODO 没变化不存
        Map<Id,Id> otoMap = new Map<Id,Id>();
        List<Rental_Apply_Equipment_Set_Detail__c> upsertList = new List<Rental_Apply_Equipment_Set_Detail__c>();
        if (Step_status == '下架') {
            for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
                //if (esd.FSD_OneToOneAccessory_Cnt__c > 0 && esd.Is_Body__c && esd.StockDown__c) {
                if (esd.Is_Body__c && esd.StockDown__c) {
                    if (String.isNotBlank(esd.Asset__c)) {
                        // Asset__c 念のための確認
                        otoMap.put(esd.Rental_Apply_Equipment_Set__c, esd.Asset__c);
                    }
                }
                if (esd.StockDown__c == true && esd.StockDown_time__c == null) {
                    upsertList.add(new Rental_Apply_Equipment_Set_Detail__c(id = esd.id, StockDown__c = true, StockDown_time__c = System.now(), StockDown_staff__c = userid ));
                    //esd.StockDown_time__c = System.now();
                    //esd.StockDown_staff__c = userid;
                }
                if (esd.StockDown__c == false) {
                    upsertList.add(new Rental_Apply_Equipment_Set_Detail__c(id = esd.id, StockDown__c = false, StockDown_time__c = null, StockDown_staff__c = null ));
                    //esd.StockDown_time__c = null;
                    //esd.StockDown_staff__c = null;
                }
            }
            needSaveDetail = true;
        }
        // otoMap を使うため、下記のロジックいらなくなります
        //List<Fixture_OneToOne_Link__c> otolinkList = new List<Fixture_OneToOne_Link__c>();
        //if (otoMap.size() > 0) {
        //    List<AggregateResult> otoList = [ select Rental_Apply_Equipment_Set__c, Asset__c, COUNT(Id) cnt
        //                                        from Rental_Apply_Equipment_Set_Detail__c 
        //                                       where Rental_Apply_Equipment_Set__c in :otoMap.keySet() 
        //                                             and FSD_Is_OneToOne__c = true and OneToOne_Flag__c = true and Asset__c != null
        //                                    group by Rental_Apply_Equipment_Set__c, Asset__c ];
        //    for (AggregateResult oto : otoList) {
        //        String key = String.valueOf(oto.get('Rental_Apply_Equipment_Set__c'));
        //        Id otoMainId = otoMap.get(key);
        //        String otoAssId = String.valueOf(oto.get('Asset__c'));
        //        Integer cnt = Integer.valueOf(oto.get('cnt'));

        //        Fixture_OneToOne_Link__c otolink = new Fixture_OneToOne_Link__c();
        //        otolink.Main_Asset__c = otoMainId;
        //        otolink.Accessory_Asset__c = otoAssId;
        //        otolink.Quantity__c = cnt;
        //        otolinkList.add(otolink);
        //    }
        //}
        
        Savepoint sp = Database.setSavepoint();
        try {
            //if (needSaveSet) ControllerUtil.upRAdEquipmentSet(es);
            //if (needSaveDetail) ControllerUtil.updRAEquipmentSetDetail(eList);
            if (needSaveDetail) FixtureUtil.withoutUpsertObjects(upsertList);

            // otoMap を使うため、下記のロジックいらなくなります
            //if (otolinkList.size() > 0) {
            //    Set<Id> mainIds = new Set<Id>();
            //    for (Fixture_OneToOne_Link__c oto : otolinkList) {
            //        if (String.isBlank(oto.Main_Asset__c) == false) {
            //            mainIds.add(oto.Main_Asset__c);
            //        }
            //    }
            //    //ControllerUtil.delOtOLinkData(mainIds);
            //    //ControllerUtil.updOtOLinkData(otolinkList);
            //    FixtureUtil.delOtOLinkData(mainIds);
            //    //FixtureUtil.withOutInsert(otolinkList);
            //}
            if (!otoMap.isEmpty()) {
                Oly_TriggerHandler.bypass(AssetHandlerCheck.class.getName());
                FixtureUtil.delOtOLinkData(otoMap.values());
                Oly_TriggerHandler.clearBypass(AssetHandlerCheck.class.getName());
            }

            //PageReference ref = new Pagereference('/apex/EquipmentSetShippmentReceived1?id=' + Id + '&type=' + SR_status + '&step=' + this.Step_status + '&open=' + this.open_type);
            //ref.setRedirect(true);
            //return ref;
            done_flg = true;
            return null;
        } catch (Exception ex) {
            system.debug('=====' + ex.getMessage());
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getMessage()+'( '+Step_status+' )'));
            Database.rollback(sp);
            done_flg = false;
            return null;
        }
        
        return null;
    }

    // Step 切り替えボタン、发货-发货运输单号 等
    public PageReference Shippment2() {
        return new PageReference('/apex/EquipmentSetShippmentReceived2?id=' + this.Id);
    }
    
    public class EsdInfo {
        public Rental_apply_equipment_Set_Detail__c rec { get; set; }
        public String imageAssetUploadedTime { get; set; }
        public String imageSerialUploadedTime { get; set; }
        // 回库はSet単位で、明細一つ一つのquickCheck要らない
        public boolean quickCheck { get; set; }
        public boolean editable { get; set; }

        public EsdInfo(Rental_apply_equipment_Set_Detail__c rec) {
            this.rec = rec;
            this.editable = false;
            
            if (rec.Asset__r.Pre_Reserve_RAES_Detail__c != null && rec.Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c != null) {
                this.quickCheck = Datetime.now() < rec.Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c + 30 ? true : false;
            } else {
                this.quickCheck = false;
            }
            
            if (rec.Asset__r.ImageAssetUploadedTime__c != null) {
                imageAssetUploadedTime = rec.Asset__r.ImageAssetUploadedTime__c.format('yyyy/MM/dd HH:mm');
            }
            if (rec.Asset__r.ImageSerialUploadedTime__c != null) {
                imageSerialUploadedTime = rec.Asset__r.ImageSerialUploadedTime__c.format('yyyy/MM/dd HH:mm');
            }
        }
    }

    // 测试类中正确场景都走到了 差点点就i++l 
    @TestVisible private void test() {
        Integer i = 0;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
    }
}