修改bug

main
刘政 3 weeks ago
parent 727202d135
commit 35d6b29dda

@ -228,7 +228,7 @@ public class IpChannelServiceImpl extends ServiceImpl<CameraMapper, Camera> impl
} }
// 开启和关闭云台守望 // 开启和关闭云台守望 0表示关闭1表示开启
@Override @Override
@Transactional @Transactional
public boolean ControlSentinel(Long id, int openOrNo, int watchTime, Integer presetIndex) { public boolean ControlSentinel(Long id, int openOrNo, int watchTime, Integer presetIndex) {
@ -237,15 +237,19 @@ public class IpChannelServiceImpl extends ServiceImpl<CameraMapper, Camera> impl
{ {
flag = manageNVR.watchful(id.intValue(), openOrNo, watchTime, -1); flag = manageNVR.watchful(id.intValue(), openOrNo, watchTime, -1);
}else { }else {
if(presetIndex==null)
{
throw new BusinessException(AdminResponseEnum.OPERATION_FAIL, null, "预置点不能为空");
}
flag = manageNVR.watchful(id.intValue(), openOrNo, watchTime, presetIndex); flag = manageNVR.watchful(id.intValue(), openOrNo, watchTime, presetIndex);
} }
if (flag) { if (flag) {
// 获取当前预置点的ptz坐标并且保存 // 获取当前预置点的ptz坐标并且保存
PTZVO ptzLocation = manageNVR.getPTZLocation(id); // PTZVO ptzLocation = manageNVR.getPTZLocation(id);
ptzLocation.setCameraId(id); // ptzLocation.setCameraId(id);
// 将ptz保存到redis中 // 将ptz保存到redis中
stringRedisTemplate.opsForValue().set("camera:sentinel", JSON.toJSONString(ptzLocation)); // stringRedisTemplate.opsForValue().set("camera:sentinel", JSON.toJSONString(ptzLocation));
log.info("ptz 坐标:{}", ptzLocation); // log.info("ptz 坐标:{}", ptzLocation);
Camera camera = this.getById(id); Camera camera = this.getById(id);
// 保存守望信息 // 保存守望信息
camera.setWatchfulTime(watchTime); camera.setWatchfulTime(watchTime);

@ -1,6 +1,7 @@
package com.sz.admin.monitor.service.impl; package com.sz.admin.monitor.service.impl;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.sz.admin.monitor.mapper.CameraMapper; import com.sz.admin.monitor.mapper.CameraMapper;
import com.sz.admin.monitor.mapper.PresetMapper; import com.sz.admin.monitor.mapper.PresetMapper;
@ -84,13 +85,12 @@ public class PresetServiceImpl extends ServiceImpl<PresetMapper, Preset> impleme
throw new BusinessException(AdminResponseEnum.CHANNEL_PRESET_FAIL, null, "当前预置位被设置为守望位,请先关闭或者修改守望位"); throw new BusinessException(AdminResponseEnum.CHANNEL_PRESET_FAIL, null, "当前预置位被设置为守望位,请先关闭或者修改守望位");
} }
if (watchful.getWatchfulState() == 0 && isCurrentWatchful) { if (watchful.getWatchfulState() == 0 && isCurrentWatchful) {
Camera updateEntity = new Camera(); // update Camera set watchfulIndex = null where id = 132 and watchfulIndex = 1
updateEntity.setWatchfulIndex(null); UpdateChain.of(Camera.class)
QueryWrapper updateWrapper = QueryWrapper.create() .set(CameraTableDef.CAMERA.WATCHFUL_INDEX, null)
.from(CameraTableDef.CAMERA)
.where(CameraTableDef.CAMERA.ID.eq(dto.getCameraId())) .where(CameraTableDef.CAMERA.ID.eq(dto.getCameraId()))
.and(CameraTableDef.CAMERA.WATCHFUL_INDEX.eq(dto.getCurrentPresetIndex())); .and(CameraTableDef.CAMERA.WATCHFUL_INDEX.eq(dto.getCurrentPresetIndex()))
int updateCount = cameraMapper.updateByQuery(updateEntity, updateWrapper); .update();
} }
} }
// 3. 删除预置位表中的数据 // 3. 删除预置位表中的数据

Loading…
Cancel
Save