Administrator
2023-08-19 8d2467a5c6647853df999261e1f5374f6a66da02
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
@@ -11,7 +11,11 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.mapper.ArdChannelMapper;
import com.ruoyi.device.channel.service.IArdChannelService;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.ruoyi.device.hiksdk.service.IHikClientService;
import com.ruoyi.scheduling.domian.SchedulingParam;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.utils.tools.ArdTool;
@@ -43,6 +47,10 @@
    private SysDeptMapper sysDeptMapper;
    @Resource
    private RedisCache redisCache;
    @Resource
    private IHikClientService hikClientService;
    @Resource
    private ArdChannelMapper ardChannelMapper;
    @PostConstruct
@@ -111,7 +119,20 @@
        ardCameras.setCreateTime(DateUtils.getNowDate());
        ardCameras.setUserId(SecurityUtils.getUserId());
        redisCache.setCacheObject(getCacheKey(ardCameras.getId()), ardCameras);
        return ardCamerasMapper.insertArdCameras(ardCameras);
        int i = ardCamerasMapper.insertArdCameras(ardCameras);
        if (i > 0) {
//            //删除当前相机的所有通道
//            ardChannelMapper.deleteArdChannelByDeviceId(ardCameras.getId());
//            //获取相机通道
//            List<ArdChannel> ipChannelList = hikClientService.getCameraChannelList(ardCameras);
//            if (ipChannelList.size() > 0) {
//                for (ArdChannel channel : ipChannelList) {
//                    channel.setId(IdUtils.simpleUUID());
//                    ardChannelMapper.insertArdChannel(channel);
//                }
//            }
        }
        return i;
    }
    /**
@@ -143,6 +164,8 @@
        if (res > 0) {
            for (String id : ids) {
                redisCache.deleteObject(getCacheKey(id));
                //删除当前相机的所有通道
                ardChannelMapper.deleteArdChannelByDeviceId(id);
            }
        }
        return res;
@@ -156,7 +179,12 @@
     */
    @Override
    public int deleteArdCamerasById(String id) {
        return ardCamerasMapper.deleteArdCamerasById(id);
        int i = ardCamerasMapper.deleteArdCamerasById(id);
        if (i > 0) {
            //删除当前相机的所有通道
            ardChannelMapper.deleteArdChannelByDeviceId(id);
        }
        return i;
    }
    public List findOptions(ArdCameras ardCameras) {
@@ -249,7 +277,7 @@
                }
                if (distance != 0.0 && distance <= camera.getCamMaxVisibleDistance()) {
                    distanceMap.put(camera.getId(), distance);
                    camera.setChannel(ArdTool.getChannelBydayNightTime(dayNightTime));
                    camera.setChanNo(ArdTool.getChannelBydayNightTime(dayNightTime));
                    ardCameras.put(distance, camera);
                }
@@ -292,7 +320,7 @@
                double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()};
                double distance = GisTool.getDistance(new double[]{longitude, latitude}, camPosition);
                if (distance <= radius) {
                    camera.setChannel(ArdTool.getChannelBydayNightTime(dayNightTime));
                    camera.setChanNo(ArdTool.getChannelBydayNightTime(dayNightTime));
                    ardCameras.add(camera);
                }
            }