高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/OPDSortManageController.cls
@@ -271,11 +271,23 @@
        soql += 'if_Newest_HaveOpportunity__c,if_HaveOpportunity__c,if_HaveEquipment__c,PlanProdDetail__c,Cnt_Rentals__c,WorkshopPlace__c,Owner.Name,OPDLendSort__c,OPDLendSortDraft__c,OPDPlan_ImplementDate__c,Status__c,IsJump__c,OrderStatusNum__c,JumpCause__c,Campaign__c,AccountType__c,Account_Laboratory__r.Name,IsSaveOrSubmit__c,OPDLendSortBefore__c';
        soql += ' FROM OPDPlan__c where  Status__c = \'计划中\' '; // 2020-12-09  mzy  update 保存完成后,本部维持原状 AND  OPDPlanSalesdepartment__c = \''+loginUser.Salesdepartment__c+'\'
        if(dateNow.month() != 12){
            soql += 'AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
            soql += 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;  //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            // 20230119 ljh start
            // soql += 'AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
            // soql += 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;  //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            if(dateNow.month() == 1){
                Integer tempYear = year -1;
                soql += 'AND(' ;
                soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+ tempYear;
                soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year + 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
                soql += ')';
            }else{
                soql += 'AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
                soql += 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;  //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            }
            // 20230119 ljh end
        }else if(dateNow.month() == 12){
            soql += 'AND(' ;
            soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;               //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;               //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+nextyear + 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
            soql += ')';
        }
@@ -558,17 +570,24 @@
        Date dateNow = Date.today();
        this.month = dateNow.month();
        this.year = dateNow.year();
        Integer MonthSearch = Integer.valueOf(OPDMonth);  // 20230120 ljh end
        //2020-12-01  mzy  如果检索的是1月则检索今年一整年+明年1月份的所有OPD计划 add
        if(this.month==12){
            this.month=1;
            this.nextyear = this.year+1;  // 2020-12-01  mzy  如果检索的是1月 则检索今年一整年+明年1月份的所有OPD计划 update  
        }else{
            this.month +=1;
            // 20230120 ljh start
            if(MonthSearch == 2 && dateNow.month() == 1){
                this.year = dateNow.year() - 1;
                this.nextyear = dateNow.year();
            }
            // 20230120 ljh end
        }
        //System.debug('年份是 : '+this.year);
        Integer MonthSearch = Integer.valueOf(OPDMonth);
        // Integer MonthSearch = Integer.valueOf(OPDMonth); // 20230120 ljh end
        if(month != MonthSearch){ 
            month = MonthSearch;
            month = MonthSearch;
            if (MonthSearch == 1){
              this.nextyear = dateNow.year() + 1;
            }
@@ -581,11 +600,22 @@
        soql +=' FROM OPDPlan__c where Status__c=\'计划中\'';  
        // 2020-12-01  mzy  如果是12月则检索今年一整年+明年1月份的所有OPD计划 update start
        if(this.month != 1){
          soql += ' AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
          soql += ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;   //2020-11-16  mzy update 检索月  修改例如,11及11月以前
        // 20230120 ljh start
          // soql += ' AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
          // soql += ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;   //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            if(this.month == 2){
                soql += 'AND(' ;
                soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;           //2020-11-16  mzy update 检索月  修改例如,11及11月以前
                soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+nextyear + ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
                soql += ')';
            }else{
                soql += ' AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
                soql += ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;   //2020-11-16  mzy update 检索月  修改例如,11及11月以前
            }
        // 20230120 ljh end
        }else if(this.month == 1){
          soql += 'AND(' ;
          soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;           //2020-11-16  mzy update 检索月  修改例如,11及11月以前
          soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;           //2020-11-16  mzy update 检索月  修改例如,11及11月以前
          soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+nextyear + ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
          soql += ')';
        }