Commit b6255bfa by admin

提交修改

parent bf40bf2d
......@@ -215,18 +215,6 @@
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version> 3.2.4.RELEASE </version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -208,10 +208,6 @@ public class DataController {
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(startTime.getTime()));
System.out.println(pt);
List<Data> datas = dataService.findByPtDay(startTime.getTime(), endTime.getTime(), pt);
for(Data d:datas) {
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH").format(d.getTime()));
}
System.out.println("datas:"+datas.size());
JsonResult result = new JsonResult(true, 200, "请求成功", datas);
return JSON.toJSONString(result);
} catch (Exception e) {
......
package com.zhiwei.manage.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.zhiwei.manage.bean.Channel;
import com.zhiwei.manage.bean.Data;
import com.zhiwei.manage.dao.DataDaoImpl;
import com.zhiwei.manage.service.ServerServiceImpl;
@RunWith(SpringJUnit4ClassRunner.class) // 使用junit4进行测试
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class Tests {
@Resource
private DataDaoImpl dd;
@Resource
private ServerServiceImpl sd;
@Test
public void test1() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -5);
List<Channel> list = sd.findDisChannel();
long count = 0;
Map<String, Long> map = new HashMap<>();
for (; cal.getTime().before(new Date()); cal.add(Calendar.HOUR_OF_DAY, 1)) {
for (Channel ch : list) {
if (cal.get(Calendar.HOUR_OF_DAY) == 0) {
count = 0;
map.put(ch.getPt(), count);
}
if (map.get(ch.getPt()) == null) {
map.put(ch.getPt(), (long) (Math.random() * 3000));
} else
map.put(ch.getPt(), map.get(ch.getPt()) + (int) (Math.random() * 3000));
Data d = new Data();
d.setCount(map.get(ch.getPt()));
d.setPt(ch.getPt());
try {
d.setTime(sdf.parse(sdf.format(cal.getTime())));
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(ch.getPt() + ":" + map.get(ch.getPt()));
dd.insertTest(d);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment