Compare commits
4 Commits
6c99cef65d
...
9f0155a6e3
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f0155a6e3 | |||
| 840c4fd68f | |||
| cf883bfa00 | |||
| 6a6397da23 |
@ -6,6 +6,7 @@ import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
@ -53,7 +54,8 @@ public class AppDeviceController extends BaseController {
|
||||
*/
|
||||
@DeleteMapping("/unBind")
|
||||
public R<Void> unBind(Long id) {
|
||||
return toAjax(appDeviceService.unBindDevice(id));
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
return toAjax(appDeviceService.unBindDevice(id,userId,0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -119,7 +119,7 @@ public class MqttMessageConsumer {
|
||||
// }
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("device_imei", message)
|
||||
.eq("online_status", 0)
|
||||
.in("online_status", 0,2)
|
||||
.set("online_status", 1);
|
||||
int update = deviceMapper.update(updateWrapper);
|
||||
// 模拟业务处理耗时
|
||||
|
||||
@ -265,35 +265,53 @@ public class DeviceBizService {
|
||||
if (device == null) {
|
||||
throw new RuntimeException("请先将设备入库!!!");
|
||||
}
|
||||
|
||||
// type: 0 app,1 web
|
||||
if (type == 0) {
|
||||
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
||||
bindRecordQueryWrapper.eq("device_id", device.getId());
|
||||
bindRecordQueryWrapper.eq("binding_user_id", userId);
|
||||
Long count = appDeviceBindRecordMapper.selectCount(bindRecordQueryWrapper);
|
||||
if (count == 0) {
|
||||
throw new RuntimeException("请先绑定设备!!!");
|
||||
}
|
||||
if(count<2){
|
||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||
deviceUpdateWrapper.eq("id", device.getId())
|
||||
.set("binding_user_id", null)
|
||||
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
||||
.set("binding_time", null);
|
||||
deviceMapper.update(null, deviceUpdateWrapper);
|
||||
|
||||
if (userId == null) {
|
||||
userId = AppLoginHelper.getUserId();
|
||||
}
|
||||
}else{
|
||||
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
|
||||
bindRecordQueryWrapper.eq("device_id", device.getId());
|
||||
// 设备端解绑 0:设备端解绑 1:web端解绑
|
||||
if (type == 1) {
|
||||
bindRecordQueryWrapper.eq("binding_user_id", userId);
|
||||
Long count = appDeviceBindRecordMapper.selectCount(bindRecordQueryWrapper);
|
||||
if (count == 0) {
|
||||
throw new RuntimeException("请先绑定设备!!!");
|
||||
}
|
||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||
deviceUpdateWrapper.eq("id", device.getId())
|
||||
.set("binding_user_id", null)
|
||||
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
||||
.set("binding_time", null);
|
||||
deviceMapper.update(null, deviceUpdateWrapper);
|
||||
}
|
||||
|
||||
// AppDeviceBindRecord appDeviceBindRecord = appDeviceBindRecordMapper.selectOne(bindRecordQueryWrapper);
|
||||
// if (appDeviceBindRecord != null) {
|
||||
// return appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId());
|
||||
// }
|
||||
QueryWrapper<AppDeviceBindRecord> brqWrapper = new QueryWrapper<>();
|
||||
brqWrapper.eq("device_id", device.getId());
|
||||
if(userId != null){
|
||||
brqWrapper.eq("binding_user_id", userId);
|
||||
}
|
||||
|
||||
List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(bindRecordQueryWrapper);
|
||||
List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(brqWrapper);
|
||||
if (CollectionUtil.isNotEmpty(appDeviceBindRecordList)) {
|
||||
appDeviceBindRecordList.forEach(appDeviceBindRecord ->
|
||||
appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId()));
|
||||
}
|
||||
|
||||
AppUserVo appUserVo = appUserMapper.selectVoById(userId);
|
||||
if(appUserVo != null){
|
||||
QueryWrapper<AppDeviceShare> appDeviceShareQueryWrapper = new QueryWrapper<>();
|
||||
appDeviceShareQueryWrapper.eq("device_id", device.getId());
|
||||
appDeviceShareQueryWrapper.eq("phonenumber", appUserVo.getPhonenumber());
|
||||
@ -302,6 +320,8 @@ public class DeviceBizService {
|
||||
appDeviceShareList.forEach(appDeviceShare ->
|
||||
appDeviceShareMapper.deleteById(appDeviceShare.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -271,10 +271,10 @@
|
||||
and a.device_name like concat('%', #{criteria.deviceName}, '%')
|
||||
</if>
|
||||
<if test="criteria.deviceImei != null and criteria.deviceImei != ''">
|
||||
and a.device_imei = #{criteria.deviceImei}
|
||||
and a.device_imei like concat('%',#{criteria.deviceImei}, '%')
|
||||
</if>
|
||||
<if test="criteria.content != null and criteria.content != ''">
|
||||
AND (a.device_imei = #{criteria.content} or a.device_mac = #{criteria.content})
|
||||
AND (a.device_imei like concat('%',#{criteria.content}, '%') or a.device_mac like concat('%',#{criteria.content}, '%') )
|
||||
</if>
|
||||
<if test="criteria.deviceStatus != null">
|
||||
and a.device_status = #{criteria.deviceStatus}
|
||||
@ -291,7 +291,7 @@
|
||||
<if test="criteria.onlineStatus != null">
|
||||
and a.online_status = #{criteria.onlineStatus}
|
||||
</if>
|
||||
ORDER BY a.binding_time DESC
|
||||
ORDER BY a.online_status,a.binding_time DESC
|
||||
</select>
|
||||
<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
|
||||
@ -307,10 +307,10 @@
|
||||
AND a.device_mac = #{bo.deviceMac}
|
||||
</if>
|
||||
<if test="bo.deviceImei != null and bo.deviceImei != ''">
|
||||
AND a.device_imei = #{bo.deviceImei}
|
||||
and a.device_imei like concat('%',#{bo.deviceImei}, '%')
|
||||
</if>
|
||||
<if test="bo.content != null and bo.content != ''">
|
||||
AND a.device_imei = #{bo.content} or a.device_mac = #{bo.content}
|
||||
AND (a.device_imei like concat('%',#{bo.content}, '%') or a.device_mac like concat('%',#{bo.content}, '%') )
|
||||
</if>
|
||||
<if test="bo.startTime != null and bo.startTime != ''">
|
||||
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
|
||||
|
||||
Reference in New Issue
Block a user