mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
接口优化
This commit is contained in:
parent
f6f67bce48
commit
29833d0185
@ -30,14 +30,14 @@ import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
import org.dromara.system.service.ISysClientService;
|
||||
import org.dromara.system.service.ISysConfigService;
|
||||
import org.dromara.system.service.ISysSocialService;
|
||||
import org.dromara.system.service.ISysTenantService;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.*;
|
||||
import org.dromara.web.domain.bo.EqUserConfigBo;
|
||||
import org.dromara.web.domain.vo.LoginTenantVo;
|
||||
import org.dromara.web.domain.vo.LoginVo;
|
||||
import org.dromara.web.domain.vo.TenantListVo;
|
||||
import org.dromara.web.service.IAuthStrategy;
|
||||
import org.dromara.web.service.IEqUserConfigService;
|
||||
import org.dromara.web.service.SysLoginService;
|
||||
import org.dromara.web.service.SysRegisterService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -63,6 +63,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
|
||||
private final ISysUserService userService;
|
||||
private final SocialProperties socialProperties;
|
||||
private final SysLoginService loginService;
|
||||
private final SysRegisterService registerService;
|
||||
@ -71,6 +72,7 @@ public class AuthController {
|
||||
private final ISysSocialService socialUserService;
|
||||
private final ISysClientService clientService;
|
||||
private final ScheduledExecutorService scheduledExecutorService;
|
||||
private final IEqUserConfigService iEqUserConfigService;
|
||||
|
||||
|
||||
/**
|
||||
@ -185,6 +187,15 @@ public class AuthController {
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
registerService.register(user);
|
||||
SysUserVo sysUserVo = userService.selectUserByUserName(user.getUsername());
|
||||
EqUserConfigBo bo = new EqUserConfigBo();
|
||||
bo.setUserId(sysUserVo.getUserId());
|
||||
bo.setLanguageType("zh-CN");
|
||||
bo.setTimezoneType("1");//默认 UTC+08:00
|
||||
bo.setTimeFormat("YYYY-MM-DD");
|
||||
bo.setCreateBy(sysUserVo.getUserId());
|
||||
bo.setUpdateBy(sysUserVo.getUserId());
|
||||
iEqUserConfigService.insertByBo(bo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package org.dromara.web.controller.app;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
@ -19,8 +23,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* app 设备业务
|
||||
@ -34,6 +42,10 @@ import java.util.Date;
|
||||
@RequestMapping("/app/device")
|
||||
public class EqDeviceController extends BaseController {
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
|
||||
|
||||
private final IEqAreaService eqAreaService;
|
||||
|
||||
private final IEqEquipmentService eqEquipmentService;
|
||||
@ -104,10 +116,35 @@ public class EqDeviceController extends BaseController {
|
||||
* @return todo
|
||||
*/
|
||||
@GetMapping("/getDeviceLogs")
|
||||
public TableDataInfo<EqEquipmentLogVo> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){
|
||||
public Map<String, List<EqEquipmentLogVo>> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){
|
||||
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
||||
if (bo.getZoneId() == null) throw new ServiceException("时区zoneId(如 UTC+08:00)不能为空");
|
||||
EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo();
|
||||
eqEquipmentLogBo.setEquipmentId(bo.getEquipmentId());
|
||||
return logService.queryPageList(eqEquipmentLogBo, pageQuery);
|
||||
TableDataInfo<EqEquipmentLogVo> data = logService.queryPageList(eqEquipmentLogBo, pageQuery);
|
||||
List<EqEquipmentLogVo> rows = data.getRows();
|
||||
if (CollUtil.isEmpty(rows)) return new HashMap<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String defaultZone = "UTC+08:00";
|
||||
String targetZone = bo.getZoneId();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
List<EqEquipmentLogVo> rowsData = rows.stream().peek(x -> {
|
||||
Integer status = x.getStatus();
|
||||
x.setLogStatus(MessageUtils.message("logStatus.name" + status));
|
||||
if(defaultZone.equals(targetZone)){
|
||||
String dateTimeStr = simpleDateFormat.format(x.getCreateTime());
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(dateTimeStr, formatter);
|
||||
ZoneId utc08 = ZoneId.of(defaultZone);// 默认指定原始时区UTC+08:00
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, utc08);// 转换为ZonedDateTime对象
|
||||
ZoneId utc = ZoneId.of(targetZone);
|
||||
String targetUtc = formatter.format(zonedDateTime.withZoneSameInstant(utc));
|
||||
x.setCreatedYearSecond(targetUtc);
|
||||
x.setCreatedYearDay(targetUtc.split(" ")[0]);
|
||||
x.setCreatedYearSecond(targetUtc.split(" ")[1]);
|
||||
//zc 字典中数据多语言按照录入
|
||||
}
|
||||
}).toList();
|
||||
return rowsData.stream().collect(Collectors.groupingBy(EqEquipmentLogVo::getCreatedYearDay));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -4,14 +4,12 @@ import cn.dev33.satoken.secure.BCrypt;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
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.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.dromara.web.config.CommonYmlConfig;
|
||||
import org.dromara.web.domain.bo.*;
|
||||
import org.dromara.web.domain.vo.*;
|
||||
import org.dromara.web.service.*;
|
||||
@ -19,7 +17,6 @@ import org.dromara.web.domain.bo.EqAppHomeBo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,10 +36,17 @@ public class EqHomeController extends BaseController {
|
||||
|
||||
private final IEqEquipmentService eqEquipmentService;
|
||||
|
||||
private final IEqEquipmentLogService logService;
|
||||
|
||||
private final IEqShareService shareService;
|
||||
private final ISysUserService userService;
|
||||
private final IEqUserConfigService eqUserConfigService;
|
||||
|
||||
/**
|
||||
* 获取用户配置
|
||||
*/
|
||||
@GetMapping("/userConfig")
|
||||
public R<EqUserConfigVo> userConfig() {
|
||||
return R.ok(eqUserConfigService.userConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询家庭主体
|
||||
@ -126,50 +130,7 @@ public class EqHomeController extends BaseController {
|
||||
return R.ok(BCrypt.checkpw(bo.getPassword(), sysUserVo.getPassword()));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
/** todo
|
||||
* 设备状态实时获取
|
||||
* @param bo
|
||||
* @return
|
||||
*//*
|
||||
|
||||
@GetMapping("/getDeviceStatus")
|
||||
public R<EqEquipmentStatusVo> getDeviceStatus(EqAppHomeBo bo){
|
||||
EqEquipmentStatusVo result = new EqEquipmentStatusVo();
|
||||
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/**
|
||||
* 获取日志
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*//*
|
||||
|
||||
@GetMapping("/getDeviceLogs")
|
||||
public TableDataInfo<EqEquipmentLogVo> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){
|
||||
EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo();
|
||||
eqEquipmentLogBo.setEquipmentId(bo.getEquipmentId());
|
||||
return logService.queryPageList(eqEquipmentLogBo, pageQuery);
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* 保存日志
|
||||
* @param eqEquipmentLogBo
|
||||
*//*
|
||||
|
||||
@GetMapping("/saveDeviceLogs")
|
||||
public void saveDeviceLogs(EqEquipmentLogBo eqEquipmentLogBo){
|
||||
logService.insertByBo(eqEquipmentLogBo);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -36,5 +36,10 @@ public class EqAppHomeBo extends BaseEntity{
|
||||
* 密码(密码校验时使用)
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 时区zoneId 用于日志 (传入字典eq_timezone_type 中的remark值 如:UTC+08:00)
|
||||
*/
|
||||
private String zoneId;
|
||||
}
|
||||
|
||||
|
||||
@ -76,9 +76,7 @@ public class EqEquipmentLogBo extends BaseEntity {
|
||||
@NotNull(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer status;
|
||||
|
||||
private String logStatus;
|
||||
|
||||
//todo 返回状态文本
|
||||
|
||||
/**
|
||||
* 故障状态
|
||||
|
||||
@ -55,12 +55,41 @@ public class EqEquipmentLogVo implements Serializable {
|
||||
private String equipmentCode;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 状态 eq_status_log_type
|
||||
* 0.停止中 stop
|
||||
* 1.关闭中 closing
|
||||
* 2.开启中 openning
|
||||
*
|
||||
* 10.无异常 none
|
||||
* 11.红外故障 irException
|
||||
* 12.电机运转故障 motorRunException
|
||||
* 13.电机维护故障 motorMaintainException
|
||||
* 14.设备故障 deviceException
|
||||
*
|
||||
* 101.烟雾报警
|
||||
* 102.红外触发报警
|
||||
* 103.电机运行报警
|
||||
* 104.电机维修报警
|
||||
* 105.非APP开门提醒
|
||||
* 106.非APP关门提醒
|
||||
* 107.关门故障报警
|
||||
* 108.开门故障报警
|
||||
* 109.开门运行提醒
|
||||
* 110.关门运行提醒
|
||||
* 111.忘记关门提醒
|
||||
* 112.门体手动开启提醒
|
||||
* 113.半开门运行提醒
|
||||
* 114.门体停止运行提醒
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "eq_status_type")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 日志状态文本
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
private String logStatus;
|
||||
|
||||
/**
|
||||
* 故障状态
|
||||
*/
|
||||
@ -75,6 +104,17 @@ public class EqEquipmentLogVo implements Serializable {
|
||||
@ExcelDictFormat(dictType = "eq_line_status")
|
||||
private Integer lineStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 年月日时分秒
|
||||
*/
|
||||
@ExcelProperty(value = "年月日时分秒")
|
||||
private String createdYearSecond;
|
||||
|
||||
/**
|
||||
* 年月日
|
||||
*/
|
||||
|
||||
@ -65,4 +65,6 @@ public interface IEqUserConfigService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
EqUserConfigVo userConfig();
|
||||
}
|
||||
|
||||
@ -83,6 +83,7 @@ public class EqEquipmentLogServiceImpl implements IEqEquipmentLogService {
|
||||
lqw.eq(bo.getDayOfWeek() != null, EqEquipmentLog::getDayOfWeek, bo.getDayOfWeek());
|
||||
lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
EqEquipmentLog::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
lqw.orderByDesc(EqEquipmentLog::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.web.domain.bo.EqUserConfigBo;
|
||||
import org.dromara.web.domain.vo.EqUserConfigVo;
|
||||
@ -129,4 +130,11 @@ public class EqUserConfigServiceImpl implements IEqUserConfigService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EqUserConfigVo userConfig() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
LambdaQueryWrapper<EqUserConfig> wrapper = Wrappers.lambdaQuery();
|
||||
return baseMapper.selectVoOne(wrapper.eq(EqUserConfig::getUserId, userId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,3 +258,11 @@ justauth:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
||||
|
||||
iot:
|
||||
baseurl: http://8.219.157.97:8080
|
||||
url:
|
||||
scopeAttribute: /api/plugins/telemetry/{entityType}/{entityId}/values/attributes/{scope}
|
||||
telemetry: /api/plugins/telemetry/{entityType}/{entityId}/values/timeseries
|
||||
operate: /api/plugins/rpc/oneway/{deviceId}
|
||||
device: /api/device/{deviceId}
|
||||
|
||||
@ -124,6 +124,7 @@ security:
|
||||
# actuator 监控配置
|
||||
- /actuator
|
||||
- /actuator/**
|
||||
- /app/text/**
|
||||
|
||||
# 多租户配置
|
||||
tenant:
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package org.dromara.test;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class TimeZoneConversion {
|
||||
private static String getTimeWithZone(String dateTimeStr, String zoneId){
|
||||
// 定义日期时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 将字符串解析为LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(dateTimeStr, formatter);
|
||||
// 默认指定原始时区UTC+08:00
|
||||
ZoneId utc08 = ZoneId.of("UTC+08:00");
|
||||
// 转换为ZonedDateTime对象
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, utc08);
|
||||
// 定义目标时区
|
||||
ZoneId utc = ZoneId.of(zoneId);
|
||||
return formatter.format(zonedDateTime.withZoneSameInstant(utc));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 给定的时间字符串
|
||||
String dateTimeStr = "2024-11-03 00:30:00";
|
||||
String zoneId = "UTC+07:00";
|
||||
String timeWithZone = getTimeWithZone(dateTimeStr, zoneId);
|
||||
System.out.println(timeWithZone);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -20,7 +20,7 @@ import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||
* @author zendwang
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(value = "websocket.enabled", havingValue = "true")
|
||||
@ConditionalOnProperty(value = "websocket.enabled", havingValue = "true")// zc
|
||||
@EnableConfigurationProperties(WebSocketProperties.class)
|
||||
@EnableWebSocket
|
||||
public class WebSocketConfig {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user