查出某个特定时间一小时内,两小时内,N小时内的累计和
来源:互联网 发布:mac截图怎么发给别人 编辑:程序博客网 时间:2024/04/29 10:58
public List<Map<String,Object>> rainchart(String year,String stcd,Date tmbegin, Date tmend) {
StringBuilder sql1 = new StringBuilder();
StringBuilder sql = new StringBuilder();
JdbcTemplate temp1=allJDBCTemplate.getJdbcTemplate();
sql1.append("select top 1 rain,tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tmbegin+"' and '"+tmend+"' order by rain desc");
List<Map<String, Object>> list1 =temp1.queryForList(sql1.toString());
List<Map<String, Object>> listall=new ArrayList(6*list1.size());
for(int i=0;i<list1.size();i++){
// Timestamp tm00=new Timestamp( (long) list1.get(i).get("tm"));
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String tm0 = sdf.format(list1.get(i).get("tm"));
Integer shi = Integer.parseInt(tm0.substring(11, 13));
Integer tian = Integer.parseInt(tm0.substring(8, 10));
String shi1 = null;
String shi6 = null;
String shi12 = null;
String shi122 = null;
String shi24 = null;
String shi48 = null;
String shi72 = null;
//1小时
if (shi < 9) {
int shi11 = shi + 1;
shi1 = "0" + String.valueOf(shi11);
} else {
shi1 = String.valueOf(shi + 1);
}
//6小时
if (shi < 3) {
int shi61 = shi + 6;
shi6 = "0" + String.valueOf(shi61);
} else {
shi6 = String.valueOf(shi + 6);
}
// 12小时
String tm12 = null;
if (shi < 13) {
int shi121 = shi + 12;
shi12 = String.valueOf(shi121);
tm12 = tm0.substring(0, 10) + " " + shi12
+ tm0.substring(13, 19);
} else {
String tian12a = null;
if (tian < 31) {
int tian12 = tian + 1;
tian12a = String.valueOf(tian12);
}
shi122 = "06";//06为大概给的时间
tm12 = tm0.substring(0, 8) + tian12a + " " + shi122
+ tm0.substring(13, 19);
}
// 一天(24小时),两天(48小时),三天(72小时)
if (tian < 31) {
int shi241 = tian + 1;
shi24 = String.valueOf(shi241);
}
if (tian < 30) {
int shi481 = tian + 2;
shi48 = String.valueOf(shi481);
}
if (tian < 29) {
int shi721 = tian + 3;
shi72 = String.valueOf(shi721);
}
String tm1 = tm0.substring(0, 10) + " " + shi1
+ tm0.substring(13, 19);
String tm6 = tm0.substring(0, 10) + " " + shi6
+ tm0.substring(13, 19);
String tm24 = tm0.substring(0, 8) + shi24
+ tm0.substring(10, 19);
String tm48 = tm0.substring(0, 8) + shi48
+ tm0.substring(10, 19);
String tm72 = tm0.substring(0, 8) + shi72
+ tm0.substring(10, 19);
sql.append("(select rain as rain,'"+tm0+"' as tm from dt_rain where stcd ='"+stcd+"' and tm='"+tm0+"')");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm1+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm1+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm6+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm6+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm12+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm12+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm24+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm24+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm48+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm48+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm72+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm72+"' )");
JdbcTemplate temp2=allJDBCTemplate.getJdbcTemplate();
List<Map<String, Object>> list =temp2.queryForList(sql.toString());
listall.addAll(list);
}
return listall;
}
StringBuilder sql1 = new StringBuilder();
StringBuilder sql = new StringBuilder();
JdbcTemplate temp1=allJDBCTemplate.getJdbcTemplate();
sql1.append("select top 1 rain,tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tmbegin+"' and '"+tmend+"' order by rain desc");
List<Map<String, Object>> list1 =temp1.queryForList(sql1.toString());
List<Map<String, Object>> listall=new ArrayList(6*list1.size());
for(int i=0;i<list1.size();i++){
// Timestamp tm00=new Timestamp( (long) list1.get(i).get("tm"));
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String tm0 = sdf.format(list1.get(i).get("tm"));
Integer shi = Integer.parseInt(tm0.substring(11, 13));
Integer tian = Integer.parseInt(tm0.substring(8, 10));
String shi1 = null;
String shi6 = null;
String shi12 = null;
String shi122 = null;
String shi24 = null;
String shi48 = null;
String shi72 = null;
//1小时
if (shi < 9) {
int shi11 = shi + 1;
shi1 = "0" + String.valueOf(shi11);
} else {
shi1 = String.valueOf(shi + 1);
}
//6小时
if (shi < 3) {
int shi61 = shi + 6;
shi6 = "0" + String.valueOf(shi61);
} else {
shi6 = String.valueOf(shi + 6);
}
// 12小时
String tm12 = null;
if (shi < 13) {
int shi121 = shi + 12;
shi12 = String.valueOf(shi121);
tm12 = tm0.substring(0, 10) + " " + shi12
+ tm0.substring(13, 19);
} else {
String tian12a = null;
if (tian < 31) {
int tian12 = tian + 1;
tian12a = String.valueOf(tian12);
}
shi122 = "06";//06为大概给的时间
tm12 = tm0.substring(0, 8) + tian12a + " " + shi122
+ tm0.substring(13, 19);
}
// 一天(24小时),两天(48小时),三天(72小时)
if (tian < 31) {
int shi241 = tian + 1;
shi24 = String.valueOf(shi241);
}
if (tian < 30) {
int shi481 = tian + 2;
shi48 = String.valueOf(shi481);
}
if (tian < 29) {
int shi721 = tian + 3;
shi72 = String.valueOf(shi721);
}
String tm1 = tm0.substring(0, 10) + " " + shi1
+ tm0.substring(13, 19);
String tm6 = tm0.substring(0, 10) + " " + shi6
+ tm0.substring(13, 19);
String tm24 = tm0.substring(0, 8) + shi24
+ tm0.substring(10, 19);
String tm48 = tm0.substring(0, 8) + shi48
+ tm0.substring(10, 19);
String tm72 = tm0.substring(0, 8) + shi72
+ tm0.substring(10, 19);
sql.append("(select rain as rain,'"+tm0+"' as tm from dt_rain where stcd ='"+stcd+"' and tm='"+tm0+"')");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm1+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm1+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm6+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm6+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm12+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm12+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm24+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm24+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm48+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm48+"' )");
sql.append(" union all ");
sql.append("(select sum(rain) as rain,'"+tm72+"' as tm from dt_rain where stcd ='"+stcd+"' and tm between '"+tm0+"' and '"+tm72+"' )");
JdbcTemplate temp2=allJDBCTemplate.getJdbcTemplate();
List<Map<String, Object>> list =temp2.queryForList(sql.toString());
listall.addAll(list);
}
return listall;
}
0 0
- 查出某个特定时间一小时内,两小时内,N小时内的累计和
- 两小时内不宜同吃的食物
- ◇ 两小时内不能一起吃的食物
- 两小时内不宜同吃的食物
- 两小时内不宜同吃的食物
- 如何判断一个时间是否在当前的两小时内
- 72小时内的2份兼职
- sudo一个小时内生效
- 一种典型问题的解决-取一个小时内的最后两条记录
- 一个女人13小时内拍的两张照片,所有人看完都沉默了~
- 一个女人13小时内拍的两张照片,所有人看完都沉默了~
- 报表统计,MySQL,统计:时间段内一天中每隔两小时统计的数量
- 请教如何实现SQL查询24小时内,当前时间之前20分钟的信息
- 删除指定文件夹内创建时间24小时之外的所有文件
- 12小时内不重复弹窗口的C#码
- 六小时内破解 Windows 密码的 Linux 群集
- 人死后的36个小时内发生了什么?
- 1小时内必须解决的5个编程问题
- 306. Additive Number
- 06-Zend引擎
- ssm+maven+bootstrap尝试
- 易语言学习第十五课
- 07-再次探讨SAPI
- 查出某个特定时间一小时内,两小时内,N小时内的累计和
- jQuery EasyUI 中EasyLoader加载器
- 139. Word Break
- 08-Apache模块介绍
- 09-通过mod_php5支持PHP
- 11g: Program with PL/SQL - 1Z0-144
- Tablyout 点击tab切换页面闪烁
- bzoj 4004: [JLOI2015]装备购买
- Apache配置信息中文版