force-app/main/default/classes/RollupToHPBatch.cls
@@ -765,11 +765,25 @@
           convertCurrency(RANK_D_inc_tax__c), convertCurrency(RANK_E_inc_tax__c),
           Today_Rate__c, Trade__c, convertCurrency(Forecast_Amount_All_F__c), convertCurrency(ShippedAmount__c),
           Opp_Actual_ThousandY__c, BO_Forecast_ThousandY__c,
           OP_ThousandY__c, Opp_Forecast_ThousandY__c,
           //Opportunity_ThousandY__c,  //lt 20220318 注释
           Amount_Without_Tax_Thousand_F__c,
           // 20220722 ljh SWAG-CE6A58 update start
           // OP_ThousandY__c, Opp_Forecast_ThousandY__c,
           // Opportunity_ThousandY__c, Amount_Without_Tax_Thousand_F__c,
           OP_ThousandY_Target__c, Opp_Forecast_ThousandY__c,
           Opportunity_ThousandY_Target__c, Amount_Without_Tax_Thousand_F__c,
           // 20220722 ljh SWAG-CE6A58 update end
           Hospital__c, Department_Class__c
           , OCSM_RMB_Without_Tax_1000TR__c//20220111 SWAG-C8MBB6 加7.询价 lt
           //20230222   DB202302339407 you start
           ,LostPrices__c
           ,convertCurrency(Dealer_Final_Price__c)
           ,order_Date_For_Report__c
           ,StageName__c
           //20230222   DB202302339407 you end
           //20230327  DB202303372329 you start
           ,OP_ThousandY_Order__c
           ,OrderThisYearQY__c
           ,Opportunity__c
           //20230327  DB202303372329 you end
           from Opportunity
           where Hospital__c in :hpList
         ]) {
@@ -791,19 +805,43 @@
      Decimal o1 = opp.Opp_Actual_ThousandY__c == null ? 0 : opp.Opp_Actual_ThousandY__c;
      Decimal o2 = opp.BO_Forecast_ThousandY__c == null ? 0 : opp.BO_Forecast_ThousandY__c;
      Decimal o3 = opp.OP_ThousandY__c == null ? 0 : opp.OP_ThousandY__c;
      // 20220722 ljh SWAG-CE6A58 update start
      // Decimal o3 = opp.OP_ThousandY__c == null ? 0 : opp.OP_ThousandY__c;
      Decimal o3 = opp.OP_ThousandY_Target__c == null ? 0 : opp.OP_ThousandY_Target__c;
      // 20220722 ljh SWAG-CE6A58 update end
      Decimal o4 = opp.Opp_Forecast_ThousandY__c == null ? 0 : opp.Opp_Forecast_ThousandY__c;
      //Decimal o5 = opp.Opportunity_ThousandY__c == null ? 0 : opp.Opportunity_ThousandY__c;//lt 20220318 注释
      //lt 20220318 start
      Decimal o5 = 0 ;
      //lt 20220318 start
      // 20220722 ljh SWAG-CE6A58 update start
      // Decimal o5 = opp.Opportunity_ThousandY__c == null ? 0 : opp.Opportunity_ThousandY__c;
      Decimal o5 = opp.Opportunity_ThousandY_Target__c == null ? 0 : opp.Opportunity_ThousandY_Target__c;
      // 20220722 ljh SWAG-CE6A58 update end
      Decimal o6 = opp.Amount_Without_Tax_Thousand_F__c == null ? 0 : opp.Amount_Without_Tax_Thousand_F__c;
      //20220111 SWAG-C8MBB6 加7.询价 lt  start
      Decimal o7 = opp.OCSM_RMB_Without_Tax_1000TR__c == null ? 0 : opp.OCSM_RMB_Without_Tax_1000TR__c;
      //20220111 SWAG-C8MBB6 加7.询价 lt  end
      setOppAmount(hpacc, o1, o2, o3, o4, o5, o6, o7);
      setOppAmount(dcacc, o1, o2, o3, o4, o5, o6, o7);
      //20230222 you start
      Decimal o8 = 0;
      Decimal o9 = 0;
      Decimal o10 = 0;
      if(opp.order_Date_For_Report__c>= thisYd && opp.order_Date_For_Report__c < nextYd){
        o8 = opp.LostPrices__c == null ? 0 : opp.LostPrices__c;
        if(opp.StageName__c !='失单' && opp.StageName__c !='取消'){
          o9 = opp.Dealer_Final_Price__c == null ? 0 : opp.Dealer_Final_Price__c / 1.13 / 1000;
        }
        o10 = o8 + o9;
      }
      //20230222 you end
      //20230327  DB202303372329 you start
      Decimal o11 = opp.OP_ThousandY_Order__c == null ? 0 : opp.OP_ThousandY_Order__c;
      Decimal o12 = opp.OrderThisYearQY__c == null ? 0 : opp.OrderThisYearQY__c;
      Decimal o13 = opp.Opportunity__c == null ? 0 : opp.Opportunity__c;
      //20230327  DB202303372329 you end
      setOppAmount(hpacc, o1, o2, o3, o4, o5, o6, o7,o8,o9,o10,o11,o12,o13);
      setOppAmount(dcacc, o1, o2, o3, o4, o5, o6, o7,o8,o9,o10,o11,o12,o13);
    }
    // 报告书
    for (Report__c report : [
@@ -1342,6 +1380,10 @@
    acc.Asset_Cnt_TB__c = 0;
    acc.Asset_Cnt_USG400__c = 0;
    //SWAG-BSC5WP you-20201021 end
    //20220601 WLIG-CEWDWS you start
    acc.Asset_Cnt_TB_0520__c = 0;
    acc.Asset_Cnt_TB_0535__c = 0;
    //20220601 WLIG-CEWDWS you end
    //20200825 ljh SWAG-BRY6PF  add start
    for (Integer columnNameInt = targetmonth + intMonth; columnNameInt <= targetmonth; columnNameInt++) {
@@ -1374,14 +1416,25 @@
    acc.Opp_Actual_ThousandY__c = 0;
    acc.BO_Forecast_ThousandY__c = 0;
    acc.OP_ThousandY__c = 0;
    acc.Opp_Forecast_ThousandY__c = 0;
    //acc.Opportunity_ThousandY__c = 0;//lt 20220318 注释
    acc.Opportunity_ThousandY__c = 0;
    acc.Amount_Without_Tax_Thousand__c = 0;
    //20230327  DB202303372329 you start
    acc.OP_ThousandY_Order__c = 0;
    acc.OrderThisYearQY__c =0;
    acc.Opportunity__c =0;
    //20230327  DB202303372329 you end
    //20220111 SWAG-C8MBB6 加7.询价 lt  start
    acc.AllOP_ThousandY__c = 0;
    //20220111 SWAG-C8MBB6 加7.询价 lt  end
    //20230222 you start
    acc.LostPrices__c = 0;
    acc.Dealer_Final_Price__c = 0;
    acc.HospitalTransactionAmount__c = 0;
    //20230222 you end
    acc.Important_product1__c = 0;
    acc.Important_product2__c = 0;
@@ -1570,7 +1623,11 @@
    acc.Opp_cnt_OTVS300__c = 0;
    acc.Opp_cnt_ESG400__c = 0;
    acc.Opp_cnt_TB__c = 0;
    //20220601 WLIG-CEWDWS you start
    acc.Opp_cnt_TB_0520__c = 0;
    acc.Opp_cnt_TB_0535__c = 0;
    //20220601 WLIG-CEWDWS you end
    acc.Delivery_cnt_290MiroBF__c = 0;
    acc.Delivery_cnt_290MiroGI__c = 0;
    acc.Delivery_cnt_290MiroGI_Plus__c = 0;
@@ -1579,6 +1636,10 @@
    acc.Delivery_cnt_OTVS300__c = 0;
    acc.Delivery_cnt_ESG400__c = 0;
    acc.Delivery_cnt_TB__c = 0;
    //20220601 WLIG-CEWDWS you start
    acc.Delivery_cnt_TB_0520__c = 0;
    acc.Delivery_cnt_TB_0535__c = 0;
    //20220601 WLIG-CEWDWS you end
    
    acc.Order_cnt_290MiroBF__c = 0;
    acc.Order_cnt_290MiroGI__c = 0;
@@ -1588,6 +1649,10 @@
    acc.Order_cnt_OTVS300__c = 0;
    acc.Order_cnt_ESG400__c = 0;
    acc.Order_cnt_TB__c = 0;
    //20220601 WLIG-CEWDWS you start
    acc.Order_cnt_TB_0520__c = 0;
    acc.Order_cnt_TB_0535__c = 0;
    //20220601 WLIG-CEWDWS you end
    acc.OPD_USG400__c = 0;
    acc.OPD_OTV_S400__c = 0;
@@ -1600,6 +1665,10 @@
    acc.OPD_ESG400__c = 0;
    acc.OPD_TB__c = 0;
    // SWAG-BQ75WE 20200609 End
    //20220601 WLIG-CEWDWS you start
    acc.OPD_TB_0520__c = 0;
    acc.OPD_TB_0535__c = 0;
    //20220601 WLIG-CEWDWS you end
    
  }
@@ -1763,16 +1832,27 @@
    acc.ShippedAmount_HP__c += sa;
  }
  private void setOppAmount(Account2__c acc, Decimal o1, Decimal o2, Decimal o3, Decimal o4, Decimal o5, Decimal o6, Decimal o7) {
  private void setOppAmount(Account2__c acc, Decimal o1, Decimal o2, Decimal o3, Decimal o4, Decimal o5, Decimal o6, Decimal o7,Decimal o8,Decimal o9,Decimal o10,Decimal o11,Decimal o12,Decimal o13) {
    acc.Opp_Actual_ThousandY__c += o1;
    acc.BO_Forecast_ThousandY__c += o2;
    acc.OP_ThousandY__c += o3;
    acc.Opp_Forecast_ThousandY__c += o4;
    //acc.Opportunity_ThousandY__c += o5;//lt 20220318 注释
    acc.Opportunity_ThousandY__c += o5;
    acc.Amount_Without_Tax_Thousand__c += o6;
    //20220111 SWAG-C8MBB6 加7.询价 lt  start
    acc.AllOP_ThousandY__c += o7;
    //20220111 SWAG-C8MBB6 加7.询价 lt  end
    //20230222 you start
    acc.LostPrices__c += o8;
    acc.Dealer_Final_Price__c += o9;
    acc.HospitalTransactionAmount__c += o10;
    //20230222 you end
    //20230327  DB202303372329 you start
    acc.OP_ThousandY_Order__c += o11;
    acc.OrderThisYearQY__c += o12;
    acc.Opportunity__c += o13;
    //20230327  DB202303372329 you end
  }
  private void setOpdIproductCount(Account2__c acc, Decimal decIP1, Decimal decIP2, Decimal decIP3, Decimal decIP4, Decimal decIP5, Decimal decIP6, Decimal decIP7, Decimal decIP8, Decimal decIP9, Decimal decIP10,
@@ -2051,7 +2131,11 @@
      when '18' {acc.Asset_Cnt_OTVS190__c += tmpCnt;}
      when '28' {acc.Asset_Cnt_ESG400__c += tmpCnt;}
      when '29' {acc.Asset_Cnt_USG400__c += tmpCnt;}
      when '30' {acc.Asset_Cnt_TB__c += tmpCnt;}
      //20220601 WLIG-CEWDWS you start
      //when '30' {acc.Asset_Cnt_TB__c += tmpCnt;}
      when '20' {acc.Asset_Cnt_TB_0535__c += tmpCnt;}
      when '21' {acc.Asset_Cnt_TB_0520__c += tmpCnt;}
      //20220601 WLIG-CEWDWS you end
      when else {
        system.debug('=====setAssetCount else:' + tmpKey + '_x_' + tmpCnt);
      }
@@ -2156,14 +2240,21 @@
              filedNameMap.put('9', '290Miro_BF__c');
              filedNameMap.put('14', 'OTV_S400__c');
              filedNameMap.put('15', 'OTV_S300__c');
              filedNameMap.put('16', 'CV_170__c');
              filedNameMap.put('17', 'CV_190__c');
              // 20210602 SWAG-C3K6L7 Start
              //filedNameMap.put('18', 'OTV_S190__c');
              // 20210602 SWAG-C3K6L7 End
              filedNameMap.put('28', 'ESG400__c');
              filedNameMap.put('29', 'USG400__c');
              filedNameMap.put('30', 'TB__c');
              filedNameMap.put('29', 'USG400__c');  //记录you 上财年没有29 ,只不过没有注释,今年有,所以不用动
              //20220601 WLIG-CEWDWS you start
              //filedNameMap.put('30', 'TB__c');
              filedNameMap.put('20', 'TB_0535__c');
              filedNameMap.put('21', 'TB_0520__c');
              //20220601 WLIG-CEWDWS you end
          } else {
              filedNameMap = new Map<String,String>();
              filedNameMap.put('1', 'CV290__c');
@@ -2177,14 +2268,20 @@
              filedNameMap.put('9', '290MiroBF__c');
              filedNameMap.put('14', 'OTVS400__c');
              filedNameMap.put('15', 'OTVS300__c');
              filedNameMap.put('16', 'CV170__c');
              filedNameMap.put('17', 'CV190__c');
              // 20210602 SWAG-C3K6L7 Start
              //filedNameMap.put('18', 'OTVS190__c');
              // 20210602 SWAG-C3K6L7 End
              filedNameMap.put('28', 'ESG400__c');
              filedNameMap.put('29', 'USG400__c');
              filedNameMap.put('30', 'TB__c');
              //20220601 WLIG-CEWDWS you start
              //filedNameMap.put('30', 'TB__c');
              filedNameMap.put('20', 'TB_0535__c');
              filedNameMap.put('21', 'TB_0520__c');
              //20220601 WLIG-CEWDWS you end
          // }
        
      }
@@ -2262,8 +2359,11 @@
        allList.add(onlyCountDepList);
      // 20210602 SWAG-C3K6L7 Start
      //}else if(i == '14' || i == '15' || i == '17' || i == '18' || i == '29' || i == '28' || i == '30'){
      } else if(i == '14' || i == '15' || i == '17' || i == '29' || i == '28' || i == '30'){
      //} else if(i == '14' || i == '15' || i == '17' || i == '29' || i == '28' || i == '30'){
      // 20210602 SWAG-C3K6L7 End
      //20220601 WLIG-CEWDWS you start
       } else if(i == '14' || i == '15' || i == '17' || i == '29' || i == '28' || i == '20' || i == '21'){
      //20220601 WLIG-CEWDWS you end
        // 这里是需要修改的 start
        allCountDepList.add(departmentGS); // 都计算在普外科里
        // noCountDepList.add() 这里没有不需要计算的科室
@@ -2318,4 +2418,470 @@
      countImportantProduct(acc,nameType,tmpCnt,tmpKey,allList,departmentE,depToOtherDepAcc2Map, updateAccount, OldAccount2);
    
  }
   @TestVisible private static 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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        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++;
        i++;
        i++;
        i++;
}
}