mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
代码优化
This commit is contained in:
parent
00634e17f2
commit
ff1006b8e9
@ -346,6 +346,7 @@ public class EqHomeController extends BaseController {
|
|||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public TableDataInfo<EqEquipmentVo> list(EqAppHomeBo bo, PageQuery pageQuery){
|
public TableDataInfo<EqEquipmentVo> list(EqAppHomeBo bo, PageQuery pageQuery){
|
||||||
//当前用户为家庭主体 切换用户后需要传输用户id
|
//当前用户为家庭主体 切换用户后需要传输用户id
|
||||||
|
//zc todo 需要返回半开门设置
|
||||||
Long currentUserId = LoginHelper.getUserId();
|
Long currentUserId = LoginHelper.getUserId();
|
||||||
boolean shared=true;
|
boolean shared=true;
|
||||||
List<Long> equipmentIdIds=null;
|
List<Long> equipmentIdIds=null;
|
||||||
|
|||||||
@ -100,6 +100,12 @@ public class EqEquipmentVo implements Serializable {
|
|||||||
@ExcelDictFormat(dictType = "eq_line_status")
|
@ExcelDictFormat(dictType = "eq_line_status")
|
||||||
private Integer lineStatus;
|
private Integer lineStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //半开门功能开关:关 false
|
||||||
|
* //半开门功能开关:开 true
|
||||||
|
*/
|
||||||
|
private Boolean PartOpenSwitch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定时间
|
* 绑定时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package org.dromara.web.service.impl;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.MessageUtils;
|
import org.dromara.common.core.utils.MessageUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
@ -97,6 +98,7 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
|||||||
}
|
}
|
||||||
record.setStatus(telemetryMsg.getOpenPercentage());
|
record.setStatus(telemetryMsg.getOpenPercentage());
|
||||||
record.setFaultStatus(telemetryMsg.getGarageException());
|
record.setFaultStatus(telemetryMsg.getGarageException());
|
||||||
|
record.setPartOpenSwitch(telemetryMsg.getPartOpenSwitch());
|
||||||
|
|
||||||
//开合状态
|
//开合状态
|
||||||
record.setOpenStatus(telemetryMsg.getOpenPercentage());
|
record.setOpenStatus(telemetryMsg.getOpenPercentage());
|
||||||
@ -432,6 +434,7 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
|||||||
//2.查询OTA资源包
|
//2.查询OTA资源包
|
||||||
// DeviceOtaPackages deviceOtaPackages = iotService.httpOtaLastPackages(profileIdId);
|
// DeviceOtaPackages deviceOtaPackages = iotService.httpOtaLastPackages(profileIdId);
|
||||||
List<DeviceOtaPackages> list = iotService.httpOtaPackages(profileIdId);
|
List<DeviceOtaPackages> list = iotService.httpOtaPackages(profileIdId);
|
||||||
|
if (CollUtil.isEmpty(list)) throw new ServiceException("未获取到OTA资源包");
|
||||||
DeviceOtaPackages lastOtaPackage = list.get(0);
|
DeviceOtaPackages lastOtaPackage = list.get(0);
|
||||||
DeviceOtaPackages currentOtaPackage = null;
|
DeviceOtaPackages currentOtaPackage = null;
|
||||||
|
|
||||||
|
|||||||
@ -16,12 +16,17 @@ import org.dromara.web.config.LastWebSocketParamDto;
|
|||||||
import org.dromara.web.controller.app.EqDeviceController;
|
import org.dromara.web.controller.app.EqDeviceController;
|
||||||
import org.dromara.web.controller.app.EqHomeController;
|
import org.dromara.web.controller.app.EqHomeController;
|
||||||
import org.dromara.web.domain.bo.EqAppHomeBo;
|
import org.dromara.web.domain.bo.EqAppHomeBo;
|
||||||
|
import org.dromara.web.domain.bo.EqUserConfigBo;
|
||||||
import org.dromara.web.domain.vo.EqEquipmentDetailVo;
|
import org.dromara.web.domain.vo.EqEquipmentDetailVo;
|
||||||
import org.dromara.web.domain.vo.EqEquipmentVo;
|
import org.dromara.web.domain.vo.EqEquipmentVo;
|
||||||
|
import org.dromara.web.domain.vo.EqUserConfigVo;
|
||||||
|
import org.dromara.web.service.IEqUserConfigService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName : WebSocketHandler
|
* @ClassName : WebSocketHandler
|
||||||
@ -39,18 +44,23 @@ public class WebSocketBusinessHandler implements WebSocketApi {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EqHomeController homeController;
|
private EqHomeController homeController;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IEqUserConfigService userConfigService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealWithDetailMsg(LoginUser loginUser, String msg) {
|
public void dealWithDetailMsg(LoginUser loginUser, String msg) {
|
||||||
EqAppHomeBo bo = null;
|
EqAppHomeBo bo = null;
|
||||||
String sendMsg = "";
|
String sendMsg = "";
|
||||||
R<EqEquipmentDetailVo> deviceMsg = null;
|
R<EqEquipmentDetailVo> deviceMsg = null;
|
||||||
boolean isTrue = true;
|
boolean isTrue = true;
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
try {
|
try {
|
||||||
|
initLanguage(userId);
|
||||||
bo = JSON.parseObject(msg, EqAppHomeBo.class);
|
bo = JSON.parseObject(msg, EqAppHomeBo.class);
|
||||||
LastWebSocketParamDto dto = new LastWebSocketParamDto();
|
LastWebSocketParamDto dto = new LastWebSocketParamDto();
|
||||||
dto.setMethod(Constants.METHOD_EQ_DETAIL);
|
dto.setMethod(Constants.METHOD_EQ_DETAIL);
|
||||||
dto.setBo(bo);
|
dto.setBo(bo);
|
||||||
RedisUtils.setCacheObject(Constants.WEBSOCKET_METHOD+loginUser.getUserId(),dto);
|
RedisUtils.setCacheObject(Constants.WEBSOCKET_METHOD+ userId,dto);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("参数错误");
|
log.error("参数错误");
|
||||||
isTrue = false;
|
isTrue = false;
|
||||||
@ -68,7 +78,19 @@ public class WebSocketBusinessHandler implements WebSocketApi {
|
|||||||
// EqEquipmentDetailVo data = deviceMsg.getData();
|
// EqEquipmentDetailVo data = deviceMsg.getData();
|
||||||
sendMsg = JsonUtils.toJsonString(deviceMsg);
|
sendMsg = JsonUtils.toJsonString(deviceMsg);
|
||||||
log.info("socket详情发送:{}",sendMsg);
|
log.info("socket详情发送:{}",sendMsg);
|
||||||
sendMsg(sendMsg,loginUser.getUserId());
|
sendMsg(sendMsg, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initLanguage(Long userId) {
|
||||||
|
EqUserConfigBo userConfigBo = new EqUserConfigBo();
|
||||||
|
userConfigBo.setUserId(userId);
|
||||||
|
List<EqUserConfigVo> eqUserConfigVos = userConfigService.queryList(userConfigBo);
|
||||||
|
if(!eqUserConfigVos.isEmpty()){
|
||||||
|
EqUserConfigVo eqUserConfigVo = eqUserConfigVos.get(0);
|
||||||
|
String languageType = eqUserConfigVo.getLanguageType();
|
||||||
|
String[] languages = languageType.split("_");
|
||||||
|
LocaleContextHolder.setDefaultLocale(new Locale(languages[0], languages[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,12 +98,14 @@ public class WebSocketBusinessHandler implements WebSocketApi {
|
|||||||
EqAppHomeBo bo = null;
|
EqAppHomeBo bo = null;
|
||||||
String sendMsg = "";
|
String sendMsg = "";
|
||||||
boolean isTure = true;
|
boolean isTure = true;
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
try {
|
try {
|
||||||
|
initLanguage(userId);
|
||||||
bo = JSON.parseObject(msg, EqAppHomeBo.class);
|
bo = JSON.parseObject(msg, EqAppHomeBo.class);
|
||||||
LastWebSocketParamDto dto = new LastWebSocketParamDto();
|
LastWebSocketParamDto dto = new LastWebSocketParamDto();
|
||||||
dto.setMethod(Constants.METHOD_EQ_LIST);
|
dto.setMethod(Constants.METHOD_EQ_LIST);
|
||||||
dto.setBo(bo);
|
dto.setBo(bo);
|
||||||
RedisUtils.setCacheObject(Constants.WEBSOCKET_METHOD +loginUser.getUserId(),dto);
|
RedisUtils.setCacheObject(Constants.WEBSOCKET_METHOD + userId,dto);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("参数错误");
|
log.error("参数错误");
|
||||||
sendMsg = "参数错误";
|
sendMsg = "参数错误";
|
||||||
@ -102,7 +126,7 @@ public class WebSocketBusinessHandler implements WebSocketApi {
|
|||||||
}
|
}
|
||||||
sendMsg = isTure? JsonUtils.toJsonString(list):sendMsg;
|
sendMsg = isTure? JsonUtils.toJsonString(list):sendMsg;
|
||||||
log.info("socket列表发送:{}",sendMsg);
|
log.info("socket列表发送:{}",sendMsg);
|
||||||
sendMsg(sendMsg,loginUser.getUserId());
|
sendMsg(sendMsg, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,15 +2,19 @@ package org.dromara.common.core.utils;
|
|||||||
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.NoSuchMessageException;
|
import org.springframework.context.NoSuchMessageException;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取i18n资源文件
|
* 获取i18n资源文件
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class MessageUtils {
|
public class MessageUtils {
|
||||||
|
|
||||||
@ -25,7 +29,9 @@ public class MessageUtils {
|
|||||||
*/
|
*/
|
||||||
public static String message(String code, Object... args) {
|
public static String message(String code, Object... args) {
|
||||||
try {
|
try {
|
||||||
return MESSAGE_SOURCE.getMessage(code, args, LocaleContextHolder.getLocale());
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
// if (locale.toLanguageTag().equals("en")) locale = Locale.CHINA;//zc change with userid because socket I18n
|
||||||
|
return MESSAGE_SOURCE.getMessage(code, args, locale);
|
||||||
} catch (NoSuchMessageException e) {
|
} catch (NoSuchMessageException e) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,9 @@ public class SecurityConfig {
|
|||||||
new AntPathRequestMatcher(adminContextPath + "/assets/**"),
|
new AntPathRequestMatcher(adminContextPath + "/assets/**"),
|
||||||
new AntPathRequestMatcher(adminContextPath + "/login"),
|
new AntPathRequestMatcher(adminContextPath + "/login"),
|
||||||
new AntPathRequestMatcher("/actuator"),
|
new AntPathRequestMatcher("/actuator"),
|
||||||
new AntPathRequestMatcher("/actuator/**")
|
new AntPathRequestMatcher("/actuator/**"),
|
||||||
|
new AntPathRequestMatcher("/protocal"),
|
||||||
|
new AntPathRequestMatcher("/protocal/**")
|
||||||
).permitAll()
|
).permitAll()
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.formLogin((formLogin) ->
|
.formLogin((formLogin) ->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user