websocket线程优化及发送控优化及ota版本优化

This commit is contained in:
zzc 2025-02-26 23:29:56 +08:00
parent d0ca7ffdff
commit dc475755d9
3 changed files with 12 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.dromara.common.core.constant.Constants;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.model.LoginUser;
@ -55,6 +56,7 @@ import java.util.stream.Collectors;
* @date 2024-07-14
*/
@Validated
@Log4j2
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/device")
@ -131,6 +133,7 @@ public class EqDeviceController extends BaseController {
*/
@GetMapping("/operate")
public R<String> operate(EqDeviceCmdBo bo){
log.info("设备控制参数 userId{}, equipmentCode{}, operateType{}",bo.getUserId(),bo.getEquipmentCode(),bo.getOperateType());
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
if (bo.getOperateType() == 0) throw new ServiceException("操作类型不能为0");
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");

View File

@ -476,7 +476,8 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
eqVersionBo.setCurrentVersion(currentVersion);
eqVersionBo.setLatestVersion(null);
}else{
eqVersionBo.setNeedUpdate(true);
if (StringUtils.isBlank(currentVersion)) throw new RuntimeException("设备无当前OTA版本");
eqVersionBo.setNeedUpdate(currentVersion.equals(lastOtaPackage.getVersion()));
eqVersionBo.setCurrentVersion(currentVersion);
eqVersionBo.setLatestVersion(lastOtaPackage.getVersion());
}

View File

@ -203,6 +203,8 @@ public class WebSocketBusinessHandler implements WebSocketApi {
pageQuery.setPageSize(100);
try {
list = homeController.listForWebSocket(bo, pageQuery,loginUser);
canSendFlag = true;
/* zc 去除去重
if (type == 1){
canSendFlag = true;
}else{
@ -211,9 +213,10 @@ public class WebSocketBusinessHandler implements WebSocketApi {
List<EqEquipmentListVo> currentVoList = new ArrayList<>();
if (rows !=null && !rows.isEmpty()){
currentVoList = BeanUtil.copyToList(rows, EqEquipmentListVo.class);
if (RedisUtils.hasKey(key)){
List<EqEquipmentVo> cacheList = RedisUtils.getCacheList(key);
for (EqEquipmentVo cacheVo : cacheList) {
List<EqEquipmentListVo> cacheList = RedisUtils.getCacheList(key);
for (EqEquipmentListVo cacheVo : cacheList) {
for (EqEquipmentListVo currentVo : currentVoList) {
if (cacheVo.getEquipmentId().equals(currentVo.getEquipmentId())){
if (
@ -232,7 +235,7 @@ public class WebSocketBusinessHandler implements WebSocketApi {
}
}
}
if (canSendFlag) RedisUtils.setCacheList(key,currentVoList);
}else{
RedisUtils.setCacheList(key,currentVoList);
canSendFlag = true;
@ -240,7 +243,7 @@ public class WebSocketBusinessHandler implements WebSocketApi {
}else{
canSendFlag = true;
}
}
}*/
} catch (Exception e) {
isTure = false;
sendMsg = "获取设备列表失败"+e.getMessage();