Compare commits
4 Commits
dev_new_co
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 33f8ce0b92 | |||
| 13acda2ddb | |||
| 3f156fe447 | |||
| 921a4b9c54 |
@@ -8,6 +8,7 @@ import com.maibu.core.controller.BaseController;
|
|||||||
import com.maibu.core.domain.AjaxResult;
|
import com.maibu.core.domain.AjaxResult;
|
||||||
import com.maibu.core.page.TableDataInfo;
|
import com.maibu.core.page.TableDataInfo;
|
||||||
import com.maibu.dto.DeviceParamAuthDTO;
|
import com.maibu.dto.DeviceParamAuthDTO;
|
||||||
|
import com.maibu.dto.DeviceRunningStatisticsQueryDTO;
|
||||||
import com.maibu.enums.BusinessType;
|
import com.maibu.enums.BusinessType;
|
||||||
import com.maibu.mapper.DeviceRunStatisticsMapper;
|
import com.maibu.mapper.DeviceRunStatisticsMapper;
|
||||||
import com.maibu.mybatis.LambdaQueryWrapperX;
|
import com.maibu.mybatis.LambdaQueryWrapperX;
|
||||||
@@ -281,6 +282,14 @@ public class DeviceController extends BaseController {
|
|||||||
return getDataTable(deviceService.getDeviceList(getLoginUser(), device));
|
return getDataTable(deviceService.getDeviceList(getLoginUser(), device));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备列表 分配页面
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDeviceBySpiltCode")
|
||||||
|
public AjaxResult getDeviceBySpiltCode(@RequestParam String code) {
|
||||||
|
return AjaxResult.success(deviceService.getDeviceBySpiltCode(code));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备授权修改
|
* 设备授权修改
|
||||||
*/
|
*/
|
||||||
@@ -289,6 +298,14 @@ public class DeviceController extends BaseController {
|
|||||||
return AjaxResult.success(deviceService.paramModifyAuth(dto));
|
return AjaxResult.success(deviceService.paramModifyAuth(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看当前设备有没授权修改参数
|
||||||
|
*/
|
||||||
|
@PostMapping("/runningHistoryStatistics")
|
||||||
|
public AjaxResult runningHistoryStatistics(@RequestBody DeviceRunningStatisticsQueryDTO dto) {
|
||||||
|
return AjaxResult.success(deviceService.runningHistoryStatistics(dto));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看当前设备有没授权修改参数
|
* 查看当前设备有没授权修改参数
|
||||||
*/
|
*/
|
||||||
@@ -297,5 +314,4 @@ public class DeviceController extends BaseController {
|
|||||||
return AjaxResult.success(deviceService.hasPermission(deviceId));
|
return AjaxResult.success(deviceService.hasPermission(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.maibu.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeviceRunningStatisticsQueryDTO {
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
private String deviceId;
|
||||||
|
}
|
||||||
@@ -91,4 +91,6 @@ public interface DeviceMapper extends BaseMapperX<Device> {
|
|||||||
*/
|
*/
|
||||||
public List<String> selectSerialNumbersByProductId(@Param("productId") Long productId);
|
public List<String> selectSerialNumbersByProductId(@Param("productId") Long productId);
|
||||||
|
|
||||||
|
|
||||||
|
public Device selectDeviceBySpiltCode(@Param("code") String code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.maibu.service;
|
package com.maibu.service;
|
||||||
|
|
||||||
import com.maibu.core.business.Device;
|
import com.maibu.core.business.Device;
|
||||||
|
import com.maibu.core.business.DeviceRunningStatusHistory;
|
||||||
import com.maibu.core.business.dto.DeviceBindDTO;
|
import com.maibu.core.business.dto.DeviceBindDTO;
|
||||||
import com.maibu.core.domain.AjaxResult;
|
import com.maibu.core.domain.AjaxResult;
|
||||||
import com.maibu.core.domain.model.LoginUser;
|
import com.maibu.core.domain.model.LoginUser;
|
||||||
import com.maibu.dto.DeviceParamAuthDTO;
|
import com.maibu.dto.DeviceParamAuthDTO;
|
||||||
|
import com.maibu.dto.DeviceRunningStatisticsQueryDTO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -92,8 +94,12 @@ public interface IDeviceService {
|
|||||||
|
|
||||||
public List<Device> getDeviceList(LoginUser loginUser, Device device);
|
public List<Device> getDeviceList(LoginUser loginUser, Device device);
|
||||||
|
|
||||||
|
public Device getDeviceBySpiltCode(String code);
|
||||||
|
|
||||||
public boolean paramModifyAuth(DeviceParamAuthDTO dto);
|
public boolean paramModifyAuth(DeviceParamAuthDTO dto);
|
||||||
|
|
||||||
public boolean hasPermission(String deviceId);
|
public boolean hasPermission(String deviceId);
|
||||||
|
|
||||||
|
public List<DeviceRunningStatusHistory> runningHistoryStatistics(DeviceRunningStatisticsQueryDTO dto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import javax.annotation.Resource;
|
|||||||
|
|
||||||
import com.maibu.constant.CacheConstants;
|
import com.maibu.constant.CacheConstants;
|
||||||
import com.maibu.dto.DeviceParamAuthDTO;
|
import com.maibu.dto.DeviceParamAuthDTO;
|
||||||
|
import com.maibu.dto.DeviceRunningStatisticsQueryDTO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -351,9 +352,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
deviceList.forEach(y -> {
|
deviceList.forEach(y -> {
|
||||||
y.setStatusStatistics(statusStatistics);
|
y.setStatusStatistics(statusStatistics);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
deviceList.sort(Comparator.comparing(Device::getFeStatus));
|
deviceList.sort(Comparator.comparing(Device::getFeStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
return deviceList;
|
return deviceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +383,12 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
return deviceList;
|
return deviceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Device getDeviceBySpiltCode(String code) {
|
||||||
|
return deviceMapper.selectDeviceBySpiltCode(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean paramModifyAuth(DeviceParamAuthDTO dto) {
|
public boolean paramModifyAuth(DeviceParamAuthDTO dto) {
|
||||||
if (dto != null && !StringUtils.isEmpty(dto.getDeviceId())) {
|
if (dto != null && !StringUtils.isEmpty(dto.getDeviceId())) {
|
||||||
@@ -402,4 +409,32 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceRunningStatusHistory> runningHistoryStatistics(DeviceRunningStatisticsQueryDTO dto) {
|
||||||
|
LambdaQueryWrapper<DeviceRunningStatusHistory> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (dto != null && !StringUtils.isEmpty(dto.getDeviceId())) {
|
||||||
|
queryWrapper.eq(DeviceRunningStatusHistory::getDeviceId, dto.getDeviceId());
|
||||||
|
}
|
||||||
|
if (dto != null && dto.getStartTime() != null && dto.getEndTime() != null) {
|
||||||
|
queryWrapper.ge(DeviceRunningStatusHistory::getCreateTime, dto.getStartTime());
|
||||||
|
queryWrapper.le(DeviceRunningStatusHistory::getCreateTime, dto.getEndTime());
|
||||||
|
}
|
||||||
|
List<DeviceRunningStatusHistory> list = deviceStatusHistoryMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
|
String key = "running_status:" + dto.getDeviceId();
|
||||||
|
DeviceStatusRecordDTO recordDTO = redisCache.getCacheObject(key);
|
||||||
|
List<DeviceRunningStatusHistory> cacheList;
|
||||||
|
if (recordDTO != null) {
|
||||||
|
cacheList = recordDTO.getHistories();
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
if (!CollectionUtils.isEmpty(cacheList)) {
|
||||||
|
list.addAll(cacheList);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return cacheList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,6 +261,11 @@
|
|||||||
where serial_number = #{serialNumber}
|
where serial_number = #{serialNumber}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDeviceBySpiltCode" parameterType="String" resultMap="DeviceResult">
|
||||||
|
<include refid="selectDeviceVo"/>
|
||||||
|
where device_name like concat('%', #{code}, '%')
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectDeviceCountBySerialNumber" parameterType="String" resultType="int">
|
<select id="selectDeviceCountBySerialNumber" parameterType="String" resultType="int">
|
||||||
select count(device_id)
|
select count(device_id)
|
||||||
from iot_device
|
from iot_device
|
||||||
|
|||||||
Reference in New Issue
Block a user