@@ -197,12 +197,16 @@ public List<DashboardTop> getDashboardTop(String[] programIds, CustomUserDetails
197197 List <DashboardTop > edList = this .namedParameterJdbcTemplate .query (sqlBuilder .toString (), params , new DashboardTopRowMapper ());
198198 Date curMonth = DateUtils .getStartOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), -1 * curUser .getRealm ().getNoOfMonthsInPastForTopDashboard ()));
199199 Date endMonth = DateUtils .getEndOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), curUser .getRealm ().getNoOfMonthsInFutureForTopDashboard () - 1 ));
200+ Date curMonthForScore = DateUtils .getStartOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), 0 ));
201+ Date endMonthForScore = DateUtils .getEndOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), 17 ));
200202 edList .forEach (ed -> {
201203 String sql1 = "SELECT SUM(IF(s1.`SUM_STOCK_OUT`>0,1,0)) `PRODUCTS_WITH_STOCK_OUT` FROM (SELECT sma.PROGRAM_ID, sma.PLANNING_UNIT_ID, SUM(IF(sma.MOS=0,1,0)) `SUM_STOCK_OUT` FROM vw_program p LEFT JOIN rm_program_planning_unit ppu ON p.PROGRAM_ID=ppu.PROGRAM_ID AND ppu.ACTIVE LEFT JOIN rm_planning_unit pu ON ppu.PLANNING_UNIT_ID=pu.PLANNING_UNIT_ID AND pu.ACTIVE LEFT JOIN rm_supply_plan_amc sma ON p.PROGRAM_ID=sma.PROGRAM_ID AND p.CURRENT_VERSION_ID=sma.VERSION_ID AND pu.PLANNING_UNIT_ID=sma.PLANNING_UNIT_ID WHERE p.PROGRAM_ID=:programId AND sma.TRANS_DATE BETWEEN :curMonth AND :endMonth group by sma.PROGRAM_ID, sma.PLANNING_UNIT_ID) s1 GROUP BY s1.PROGRAM_ID" ;
202204 Map <String , Object > eParams = new HashMap <>();
203205 eParams .put ("programId" , ed .getProgram ().getId ());
204206 eParams .put ("curMonth" , curMonth );
205207 eParams .put ("endMonth" , endMonth );
208+ eParams .put ("curMonthForScore" , curMonthForScore );
209+ eParams .put ("endMonthForScore" , endMonthForScore );
206210 String sql2 = "SELECT SUM(ROUND(p1.EXPIRED_STOCK*st.RATE,0)) EXPIRED_VALUE "
207211 + " FROM ( "
208212 + " SELECT "
@@ -231,7 +235,7 @@ public List<DashboardTop> getDashboardTop(String[] programIds, CustomUserDetails
231235
232236 }
233237
234- String sqlString = "CALL getDashboardStockStatus(:curMonth , :endMonth , :programId)" ;
238+ String sqlString = "CALL getDashboardStockStatus(:curMonthForScore , :endMonthForScore , :programId)" ;
235239 ed .setStockStatus (this .namedParameterJdbcTemplate .queryForObject (sqlString , eParams , new DashboardStockStatusRowMapper ()));
236240
237241 sqlString = "CALL getDashboardForecastConsumptionProblems(:programId)" ;
@@ -252,17 +256,21 @@ public List<DashboardTop> getDashboardTop(String[] programIds, CustomUserDetails
252256 @ Override
253257 public DashboardBottom getDashboardBottom (int programId , String startDate , String stopDate , int displayShipmentsBy , CustomUserDetails curUser ) throws ParseException {
254258 DashboardBottom db = new DashboardBottom ();
255- String sqlString = "CALL getDashboardStockStatus(:startDate, :stopDate, :programId)" ;
259+ Date curMonthForScore = DateUtils .getStartOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), 0 ));
260+ Date endMonthForScore = DateUtils .getEndOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), 17 ));
261+ String sqlString = "CALL getDashboardStockStatus(:curMonthForScore, :endMonthForScore, :programId)" ;
256262 Map <String , Object > params = new HashMap <>();
257263 params .put ("programId" , programId );
258264 params .put ("startDate" , startDate );
259265 params .put ("stopDate" , DateUtils .getEndOfMonthVariable (stopDate ));
266+ params .put ("curMonthForScore" , curMonthForScore );
267+ params .put ("endMonthForScore" , endMonthForScore );
260268 params .put ("curDate" , DateUtils .getCurrentDateString (DateUtils .EST , DateUtils .YMD ));
261269 params .put ("curStartOfMonth" , DateUtils .getStartOfMonthString (DateUtils .YMD ));
262270 params .put ("curEndOfMonth" , DateUtils .getEndOfMonthString (DateUtils .YMD ));
263271 db .setStockStatus (this .namedParameterJdbcTemplate .queryForObject (sqlString , params , new DashboardStockStatusRowMapper ()));
264272
265- sqlString = "CALL getDashboardStockOutCount(:startDate , :stopDate , :programId, -1)" ;
273+ sqlString = "CALL getDashboardStockOutCount(:curMonthForScore , :endMonthForScore , :programId, -1)" ;
266274// logger.debug(LogUtils.buildStringForLog(sqlString, params));
267275 db .getStockStatus ().setPuStockOutList (this .namedParameterJdbcTemplate .query (sqlString , params , new DashboardPuWithCountRowMapper ()).stream ().filter (d -> d .getCount () > 0 ).collect (Collectors .toList ()));
268276// logger.debug(LogUtils.buildStringForLog("completed", params));
@@ -313,14 +321,16 @@ public DashboardBottom getDashboardBottom(int programId, String startDate, Strin
313321
314322 @ Override
315323 public DashboardForLoadProgram getDashboardForLoadProgram (int programId , int versionId , int noOfMonthsInPastForBottom , int noOfMonthsInFutureForBottom , int noOfMonthsInPastForTop , int noOfMonthsInFutureForTop , CustomUserDetails curUser ) throws ParseException {
324+ Date curMonthForScore = DateUtils .getStartOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), 0 ));
325+ Date endMonthForScore = DateUtils .getEndOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), 17 ));
316326 DashboardForLoadProgram db = new DashboardForLoadProgram ();
317327 db .setCurDate (DateUtils .getCurrentDateObject (DateUtils .EST ));
318328 db .setStartDateBottom (DateUtils .getStartOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), -1 * noOfMonthsInPastForBottom )));
319329 db .setStopDateBottom (DateUtils .getEndOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), noOfMonthsInFutureForBottom - 1 )));
320330 db .setStartDateTop (DateUtils .getStartOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), -1 * noOfMonthsInPastForTop )));
321331 db .setStopDateTop (DateUtils .getEndOfMonthVariable (DateUtils .addMonths (DateUtils .getCurrentDateObject (DateUtils .EST ), noOfMonthsInFutureForTop - 1 )));
322332
323- String sqlString = "CALL getDashboardStockStatusForLoadProgram(:startDateBottom , :stopDateBottom , :programId, :versionId)" ;
333+ String sqlString = "CALL getDashboardStockStatusForLoadProgram(:curMonthForScore , :endMonthForScore , :programId, :versionId)" ;
324334 Map <String , Object > params = new HashMap <>();
325335 params .put ("programId" , programId );
326336 params .put ("versionId" , versionId );
@@ -331,6 +341,8 @@ public DashboardForLoadProgram getDashboardForLoadProgram(int programId, int ver
331341 params .put ("curDate" , db .getCurDate ());
332342 params .put ("curStartOfMonth" , DateUtils .getStartOfMonthString (DateUtils .YMD ));
333343 params .put ("curEndOfMonth" , DateUtils .getEndOfMonthString (DateUtils .YMD ));
344+ params .put ("curMonthForScore" , curMonthForScore );
345+ params .put ("endMonthForScore" , endMonthForScore );
334346 this .namedParameterJdbcTemplate .query (sqlString , params , new DashboardStockStatusForLoadProgramResultSetExtractor (db ));
335347
336348 sqlString = "SELECT p1.*, st.`RATE` FROM (SELECT "
@@ -363,7 +375,7 @@ public DashboardForLoadProgram getDashboardForLoadProgram(int programId, int ver
363375 this .namedParameterJdbcTemplate .query (sqlString , params , new DashboardQplForLoadProgramResultSetExtractor (db , 3 ));
364376 sqlString = "CALL getDashboardShipmentProblemsForLoadProgram(:programId, :versionId, :curEndOfMonth)" ;
365377 this .namedParameterJdbcTemplate .query (sqlString , params , new DashboardQplForLoadProgramResultSetExtractor (db , 4 ));
366- sqlString = "CALL getDashboardStockOutCount(:startDateTop , :stopDateTop , :programId, :versionId)" ;
378+ sqlString = "CALL getDashboardStockOutCount(:curMonthForScore , :endMonthForScore , :programId, :versionId)" ;
367379 this .namedParameterJdbcTemplate .query (sqlString , params , new DashboardTopStockOutForLoadProgramResultSetExtractor (db ));
368380 sqlString = "CALL getDashboardExpiriesList(:startDateTop, :stopDateTop, :programId, :versionId)" ;
369381 this .namedParameterJdbcTemplate .query (sqlString , params , new DashboardTopExpiriesForLoadProgramResultSetExtractor (db ));
0 commit comments