From 561c48194944a2fa68796a429ed5d1425ecf57f6 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Tue, 19 Jul 2022 15:30:44 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=89=8B=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E8=AE=BE=E6=96=BD-=E6=91=84=E5=83=8F?= =?UTF-8?q?=E5=A4=B4=E4=BF=A1=E6=81=AF=E5=90=8E=E5=90=8C=E6=AD=A5monitor?= =?UTF-8?q?=5Fservice=E9=A1=B9=E7=9B=AE=E4=B8=AD=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/mapper/CameraChannelMapper.java | 2 + .../monitor/service/MonitorService.java | 42 +++++++++++++++++++ .../src/main/resources/application-my.yml | 7 ++++ .../mapper/monitor/CameraChannelMapper.xml | 10 +++++ 4 files changed, 61 insertions(+) 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