|
@@ -44,10 +44,12 @@ public class RawDataServiceImpl extends ServiceImpl<RawDataMapper, RawData> impl
|
|
wrapper.eq("device_code",deviceCode);
|
|
wrapper.eq("device_code",deviceCode);
|
|
}
|
|
}
|
|
if (StringUtils.isNotBlank(startDate)){
|
|
if (StringUtils.isNotBlank(startDate)){
|
|
- wrapper.ge("create_time", DateUtil.beginOfDay(new Date()));
|
|
|
|
|
|
+ startDate += " 00:00:00";
|
|
|
|
+ wrapper.ge("create_time", startDate);
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
|
|
|
|
- wrapper.between("create_time", startDate,endDate);
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(endDate)){
|
|
|
|
+ endDate += " 23:59:59";
|
|
|
|
+ wrapper.le("create_time", endDate);
|
|
}
|
|
}
|
|
wrapper.orderByDesc("id");
|
|
wrapper.orderByDesc("id");
|
|
Page<RawData> page = this.page(new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize)), wrapper);
|
|
Page<RawData> page = this.page(new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize)), wrapper);
|
|
@@ -59,27 +61,54 @@ public class RawDataServiceImpl extends ServiceImpl<RawDataMapper, RawData> impl
|
|
String id = paramsMap.get("id");
|
|
String id = paramsMap.get("id");
|
|
String time = paramsMap.get("time");
|
|
String time = paramsMap.get("time");
|
|
Integer value = Integer.valueOf(time);
|
|
Integer value = Integer.valueOf(time);
|
|
-
|
|
|
|
|
|
+ String startDate = paramsMap.get("startDate");
|
|
|
|
+ String endDate = paramsMap.get("endDate");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ List list = new ArrayList();
|
|
RawData rawData = new RawData();
|
|
RawData rawData = new RawData();
|
|
if (StringUtils.isNotBlank(id)){
|
|
if (StringUtils.isNotBlank(id)){
|
|
rawData = this.getById(id);
|
|
rawData = this.getById(id);
|
|
}
|
|
}
|
|
- Date endTime = rawData.getCreateTime();
|
|
|
|
- String data = rawData.getData();
|
|
|
|
- String[] s = data.split(" ");
|
|
|
|
-
|
|
|
|
- List list = new ArrayList();
|
|
|
|
- long timestamp = endTime.getTime() / 1000;
|
|
|
|
- for (int i = 0; i < 60; i++) {
|
|
|
|
- long l = timestamp - ((60 - i) * value); // 修正此行
|
|
|
|
- Date thenTime = new Date(l * 1000); // 将秒转换为毫秒
|
|
|
|
- String str1 = s[i * 2 + 11] + s[i * 2 + 10];
|
|
|
|
- BigDecimal weight = new BigDecimal(Integer.parseInt(str1, 16));
|
|
|
|
- Map weightMap = new HashMap();
|
|
|
|
- weightMap.put("time", sdf.format(thenTime));
|
|
|
|
- weightMap.put("weight",weight);
|
|
|
|
- list.add(weightMap);
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
|
|
|
|
+ String deviceCode = rawData.getDeviceCode();
|
|
|
|
+ QueryWrapper<RawData> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.eq("device_code",deviceCode);
|
|
|
|
+ startDate += " 00:00:00";
|
|
|
|
+ endDate += " 23:59:59";
|
|
|
|
+ wrapper.between("create_time",startDate,endDate);
|
|
|
|
+ wrapper.orderByAsc("id");
|
|
|
|
+ List<RawData> rawDataList = this.list(wrapper);
|
|
|
|
+ for (RawData data : rawDataList) {
|
|
|
|
+ String weightDate = data.getData();
|
|
|
|
+ Date endTime = rawData.getCreateTime();
|
|
|
|
+ String[] s = weightDate.split(" ");
|
|
|
|
+ long timestamp = endTime.getTime() / 1000;
|
|
|
|
+ for (int i = 0; i < 60; i++) {
|
|
|
|
+ long l = timestamp - ((60 - i) * value); // 修正此行
|
|
|
|
+ Date thenTime = new Date(l * 1000); // 将秒转换为毫秒
|
|
|
|
+ String str1 = s[i * 2 + 11] + s[i * 2 + 10];
|
|
|
|
+ BigDecimal weight = new BigDecimal(Integer.parseInt(str1, 16));
|
|
|
|
+ Map weightMap = new HashMap();
|
|
|
|
+ weightMap.put("time", sdf.format(thenTime));
|
|
|
|
+ weightMap.put("weight",weight);
|
|
|
|
+ list.add(weightMap);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ Date endTime = rawData.getCreateTime();
|
|
|
|
+ String data = rawData.getData();
|
|
|
|
+ String[] s = data.split(" ");
|
|
|
|
+ long timestamp = endTime.getTime() / 1000;
|
|
|
|
+ for (int i = 0; i < 60; i++) {
|
|
|
|
+ long l = timestamp - ((60 - i) * value); // 修正此行
|
|
|
|
+ Date thenTime = new Date(l * 1000); // 将秒转换为毫秒
|
|
|
|
+ String str1 = s[i * 2 + 11] + s[i * 2 + 10];
|
|
|
|
+ BigDecimal weight = new BigDecimal(Integer.parseInt(str1, 16));
|
|
|
|
+ Map weightMap = new HashMap();
|
|
|
|
+ weightMap.put("time", sdf.format(thenTime));
|
|
|
|
+ weightMap.put("weight",weight);
|
|
|
|
+ list.add(weightMap);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return new Result(ResultCode.SUCCESS,list);
|
|
return new Result(ResultCode.SUCCESS,list);
|
|
}
|
|
}
|