mysql - Java Map<String,Map<String,Integer> use to populate results -


i want create 1 report select product , storename , returns sales per date (within range).

the db view helped me other reports looks this: product - store_name - date

so far approach return records db in list , following:

public void salesreport(string product, string store, string date){     list<recordsalesinfo> salesresults = salesdao.getsales();     map<string, integer> mapper = new hashmap();      //calculation         (recordsalesinfo record : salesresults) {             stringbuilder key = new stringbuilder();             key.append(record.getproduct()).append(":")                         .append(record.getstorename()).append(":")                         .append(record.getwagereddate()).append(":");              if (mapper.containskey(key.tostring())) {                     integer = mapper.get(key.tostring());                     get++;                     mapper.put(key.tostring(), get);             } else {                     mapper.put(key.tostring(), 1);             }        }         (string key : mapper.keyset()) {            if(key.tostring.equals("pen:london:13june2016"){                 system.out.println("sales:" + mapper.get(key.tostring);            }        } } 

the query in salesdao(saving "recordsalesinfo") is:

select  rs.product product,  rs.store_name store,  rs.date date,  rs.product_id productid  sales rs  order rs.product,rs.store_name,rs.date 

the reason didn't query "count(blabla) product='a' , store_name='b' , date='c' " because user changes input using jslider (input=product,store,date), means many queries. thought better take results db , display user needs.

a) there better way this?

b) in next phase user enter product , store , have return list of sales date, looking this:

pen - london (manual input) 12june2016 100 15june2016 30 19july2016 67

with have done far, can't dates have sales, , have "search" hashmap dates(specific range). think solution change key "product:storename" 1 existing map , have value map string date , integer amount of sales.

again there better way on doing that?

what not hold/keep map, rather fetch results query changes based on jslider etc.

you can 1 thing when query sent until results available can disable jslider , show spinner notifies user processing going on.

once result available, enable slider , hide spinner.

to have data in map not seem idea. disconnected state of data.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -