49d66248 张雷

奥体项目实时数据接口开发

1 个父辈 85d87b7a
package com.skua.modules.business.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 奥体资产管理
*/
@Data
@TableName("what_struct_data")
@ApiModel(value="what_struct_data对象", description="奥体资产管理")
public class WhatStructData {
/**主键id*/
@TableId(type = IdType.UUID)
@ApiModelProperty(value = "主键id")
private String id;
/**设备编码*/
@ApiModelProperty(value = "设备编码")
private String equipCode;
/**设备类型*/
@ApiModelProperty(value = "设备类型")
private String equipType;
/**所属系统*/
@ApiModelProperty(value = "所属系统")
private String systemCode;
/**点表ID*/
@ApiModelProperty(value = "点表ID")
private String monitorId;
/**点类型*/
@ApiModelProperty(value = "点类型")
private String monitorType;
/**点实时值*/
@ApiModelProperty(value = "点实时值")
private String monitorValue;
/**所属泵站*/
@ApiModelProperty(value = "所属泵站")
private String pumpCode;
/**备注*/
@ApiModelProperty(value = "备注")
private String remark;
/**创建人id*/
@ApiModelProperty(value = "创建人id")
private String createBy;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**修改人id*/
@ApiModelProperty(value = "修改人id")
private String updateBy;
/**修改时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "修改时间")
private Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private String createDept;
/**所属公司*/
@ApiModelProperty(value = "所属公司")
private String createCmpy;
/**删除标识*/
@ApiModelProperty(value = "删除标识")
private Integer delFlag;
}
......@@ -7,15 +7,19 @@ import com.skua.modules.business.mapper.WhatStructDataMapper;
import com.skua.modules.business.service.IOlympicCenterService;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.TextResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 武汉奥体中心接口
*/
@Slf4j
@Service
public class OlympicCenterServiceImpl implements IOlympicCenterService {
......@@ -224,26 +228,88 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
@Override
public List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
List<EchartResult> list = new ArrayList<>();
for (int i = 0; i < 30; i++) {
if("30".equals(dateType)){
Calendar date = Calendar.getInstance();
date.add(Calendar.DATE, i-30);
String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10);
EchartResult rgsResult = new EchartResult();
rgsResult.setName(newDate);
rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString());
rgsResult.setSeries("日供水量");
list.add(rgsResult);
EchartResult shResult = new EchartResult();
shResult.setName(newDate);
shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString());
shResult.setSeries("生活用水");
list.add(shResult);
EchartResult xzResult = new EchartResult();
xzResult.setName(newDate);
xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString());
xzResult.setSeries("行政用水");
list.add(xzResult);
date.add(Calendar.DATE, -30);
start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
end = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}else{
if(start==null||end==null){
Calendar date = Calendar.getInstance();
date.add(Calendar.DATE, -30);
start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
end = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
}
try{
Long startTime = df.parse(start).getTime();
Long endTime = df.parse(end).getTime();
Long oneDay = 1000 * 60 * 60 * 24l;
Long time = startTime;
if("feed".equals(sourceType)){
while (time <= endTime) {
Date d = new Date(time);
String newDate = df.format(d).substring(5,10);
EchartResult rgsResult = new EchartResult();
rgsResult.setName(newDate);
rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString());
rgsResult.setSeries("日供水量");
list.add(rgsResult);
EchartResult shResult = new EchartResult();
shResult.setName(newDate);
shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString());
shResult.setSeries("生活用水1");
list.add(shResult);
EchartResult xzResult = new EchartResult();
xzResult.setName(newDate);
xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString());
xzResult.setSeries("生活用水2");
list.add(xzResult);
time += oneDay;
}
}else if("hot".equals(sourceType)){
while (time <= endTime) {
Date d = new Date(time);
String newDate = df.format(d).substring(5,10);
EchartResult rgsResult = new EchartResult();
rgsResult.setName(newDate);
rgsResult.setValue(formatDouble(100*getRandom(2.00,3.00)).toString());
rgsResult.setSeries("日供水量");
list.add(rgsResult);
time += oneDay;
}
}else if("fire".equals(sourceType)){
while (time <= endTime) {
Date d = new Date(time);
String newDate = df.format(d).substring(5,10);
EchartResult shResult = new EchartResult();
shResult.setName(newDate);
shResult.setValue(formatDouble(getRandom(4.00,8.00)).toString());
shResult.setSeries("表1");
list.add(shResult);
EchartResult xzResult = new EchartResult();
xzResult.setName(newDate);
xzResult.setValue(formatDouble(getRandom(4.00,8.00)).toString());
xzResult.setSeries("表2");
list.add(xzResult);
time += oneDay;
}
}else{
while (time <= endTime) {
Date d = new Date(time);
String newDate = df.format(d).substring(5,10);
EchartResult rgsResult = new EchartResult();
rgsResult.setName(newDate);
rgsResult.setValue("--");
rgsResult.setSeries("--");
list.add(rgsResult);
time += oneDay;
}
}
}catch (Exception e){
log.error(e.getMessage());
}
return list;
}
......@@ -305,14 +371,21 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
return list;
}
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -7);
String startDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
String start = startDate + " 00:00:00";
String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String end = endDate + " 23:59:59";
System.out.println(start+"-----"+end);
public static void main(String[] args) throws ParseException {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String start = "2023-04-01";
String end = "2023-04-24";
Long startTime = df.parse(start).getTime();
Long endTime = df.parse(end).getTime();
Long oneDay = 1000 * 60 * 60 * 24l;
Long time = startTime;
while (time <= endTime) {
Date d = new Date(time);
System.out.println(df.format(d));
time += oneDay;
}
}
@Override
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!