diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraChannelMapper.java b/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraChannelMapper.java index 6c3c60be..40d9092b 100644 --- a/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraChannelMapper.java +++ b/renren-admin/src/main/java/io/renren/modules/monitor/mapper/CameraChannelMapper.java @@ -69,4 +69,6 @@ public interface CameraChannelMapper extends BaseDao { Integer selectByParentIdCountNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("path") String path); List selectChannelNumByRegion(); + + void batchSaveMtmLabel(@Param("list") List> list); } diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/service/MonitorService.java b/renren-admin/src/main/java/io/renren/modules/monitor/service/MonitorService.java index f15068d4..3a4b1618 100644 --- a/renren-admin/src/main/java/io/renren/modules/monitor/service/MonitorService.java +++ b/renren-admin/src/main/java/io/renren/modules/monitor/service/MonitorService.java @@ -1,6 +1,7 @@ package io.renren.modules.monitor.service; import cn.hutool.crypto.SecureUtil; +import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -14,7 +15,9 @@ import org.bytedeco.javacv.Frame; import org.bytedeco.javacv.Java2DFrameConverter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.http.*; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -27,6 +30,7 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.PostConstruct; import javax.imageio.ImageIO; +import javax.sql.DataSource; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; @@ -71,6 +75,10 @@ public class MonitorService { @Autowired private BoothMapper boothMapper; + @Lazy + @Autowired + private JdbcTemplate jdbcTemplate; + @Value("${resource.path}") private String fileDir; @Value("${resource.pic-host}") @@ -79,6 +87,18 @@ public class MonitorService { @Value("iOgQotfgfyLvhj6WgfDTpq7F") private String key; + @Value("${synchro.driver-class-name}") + private String jdbcDriverClassName; + + @Value("${synchro.url}") + private String jdbcUrl; + + @Value("${synchro.username}") + private String jdbcUserName; + + @Value("${synchro.password}") + private String jdbcPassWord; + private static final String userName = "ynszdz"; private static final String password = "Admin@123"; private static final String monitorDomain = "http://10.132.191.3:8314"; @@ -1296,9 +1316,31 @@ public class MonitorService { editChannelCount(); //7-同步武伟达的t_channel_mtm_label数据 + synchronizeMtmLabel(); + } + + //同步武伟达的t_channel_mtm_label数据 + public void synchronizeMtmLabel(){ + DruidDataSource druidDataSource = new DruidDataSource(); + druidDataSource.setUrl(jdbcUrl); + druidDataSource.setDriverClassName(jdbcDriverClassName); + druidDataSource.setUsername(jdbcUserName); + druidDataSource.setPassword(jdbcPassWord); + jdbcTemplate.setDataSource(druidDataSource); + + List> maps = jdbcTemplate.queryForList("select * from t_channel_mtm_label"); + if(maps.size() > 0){ + //清空t_channel_mtm_label + cameraOrgenMapper.truncate("t_channel_mtm_label"); + List>> partition = Lists.partition(maps, 200); + partition.forEach(list->{ + cameraChannelMapper.batchSaveMtmLabel(list); + }); + } } + //单独保存视频通道信息 public void batchSaveChannelInfos(List list,String parentId){ List needSave = new ArrayList<>(); diff --git a/renren-admin/src/main/resources/application-my.yml b/renren-admin/src/main/resources/application-my.yml index 30b08690..c26595ea 100644 --- a/renren-admin/src/main/resources/application-my.yml +++ b/renren-admin/src/main/resources/application-my.yml @@ -62,3 +62,10 @@ hisense: qdyjj: ipAndPort: 15.2.21.238:9015 + +#同步摄像头标签表t_channel_mtm_label需要链接的数据库配置 +synchro: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false + username: root + password: Hisense2019 diff --git a/renren-admin/src/main/resources/mapper/monitor/CameraChannelMapper.xml b/renren-admin/src/main/resources/mapper/monitor/CameraChannelMapper.xml index e8a299b8..f7055b14 100644 --- a/renren-admin/src/main/resources/mapper/monitor/CameraChannelMapper.xml +++ b/renren-admin/src/main/resources/mapper/monitor/CameraChannelMapper.xml @@ -217,4 +217,14 @@ + + + INSERT INTO t_channel_mtm_label ( + channel_code,label_code + ) + VALUES + + (#{item.channel_code},#{item.label_code}) + + \ No newline at end of file