Commit 0789393b authored by co_dengxiongwen's avatar co_dengxiongwen

首页接口调整

parent 9c609a99
package com.devplatform.admin.modules.eq.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@ApiModel(value="当月能耗-天对象",description="当月能耗-天对象")
@TableName("total_day")
public class TotalDay implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键id */
@ApiModelProperty(value="主键ID",name="id")
@TableId
private java.lang.String id;
/** 电能 */
@ApiModelProperty(value="电能",name="electricEnergy")
private java.lang.String electricEnergy;
/** 站点表id */
@ApiModelProperty(value="站点表id",name="stationId")
private java.lang.String stationId;
/** 创建时间 */
@ApiModelProperty(value="创建时间",name="createTime")
private java.util.Date createTime;
}
package com.devplatform.admin.modules.eq.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@ApiModel(value="当天能耗-时对象",description="当天能耗-时对象")
@TableName("total_hour")
public class TotalHour implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键id */
@ApiModelProperty(value="主键ID",name="id")
@TableId
private java.lang.String id;
/** 电能 */
@ApiModelProperty(value="电能",name="electricEnergy")
private java.lang.String electricEnergy;
/** 站点表id */
@ApiModelProperty(value="站点表id",name="stationId")
private java.lang.String stationId;
/** 创建时间 */
@ApiModelProperty(value="创建时间",name="createTime")
private java.util.Date createTime;
}
package com.devplatform.admin.modules.eq.controller;
import com.devplatform.admin.common.utils.AbstractController;
import com.devplatform.admin.common.utils.Constants;
import com.devplatform.admin.modules.sys.bean.SysSystemParams;
import com.devplatform.admin.modules.eq.service.AnalysisService;
import com.devplatform.admin.modules.sys.service.SysFaulalarmService;
import com.devplatform.admin.modules.sys.service.SysSystemParamsService;
import com.devplatform.common.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -15,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -31,7 +27,7 @@ public class AnalysisController extends AbstractController {
@Autowired
private SysFaulalarmService sysFaulalarmService;
@Autowired
private SysSystemParamsService sysSystemParamsService;
private AnalysisService analysisService;
/**
* 首页
......@@ -39,80 +35,8 @@ public class AnalysisController extends AbstractController {
*/
@ApiOperation(value="获取首页展示数据", notes="获取首页展示数据")
@GetMapping("/getSyParam")
public R getSyParam() {
SysSystemParams sysSystemParams = sysSystemParamsService.getById(Constants.STRING_1);
Map<String,Object> map = new HashMap<>();
//系统运行时间
map.put("systemRunningTime",sysSystemParams.getSystemRunningTime());
//报警总数
map.put("faultAlarm",2);
//供暖模式
map.put("sun",1);
//机械通风模式
map.put("fan",2);
//自然通风模式
map.put("nan",2);
//能耗
Map<String,Object> energy = new HashMap<>();
//当天
//手动运行时间-天
energy.put("sdSystemRunningTimeDay",sysSystemParams.getSdSystemRunningTimeDay());
//节能运行时间-天
energy.put("jnSystemRunningTimeDay",sysSystemParams.getJnSystemRunningTimeDay());
energy.put("sdEnergyDay",100);
energy.put("jnEnergyDay",100);
energy.put("totalEnergyDay",200);
//当月
//手动运行时间-月
energy.put("sdSystemRunningTimeMonth",sysSystemParams.getSdSystemRunningTimeMonth());
//节能运行时间-月
energy.put("jnSystemRunningTimeMonth",sysSystemParams.getJnSystemRunningTimeMonth());
energy.put("sdEnergyMonth",100);
energy.put("jnEnergyMonth",100);
energy.put("totalEnergyMonth",200);
map.put("energy",energy);
//能耗统计
List<List<String>> list = new ArrayList<List<String>>();
List<String> listDetail = new ArrayList<String>();
listDetail.add("2021-04-12 8:00:00");
listDetail.add("100");
List<String> listDetail1 = new ArrayList<String>();
listDetail1.add("2021-04-12 9:00:00");
listDetail1.add("200");
List<String> listDetail2 = new ArrayList<String>();
listDetail2.add("2021-04-12 10:00:00");
listDetail2.add("300");
List<String> listDetail3 = new ArrayList<String>();
listDetail3.add("2021-04-12 11:00:00");
listDetail3.add("400");
list.add(listDetail);
list.add(listDetail1);
list.add(listDetail2);
list.add(listDetail3);
List<List<String>> listMonth = new ArrayList<List<String>>();
List<String> listDetailMonth = new ArrayList<String>();
listDetailMonth.add("2021-04-12 8:00:00");
listDetailMonth.add("100");
List<String> listDetailMonth1 = new ArrayList<String>();
listDetailMonth1.add("2021-04-12 9:00:00");
listDetailMonth1.add("200");
List<String> listDetailMonth2 = new ArrayList<String>();
listDetailMonth2.add("2021-04-12 10:00:00");
listDetailMonth2.add("300");
List<String> listDetailMonth3 = new ArrayList<String>();
listDetailMonth3.add("2021-04-12 11:00:00");
listDetailMonth3.add("400");
listMonth.add(listDetailMonth);
listMonth.add(listDetailMonth1);
listMonth.add(listDetailMonth2);
listMonth.add(listDetailMonth3);
map.put("energyList",list);
map.put("energyListMonth",listMonth);
return R.ok().put("bean", map);
public R getSyParam(){
return R.ok().put("bean", analysisService.getSyParam());
}
/**
......
......@@ -6,6 +6,7 @@ import com.devplatform.admin.modules.eq.bean.DlswjInfoHour;
import com.devplatform.common.dao.MyBaseMapper;
import java.util.List;
import java.util.Map;
/**
* DlswjInfoHour Mapper
......@@ -29,4 +30,6 @@ public interface DlswjInfoHourDao extends MyBaseMapper<DlswjInfoHour> {
* @return
*/
List<DlswjInfoHour> queryPageList(DlswjInfoHourModel model);
List<Map<String, Object>> querySum();
}
package com.devplatform.admin.modules.eq.dao;
import org.apache.ibatis.annotations.Mapper;
import com.devplatform.admin.modules.eq.model.TotalDayModel;
import com.devplatform.admin.modules.eq.bean.TotalDay;
import com.devplatform.common.dao.MyBaseMapper;
import java.util.List;
/**
* TotalDay Mapper
* 用于当月能耗-天的数据库操作
* @author Administrator
*
*/
@Mapper
public interface TotalDayDao extends MyBaseMapper<TotalDay> {
/**
* 查询分页数量
* @param model
* @return
*/
Integer queryPageByCount(TotalDayModel model);
/**
* 查询当月能耗-天分页数据
* @param model
* @return
*/
List<TotalDay> queryPageList(TotalDayModel model);
List<TotalDay> queryList();
}
package com.devplatform.admin.modules.eq.dao;
import org.apache.ibatis.annotations.Mapper;
import com.devplatform.admin.modules.eq.model.TotalHourModel;
import com.devplatform.admin.modules.eq.bean.TotalHour;
import com.devplatform.common.dao.MyBaseMapper;
import java.util.List;
/**
* TotalHour Mapper
* 用于当天能耗-时的数据库操作
* @author Administrator
*
*/
@Mapper
public interface TotalHourDao extends MyBaseMapper<TotalHour> {
/**
* 查询分页数量
* @param model
* @return
*/
Integer queryPageByCount(TotalHourModel model);
/**
* 查询当天能耗-时分页数据
* @param model
* @return
*/
List<TotalHour> queryPageList(TotalHourModel model);
List<TotalHour> queryList();
}
package com.devplatform.admin.modules.eq.model;
import com.devplatform.admin.common.model.BaseModel;
import lombok.Data;
/**
* 当月能耗-天的Model
* <br>
* @author 代码生成器产生
*/
@Data
public class TotalDayModel extends BaseModel {
/** 主键id */
private java.lang.String id;
/** 电能 */
private java.lang.String electricEnergy;
/** 站点表id */
private java.lang.String stationId;
/** 创建时间 */
private java.util.Date createTime;
}
package com.devplatform.admin.modules.eq.model;
import com.devplatform.admin.common.model.BaseModel;
import lombok.Data;
/**
* 当天能耗-时的Model
* <br>
* @author 代码生成器产生
*/
@Data
public class TotalHourModel extends BaseModel {
/** 主键id */
private java.lang.String id;
/** 电能 */
private java.lang.String electricEnergy;
/** 站点表id */
private java.lang.String stationId;
/** 创建时间 */
private java.util.Date createTime;
}
package com.devplatform.admin.modules.eq.service;
import java.util.Map;
/**
* 设备的service接口
* @author dxw
*/
public interface AnalysisService {
Map<String,Object> getSyParam();
}
package com.devplatform.admin.modules.eq.service;
import com.devplatform.common.service.MyBaseService;
import com.devplatform.admin.modules.eq.bean.DlswjInfoHour;
import com.devplatform.admin.modules.eq.model.DlswjInfoHourModel;
import com.devplatform.common.service.MyBaseService;
import java.util.List;
import java.util.Map;
/**
* 多联室外机信息-时的service接口
......@@ -22,6 +22,6 @@ public interface DlswjInfoHourService extends MyBaseService<DlswjInfoHour> {
*/
List<DlswjInfoHour> queryPageList(DlswjInfoHourModel model);
List<Map<String,Object>> querySum();
}
package com.devplatform.admin.modules.eq.service;
import com.devplatform.common.service.MyBaseService;
import com.devplatform.admin.modules.eq.bean.TotalDay;
import com.devplatform.admin.modules.eq.model.TotalDayModel;
import java.util.List;
/**
* 当月能耗-天的service接口
* <br>
* <b>功能:</b>TotalDayService<br>
* @author 代码生成器产生
*/
public interface TotalDayService extends MyBaseService<TotalDay> {
/**
* 查询当月能耗-天分页数据
* @param model
* @return
*/
List<TotalDay> queryPageList(TotalDayModel model);
List<TotalDay> queryList();
}
package com.devplatform.admin.modules.eq.service;
import com.devplatform.common.service.MyBaseService;
import com.devplatform.admin.modules.eq.bean.TotalHour;
import com.devplatform.admin.modules.eq.model.TotalHourModel;
import java.util.List;
/**
* 当天能耗-时的service接口
* <br>
* <b>功能:</b>TotalHourService<br>
* @author 代码生成器产生
*/
public interface TotalHourService extends MyBaseService<TotalHour> {
/**
* 查询当天能耗-时分页数据
* @param model
* @return
*/
List<TotalHour> queryPageList(TotalHourModel model);
List<TotalHour> queryList();
}
package com.devplatform.admin.modules.eq.service.impl;
import com.devplatform.admin.common.utils.Constants;
import com.devplatform.admin.common.utils.DateUtil;
import com.devplatform.admin.common.utils.DateUtils;
import com.devplatform.admin.modules.eq.bean.TotalDay;
import com.devplatform.admin.modules.eq.bean.TotalHour;
import com.devplatform.admin.modules.eq.service.*;
import com.devplatform.admin.modules.sys.bean.SysSystemParams;
import com.devplatform.admin.modules.sys.service.SysSystemParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 设备的service接口实现类
* @author dxw
*/
@Service("analysisService")
public class AnalysisServiceImpl implements AnalysisService {
@Autowired
private SysSystemParamsService sysSystemParamsService;
@Autowired
private TotalDayService totalDayService;
@Autowired
private TotalHourService totalHourService;
@Override
public Map<String,Object> getSyParam(){
Map<String,Object> map = new HashMap<>();
try {
SysSystemParams sysSystemParams = sysSystemParamsService.getById(Constants.STRING_1);
//系统运行时间
map.put("systemRunningTime",sysSystemParams.getSystemRunningTime());
//报警总数
map.put("faultAlarm",2);
//供暖模式
map.put("sun",1);
//机械通风模式
map.put("fan",2);
//自然通风模式
map.put("nan",2);
//能耗
Map<String,Object> energy = new HashMap<>();
//当天
//手动运行时间-天
energy.put("sdSystemRunningTimeDay",sysSystemParams.getSdSystemRunningTimeDay());
//节能运行时间-天
energy.put("jnSystemRunningTimeDay",sysSystemParams.getJnSystemRunningTimeDay());
energy.put("sdEnergyDay",100);
energy.put("jnEnergyDay",100);
energy.put("totalEnergyDay",200);
//当月
//手动运行时间-月
energy.put("sdSystemRunningTimeMonth",sysSystemParams.getSdSystemRunningTimeMonth());
//节能运行时间-月
energy.put("jnSystemRunningTimeMonth",sysSystemParams.getJnSystemRunningTimeMonth());
energy.put("sdEnergyMonth",100);
energy.put("jnEnergyMonth",100);
energy.put("totalEnergyMonth",200);
map.put("energy",energy);
//能耗统计
List<List<String>> list = new ArrayList<List<String>>();
//当天
List<TotalHour> listHour = totalHourService.queryList();
for (int i = 0; i < Integer.valueOf(DateUtil.getNowHour()); i++) {
Boolean flag = true;
List<String> listDetail = new ArrayList<String>();
for(TotalHour bean : listHour){
String hour = DateUtil.convertDateToHour(bean.getCreateTime());
if(i == Integer.parseInt(hour)){
listDetail.add(DateUtils.format(bean.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
listDetail.add(bean.getElectricEnergy());
flag = false;
break;
}
}
if(flag){
// 0 代表前面补充0
// 10代表长度为10
// d 代表参数为正数型
listDetail.add(DateUtils.format(new Date()) + String.format("%02d", i) +":00:00");
listDetail.add(Constants.STRING_0);
}
list.add(listDetail);
}
List<List<String>> listMonth = new ArrayList<List<String>>();
//当月
List<TotalDay> listDay = totalDayService.queryList();
for (int i = 0; i < Integer.valueOf(DateUtil.getNowDay()); i++) {
Boolean flag = true;
List<String> listDetail = new ArrayList<String>();
for(TotalDay bean : listDay){
String day = DateUtil.convertDateToDay(bean.getCreateTime());
if(i == Integer.parseInt(day)){
listDetail.add(DateUtils.format(bean.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
listDetail.add(bean.getElectricEnergy());
flag = false;
break;
}
}
if(flag){
// 0 代表前面补充0
// 10代表长度为10
// d 代表参数为正数型
listDetail.add(DateUtils.format(new Date(),"yyyy-MM") +"-" +String.format("%02d", i) +" 00:00:00");
listDetail.add(Constants.STRING_0);
}
listMonth.add(listDetail);
}
map.put("energyList",listDay);
map.put("energyListMonth",listMonth);
}catch (Exception e){
e.printStackTrace();
}
return map;
}
}
package com.devplatform.admin.modules.eq.service.impl;
import org.springframework.stereotype.Service;
import com.devplatform.admin.modules.eq.model.DlswjInfoHourModel;
import com.devplatform.admin.modules.eq.bean.DlswjInfoHour;
import com.devplatform.admin.modules.eq.dao.DlswjInfoHourDao;
import com.devplatform.admin.modules.eq.model.DlswjInfoHourModel;
import com.devplatform.admin.modules.eq.service.DlswjInfoHourService;
import com.devplatform.common.service.impl.MyBaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 多联室外机信息-时的service接口实现类
......@@ -28,4 +26,9 @@ public class DlswjInfoHourServiceImpl extends MyBaseServiceImpl<DlswjInfoHourDao
return baseMapper.queryPageList(model);
}
@Override
public List<Map<String, Object>> querySum() {
return baseMapper.querySum();
}
}
package com.devplatform.admin.modules.eq.service.impl;
import com.devplatform.admin.modules.eq.bean.TotalDay;
import com.devplatform.admin.modules.eq.dao.TotalDayDao;
import com.devplatform.admin.modules.eq.model.TotalDayModel;
import com.devplatform.admin.modules.eq.service.TotalDayService;
import com.devplatform.common.service.impl.MyBaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 当月能耗-天的service接口实现类
* <br>
* <b>功能:</b>TotalDayServiceImpl<br>
* @author 代码生成器产生
*/
@Service("totalDayService")
public class TotalDayServiceImpl extends MyBaseServiceImpl<TotalDayDao, TotalDay> implements TotalDayService {
@Override
public List<TotalDay> queryPageList(TotalDayModel model) {
Integer rowCount = baseMapper.queryPageByCount(model);
model.getPager().setRowCount(rowCount);
return baseMapper.queryPageList(model);
}
@Override
public List<TotalDay> queryList() {
return baseMapper.queryList();
}
}
package com.devplatform.admin.modules.eq.service.impl;
import com.devplatform.admin.modules.eq.bean.TotalHour;
import com.devplatform.admin.modules.eq.dao.TotalHourDao;
import com.devplatform.admin.modules.eq.model.TotalHourModel;
import com.devplatform.admin.modules.eq.service.TotalHourService;
import com.devplatform.common.service.impl.MyBaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 当天能耗-时的service接口实现类
* <br>
* <b>功能:</b>TotalHourServiceImpl<br>
* @author 代码生成器产生
*/
@Service("totalHourService")
public class TotalHourServiceImpl extends MyBaseServiceImpl<TotalHourDao, TotalHour> implements TotalHourService {
@Override
public List<TotalHour> queryPageList(TotalHourModel model) {
Integer rowCount = baseMapper.queryPageByCount(model);
model.getPager().setRowCount(rowCount);
return baseMapper.queryPageList(model);
}
@Override
public List<TotalHour> queryList() {
return baseMapper.queryList();
}
}
......@@ -42,6 +42,10 @@
${pager.mysqlQueryCondition}
</if>
</select>
<select id="querySum" resultType="java.util.Map">
select create_time,sum(cast(electric_energy as decimal(10, 5))) from dlswj_info_hour where TO_DAYS(create_time) = TO_DAYS(NOW())
group by create_time order by create_time
</select>
</mapper>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.devplatform.admin.modules.eq.dao.TotalDayDao">
<!-- Result Map -->
<resultMap id="BaseResultMap" type="com.devplatform.admin.modules.eq.bean.TotalDay">
<result column="id" property="id"/>
<result column="electric_energy" property="electricEnergy"/>
<result column="station_id" property="stationId"/>
<result column="create_time" property="createTime"/>
</resultMap>
<!-- total_day table all fields -->
<sql id="Base_Column_List">
id,electric_energy,station_id,create_time
</sql>
<!-- 公共查询条件 -->
<sql id="Example_Where_Clause">
where t.deleted=0
<if test="id!=null and id!=''">and t.id = #{id}</if>
<if test="electricEnergy!=null and electricEnergy!=''">and t.electric_energy = #{electricEnergy}</if>
<if test="stationId!=null and stationId!=''">and t.station_id = #{stationId}</if>
<if test="createTime!=null ">and t.create_time = #{createTime}</if>
</sql>
<select id="queryPageByCount" parameterType="Object" resultType="java.lang.Integer">
select count(1) from total_day t
<include refid="Example_Where_Clause"/>
</select>
<select id="queryPageList" parameterType="Object" resultMap="BaseResultMap">
select t.* from total_day t
<include refid="Example_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''">
${pager.orderCondition}
</if>
<if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''">
${pager.mysqlQueryCondition}
</if>
</select>
<select id="queryList" resultType="com.devplatform.admin.modules.eq.bean.TotalDay">
select * from total_day where TO_DAYS(create_time) = TO_DAYS(NOW())
order by create_time
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.devplatform.admin.modules.eq.dao.TotalHourDao">
<!-- Result Map -->
<resultMap id="BaseResultMap" type="com.devplatform.admin.modules.eq.bean.TotalHour">
<result column="id" property="id"/>
<result column="electric_energy" property="electricEnergy"/>
<result column="station_id" property="stationId"/>
<result column="create_time" property="createTime"/>
</resultMap>
<!-- total_hour table all fields -->
<sql id="Base_Column_List">
id,electric_energy,station_id,create_time
</sql>
<!-- 公共查询条件 -->
<sql id="Example_Where_Clause">
where t.deleted=0
<if test="id!=null and id!=''">and t.id = #{id}</if>
<if test="electricEnergy!=null and electricEnergy!=''">and t.electric_energy = #{electricEnergy}</if>
<if test="stationId!=null and stationId!=''">and t.station_id = #{stationId}</if>
<if test="createTime!=null ">and t.create_time = #{createTime}</if>
</sql>
<select id="queryPageByCount" parameterType="Object" resultType="java.lang.Integer">
select count(1) from total_hour t
<include refid="Example_Where_Clause"/>
</select>
<select id="queryPageList" parameterType="Object" resultMap="BaseResultMap">
select t.* from total_hour t
<include refid="Example_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''">
${pager.orderCondition}
</if>
<if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''">
${pager.mysqlQueryCondition}
</if>
</select>
<select id="queryList" resultType="com.devplatform.admin.modules.eq.bean.TotalHour">
select * from total_day where DATE_FORMAT(create_time,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m')
order by create_time
</select>
</mapper>
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