图表数据结构生成工具类:

public class GraphicUtils {public  static List<GraphicDTO>  getDayHures(List<GraphicDTO> list){List<GraphicDTO> newList= new ArrayList<>();for (int i=0;i<=23;i++){newList.add(getGraphicDTO(i+""));}return getGraphicDTOS(list, newList);}/***  曲线图数据拷贝赋值* @param list SQL统计数据集合* @param newList 工具生成数据集合* @return list*/private static List<GraphicDTO> getGraphicDTOS(List<GraphicDTO> list, List<GraphicDTO> newList) {if(list==null||list.size()==0)return newList;newList=newList.stream().map(m -> {list.stream().filter(m2-> Objects.equals(m.getCreateTime(),m2.getCreateTime())).forEach(m2-> {m.setAmount(m2.getAmount());m.setOrderNum(m2.getOrderNum());m.setUserCount(m2.getUserCount());});return m;}).collect(Collectors.toList());return newList;}public static  GraphicDTO getGraphicDTO(String count){return new GraphicDTO(count);}public  static List<GraphicDTO>  getDay(List<GraphicDTO> list, String startDate, String endDate){List<GraphicDTO> newList;newList=GraphicUtils.getGraphicDTODate(startDate,endDate);return getGraphicDTOS(list, newList);}/***  获取两个时间段之间的所有日期 (年月日)*  * @param startTime 开始时间* @param endTime 结束时间* @return list*/public static List<GraphicDTO> getGraphicDTODate(String startTime, String endTime){SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 声明保存日期集合List<GraphicDTO> list = new ArrayList<GraphicDTO>();try {// 转化成日期类型Date startDate = sdf.parse(startTime);Date endDate = sdf.parse(endTime);//用Calendar 进行日期比较判断Calendar calendar = Calendar.getInstance();while (startDate.getTime()<=endDate.getTime()){// 把日期添加到集合list.add(new GraphicDTO(sdf.format(startDate)));// 设置日期calendar.setTime(startDate);//把日期增加一天calendar.add(Calendar.DATE, 1);// 获取增加后的日期startDate=calendar.getTime();}} catch (ParseException e) {e.printStackTrace();}return list;}public static List<UserMemberRightDTO> initiUserMemberRightDTOList(){List<UserMemberRightDTO> newList = new ArrayList<>();newList.add(new UserMemberRightDTO("企业版","enterprise",0));newList.add(new UserMemberRightDTO("旗舰版","personal",0));newList.add(new UserMemberRightDTO("个人版","regular",0));newList.add(new UserMemberRightDTO("团队版","team",0));return newList;}/***  饼图数据拷贝赋值,算出总数* @param dataList SQL统计数据集合* @return Map*/public static Map<String,Object> setUserMemberRightDTOListData(List<UserMemberRightDTO> dataList){List<UserMemberRightDTO> newList = initiUserMemberRightDTOList();AtomicInteger total = new AtomicInteger();Map<String,Object> objectMap = new HashMap<>();if(dataList.size()>0) {newList = newList.stream().map(m -> {dataList.stream().filter(m2 -> Objects.equals(m.getMemberCode(), m2.getMemberCode())).forEach(m2 -> {m.setMemberNum(m2.getMemberNum());total.addAndGet(m2.getMemberNum());});return m;}).collect(Collectors.toList());}objectMap.put("total",total);objectMap.put("records",newList);return objectMap;}
}

曲线图实体类:

public class GraphicDTO {public GraphicDTO() {}public GraphicDTO(String createTime) {this.createTime = createTime;}public GraphicDTO(String createTime, Integer orderNum) {this.createTime = createTime;this.orderNum = orderNum;}public GraphicDTO(String createTime, BigDecimal amount, int orderNum, int userCount) {this.createTime = createTime;this.amount = amount;this.orderNum = orderNum;this.userCount = userCount;}@ApiModelProperty("图表横向数据")private String createTime;@ApiModelProperty("充值金额")private BigDecimal amount = BigDecimal.valueOf(0);@ApiModelProperty("充值笔数")private int orderNum = 0;@ApiModelProperty("充值商家数")private int userCount = 0;
}

饼图实体类:

public class UserMemberRightDTO {@ApiModelProperty(value = "套餐名称")public String memberName;@ApiModelProperty(value = "套餐编码")private String memberCode;@ApiModelProperty(value = "会员数量")private Integer memberNum;public UserMemberRightDTO() {}public UserMemberRightDTO(String memberName, String memberCode, Integer memberNum) {this.memberName = memberName;this.memberCode = memberCode;this.memberNum = memberNum;}
}

时间转换工具类:

public class DateUtils {/*** 得到X天后的时间(时间格式)* @param date* @param day* @return*/public static Date getXDateAfterDate(Date date, int day) {Calendar now = Calendar.getInstance();now.setTime(date);now.set(Calendar.DATE, now.get(Calendar.DATE) + day);return now.getTime();}/*** 获取指定日期后N天** @param specifiedDay 日期* @param n            后几天* @return*/public static LocalDateTime getSpecifiedDayAfter(String specifiedDay, int n) {Calendar c = Calendar.getInstance();Date date = null;try {date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(specifiedDay);} catch (ParseException e) {e.printStackTrace();}c.setTime(date);int day = c.get(Calendar.DATE);c.set(Calendar.DATE, day + n);String dayAfter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.getTime());DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");return LocalDateTime.parse(dayAfter, df);}/**获取当前时间转字符串*/public static String getCurDateStr() {DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");LocalDateTime now = LocalDateTime.now();return now.format(dateTimeFormatter);}/*** 获取本月第一天* @return STR*/public static String getMonthFirstDay(){Calendar calendar = Calendar.getInstance();calendar.set(Calendar.DAY_OF_MONTH,1);calendar.add(Calendar.MONTH,0);return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime())+" 00:00:00";}/*** 获取本月最后一天* @return STR*/public static String getMonthLastDay(){Calendar calendar = Calendar.getInstance();calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime())+" 23:59:59";}/*** 获取本周的第一天* @return String* **/public static String getWeekStart(){Calendar cal=Calendar.getInstance();cal.add(Calendar.WEEK_OF_MONTH, 0);cal.set(Calendar.DAY_OF_WEEK, 2);Date time=cal.getTime();return new SimpleDateFormat("yyyy-MM-dd").format(time)+" 00:00:00";}/*** 获取本周的最后一天* @return String* **/public static String getWeekEnd(){Calendar cal=Calendar.getInstance();cal.set(Calendar.DAY_OF_WEEK, cal.getActualMaximum(Calendar.DAY_OF_WEEK));cal.add(Calendar.DAY_OF_WEEK, 1);Date time=cal.getTime();return new SimpleDateFormat("yyyy-MM-dd").format(time)+" 23:59:59";}/*** 获取两个时间之间的天数* @param s1 s1* @param s2 s2* @return int*/public static  int fun(String s1,String s2){//ctrl+alt+/提示方法参数//指定日期格式DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//按照指定格式转化为LocalDate对象LocalDate time1 = LocalDate.parse(s1,dateTimeFormatter);LocalDate time2 = LocalDate.parse(s2,dateTimeFormatter);//调方法计算两个LocalDate的天数差long between = ChronoUnit.DAYS.between(time1, time2);return (int)between;}/**** @param s1 yyyy-MM-dd HH:mm:ss* @return yyyy-MM-dd*/public static  String dateStr(String s1){//ctrl+alt+/提示方法参数//指定日期格式DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");//按照指定格式转化为LocalDate对象LocalDate time1 = LocalDate.parse(s1,dateTimeFormatter);return dateTimeFormatter1.format(time1);}
}

时间曲线统计图数据结构,时间工具相关推荐

  1. 头部玩家指的是什么_MMO等级提升背后:如何设计经验,才能使玩家达成预期时间曲线?...

    本文由腾讯游戏学院<真经阁>栏目投稿,授权游戏陀螺发布 导语 本期腾讯游戏学院<真经阁>栏目邀请到腾讯互娱天美工作室群游戏策划zhenbin,其从自身项目经验出发,以<斗 ...

  2. python显示血量条,利用Python绘制血药浓度-时间曲线——口服吸收一室模型

    血药浓度-时间曲线一般是通过拟合所测定的血药浓度点而画出来的,但是在某些时候,如阅读文献时,我们需要根据别人报道的PK参数来画出药时曲线.Python语法简单,拥有丰富的开源库,下面尝试通过Pytho ...

  3. (接上)将txt中的一组时间转换为简化儒略日的小工具

    (接上)将txt中的一组时间转换为简化儒略日的小工具 将txt中的一组时间转换为儒略日的小工具,输入年月日时分秒转换天文地理中常用的简化儒略日(MJD) (只适用于1901年至2099年) #incl ...

  4. java 时间类 joda_Java Joda-Time 处理时间工具类(JDK1.7以上)

    import org.joda.time.*;importorg.joda.time.format.DateTimeFormat;importorg.joda.time.format.DateTime ...

  5. 利用python画曲线_利用Python绘制血药浓度-时间曲线——口服吸收一室模型

    血药浓度-时间曲线一般是通过拟合所测定的血药浓度点而画出来的,但是在某些时候,如阅读文献时,我们需要根据别人报道的PK参数来画出药时曲线.Python语法简单,拥有丰富的开源库,下面尝试通过Pytho ...

  6. java 表达式 日期加减_jdk8获取当前时间|时间加减|java8时间格式化|时间处理工具|时间比较|线程安全的时间处理方法...

    目录 前言 在很久之前,我总结了一些jdk7版本之前的关于时间处理的一些公共方法,日期转换成字符串.指定时间加上指定天数后的日期.获取上周周一时间 等等:具体的可以戳链接查看完整的:https://b ...

  7. 分级时间轮优化普通时间轮定时器(2):滴答式分层计时轮

    <实现较低的计时器粒度以重传TCP(RTO):时间轮算法如何减少开销> <分级时间轮优化普通时间轮定时器> Table of Contents 描述 新闻 用法 执照 资源 其 ...

  8. python 当前时间字符串,Python常用时间操作总结【取得当前时间、时间函数、应用等】...

    本文实例讲述了Python常用时间操作.分享给大家供大家参考,具体如下: 我们先导入必须用到的一个module >>> import time 设置一个时间的格式,下面会用到 > ...

  9. vue 发展历程时间轴动画_PPT时间轴如何做出创意感?海量素材免费分享,网友:收藏...

    时间轴页面,是工作型PPT中常见的页面之一.个人述职或者公司介绍PPT中,使用时间轴,能够让观众更加清晰地了解公司的发展历程. 但是,很多人在制作时间轴页面时,往往是这样的效果: 只有几行字和一根线, ...

  10. java 时间轮算法_时间轮算法(TimingWheel)是如何实现的?

    前言 我在2. SOFAJRaft源码分析-JRaft的定时任务调度器是怎么做的?这篇文章里已经讲解过时间轮算法在JRaft中是怎么应用的,但是我感觉我并没有讲解清楚这个东西,导致看了这篇文章依然和没 ...

最新文章

  1. Painting A Board --POJ 1691
  2. 网易有道词典笔 —— 73 岁“人类高质量”奶奶梅耶马斯克的中文学习之选
  3. 免费!这里有一份开发者进阶“宝典”求带走
  4. Android文档-开发者指南-第一部分:入门-中英文对照版
  5. 《精通javascript》5,6章复习(三)
  6. C++ 深复制与浅复制 RVO问题
  7. ogg oracle 测试kafka_利用ogg实现oracle到kafka的增量数据实时同步
  8. Google Protocol Buffer
  9. 15.3 实时时钟芯片DS1302介绍
  10. 精读《useEffect 完全指南》
  11. 装完金蝶电脑无限重启_电脑一直自动重启的原因与解决方法
  12. 如何以应届生的身份进入阿里巴巴?
  13. Heartbeat简介
  14. 兼容win7桌面待办软件 美化桌面的待办小工具
  15. (附源码)ssm基于JavaEE的电脑销售管理系统设计与实现 毕业设计021143
  16. 2021-5-21-博弈论--金刚狼与小狗灰
  17. win10桌面右下角网络图标中找不到网络
  18. ITOP资产信息登记指导书
  19. MATLAB下载DeepLearnToolbox-master工具箱
  20. 这个周末很开心 - 虽然脚丫疼

热门文章

  1. 计算机windows用户名密码怎么查,如何查看Windows和Office的密码、序列号
  2. 高性能软件系统设计中应该考虑的问题
  3. 微信服务器IP地址清单
  4. 网易面试总结——面试案例5~面试案例8
  5. win10下安装Elasticsearch和kibana教程
  6. 2.(leaflet篇)leaflet加载接入百度地图
  7. 第四讲 身份认证技术
  8. 手把手教你使用YOLOV5训练自己的目标检测模型-口罩检测-视频教程
  9. 手把手教你:个人信贷违约预测模型
  10. 在LINLUX下面建立GPRS无线MODEM拨号