6868import cc .altius .FASP .model .report .ShipmentDetailsMonthRowMapper ;
6969import cc .altius .FASP .model .report .ShipmentGlobalDemandCountryShipmentSplitRowMapper ;
7070import cc .altius .FASP .model .report .ShipmentGlobalDemandCountrySplitRowMapper ;
71- import cc .altius .FASP .model .report .ShipmentGlobalDemandDateSplitRowMapper ;
7271import cc .altius .FASP .model .report .ShipmentGlobalDemandInput ;
7372import cc .altius .FASP .model .report .ShipmentGlobalDemandOutput ;
74- import cc .altius .FASP .model .report .ShipmentGlobalDemandShipmentListRowMapper ;
75- import cc .altius .FASP .model .report .ShipmentOverviewFundindSourceSplitRowMapper ;
73+ import cc .altius .FASP .model .report .ShipmentOverviewFspaCostAndPercRowMapper ;
74+ import cc .altius .FASP .model .report .ShipmentOverviewFspaSplitRowMapper ;
7675import cc .altius .FASP .model .report .ShipmentOverviewInput ;
7776import cc .altius .FASP .model .report .ShipmentOverviewOutput ;
78- import cc .altius .FASP .model .report .ShipmentOverviewPlanningUnitSplitRowMapper ;
79- import cc .altius .FASP .model .report .ShipmentOverviewProcurementAgentSplit ;
80- import cc .altius .FASP .model .report .ShipmentOverviewProcurementAgentSplitRowMapper ;
77+ import cc .altius .FASP .model .report .ShipmentOverviewPlanningUnitQuantityResultSetExtractor ;
8178import cc .altius .FASP .model .report .ShipmentReportInput ;
8279import cc .altius .FASP .model .report .ShipmentReportOutput ;
8380import cc .altius .FASP .model .report .ShipmentReportOutputRowMapper ;
113110import cc .altius .FASP .model .rowMapper .StockAdjustmentReportOutputRowMapper ;
114111import cc .altius .FASP .service .AclService ;
115112import cc .altius .FASP .utils .ArrayUtils ;
116- import cc .altius .FASP .utils .LogUtils ;
117113import java .util .Date ;
118114import java .util .HashMap ;
119- import java .util .LinkedList ;
120115import java .util .List ;
121116import java .util .Map ;
122117import java .util .stream .Collectors ;
@@ -530,51 +525,27 @@ public ShipmentDetailsOutput getShipmentDetails(ShipmentDetailsInput sd, CustomU
530525 @ Override
531526 public ShipmentOverviewOutput getShipmentOverview (ShipmentOverviewInput so , CustomUserDetails curUser ) {
532527 Map <String , Object > params = new HashMap <String , Object >();
528+ params .put ("curUser" , curUser .getUserId ());
533529 params .put ("realmId" , so .getRealmId ());
534530 params .put ("startDate" , so .getStartDate ());
535531 params .put ("stopDate" , so .getStopDate ());
536532 params .put ("realmCountryIds" , so .getRealmCountryIdsString ());
537533 params .put ("programIds" , so .getProgramIdsString ());
534+ params .put ("versionId" , so .getVersionId ());
535+ params .put ("fspa" , so .getFspa ());
536+ params .put ("fspaIds" , so .getFundingSourceIdsString ());
538537 params .put ("planningUnitIds" , so .getPlanningUnitIdsString ());
539- params .put ("fundingSourceIds" , so .getFundingSourceIdsString ());
540538 params .put ("shipmentStatusIds" , so .getShipmentStatusIdsString ());
541- params .put ("approvedSupplyPlanOnly" , so .isUseApprovedSupplyPlanOnly ());
542- params .put ("groupByProcurementAgentType" , so .isGroupByProcurementAgentType ());
543- params .put ("curUser" , curUser .getUserId ());
539+
544540 ShipmentOverviewOutput soo = new ShipmentOverviewOutput ();
545- String sql = "" ;
546- if (!so .isGroupByFundingSourceType ()) {
547- sql = "CALL shipmentOverview_FundingSourceSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :fundingSourceIds, :planningUnitIds, :shipmentStatusIds, :approvedSupplyPlanOnly)" ;
548- } else {
549- sql = "CALL shipmentOverview_FundingSourceTypeSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :fundingSourceIds, :planningUnitIds, :shipmentStatusIds, :approvedSupplyPlanOnly)" ;
550- }
551- soo .setFundingSourceSplit (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewFundindSourceSplitRowMapper ()));
552- sql = "CALL shipmentOverview_PlanningUnitSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :fundingSourceIds, :planningUnitIds, :shipmentStatusIds, :approvedSupplyPlanOnly)" ;
553- soo .setPlanningUnitSplit (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewPlanningUnitSplitRowMapper ()));
554- if (!so .isGroupByProcurementAgentType ()) {
555- sql = "CALL shipmentOverview_ProcurementAgentSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :fundingSourceIds, :planningUnitIds, :shipmentStatusIds, :approvedSupplyPlanOnly)" ;
556- } else {
557- sql = "CALL shipmentOverview_ProcurementAgentTypeSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :fundingSourceIds, :planningUnitIds, :shipmentStatusIds, :approvedSupplyPlanOnly)" ;
558- }
559- List <ShipmentOverviewProcurementAgentSplit > sopList = this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewProcurementAgentSplitRowMapper ());
560- if (!sopList .isEmpty ()) {
561- List <String > keyListToRemove = new LinkedList <>();
562- for (String key : sopList .get (0 ).getProcurementAgentQty ().keySet ()) {
563- Double total = sopList .stream ()
564- .map (x -> (Double ) x .getProcurementAgentQty ().get (key ))
565- .collect (Collectors .summingDouble (Double ::doubleValue ));
566- if (total .doubleValue () == 0 ) {
567- // Add to the remove List
568- keyListToRemove .add (key );
569- }
570- }
571- keyListToRemove .forEach (key -> {
572- sopList .forEach (sop -> {
573- sop .getProcurementAgentQty ().remove (key );
574- });
575- });
576- }
577- soo .setProcurementAgentSplit (sopList );
541+ String sql = "CALL shipmentOverview_planningUnitQuantity(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :versionId, :fspa, :fspaIds, :planningUnitIds, :shipmentStatusIds)" ;
542+ soo .setPlanningUnitQuantity (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewPlanningUnitQuantityResultSetExtractor ()));
543+ sql = "CALL shipmentOverview_fspaCost(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :versionId, :fspa, :fspaIds, :planningUnitIds, :shipmentStatusIds)" ;
544+ soo .setFspaCostAndPerc (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewFspaCostAndPercRowMapper ()));
545+ sql = "CALL shipmentOverview_fspaProgramSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :versionId, :fspa, :fspaIds, :planningUnitIds, :shipmentStatusIds)" ;
546+ soo .setFspaProgramSplit (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewFspaSplitRowMapper ()));
547+ sql = "CALL shipmentOverview_fspaCountrySplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :versionId, :fspa, :fspaIds, :planningUnitIds, :shipmentStatusIds)" ;
548+ soo .setFspaCountrySplit (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentOverviewFspaSplitRowMapper ()));
578549 return soo ;
579550 }
580551
@@ -594,44 +565,11 @@ public ShipmentGlobalDemandOutput getShipmentGlobalDemand(ShipmentGlobalDemandIn
594565 params .put ("includePlannedShipments" , sgd .isIncludePlannedShipments ());
595566 params .put ("curUser" , curUser .getUserId ());
596567 ShipmentGlobalDemandOutput sgdo = new ShipmentGlobalDemandOutput ();
597- // String sql = "CALL shipmentGlobalDemand_ShipmentList(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :reportView, :fundingSourceProcurementAgentIds, :planningUnitId, :approvedSupplyPlanOnly, :includePlannedShipments)";
598- // sgdo.setShipmentList(this.namedParameterJdbcTemplate.query(sql, params, new ShipmentGlobalDemandShipmentListRowMapper()));
599- // switch (sgd.getReportView()) {
600- // case 1: //Funding Source
601- // sql = "CALL shipmentGlobalDemand_FundingSourceDateSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :reportView, :fundingSourceProcurementAgentIds, :planningUnitId, :approvedSupplyPlanOnly, :includePlannedShipments)";
602- // break;
603- // case 2: // Procurement Agent
604- // sql = "CALL shipmentGlobalDemand_ProcurementAgentDateSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :reportView, :fundingSourceProcurementAgentIds, :planningUnitId, :approvedSupplyPlanOnly, :includePlannedShipments)";
605- // break;
606- // case 3: // Procurement Agent Type
607- // sql = "CALL shipmentGlobalDemand_ProcurementAgentTypeDateSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :reportView, :fundingSourceProcurementAgentIds, :planningUnitId, :approvedSupplyPlanOnly, :includePlannedShipments)";
608- // break;
609- // case 4: // Funding Source Type
610- // sql = "CALL shipmentGlobalDemand_FundingSourceTypeDateSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :reportView, :fundingSourceProcurementAgentIds, :planningUnitId, :approvedSupplyPlanOnly, :includePlannedShipments)";
611- // break;
612- // }
613- // sgdo.setDateSplitList(this.namedParameterJdbcTemplate.query(sql, params, new ShipmentGlobalDemandDateSplitRowMapper()));
614- // String sql = "";
615- // switch (sgd.getReportView()) {
616- // case 1: //Funding Source
617- // sql = "CALL shipmentGlobalDemand_FundingSourceCountrySplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :equivalencyUnitId, :planningUnitIds, :reportView, :fundingSourceProcurementAgentIds, :includePlannedShipments)";
618- // break;
619- // case 2: // Procurement Agent
620- // sql = "CALL shipmentGlobalDemand_ProcurementAgentCountrySplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :equivalencyUnitId, :planningUnitIds, :reportView, :fundingSourceProcurementAgentIds, :includePlannedShipments)";
621- // break;
622- // case 3: // Procurement Agent Type
623- // sql = "CALL shipmentGlobalDemand_ProcurementAgentTypeCountrySplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :equivalencyUnitId, :planningUnitIds, :reportView, :fundingSourceProcurementAgentIds, :includePlannedShipments)";
624- // break;
625- // case 4: // Funding Source Type
626- // sql = "CALL shipmentGlobalDemand_FundingSourceTypeCountrySplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :equivalencyUnitId, :planningUnitIds, :reportView, :fundingSourceProcurementAgentIds, :includePlannedShipments)";
627- // break;
628- // }
629- // sgdo.setCountrySplitList(this.namedParameterJdbcTemplate.query(sql, params, new ShipmentGlobalDemandCountrySplitRowMapper()));
630- //
631568 String sql = "CALL shipmentGlobalDemand_CountrySplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :equivalencyUnitId, :planningUnitIds, :reportView, :fundingSourceProcurementAgentIds, :includePlannedShipments)" ;
632569 sgdo .setCountrySplitList (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentGlobalDemandCountrySplitRowMapper ()));
633570 sql = "CALL shipmentGlobalDemand_CountryShipmentSplit(:curUser, :realmId, :startDate, :stopDate, :realmCountryIds, :programIds, :equivalencyUnitId, :planningUnitIds, :reportView, :fundingSourceProcurementAgentIds, :includePlannedShipments)" ;
634571 sgdo .setCountryShipmentSplitList (this .namedParameterJdbcTemplate .query (sql , params , new ShipmentGlobalDemandCountryShipmentSplitRowMapper (sgd .isIncludePlannedShipments ())));
572+
635573 return sgdo ;
636574 }
637575
@@ -699,7 +637,7 @@ public List<BudgetReportOutput> getBudgetReport(BudgetReportInput br, CustomUser
699637 + "LEFT JOIN vw_funding_source_type fst ON fs.FUNDING_SOURCE_TYPE_ID=fst.FUNDING_SOURCE_TYPE_ID "
700638 + "LEFT JOIN vw_currency c ON b.CURRENCY_ID=c.CURRENCY_ID "
701639 + "LEFT JOIN ( "
702- + " SELECT "
640+ + " SELECT "
703641 + " st.BUDGET_ID, "
704642 + " SUM(IF(st.SHIPMENT_STATUS_ID IN (1), ((IFNULL(st.FREIGHT_COST,0)+IFNULL(st.PRODUCT_COST,0))*s.CONVERSION_RATE_TO_USD),0)) `PLANNED_BUDGET`, "
705643 + " SUM(IF(st.SHIPMENT_STATUS_ID IN (3,4,5,6,7,9), ((IFNULL(st.FREIGHT_COST,0)+IFNULL(st.PRODUCT_COST,0))*s.CONVERSION_RATE_TO_USD),0)) `ORDERED_BUDGET`, SUM(IF(:programIds='' OR FIND_IN_SET(s.PROGRAM_ID, :programIds), 1, 0)) AS MATCH_COUNT "
0 commit comments