Administrator
2023-08-19 8d2467a5c6647853df999261e1f5374f6a66da02
Merge remote-tracking branch 'origin/master'
已添加6个文件
已修改8个文件
653 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/channel/controller/ArdChannelController.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/channel/domain/ArdChannel.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/channel/mapper/ArdChannelMapper.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/channel/service/IArdChannelService.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/channel/service/impl/ArdChannelServiceImpl.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/HCNetSDK.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/device/ArdChannelMapper.xml 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java
@@ -137,7 +137,7 @@
            Map option = new HashMap();
            option.put("value", item.getId());
            option.put("label", item.getName());
            option.put("channel", item.getChannel());
            option.put("channel", item.getChanNo());
            List timeList = ardVideoInspectTaskService.getCameraIdleTimeList(item.getId());
            option.put("idleTimeList", timeList);//空闲时间段
            options.add(option);
ard-work/src/main/java/com/ruoyi/device/camera/domain/ArdCameras.java
@@ -1,5 +1,6 @@
package com.ruoyi.device.camera.domain;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.sun.jna.Structure;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -8,6 +9,7 @@
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
import java.util.List;
/**
 * ç›¸æœºè®¾å¤‡å¯¹è±¡ ard_cameras
@@ -72,11 +74,7 @@
    @Excel(name = "光电类型")
    private String gdtype;
    /**
     * é€šé“号
     */
    @Excel(name = "通道号")
    private Integer channel;
    /**
     * ç»åº¦
@@ -175,4 +173,21 @@
    private Integer loginId;
    private String operatorId;
    private Date operatorExpired;
    /**
     * é€šé“号
     */
    private Integer chanNo;
    /**
     * èµ·å§‹é€šé“号
     */
    private Integer startDChan;
    /**
     * é€šé“æ•°
     */
    @Excel(name = "通道数")
    private Integer chanNum;
    /**
     * é€šé“
     */
    private List<ArdChannel> channelList;
}
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);
                }
            }
ard-work/src/main/java/com/ruoyi/device/channel/controller/ArdChannelController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,110 @@
package com.ruoyi.device.channel.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.service.IArdChannelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
 * é€šé“管理Controller
 *
 * @author ard
 * @date 2023-08-19
 */
@RestController
@RequestMapping("/device/channel")
@Api(tags = "通道管理接口")
public class ArdChannelController extends BaseController
{
    @Autowired
    private IArdChannelService ardChannelService;
    /**
     * æŸ¥è¯¢é€šé“管理列表
     */
    @ApiOperation("查询通道管理列表")
//    @PreAuthorize("@ss.hasPermi('device:channel:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArdChannel ardChannel)
    {
        startPage();
        List<ArdChannel> list = ardChannelService.selectArdChannelList(ardChannel);
        return getDataTable(list);
    }
    /**
     * å¯¼å‡ºé€šé“管理列表
     */
    @PreAuthorize("@ss.hasPermi('device:channel:export')")
    @Log(title = "通道管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArdChannel ardChannel)
    {
        List<ArdChannel> list = ardChannelService.selectArdChannelList(ardChannel);
        ExcelUtil<ArdChannel> util = new ExcelUtil<ArdChannel>(ArdChannel.class);
        util.exportExcel(response, list, "通道管理数据");
    }
    /**
     * èŽ·å–é€šé“ç®¡ç†è¯¦ç»†ä¿¡æ¯
     */
    @ApiOperation("获取通道管理详细信息")
//    @PreAuthorize("@ss.hasPermi('device:channel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(ardChannelService.selectArdChannelById(id));
    }
    /**
     * æ–°å¢žé€šé“管理
     */
    @PreAuthorize("@ss.hasPermi('device:channel:add')")
    @Log(title = "通道管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArdChannel ardChannel)
    {
        return toAjax(ardChannelService.insertArdChannel(ardChannel));
    }
    /**
     * ä¿®æ”¹é€šé“管理
     */
    @PreAuthorize("@ss.hasPermi('device:channel:edit')")
    @Log(title = "通道管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArdChannel ardChannel)
    {
        return toAjax(ardChannelService.updateArdChannel(ardChannel));
    }
    /**
     * åˆ é™¤é€šé“管理
     */
    @PreAuthorize("@ss.hasPermi('device:channel:remove')")
    @Log(title = "通道管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ardChannelService.deleteArdChannelByIds(ids));
    }
}
ard-work/src/main/java/com/ruoyi/device/channel/domain/ArdChannel.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,79 @@
package com.ruoyi.device.channel.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
 * é€šé“管理对象 ard_channel
 *
 * @author ard
 * @date 2023-08-19
 */
public class ArdChannel extends BaseEntity
{
    private static final long serialVersionUID = 1L;
    /** id */
    private String id;
    /** é€šé“名称 */
    @Excel(name = "通道名称")
    private String name;
    /** é€šé“号 */
    @Excel(name = "通道号")
    private Integer chanNo;
    /** æ‰€å±žè®¾å¤‡id */
    @Excel(name = "所属设备id")
    private String deviceId;
    public void setId(String id)
    {
        this.id = id;
    }
    public String getId()
    {
        return id;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    public String getName()
    {
        return name;
    }
    public void setChanNo(Integer chanNo)
    {
        this.chanNo = chanNo;
    }
    public Integer getChanNo()
    {
        return chanNo;
    }
    public void setDeviceId(String deviceId)
    {
        this.deviceId = deviceId;
    }
    public String getDeviceId()
    {
        return deviceId;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("name", getName())
            .append("chanNo", getChanNo())
            .append("deviceId", getDeviceId())
            .toString();
    }
}
ard-work/src/main/java/com/ruoyi/device/channel/mapper/ArdChannelMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,69 @@
package com.ruoyi.device.channel.mapper;
import java.util.List;
import com.ruoyi.device.channel.domain.ArdChannel;
/**
 * é€šé“管理Mapper接口
 *
 * @author ard
 * @date 2023-08-19
 */
public interface ArdChannelMapper
{
    /**
     * æŸ¥è¯¢é€šé“管理
     *
     * @param id é€šé“管理主键
     * @return é€šé“管理
     */
    public ArdChannel selectArdChannelById(String id);
    /**
     * æŸ¥è¯¢é€šé“管理列表
     *
     * @param ardChannel é€šé“管理
     * @return é€šé“管理集合
     */
    public List<ArdChannel> selectArdChannelList(ArdChannel ardChannel);
    /**
     * æ–°å¢žé€šé“管理
     *
     * @param ardChannel é€šé“管理
     * @return ç»“æžœ
     */
    public int insertArdChannel(ArdChannel ardChannel);
    /**
     * ä¿®æ”¹é€šé“管理
     *
     * @param ardChannel é€šé“管理
     * @return ç»“æžœ
     */
    public int updateArdChannel(ArdChannel ardChannel);
    /**
     * åˆ é™¤é€šé“管理
     *
     * @param id é€šé“管理主键
     * @return ç»“æžœ
     */
    public int deleteArdChannelById(String id);
    /**
     * æ‰¹é‡åˆ é™¤é€šé“管理
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ•°æ®ä¸»é”®é›†åˆ
     * @return ç»“æžœ
     */
    public int deleteArdChannelByIds(String[] ids);
    /**
     * åˆ é™¤é€šé“管理按设备ID
     *
     * @param deviceId æ‰€å±žè®¾å¤‡ID
     * @return ç»“æžœ
     */
    public int deleteArdChannelByDeviceId(String deviceId);
}
ard-work/src/main/java/com/ruoyi/device/channel/service/IArdChannelService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
package com.ruoyi.device.channel.service;
import java.util.List;
import com.ruoyi.device.channel.domain.ArdChannel;
/**
 * é€šé“管理Service接口
 *
 * @author ard
 * @date 2023-08-19
 */
public interface IArdChannelService
{
    /**
     * æŸ¥è¯¢é€šé“管理
     *
     * @param id é€šé“管理主键
     * @return é€šé“管理
     */
    public ArdChannel selectArdChannelById(String id);
    /**
     * æŸ¥è¯¢é€šé“管理列表
     *
     * @param ardChannel é€šé“管理
     * @return é€šé“管理集合
     */
    public List<ArdChannel> selectArdChannelList(ArdChannel ardChannel);
    /**
     * æ–°å¢žé€šé“管理
     *
     * @param ardChannel é€šé“管理
     * @return ç»“æžœ
     */
    public int insertArdChannel(ArdChannel ardChannel);
    /**
     * ä¿®æ”¹é€šé“管理
     *
     * @param ardChannel é€šé“管理
     * @return ç»“æžœ
     */
    public int updateArdChannel(ArdChannel ardChannel);
    /**
     * æ‰¹é‡åˆ é™¤é€šé“管理
     *
     * @param ids éœ€è¦åˆ é™¤çš„通道管理主键集合
     * @return ç»“æžœ
     */
    public int deleteArdChannelByIds(String[] ids);
    /**
     * åˆ é™¤é€šé“管理信息
     *
     * @param id é€šé“管理主键
     * @return ç»“æžœ
     */
    public int deleteArdChannelById(String id);
    /**
     * åˆ é™¤é€šé“管理信息
     *
     * @param deviceId æ‰€å±žè®¾å¤‡ID
     * @return ç»“æžœ
     */
     public int deleteArdChannelByDeviceId(String deviceId);
}
ard-work/src/main/java/com/ruoyi/device/channel/service/impl/ArdChannelServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,99 @@
package com.ruoyi.device.channel.service.impl;
import java.util.List;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.channel.mapper.ArdChannelMapper;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.service.IArdChannelService;
/**
 * é€šé“管理Service业务层处理
 *
 * @author ard
 * @date 2023-08-19
 */
@Service
public class ArdChannelServiceImpl implements IArdChannelService {
    @Autowired
    private ArdChannelMapper ardChannelMapper;
    /**
     * æŸ¥è¯¢é€šé“管理
     *
     * @param id é€šé“管理主键
     * @return é€šé“管理
     */
    @Override
    public ArdChannel selectArdChannelById(String id) {
        return ardChannelMapper.selectArdChannelById(id);
    }
    /**
     * æŸ¥è¯¢é€šé“管理列表
     *
     * @param ardChannel é€šé“管理
     * @return é€šé“管理
     */
    @Override
    public List<ArdChannel> selectArdChannelList(ArdChannel ardChannel) {
        return ardChannelMapper.selectArdChannelList(ardChannel);
    }
    /**
     * æ–°å¢žé€šé“管理
     *
     * @param ardChannel é€šé“管理
     * @return ç»“æžœ
     */
    @Override
    public int insertArdChannel(ArdChannel ardChannel) {
                ardChannel.setId(IdUtils.simpleUUID());
            return ardChannelMapper.insertArdChannel(ardChannel);
    }
    /**
     * ä¿®æ”¹é€šé“管理
     *
     * @param ardChannel é€šé“管理
     * @return ç»“æžœ
     */
    @Override
    public int updateArdChannel(ArdChannel ardChannel) {
        return ardChannelMapper.updateArdChannel(ardChannel);
    }
    /**
     * æ‰¹é‡åˆ é™¤é€šé“管理
     *
     * @param ids éœ€è¦åˆ é™¤çš„通道管理主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdChannelByIds(String[] ids) {
        return ardChannelMapper.deleteArdChannelByIds(ids);
    }
    /**
     * åˆ é™¤é€šé“管理信息
     *
     * @param id é€šé“管理主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdChannelById(String id) {
        return ardChannelMapper.deleteArdChannelById(id);
    }
    /**
     * åˆ é™¤é€šé“管理信息
     *
     * @param deviceId æ‰€å±žè®¾å¤‡ID
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdChannelByDeviceId(String deviceId) {
        return ardChannelMapper.deleteArdChannelByDeviceId(deviceId);
    }
}
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java
@@ -2,6 +2,9 @@
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.channel.domain.ArdChannel;
import java.util.List;
import java.util.Map;
/**
@@ -103,4 +106,7 @@
    //停止录像-不上传minio
    void recordStopNotToMinio(CameraCmd cmd);
    //获取相机通道信息
    public List<ArdChannel> getCameraChannelList(ArdCameras camera);
}
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
@@ -1,9 +1,12 @@
package com.ruoyi.device.hiksdk.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.annotation.SdkOperate;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.service.IArdChannelService;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.hiksdk.config.MinioClientSingleton;
@@ -13,11 +16,14 @@
import com.ruoyi.device.hiksdk.util.hikSdkUtil.LoginResultCallBack;
import com.ruoyi.storage.minio.utils.MinioUtils;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Base64;
import javax.annotation.Resource;
import java.io.*;
@@ -26,6 +32,7 @@
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.device.hiksdk.util.hikSdkUtil.HCNetSDK.*;
@@ -125,7 +132,7 @@
        GlobalVariable.loginMap.remove(camera.getId());
        GlobalVariable.loginMap.put(camera.getId(), lUserID);
        camera.setLoginId(lUserID);
        camera.setChannel((int) m_strDeviceInfo.byStartChan);
        camera.setStartDChan((int) m_strDeviceInfo.byStartChan);
        return camera;
    }
@@ -1093,7 +1100,7 @@
        log.debug("-----------这里开始图片存入内存----------" + is);
        Base64.Encoder decoder = Base64.getEncoder();
      //  BASE64Encoder encoder = new BASE64Encoder();
        //  BASE64Encoder encoder = new BASE64Encoder();
        String png_base64 = decoder.encodeToString(jpegBuffer.array());//转换成base64串
        png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n
        log.debug("-----------处理完成截图数据----------");
@@ -1386,4 +1393,41 @@
            log.error("录像停止异常" + ex.getMessage());
        }
    }
    //获取IP通道
    @Override
    public List<ArdChannel> getCameraChannelList(ArdCameras camera) {
        /*获取通道*/
        List<ArdChannel> channelList = new ArrayList<>();
        try {
            Integer chanNum = camera.getChanNum();
            Integer startDChan = camera.getStartDChan();
            if (chanNum > 0) {
                // èŽ·å–é€šé“å·
                for (int iChannum = 0; iChannum < chanNum; iChannum++) {
                    ArdChannel ardChannel = new ArdChannel();
                    int channum = iChannum + startDChan+1;
                    HCNetSDK.NET_DVR_PICCFG_V40 strPicCfg = new HCNetSDK.NET_DVR_PICCFG_V40();
                    strPicCfg.dwSize = strPicCfg.size();
                    strPicCfg.write();
                    Pointer pStrPicCfg = strPicCfg.getPointer();
                    NativeLong lChannel = new NativeLong(channum);
                    IntByReference pInt = new IntByReference(0);
                    boolean b_GetPicCfg = hCNetSDK.NET_DVR_GetDVRConfig(camera.getLoginId(), HCNetSDK.NET_DVR_GET_PICCFG_V40, lChannel.intValue(),
                            pStrPicCfg, strPicCfg.size(), pInt);
                    if (b_GetPicCfg) {
                        strPicCfg.read();
                        String channelName = new String(strPicCfg.sChanName, "GBK").trim();
                        ardChannel.setName(channelName);
                    }
                    ardChannel.setDeviceId(camera.getId());
                    ardChannel.setChanNo(iChannum + 1);
                    channelList.add(ardChannel);
                }
            }
        } catch (Exception ex) {
            log.error("获取相机通道异常:" + ex.getMessage());
        }
        return channelList;
    }
}
ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/HCNetSDK.java
@@ -2252,7 +2252,8 @@
    public static class NET_DVR_IPCHANINFO extends HIKSDKStructure {/* IP通道匹配参数 */
        public byte byEnable;                    /* è¯¥é€šé“是否启用 */
        public byte byIPID;                    /* IP设备ID å–值1- MAX_IP_DEVICE */
        public byte byChannel;                    /* é€šé“号 */
        public byte byChannel;                  /* é€šé“号 */
        public byte byIPIDHigh;
        public byte[] byres = new byte[33];                    /* ä¿ç•™ */
ard-work/src/main/java/com/ruoyi/device/hiksdk/util/hikSdkUtil/LoginResultCallBack.java
@@ -3,13 +3,18 @@
import com.ruoyi.alarm.global.domain.GuidePriorityQueue;
import com.ruoyi.alarm.global.domain.GuideTask;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.service.IArdChannelService;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.ruoyi.device.hiksdk.service.IHikClientService;
import com.sun.jna.Pointer;
import lombok.extern.slf4j.Slf4j;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.PriorityBlockingQueue;
/**
@@ -30,6 +35,9 @@
    @Override
    public int invoke(int lUserID, int dwResult, HCNetSDK.NET_DVR_DEVICEINFO_V30 lpDeviceinfo, Pointer pUser) {
        IArdChannelService ardChannelService = SpringUtils.getBean(IArdChannelService.class);
        IHikClientService hikClientService = SpringUtils.getBean(IHikClientService.class);
        IArdCamerasService ardCamerasService = SpringUtils.getBean(IArdCamerasService.class);
        if (GlobalVariable.loginMap.containsKey(camera.getId())) {
            GlobalVariable.loginMap.remove(camera.getId());
        }
@@ -37,17 +45,28 @@
            GlobalVariable.loginMap.put(camera.getId(), lUserID);
            log.debug(camera.getIp() + ":" + camera.getPort() + "登录成功");
            camera.setLoginId(lUserID);
            camera.setChannel((int) lpDeviceinfo.byChanNum);
            camera.setChanNum((int) lpDeviceinfo.byChanNum);
            camera.setStartDChan((int)lpDeviceinfo.byStartDChan);
            //获取最新通道
            List<ArdChannel> cameraChannelList = hikClientService.getCameraChannelList(camera);
            if(cameraChannelList.size()>0) {
                //删除管理通道
                ardChannelService.deleteArdChannelByDeviceId(camera.getId());
                for (ArdChannel channel : cameraChannelList) {
                    channel.setId(IdUtils.simpleUUID());
                    ardChannelService.insertArdChannel(channel);
                }
            }
            //创建引导队列
            Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
            PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000,comparator);
            PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
            GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
        } else {
            log.debug(camera.getIp() + ":" + camera.getPort() + "登录失败");
            camera.setChannel(0);
            camera.setChanNum(0);
            camera.setLoginId(-1);
        }
        IArdCamerasService ardCamerasService = SpringUtils.getBean(IArdCamerasService.class);
        ardCamerasService.updateArdCameras(camera);
        return 1;
    }
ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml
@@ -13,7 +13,7 @@
        <result property="username" column="username"/>
        <result property="password" column="password"/>
        <result property="gdtype" column="gdtype"/>
        <result property="channel" column="channel"/>
        <result property="chanNum" column="channel"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="altitude" column="altitude"/>
@@ -78,7 +78,7 @@
            <if test="username != null  and username != ''">and c.username like '%'||#{username}||'%'</if>
            <if test="password != null  and password != ''">and c.password = #{password}</if>
            <if test="gdtype != null  and gdtype != ''">and c.gdtype = #{gdtype}</if>
            <if test="channel != null ">and c.channel = #{channel}</if>
            <if test="chanNum != null ">and c.channel = #{chanNum}</if>
            <if test="longitude != null ">and c.longitude = #{longitude}</if>
            <if test="latitude != null ">and c.latitude = #{latitude}</if>
            <if test="altitude != null ">and c.altitude = #{altitude}</if>
@@ -111,7 +111,7 @@
            <if test="username != null  and username != ''">and c.username like '%'||#{username}||'%'</if>
            <if test="password != null  and password != ''">and c.password = #{password}</if>
            <if test="gdtype != null  and gdtype != ''">and c.gdtype = #{gdtype}</if>
            <if test="channel != null ">and c.channel = #{channel}</if>
            <if test="chanNum != null ">and c.channel = #{chanNum}</if>
            <if test="longitude != null ">and c.longitude = #{longitude}</if>
            <if test="latitude != null ">and c.latitude = #{latitude}</if>
            <if test="altitude != null ">and c.altitude = #{altitude}</if>
@@ -148,7 +148,7 @@
            <if test="username != null">username,</if>
            <if test="password != null">password,</if>
            <if test="gdtype != null">gdtype,</if>
            <if test="channel != null">channel,</if>
            <if test="chanNum != null">channel,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="altitude != null">altitude,</if>
@@ -179,7 +179,7 @@
            <if test="username != null">#{username},</if>
            <if test="password != null">#{password},</if>
            <if test="gdtype != null">#{gdtype},</if>
            <if test="channel != null">#{channel},</if>
            <if test="chanNum != null">#{chanNum},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="altitude != null">#{altitude},</if>
@@ -213,7 +213,7 @@
            <if test="username != null">username = #{username},</if>
            <if test="password != null">password = #{password},</if>
            <if test="gdtype != null">gdtype = #{gdtype},</if>
            <if test="channel != null">channel = #{channel},</if>
            <if test="chanNum != null">channel = #{chanNum},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="altitude != null">altitude = #{altitude},</if>
ard-work/src/main/resources/mapper/device/ArdChannelMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.device.channel.mapper.ArdChannelMapper">
    <resultMap type="ArdChannel" id="ArdChannelResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="chanNo"    column="chan_no"    />
        <result property="deviceId"    column="device_id"    />
    </resultMap>
    <sql id="selectArdChannelVo">
        select id, name, chan_no, device_id from ard_channel
    </sql>
    <select id="selectArdChannelList" parameterType="ArdChannel" resultMap="ArdChannelResult">
        <include refid="selectArdChannelVo"/>
        <where>
            <if test="deviceId!=null">device_id=#{deviceId}</if>
        </where>
    </select>
    <select id="selectArdChannelById" parameterType="String" resultMap="ArdChannelResult">
        <include refid="selectArdChannelVo"/>
        where id = #{id}
    </select>
    <insert id="insertArdChannel" parameterType="ArdChannel">
        insert into ard_channel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="chanNo != null">chan_no,</if>
            <if test="deviceId != null">device_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="chanNo != null">#{chanNo},</if>
            <if test="deviceId != null">#{deviceId},</if>
         </trim>
    </insert>
    <update id="updateArdChannel" parameterType="ArdChannel">
        update ard_channel
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="chanNo != null">chan_no = #{chanNo},</if>
            <if test="deviceId != null">device_id = #{deviceId},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteArdChannelById" parameterType="String">
        delete from ard_channel where id = #{id}
    </delete>
    <delete id="deleteArdChannelByIds" parameterType="String">
        delete from ard_channel where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteArdChannelByDeviceId" parameterType="String">
        delete from ard_channel where device_id = #{deviceId}
    </delete>
</mapper>