当前位置: 首页 > news >正文

网页特技的网站抖音视界北京有限公司

网页特技的网站,抖音视界北京有限公司,怎么自助建站,seo谷歌推广需求#xff1a;#xff1a; 有一个ListMapString.Object,存储了某年某月的数据#xff0c; 数据是根据用户查询条件进行显示的#xff1b;所以查询的数据是动态的#xff1b;需按月份统计每个年月数据出现的次数#xff0c;并且按照月份排序#xff1…需求 有一个ListMapString.Object,存储了某年某月的数据 数据是根据用户查询条件进行显示的所以查询的数据是动态的需按月份统计每个年月数据出现的次数并且按照月份排序统计周期不超过一年前端页面控制 分析 后端给前端返回值不能用对象返回因为数据是动态的key是不固定的 可以使用ListMapString,Object返回Map中key为年月value为统计次数 Demo案例 import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;public class day06 {public static void main(String[] args) {ListMapString,Object list new ArrayList();MapString,Object map1 new HashMap();map1.put(month,2023年02月);MapString,Object map2 new HashMap();map2.put(month,2023年05月);MapString,Object map3 new HashMap();map3.put(month,2023年04月);MapString,Object map4 new HashMap();map4.put(month,2023年02月);MapString,Object map5 new HashMap();map5.put(month,2023年01月);list.add(map1);list.add(map2);list.add(map3);list.add(map4);list.add(map5);String[] auditMonthArr {01,02,03,04,05,06,07,08,09,10,11,12};int[] count new int[auditMonthArr.length];String[] yearArr new String[auditMonthArr.length];for (int i 0; i list.size(); i) {String auditMonth String.valueOf(list.get(i).get(month)).trim();String auditMonth2 auditMonth.substring(auditMonth.indexOf(年)1,auditMonth.indexOf(月));for (int j 0; j auditMonthArr.length; j) {if(auditMonth2.equals(auditMonthArr[j].trim())){count[j] count[j] 1;yearArr[j] auditMonth;}}}ListMapString,Object listResult new ArrayList();// 按照1月到12月动态展示数据for (int i 0; i auditMonthArr.length; i) {MapString,Object map new HashMap();String title yearArr[i];int value count[i];if(!String.valueOf(value).equals(0)){map.put(title,title);map.put(value,value);listResult.add(map);}} for (int i 0; i listResult.size(); i) {listResult.get(i).put(sortValue,i1);}System.out.println(listResult:listResult);} } 测试输出 listResult: listResult:[{sortValue1, title2023年01月, value1}, {sortValue2, title2023年02月, value2}, {sortValue3, title2023年04月, value1}, {sortValue4, title2023年05月, value1}] 案例二 需求前端根据后端的返回数据画趋势图 X轴是动态的有对应月份数据则展示X轴 按照1-12月排序没月份则跳过 // Controllerpublic Result getTrendData(HttpServletRequest request,RequestBody String param) {try {MapString, Object paramMap JsonUtils.readValue(param, Map.class);return Result.success().result(questionListService.getTrendData(request,paramMap));} catch (Exception e) {log.error(QuestionListController getTrendData is error: e.getMessage(), e);return Result.failure(统计失败);}}// Service ListMapString,Object getTrendData(HttpServletRequest request,MapString, Object paramMap);// ServiceImpl Overridepublic ListMapString,Object getTrendData(HttpServletRequest request, MapString, Object paramMap) {ListMapString,Object list getCountData(request,paramMap); // 封装统计查询的数据与数据库交互ListMapString,Object listResult new ArrayList();String[] auditMonthArr {01,02,03,04,05,06,07,08,09,10,11,12};int[] monDataArr new int[auditMonthArr.length];String[] yearArr new String[auditMonthArr.length];for (int i 0; i list.size(); i) {String auditMonth String.valueOf(list.get(i).get(auditMonth));String mon auditMonth.substring(auditMonth.indexOf(年)1,auditMonth.lastIndexOf(月));for (int j 0; j auditMonthArr.length; j) {if(mon.equals(auditMonthArr[j])){monDataArr[j] monDataArr[j] 1;yearArr[j] auditMonth;}}}// 按照1月到12月动态展示数据for (int i 0; i auditMonthArr.length; i) {MapString,Object map new HashMap();String title yearArr[i];int value monDataArr[i];// 该判断很重要仔细品if(!String.valueOf(value).equals(0)){map.put(title,title);map.put(value,value);listResult.add(map);}}return listResult;} Postman接口测试
http://www.zqtcl.cn/news/368342/

相关文章:

  • 在手机上如何制作网站qq注册网页入口
  • asp.net程序做的网站安全吗国内什么网站用asp.net
  • 凡科网做网站网站编辑知识
  • c#做交易网站taxonomy wordpress
  • 统一门户网站开发员给我用织梦做的网站
  • 网站上有声的文章是怎么做的深圳市住房和建设局网站和市住宅租赁管理服务中心
  • 如何对网站进行爬虫页面设计存在的问题
  • 知名网站建设加盟合作企业邮箱如何登录
  • asp net mvc做网站软文推广是什么
  • 张家口住房和城乡建设厅网站如何做点击赚钱的网站
  • 网站在建设中无法访问贵州碧江区住房和城乡建设局网站
  • 营销类网站 英文东莞正规的免费网站优化
  • 柳州网站推广最好的公司百度seo优化培训
  • 哈尔滨门户网站建站哪个网站做农产品
  • 网站行业关键词如何建设网站
  • wordpress插件目录504wordpress访问优化插件
  • 固定ip做网站网页源码提取工具
  • php网站模板源码下载公司网络营销推广软件
  • 免费电子版个人简历模板温州快速排名优化
  • 网站修改titlewordpress显示icp备案
  • 中国国际贸易单一窗口登录南京专业网站优化公司
  • 手机网站建设合同wordpress案例分析
  • 深圳做网站什么公司好广州电商小程序开发
  • 郑州高新区做网站的公司如何欣赏网站
  • 网站做维恩图做网站的公司杭州
  • 柳州公司网站制作公司wordpress 网店
  • 网站增加栏目费用在网站开发中如何设置登录
  • 怎样用php做网站百度推广联系人
  • 怎么建立手机网站如何申请公司域名
  • 营销型网站怎么收费邓州企业网站