首页 > 编程语言 >程序人生

程序人生

时间:2024-07-27 17:41:19浏览次数:7  
标签:time 程序 month add 人生 taa year apply

程序人生

忠告,项目经验

万事开头难,一开始做一件事很痛苦的话,这是很正常的,冷静下来,慢慢来就是了。慢就是快,现在耐心做了,搞懂了,以后基本就是重复现在的。我现在在写毕业设计,年前可能做不完了,但我坚信过几天会越来越快。

效率最高的做事方法:平静,冷静,用心,用心思考。由简入繁。不要一上来就假设那种最难的情况,从最简单,最常见的情况入手,搞清楚后,控制变量,提升难度。

先照猫画虎。最后,你总能发现真理,原理,不一样的东西,然后感叹:原来如此。

列举:所有情况列举出来,难度低的往前排,一个一个试就是了。

下面是一个统计领养数据图表的例子

//管理员首页数据统计
@RequestMapping("/admin/indexData")
@ResponseBody
public Message getIndexCount() {
Integer userCount = userService.getGeneralUserCount(2);
Integer petCount = petService.findAllPets().size();
Integer cmmdCount = commodityService.findAllCmmdCount();
Integer actCount = activityService.findAllActivities().size();

List<AdoptCount> allCountResult = applyAdoptService.getAllAdoptCounts(); //总领养申请列表
List<AdoptCount> agreeCountsResult = applyAdoptService.getAgreeCounts(); //当前领养列表

List<Long> allCounts = new ArrayList<>(); //领养申请总数列表
List<Long> agreeCounts = new ArrayList<>(); //当前正领养数量列表
List<String> labels = new ArrayList<>();

for (int i = 0; i < allCountResult.size(); i++) { //遍历所有的adoptCount对象
AdoptCount allCount = allCountResult.get(i); //获取每一个adoptCount对象
AdoptCount agreeCount = null;
allCounts.add(allCount.getCount()); //将每一个adoptCount对象的count属性添加到allCounts列表中
if (i < agreeCountsResult.size()) //agreeCount数量必定≤allCount数量
agreeCount = agreeCountsResult.get(i);
labels.add(allCount.getYear() + "-" + allCount.getMonth());
if (agreeCount == null //如果当前agreeCount为空,或者年月与allCount中的不相同,则:
|| allCount.getYear().intValue() != agreeCount.getYear().intValue()
|| allCount.getMonth().intValue() != agreeCount.getMonth().intValue()
) {
agreeCounts.add(0L); //agreeCounts追加0,确保allCount与agreeCount一一对应
agreeCountsResult.add(i, null); //agreeCountsResult追加null,确保allCountResult与agreeCountResult一一对应
} else {
agreeCounts.add(agreeCount.getCount()); //将每一个agreeCount对象的count属性添加到agreeCounts列表中
}
}

return Message.success()
.add("userCount", userCount)
.add("petCount", petCount)
.add("cmmdCount", cmmdCount)
.add("actCount", actCount)
.add("allCounts", allCounts)
.add("agreeCounts", agreeCounts)
.add("labels", labels);
}

<resultMap id="AdoptCountResultMap" type="cn.edu.zisu.entity.AdoptCount">
<result column="cnt" jdbcType="BIGINT" property="count"/>
<result column="y" jdbcType="INTEGER" property="year"/>
<result column="m" jdbcType="INTEGER" property="month"/>
</resultMap>

<!-- year(),month()是MySQL的函数,用于提取日期字段的年,月。不是随便写的-->
<select id="selectAllAdoptCount" resultMap="AdoptCountResultMap">
select count(*) cnt,year(taa.apply_time) y, month(taa.apply_time) m
from tb_apply_adopt taa
group by year(taa.apply_time), month(taa.apply_time)
order by year(taa.apply_time) desc, month(taa.apply_time) desc
limit 0,5
</select>

<select id="selectAgreeAdoptCount" resultMap="AdoptCountResultMap">
select count(*) cnt,year(taa.apply_time) y, month(taa.apply_time) m
from tb_apply_adopt taa
where taa.check_state = 1
group by year(taa.apply_time), month(taa.apply_time)
order by year(taa.apply_time) desc, month(taa.apply_time) desc
limit 0,5
</select>

package cn.edu.zisu.entity;

public class AdoptCount {
private Long count;
private Integer year;
private Integer month;

@Override
public String toString() {
return "MsgCount{" +
"count=" + count +
", year=" + year +
", month=" + month +
'}';
}

public Integer getYear() {
return year;
}

public void setYear(Integer year) {
this.year = year;
}

public Integer getMonth() {
return month;
}

public void setMonth(Integer month) {
this.month = month;
}

public Long getCount() {
return count;
}

public void setCount(Long count) {
this.count = count;
}

}

结果:

标签:time,程序,month,add,人生,taa,year,apply
From: https://www.cnblogs.com/yx-study/p/18327256

相关文章

  • STM32自定义协议串口接收解析指令程序
    1、在使用串口接收自定义协议指令时,需要串口解析收到的是什么指令,举例通信报文为上位机->单片机名称长度备注帧头1Byte0x5A0x5A帧长度1Byte数据包的长度0x00-0xFF数据包命令字1Byte功能标识数据可以为空校验1Byte数据包所有字节按位异......
  • 01-从WordCount程序理解Spark术语及术语间的关系
    1.应用程序(Application)通过下面的代码设置应用程序名称,设置后再UI中可以看到相应的名称。//1.设置Application的名称valconf=newSparkConf()conf.setAppName("WordCount")conf.setMaster("local")2.作业(Job)Job由scala的执行算子生成,每个执行的算子会调起runjob,从而......
  • ssm+vue4s店汽车销售管理系统【开题+程序+论文】-计算机毕业设计
    本系统(程序+源码)带文档lw万字以上文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着汽车行业的蓬勃发展,4S店(集整车销售、零配件、售后服务、信息反馈四位一体的汽车销售服务企业)作为汽车销售与服务的重要渠道,其管理效率与服务质量......
  • ssm+vueAndroid共享停车位【开题+程序+论文】-计算机毕业设计
    本系统(程序+源码)带文档lw万字以上文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着城市化进程的加速,私家车数量急剧增加,停车难问题日益凸显,尤其是在繁华商业区、医院、学校等热点区域,停车位供需矛盾尤为突出。传统的停车管理模式......
  • 如何在Linux上的python中以后台模式打开程序?
    我需要在Linux上以后台模式使用python打开另一个程序。我尝试过subprocess.call("yourcommand")但它不是后台模式。并且os.startfile("file")在Linux上不起作用。请帮助我。可以使用Python的subprocess模块在Linux上以后台模......
  • Linux工作原理10网络应用程序和服务
    10网络应用程序和服务本章探讨基本的网络应用--在用户空间运行的客户端和服务器,它们位于应用层。由于这一层位于堆栈的顶层,离最终用户很近,因此你可能会发现这部分内容比第9章的内容更容易理解。事实上,你每天都在与网络浏览器等网络客户端应用程序交互。为了完成工作,网络客户......
  • 如何将flask应用程序分成多个py文件?
    我的Flask应用程序当前由一个具有多个路径的文件组成,并定义了路径。有什么方法可以创建一个test.py文件,其中包含main()中未处理的路由吗?test2.py我担心test.py中的路由太多,并且希望使其可以[email protected]('/somepath')defsomehandler(......
  • 开发一个志愿者小程序源码志愿者APP源码志愿者小程序开发志愿者APP开发小程序源码志愿
    开发一个志愿者小程序是一个涉及多个步骤和技术领域的项目。以下是开发志愿者小程序的基本步骤和考虑要点:###1.需求分析-**目标定义**:明确小程序的目标,比如连接志愿者与非营利组织,提高公益活动的可见度和参与度。-**用户研究**:理解目标用户(志愿者和组织者)的需求和痛点。......
  • 【微信小程序开发】API使用、自定义组件、页面实现图解超详细
    文章目录常用API消息交互消息加载转发给朋友模态对话框获取用户信息调起客户端扫码界面发起支付获取位置自定义组件创建自定义组件使用自定义组件组件生命周期组件所在页面的生命周期页面实现淘宝订单简化页面饮品订单简化页面本篇总结更多相关内容可查看常用......
  • Ubuntu14.04QT程序开机自启动(转)
     按语:    linux应用程序设为开机自启动,可修改/etc/rc.local中添加启动代码,但QT应用程序无法自动启动,后参考此文,添加应用(原来做好的desktop文件),成功。1.运行已经编辑好的QT程序,run、debug,生成类似于build-qtplot-Desktop-Debug的文件,当然程序在编译时会显示该debu......