parent
ecd9a4de0d
commit
45b8476d40
@ -0,0 +1,197 @@
|
||||
package com.ssf.mysqloracletest.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 智能设备信息表
|
||||
* @TableName devops_device_info
|
||||
*/
|
||||
@TableName(value ="devops_device_info")
|
||||
@Data
|
||||
public class DevopsDeviceInfo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 场所编码
|
||||
*/
|
||||
private String placeCode;
|
||||
|
||||
/**
|
||||
* 场所名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 通道国标编码
|
||||
*/
|
||||
private String gbsChannelNo;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 设备能力集
|
||||
*/
|
||||
private String structuredCameraType;
|
||||
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
private String deviceAddress;
|
||||
|
||||
/**
|
||||
* 设备方位
|
||||
*/
|
||||
private Integer orientation;
|
||||
|
||||
/**
|
||||
* 设备SN编号
|
||||
*/
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 设备品牌
|
||||
*/
|
||||
private String deviceBrand;
|
||||
|
||||
/**
|
||||
* 设备ip
|
||||
*/
|
||||
private String deviceIp;
|
||||
|
||||
/**
|
||||
* 设备端口
|
||||
*/
|
||||
private Integer devicePort;
|
||||
|
||||
/**
|
||||
* 设备MAC
|
||||
*/
|
||||
private String deviceMac;
|
||||
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceImei;
|
||||
|
||||
/**
|
||||
* 设备经度
|
||||
*/
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 设备纬度
|
||||
*/
|
||||
private BigDecimal latitude;
|
||||
|
||||
/**
|
||||
* U3D经度
|
||||
*/
|
||||
private BigDecimal u3dLongitude;
|
||||
|
||||
/**
|
||||
* U3D纬度
|
||||
*/
|
||||
private BigDecimal u3dLatitude;
|
||||
|
||||
/**
|
||||
* 设备高度
|
||||
*/
|
||||
private String deviceHeight;
|
||||
|
||||
/**
|
||||
* 设备厂家
|
||||
*/
|
||||
private String manufactor;
|
||||
|
||||
/**
|
||||
* 设备登陆帐号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 设备登陆密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 进出方向
|
||||
*/
|
||||
private Integer direction;
|
||||
|
||||
/**
|
||||
* RTSP流地址
|
||||
*/
|
||||
private String rtspAddress;
|
||||
|
||||
/**
|
||||
* 是否卡口设备
|
||||
*/
|
||||
private Integer isDoorwayVideo;
|
||||
|
||||
/**
|
||||
* 商汤region_id
|
||||
*/
|
||||
private String stRegionId;
|
||||
|
||||
/**
|
||||
* 商汤camera_idx
|
||||
*/
|
||||
private String stCameraIdx;
|
||||
|
||||
/**
|
||||
* 通道号
|
||||
*/
|
||||
private Integer channelNo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Integer createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Integer updateBy;
|
||||
|
||||
/**
|
||||
* 0:不活跃,1:活跃
|
||||
*/
|
||||
private Integer isActive;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.ssf.mysqloracletest.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设备状态信息表
|
||||
* @TableName devops_device_status
|
||||
*/
|
||||
@TableName(value ="devops_device_status")
|
||||
@Data
|
||||
public class DevopsDeviceStatus implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 场所编码
|
||||
*/
|
||||
private String placeCode;
|
||||
|
||||
/**
|
||||
* 场所名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 通道国标编码
|
||||
*/
|
||||
private String gbsChannelNo;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备ip
|
||||
*/
|
||||
private String deviceIp;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 心跳时间
|
||||
*/
|
||||
private Long heartbeatTime;
|
||||
|
||||
/**
|
||||
* 是否在线
|
||||
*/
|
||||
private Integer isOnline;
|
||||
|
||||
/**
|
||||
* 是否存在告警
|
||||
*/
|
||||
private Integer isAlarm;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Integer createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Integer updateBy;
|
||||
|
||||
/**
|
||||
* 0:不活跃,1:活跃
|
||||
*/
|
||||
private Integer isActive;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.ssf.mysqloracletest.mapper;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【devops_device_info(智能设备信息表)】的数据库操作Mapper
|
||||
* @createDate 2023-12-02 17:42:39
|
||||
* @Entity com.ssf.mysqloracletest.domain.DevopsDeviceInfo
|
||||
*/
|
||||
@Mapper
|
||||
public interface DevopsDeviceInfoMapper extends BaseMapper<DevopsDeviceInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.ssf.mysqloracletest.mapper;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceStatus;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【devops_device_status(设备状态信息表)】的数据库操作Mapper
|
||||
* @createDate 2023-12-07 17:19:14
|
||||
* @Entity com.ssf.mysqloracletest.domain.DevopsDeviceStatus
|
||||
*/
|
||||
@Mapper
|
||||
public interface DevopsDeviceStatusMapper extends BaseMapper<DevopsDeviceStatus> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.ssf.mysqloracletest.service;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【devops_device_info(智能设备信息表)】的数据库操作Service
|
||||
* @createDate 2023-12-02 17:42:39
|
||||
*/
|
||||
public interface DevopsDeviceInfoService extends IService<DevopsDeviceInfo> {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.ssf.mysqloracletest.service;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceStatus;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【devops_device_status(设备状态信息表)】的数据库操作Service
|
||||
* @createDate 2023-12-07 17:19:14
|
||||
*/
|
||||
public interface DevopsDeviceStatusService extends IService<DevopsDeviceStatus> {
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.ssf.mysqloracletest.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceInfo;
|
||||
import com.ssf.mysqloracletest.service.DevopsDeviceInfoService;
|
||||
import com.ssf.mysqloracletest.mapper.DevopsDeviceInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【devops_device_info(智能设备信息表)】的数据库操作Service实现
|
||||
* @createDate 2023-12-02 17:42:39
|
||||
*/
|
||||
@Service
|
||||
@DS("mysql")
|
||||
public class DevopsDeviceInfoServiceImpl extends ServiceImpl<DevopsDeviceInfoMapper, DevopsDeviceInfo> implements DevopsDeviceInfoService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.ssf.mysqloracletest.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceStatus;
|
||||
import com.ssf.mysqloracletest.service.DevopsDeviceStatusService;
|
||||
import com.ssf.mysqloracletest.mapper.DevopsDeviceStatusMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【devops_device_status(设备状态信息表)】的数据库操作Service实现
|
||||
* @createDate 2023-12-07 17:19:14
|
||||
*/
|
||||
@Service
|
||||
@DS("mysql")
|
||||
public class DevopsDeviceStatusServiceImpl extends ServiceImpl<DevopsDeviceStatusMapper, DevopsDeviceStatus>
|
||||
implements DevopsDeviceStatusService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,113 @@
|
||||
package com.ssf.mysqloracletest.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceInfo;
|
||||
import com.ssf.mysqloracletest.domain.DevopsDeviceStatus;
|
||||
import com.ssf.mysqloracletest.domain.TJksbglMysql;
|
||||
import com.ssf.mysqloracletest.service.DevopsDeviceInfoService;
|
||||
import com.ssf.mysqloracletest.service.DevopsDeviceStatusService;
|
||||
import com.ssf.mysqloracletest.service.TJksbglMysqlService;
|
||||
import com.ssf.mysqloracletest.utils.ConfigParam;
|
||||
import com.ssf.mysqloracletest.utils.StringKit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Component
|
||||
public class DevopeDeviceTask {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RentalHousingTask.class);
|
||||
@Resource
|
||||
private TJksbglMysqlService jksbglMysqlService;
|
||||
@Resource
|
||||
private DevopsDeviceInfoService devopsDeviceInfoService;
|
||||
@Resource
|
||||
private DevopsDeviceStatusService deviceStatusService;
|
||||
|
||||
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
||||
public void transDevopeDevice() {
|
||||
if (!"true".equals(ConfigParam.DevopeDeviceSwitch)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
QueryWrapper<TJksbglMysql> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.isNull("STATUS");
|
||||
Page<TJksbglMysql> page = new Page<>(1, 1000);
|
||||
List<TJksbglMysql> resultList = jksbglMysqlService.page(page, queryWrapper).getRecords();
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(resultList.size());
|
||||
ExecutorService DevicePool = Executors.newFixedThreadPool(5);
|
||||
|
||||
for (TJksbglMysql bean : resultList) {
|
||||
DevicePool.submit(() -> {
|
||||
cleanJksbInfo(bean);
|
||||
logger.info("清洗完成");
|
||||
latch.countDown();
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
//Wait for all threads to complete
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//关闭线程池
|
||||
DevicePool.shutdown();
|
||||
} catch (Exception e) {
|
||||
logger.info(StringKit.getTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanJksbInfo(TJksbglMysql bean) {
|
||||
TJksbglMysql jksbglMysqlCp = new TJksbglMysql();
|
||||
try {
|
||||
BeanUtils.copyProperties(bean, jksbglMysqlCp);
|
||||
DevopsDeviceInfo deviceInfo = new DevopsDeviceInfo();
|
||||
DevopsDeviceStatus deviceStatus = new DevopsDeviceStatus();
|
||||
deviceInfo.setDeviceName(jksbglMysqlCp.getSbmc());
|
||||
deviceStatus.setDeviceName(jksbglMysqlCp.getSbmc());
|
||||
deviceInfo.setGbsChannelNo(jksbglMysqlCp.getSbbh());
|
||||
deviceStatus.setGbsChannelNo(jksbglMysqlCp.getSbbh());
|
||||
deviceInfo.setDeviceIp(jksbglMysqlCp.getIpdz());
|
||||
deviceStatus.setDeviceIp(jksbglMysqlCp.getIpdz());
|
||||
deviceInfo.setDeviceMac(jksbglMysqlCp.getMacdz());
|
||||
deviceInfo.setDeviceSn(jksbglMysqlCp.getId());
|
||||
deviceStatus.setDeviceCode(jksbglMysqlCp.getId());
|
||||
if (jksbglMysqlCp.getSbdk() != null && !jksbglMysqlCp.getSbdk().isEmpty()) {
|
||||
deviceInfo.setDevicePort(Integer.parseInt(jksbglMysqlCp.getSbdk()));
|
||||
} else {
|
||||
deviceInfo.setDevicePort(null);
|
||||
}
|
||||
deviceInfo.setDeviceType(Integer.parseInt(jksbglMysqlCp.getSblx()));
|
||||
deviceStatus.setDeviceType(Integer.parseInt(jksbglMysqlCp.getSblx()));
|
||||
deviceInfo.setLongitude(new BigDecimal(jksbglMysqlCp.getSbjd()));
|
||||
deviceInfo.setLatitude(new BigDecimal(jksbglMysqlCp.getSbwd()));
|
||||
deviceStatus.setIsOnline(Integer.parseInt(jksbglMysqlCp.getSbzt()));
|
||||
deviceInfo.setDeviceAddress(jksbglMysqlCp.getAzdz());
|
||||
boolean a = devopsDeviceInfoService.save(deviceInfo);
|
||||
boolean b = deviceStatusService.save(deviceStatus);
|
||||
|
||||
if (a && b) {
|
||||
jksbglMysqlCp.setStatus("1");
|
||||
jksbglMysqlService.updateTJksbglById(jksbglMysqlCp);
|
||||
logger.info("状态修改为:1");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info(StringKit.getTrace(e));
|
||||
jksbglMysqlCp.setStatus("2");
|
||||
jksbglMysqlService.updateTJksbglById(jksbglMysqlCp);
|
||||
logger.info("状态修改为:2");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue