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

网站开发设计公创意营销案例

网站开发设计公,创意营销案例,给网站做seo的必要性,更换网站备案需求&#xff1a;&#xff1a; 有一个List<Map<String.Object>>,存储了某年某月的数据&#xff0c; 数据是根据用户查询条件进行显示的&#xff1b;所以查询的数据是动态的&#xff1b;需按月份统计每个年月数据出现的次数&#xff0c;并且按照月份排序&#xff1…

需求:

  1. 有一个List<Map<String.Object>>,存储了某年某月的数据,
    数据是根据用户查询条件进行显示的;所以查询的数据是动态的;
  2. 需按月份统计每个年月数据出现的次数,并且按照月份排序;
  3. 统计周期不超过一年(前端页面控制);

分析:
后端给前端返回值:不能用对象返回,因为数据是动态的,key是不固定的;
可以使用:List<Map<String,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) {List<Map<String,Object>> list = new ArrayList<>();Map<String,Object> map1 = new HashMap<>();map1.put("month","2023年02月");Map<String,Object> map2 = new HashMap<>();map2.put("month","2023年05月");Map<String,Object> map3 = new HashMap<>();map3.put("month","2023年04月");Map<String,Object> map4 = new HashMap<>();map4.put("month","2023年02月");Map<String,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;}}}List<Map<String,Object>> listResult = new ArrayList<>();// 按照1月到12月动态展示数据;for (int i = 0; i < auditMonthArr.length; i++) {Map<String,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",i+1);}System.out.println("listResult:"+listResult);}
}

测试输出:

listResult:
listResult:[{sortValue=1, title=202301, value=1}, {sortValue=2, title=202302, value=2}, {sortValue=3, title=202304, value=1}, {sortValue=4, title=202305, value=1}]

案例二:
需求:前端根据后端的返回数据:画趋势图;

  1. X轴是动态的,有对应月份数据则展示;
  2. X轴 按照1-12月排序(没月份则跳过);
    在这里插入图片描述
// Controllerpublic Result getTrendData(HttpServletRequest request,@RequestBody String param) {try {Map<String, 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    List<Map<String,Object>> getTrendData(HttpServletRequest request,Map<String, Object> paramMap);// ServiceImpl  @Overridepublic List<Map<String,Object>> getTrendData(HttpServletRequest request, Map<String, Object> paramMap) {List<Map<String,Object>> list = getCountData(request,paramMap); // 封装统计查询的数据(与数据库交互)List<Map<String,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++) {Map<String,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.hkea.cn/news/797383/

相关文章:

  • 企业网站php模板下载百度百科官网首页
  • 做愛視頻网站在线网页制作网站
  • 织梦pc怎么做手机网站搜索引擎优化的基础是什么
  • 课程建设网站设计源码爱站网反链查询
  • 安徽省建设业协会网站个人网页制作教程
  • 好的摄影网站推荐福州seo顾问
  • html做的好看的网站如何宣传推广产品
  • 微信手机网站制作怎么引流客源最好的方法
  • 宿州建设网站公司前端seo搜索引擎优化
  • 做王境泽表情的网站百度seo关键词优化排名
  • 怎么选择无锡网站建设虚拟主机搭建网站
  • 做原油期货关注什么网站搜索引擎优化是做什么
  • 微信小程序怎么制作游戏安卓优化清理大师
  • 胶南做网站初学者做电商怎么入手
  • 网站为什么要维护佛山网络营销推广
  • 国企网站建设报告怎么建造自己的网站
  • 免费做司考真题的网站余姚网站如何进行优化
  • 如何网站开发1688网站
  • 丽水专业网站建设价格青岛网站优化
  • 网站开发专业培训学校百度推广登录官网入口
  • 贵阳做网站公司网站热度查询
  • 做课件最好的素材网站考拉seo
  • 网站建设玖首选金手指seo网站优化收藏
  • 台州卓远做网站好不好广州seo教程
  • dz网站数据备份bt磁力猪
  • github 可以做网站吗360seo
  • 杭州 企业门户网站建设爱链
  • dj那个网站做的好长沙公司网络营销推广
  • 设计师培训招生视频黑帽seo联系方式
  • 做网上贸易哪个网站好西宁网站seo