mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
Merge remote-tracking branch 'origin/5.X' into 5.X
This commit is contained in:
commit
c145400af3
@ -192,6 +192,7 @@ public class AuthController {
|
||||
bo.setUserId(sysUserVo.getUserId());
|
||||
bo.setLanguageType("zh_CN");
|
||||
bo.setTimezoneType("1");//默认 UTC+08:00
|
||||
bo.setZoneId("UTC+08:00");
|
||||
bo.setTimeFormat("YYYY-MM-DD");
|
||||
bo.setCreateBy(sysUserVo.getUserId());
|
||||
bo.setUpdateBy(sysUserVo.getUserId());
|
||||
|
||||
@ -12,7 +12,9 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysDictTypeService;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.dromara.web.device.iot.DeviceDto;
|
||||
import org.dromara.web.domain.bo.*;
|
||||
@ -54,6 +56,8 @@ public class EqDeviceController extends BaseController {
|
||||
private final IEqEquipmentService eqEquipmentService;
|
||||
|
||||
private final IEqEquipmentLogService logService;
|
||||
|
||||
private final ISysDictTypeService dictTypeService;
|
||||
private final IotService iotService;
|
||||
|
||||
private final IEqShareService shareService;
|
||||
@ -136,6 +140,12 @@ public class EqDeviceController extends BaseController {
|
||||
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
||||
String zoneId = bo.getZoneId();
|
||||
if (StringUtils.isEmpty(zoneId)) throw new ServiceException("时区zoneId(如 UTC+08:00)不能为空");
|
||||
/*if (StringUtils.isEmpty(zoneId)) throw new ServiceException("时区zoneId不能为空");
|
||||
List<SysDictDataVo> eqTimezoneType = dictTypeService.selectDictDataByType("eq_timezone_type");
|
||||
String finalZoneId = zoneId;
|
||||
List<SysDictDataVo> collect = eqTimezoneType.stream().filter(dictDataVo -> dictDataVo.getDictValue().equals(finalZoneId)).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) throw new ServiceException("zoneId不正确:"+zoneId);
|
||||
zoneId = collect.get(0).getRemark();*/
|
||||
if (zoneId.contains(" ")) zoneId = zoneId.replace(" ", "+");
|
||||
EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo();
|
||||
eqEquipmentLogBo.setEquipmentId(bo.getEquipmentId());
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : DeviceMsgDto
|
||||
* @Author : ZZC
|
||||
* @Date : 2024/7/25 0:44
|
||||
* @Description : 设备信息
|
||||
**/
|
||||
@Data
|
||||
public class DeviceClientMsgDto implements Serializable {
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String equipmentType;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
private String serializableNum;
|
||||
|
||||
/**
|
||||
* 模组版本
|
||||
*/
|
||||
private String modelVersion;
|
||||
|
||||
/**
|
||||
* MCU版本
|
||||
*/
|
||||
private String mcuVersion;
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : DeviceMsgDto
|
||||
* @Author : ZZC
|
||||
@ -9,7 +11,7 @@ import lombok.Data;
|
||||
* @Description : 设备信息
|
||||
**/
|
||||
@Data
|
||||
public class DeviceServerMsgDto {
|
||||
public class DeviceServerMsgDto implements Serializable {
|
||||
private Boolean lineStatus;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package org.dromara.web.domain;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
@ -37,6 +40,11 @@ public class EqUserConfig extends BaseEntity {
|
||||
*/
|
||||
private String timezoneType;
|
||||
|
||||
/**
|
||||
* 时区id(UTC+8:00)
|
||||
*/
|
||||
private String zoneId;
|
||||
|
||||
/**
|
||||
* 时间格式
|
||||
*/
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package org.dromara.web.domain.bo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.web.domain.EqUserConfig;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
@ -38,6 +41,12 @@ public class EqUserConfigBo extends BaseEntity {
|
||||
@NotNull(message = "时区类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String timezoneType;
|
||||
|
||||
/**
|
||||
* 时区id(UTC+8:00)
|
||||
*/
|
||||
@NotNull(message = "时区id(UTC+8:00)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String zoneId;
|
||||
|
||||
/**
|
||||
* 时间格式
|
||||
*/
|
||||
|
||||
@ -29,6 +29,23 @@ public class EqEquipmentDetailVo implements Serializable {
|
||||
@ExcelProperty(value = "主键ID")
|
||||
private Long equipmentId;
|
||||
|
||||
/**
|
||||
* 设备所属用户id
|
||||
*/
|
||||
private Long ownerUserId;
|
||||
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
@ExcelProperty(value = "区域id")
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@ -122,6 +139,27 @@ public class EqEquipmentDetailVo implements Serializable {
|
||||
@ExcelProperty(value = "绑定时间")
|
||||
private Date bindTime;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String equipmentType;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
private String serializableNum;
|
||||
|
||||
/**
|
||||
* 模组版本
|
||||
*/
|
||||
private String modelVersion;
|
||||
|
||||
/**
|
||||
* MCU版本
|
||||
*/
|
||||
private String mcuVersion;
|
||||
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
|
||||
@ -47,6 +47,13 @@ public class EqUserConfigVo implements Serializable {
|
||||
@ExcelDictFormat(dictType = "eq_timezone_type")
|
||||
private String timezoneType;
|
||||
|
||||
/**
|
||||
* 时区id(UTC+8:00)
|
||||
*/
|
||||
@ExcelProperty(value = "时区id(UTC+8:00)", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "eq_timezone_type")
|
||||
private String zoneId;
|
||||
|
||||
/**
|
||||
* 时间格式
|
||||
*/
|
||||
|
||||
@ -9,16 +9,15 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.web.config.CommonYmlConfig;
|
||||
import org.dromara.web.device.iot.DeviceCtlDto;
|
||||
import org.dromara.web.device.iot.DeviceMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceServerMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceDto;
|
||||
import org.dromara.web.device.iot.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @ClassName : IotService
|
||||
@ -110,7 +109,7 @@ public class IotService {
|
||||
try {
|
||||
jsonObject = JSON.parseArray(send);
|
||||
} catch (Exception e) {
|
||||
log.error("设备信息获取失败,请检查设备编号是否正确,设备编号:{},IOT接口返回:{}", deviceCode, send);
|
||||
log.error("服务端属性获取:设备信息获取失败,请检查设备编号是否正确,设备编号:{},IOT接口返回:{}", deviceCode, send);
|
||||
throw new RuntimeException(MessageUtils.message("message.fault.device.notfound"));
|
||||
}
|
||||
String resultString = JSON.toJSONString(jsonObject.get(0));
|
||||
@ -120,6 +119,47 @@ public class IotService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端属性信息
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public DeviceClientMsgDto httpClientGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("entityType","DEVICE");
|
||||
map.put("entityId",deviceCode);
|
||||
map.put("scope","CLIENT_SCOPE");
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_SCOPE_ATTRIBUTE + "?keys=equipmentType,serializableNum,modelVersion,mcuVersion", map);
|
||||
// String send = getSend(CommonYmlConfig.URL_IOT_SCOPE_ATTRIBUTE + "?keys=", map);
|
||||
log.info("客户端属性获取:设备信息获取成功,设备编号:{},IOT接口返回:{}", deviceCode, send);
|
||||
if (send.startsWith("{")) throw new RuntimeException(MessageUtils.message("message.fault.device.notfound"));
|
||||
JSONArray jsonObject = null;
|
||||
try {
|
||||
jsonObject = JSON.parseArray(send);
|
||||
} catch (Exception e) {
|
||||
log.error("设备信息获取失败,请检查设备编号是否正确,设备编号:{},IOT接口返回:{}", deviceCode, send);
|
||||
throw new RuntimeException(MessageUtils.message("message.fault.device.notfound"));
|
||||
}
|
||||
|
||||
DeviceClientMsgDto result = new DeviceClientMsgDto();
|
||||
for (int i = 0; i < jsonObject.size(); i++) {
|
||||
String resultString = JSON.toJSONString(jsonObject.get(i));
|
||||
Object value = JSON.parseObject(resultString).get("key");
|
||||
if (Objects.isNull(value)|| StringUtils.isBlank(value.toString())) continue;
|
||||
String key = value.toString();
|
||||
if (key.equals("equipmentType")){
|
||||
result.setEquipmentType(JSON.parseObject(resultString).getString("value"));
|
||||
}else if (key.equals("serializableNum")){
|
||||
result.setSerializableNum(JSON.parseObject(resultString).getString("value"));
|
||||
}else if (key.equals("modelVersion")){
|
||||
result.setModelVersion(JSON.parseObject(resultString).getString("value"));
|
||||
}else if (key.equals("mcuVersion")){
|
||||
result.setMcuVersion(JSON.parseObject(resultString).getString("value"));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
|
||||
@ -14,13 +14,16 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.dromara.web.device.*;
|
||||
import org.dromara.web.device.iot.DeviceClientMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceDto;
|
||||
import org.dromara.web.device.iot.DeviceMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceServerMsgDto;
|
||||
import org.dromara.web.domain.EqArea;
|
||||
import org.dromara.web.domain.bo.*;
|
||||
import org.dromara.web.domain.vo.EqEquipmentDetailVo;
|
||||
import org.dromara.web.domain.vo.EqEquipmentStatisticsVo;
|
||||
import org.dromara.web.domain.vo.EqUserEquipmentVo;
|
||||
import org.dromara.web.mapper.EqAreaMapper;
|
||||
import org.dromara.web.service.IotService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.web.domain.vo.EqEquipmentVo;
|
||||
@ -42,6 +45,8 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
|
||||
private final EqEquipmentMapper baseMapper;
|
||||
|
||||
private final EqAreaMapper areaMapper;
|
||||
|
||||
private final IotService iotService;
|
||||
|
||||
private final ISysUserService userService;
|
||||
@ -209,9 +214,23 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
result.setEquipmentCode(bo.getEquipmentCode());
|
||||
//查看设备
|
||||
EqEquipmentVo eqEquipmentVo = baseMapper.selectVoById(bo.getEquipmentId());
|
||||
EqArea eqArea = areaMapper.selectById(eqEquipmentVo.getAreaId());
|
||||
result.setAreaId(eqArea==null?null:eqArea.getAreaId());
|
||||
result.setAreaName(eqArea==null?null:eqArea.getAreaName());
|
||||
result.setOwnerUserId(eqEquipmentVo.getUserId());
|
||||
|
||||
//获取服务属性状态
|
||||
DeviceServerMsgDto serverMsg = iotService.httpServerGetSend(bo.getEquipmentCode());
|
||||
result.setLineStatus(serverMsg.getLineStatus()?1:0);
|
||||
|
||||
//获取客户端属性
|
||||
DeviceClientMsgDto clientMsg = iotService.httpClientGetSend(bo.getEquipmentCode());
|
||||
result.setEquipmentType(clientMsg.getEquipmentType());
|
||||
result.setSerializableNum(clientMsg.getSerializableNum());
|
||||
result.setModelVersion(clientMsg.getModelVersion());
|
||||
result.setMcuVersion(clientMsg.getMcuVersion());
|
||||
|
||||
|
||||
//获取遥测数据
|
||||
DeviceMsgDto telemetryMsg = iotService.httpTelemetryGetSend(bo.getEquipmentCode());
|
||||
|
||||
|
||||
@ -5,14 +5,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<mapper namespace="org.dromara.web.mapper.EqEquipmentMapper">
|
||||
|
||||
|
||||
<select id="selectEquipmentVoPage" resultType="org.dromara.web.domain.vo.EqUserEquipmentVo">
|
||||
<!--<select id="selectEquipmentVoPage" resultType="org.dromara.web.domain.vo.EqUserEquipmentVo">
|
||||
SELECT
|
||||
user_id,
|
||||
nick_name,
|
||||
user_name,
|
||||
COUNT(*) AS bind_num, -- 设备总数
|
||||
SUM(CASE WHEN line_status = 0 THEN 1 ELSE 0 END) AS offline_num, -- 离线个数
|
||||
SUM(CASE WHEN line_status = 1 THEN 1 ELSE 0 END) AS online_num, -- 在线个数
|
||||
COUNT(*) AS bind_num, -- 设备总数
|
||||
SUM(CASE WHEN line_status = 0 THEN 1 ELSE 0 END) AS offline_num, -- 离线个数
|
||||
SUM(CASE WHEN line_status = 1 THEN 1 ELSE 0 END) AS online_num -- 在线个数
|
||||
FROM eq_equipment
|
||||
<where>
|
||||
<if test="nickName != null and nickName != ''">
|
||||
@ -21,6 +21,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY user_name, nick_name
|
||||
</select>-->
|
||||
|
||||
<select id="selectEquipmentVoPage" resultType="org.dromara.web.domain.vo.EqUserEquipmentVo">
|
||||
SELECT
|
||||
e.user_id,
|
||||
s.nick_name,
|
||||
e.user_name,
|
||||
COUNT(*) AS bind_num, -- 设备总数
|
||||
SUM(CASE WHEN e.line_status = 0 THEN 1 ELSE 0 END) AS offline_num, -- 离线个数
|
||||
SUM(CASE WHEN e.line_status = 1 THEN 1 ELSE 0 END) AS online_num -- 在线个数
|
||||
FROM
|
||||
eq_equipment e
|
||||
JOIN
|
||||
sys_user s ON e.user_id = s.user_id
|
||||
<where>
|
||||
<if test="nickName != null and nickName != ''">
|
||||
AND nick_name like
|
||||
CONCAT('%', #{nickName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
e.user_name, s.nick_name;
|
||||
</select>
|
||||
|
||||
<select id="selectStatisticEquipmentList" resultType="org.dromara.web.domain.vo.EqEquipmentStatisticsVo">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user