Merge branch '6170' into prod
This commit is contained in:
@ -4,6 +4,7 @@ import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.fuyuanshen.app.domain.bo.AppDeviceBindRecordBo;
|
||||
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceBindRecordVo;
|
||||
@ -27,6 +28,8 @@ import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.exception.TenantException;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import com.fuyuanshen.system.domain.vo.SysTenantVo;
|
||||
import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -59,6 +62,7 @@ public class AppLoginService {
|
||||
private final IAppUserService appUserService;
|
||||
private final IAppDeviceShareService appDeviceShareService;
|
||||
private final IAppDeviceBindRecordService appDeviceBindRecordService;
|
||||
private final DeviceService deviceService;
|
||||
|
||||
|
||||
/**
|
||||
@ -209,8 +213,7 @@ public class AppLoginService {
|
||||
if(ObjectUtil.length(appDeviceBindRecordVos)>0){
|
||||
|
||||
|
||||
// 根据设备id批量删除
|
||||
List<Long> deviceIds = appDeviceBindRecordVos.stream().map(AppDeviceBindRecordVo::getDeviceId).toList();
|
||||
Set<Long> deviceIds = appDeviceBindRecordVos.stream().map(AppDeviceBindRecordVo::getDeviceId).collect(Collectors.toSet());
|
||||
appDeviceShareService.deleteByDeviceIds(deviceIds);
|
||||
|
||||
|
||||
@ -219,6 +222,21 @@ public class AppLoginService {
|
||||
.collect(Collectors.toList());
|
||||
appDeviceBindRecordService.deleteWithValidByIds(ids, true);
|
||||
log.info("删除绑定关系表数据:ids={}",ids);
|
||||
|
||||
|
||||
// 检查设备id是否存在绑定关系
|
||||
for (Long deviceId : deviceIds){
|
||||
// 根据设备id查询是否存在绑定关系
|
||||
Long count = appDeviceBindRecordService.checkDeviceExistBindRecord(deviceId);
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id",deviceId);
|
||||
if(count>0){
|
||||
updateWrapper.set("binding_status",1);
|
||||
}else{
|
||||
updateWrapper.set("binding_status",0);
|
||||
}
|
||||
deviceService.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
|
||||
|
||||
@ -101,13 +101,13 @@ public class AuthController {
|
||||
// 登录
|
||||
LoginVo loginVo = IAuthStrategy.login(body, client, grantType);
|
||||
|
||||
Long userId = LoginHelper.getUserId();
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
SseMessageDto dto = new SseMessageDto();
|
||||
dto.setMessage("欢迎登录fys-Vue-Plus后台管理系统");
|
||||
dto.setUserIds(List.of(userId));
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
// Long userId = LoginHelper.getUserId();
|
||||
// scheduledExecutorService.schedule(() -> {
|
||||
// SseMessageDto dto = new SseMessageDto();
|
||||
// dto.setMessage("欢迎登录fys-Vue-Plus后台管理系统");
|
||||
// dto.setUserIds(List.of(userId));
|
||||
// SseMessageUtils.publishMessage(dto);
|
||||
// }, 5, TimeUnit.SECONDS);
|
||||
return R.ok(loginVo);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.fuyuanshen.app.mapper;
|
||||
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceBindRecordVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 设备绑定关系Mapper接口
|
||||
@ -12,4 +13,5 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface AppDeviceBindRecordMapper extends BaseMapperPlus<AppDeviceBindRecord, AppDeviceBindRecordVo> {
|
||||
|
||||
Long checkDeviceExistBindRecord(@Param("deviceId") Long deviceId);
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 设备分享Mapper接口
|
||||
@ -30,5 +31,5 @@ public interface AppDeviceShareMapper extends BaseMapperPlus<AppDeviceShare, App
|
||||
*/
|
||||
Page<AppDeviceShareVo> selectWebDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
|
||||
|
||||
void deleteByDeviceIds(@Param("deviceIds") List<Long> deviceIds);
|
||||
void deleteByDeviceIds(@Param("deviceIds") Set<Long> deviceIds);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.fuyuanshen.app.domain.vo.AppDeviceBindRecordVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppDeviceBindRecordBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -65,4 +66,6 @@ public interface IAppDeviceBindRecordService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
Long checkDeviceExistBindRecord(Long deviceId);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 设备分享Service接口
|
||||
@ -68,5 +69,5 @@ public interface IAppDeviceShareService {
|
||||
|
||||
TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery);
|
||||
|
||||
void deleteByDeviceIds(List<Long> deviceIds);
|
||||
void deleteByDeviceIds(Set<Long> deviceIds);
|
||||
}
|
||||
|
||||
@ -130,4 +130,9 @@ public class AppDeviceBindRecordServiceImpl implements IAppDeviceBindRecordServi
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long checkDeviceExistBindRecord(Long deviceId) {
|
||||
return baseMapper.checkDeviceExistBindRecord(deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import com.fuyuanshen.app.service.IAppDeviceShareService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 设备分享Service业务层处理
|
||||
@ -168,7 +169,7 @@ public class AppDeviceShareServiceImpl implements IAppDeviceShareService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByDeviceIds(List<Long> deviceIds) {
|
||||
public void deleteByDeviceIds(Set<Long> deviceIds) {
|
||||
baseMapper.deleteByDeviceIds(deviceIds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,4 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper">
|
||||
|
||||
<select id="checkDeviceExistBindRecord" resultType="java.lang.Long">
|
||||
select count(1) from app_device_bind_record where device_id = #{deviceId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -123,4 +123,12 @@ public class DeviceQueryCriteria extends BaseEntity {
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
* 1 已绑定
|
||||
*/
|
||||
@Schema(title = "绑定状态")
|
||||
private Integer bindingStatus;
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
|
||||
@ -74,6 +74,9 @@
|
||||
<if test="criteria.onlineStatus != null">
|
||||
and d.online_status = #{criteria.onlineStatus}
|
||||
</if>
|
||||
<if test="criteria.bindingStatus != null">
|
||||
and d.binding_status = #{criteria.bindingStatus}
|
||||
</if>
|
||||
<if test="criteria.groupId != null">
|
||||
and d.group_id = #{criteria.groupId}
|
||||
</if>
|
||||
@ -305,7 +308,7 @@
|
||||
<select id="getLocationHistory" resultType="com.fuyuanshen.equipment.domain.vo.LocationHistoryVo">
|
||||
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
|
||||
inner join device_type b on a.device_type = b.id
|
||||
|
||||
where b.communication_mode in (0, 2)
|
||||
<if test="bo.deviceType != null">
|
||||
AND b.id = #{bo.deviceType}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user