增加 设备实时数据接口

master
wangh 2 years ago
parent 1e4bef9fdd
commit 35f612e0b2

@ -3,6 +3,7 @@ package com.haiwei.web.controller.broad;
import com.haiwei.common.core.domain.AjaxResult;
import static com.haiwei.common.core.domain.AjaxResult.*;
import com.haiwei.manage.service.IApiService;
import com.haiwei.manage.service.IBaseCustomerService;
import com.haiwei.manage.service.IBaseDeviceInfoService;
import com.haiwei.manage.service.IBaseDeviceTypeService;
@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/broad")
public class ApiController {
@Autowired
IApiService iApiService;
@Autowired
private IBaseDeviceTypeService baseDeviceTypeService;
@ -44,5 +47,22 @@ public class ApiController {
return success(baseDeviceTypeService.selectBaseDeviceTypeList(null));
}
@ApiOperation(tags = {"60脱水机"}, value = "获取实时数据")
@GetMapping("/home/queryParam")
public AjaxResult queryPram(){
return success(iApiService.queryPram());
}
@ApiOperation(tags = {"60脱水机"}, value = "获取设备状态 1=绿灯 0红灯")
@GetMapping("/home/queryDeviceState")
public AjaxResult queryDeviceState(){
return success(iApiService.queryDeviceState());
}
@ApiOperation(tags = {"60脱水机"}, value = "获取历史趋势")
@GetMapping("/home/queryParamList")
public AjaxResult queryPramList(){
return success(iApiService.queryPram());
}
}

@ -0,0 +1,33 @@
package com.haiwei.manage.domain;
/**
* @author wanghao
* @date 2023/8/30 17:10
*/
public class ParamVo {
private String name, pointname, data;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPointname() {
return pointname;
}
public void setPointname(String pointname) {
this.pointname = pointname;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}

@ -0,0 +1,16 @@
package com.haiwei.manage.mapper;
import com.haiwei.manage.domain.ParamVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author wanghao
* @date 2023/8/30 17:15
*/
@Repository
public interface ApiMapper {
List<ParamVo> queryPram();
List<ParamVo> queryDeviceState();
}

@ -0,0 +1,15 @@
package com.haiwei.manage.service;
import com.haiwei.manage.domain.ParamVo;
import java.util.List;
/**
* @author wanghao
* @date 2023/8/30 17:09
*/
public interface IApiService {
List<ParamVo> queryPram();
List<ParamVo> queryDeviceState();
}

@ -0,0 +1,29 @@
package com.haiwei.manage.service.impl;
import com.haiwei.manage.domain.ParamVo;
import com.haiwei.manage.mapper.ApiMapper;
import com.haiwei.manage.service.IApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author wanghao
* @date 2023/8/30 17:12
*/
@Service
public class ApiServiceImpl implements IApiService {
@Autowired
ApiMapper mapper;
@Override
public List<ParamVo> queryPram() {
return mapper.queryPram();
}
@Override
public List<ParamVo> queryDeviceState() {
return mapper.queryDeviceState();
}
}

@ -0,0 +1,35 @@
<?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.haiwei.manage.mapper.ApiMapper">
<select id="queryPram" resultType="com.haiwei.manage.domain.ParamVo">
SELECT
ee.name,
info.PointName as pointname,
ed.Data as data
FROM EPointData ed
right join (
SELECT PID, MAX(CreateTime) AS LatestTime
FROM EPointData
GROUP BY PID
) ld on ld.PID = ed.PID and ld.LatestTime = CreateTime
right join EPointsInfo info on ed.PID = info.ID
left join EEquipmentMaintenance ee on ee.ID = info.EID
where ee.EquipmentType =1
</select>
<select id="queryDeviceState" resultType="com.haiwei.manage.domain.ParamVo">
SELECT name,
DataType as data
FROM EEquipmentState
where PID=7
</select>
</mapper>
Loading…
Cancel
Save