设备状态,设备信息---清洗

develop
Angel 11 months ago
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;
}

@ -389,5 +389,6 @@ public class TJksbglMysql {
@TableField(value = "sfzzrkyj") @TableField(value = "sfzzrkyj")
private String sfzzrkyj; private String sfzzrkyj;
@TableField(value = "status")
private String status;
} }

@ -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");
}
}
}

@ -41,6 +41,8 @@ public class ConfigParam {
public static String RentalHouseSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("RentalHouseSwitch")); public static String RentalHouseSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("RentalHouseSwitch"));
public static String metaRealEstateInfoSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("metaRealEstateInfoSwitch")); public static String metaRealEstateInfoSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("metaRealEstateInfoSwitch"));
public static String DevopeDeviceSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DevopeDeviceSwitch"));
public static String sydzToEstateInfoSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("sydzToEstateInfoSwitch")); public static String sydzToEstateInfoSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("sydzToEstateInfoSwitch"));

@ -67,6 +67,7 @@
<result property="lxdh" column="LXDH" jdbcType="VARCHAR"/> <result property="lxdh" column="LXDH" jdbcType="VARCHAR"/>
<result property="sfjsbryj" column="SFJSBRYJ" jdbcType="VARCHAR"/> <result property="sfjsbryj" column="SFJSBRYJ" jdbcType="VARCHAR"/>
<result property="sfzzrkyj" column="SFZZRKYJ" jdbcType="VARCHAR"/> <result property="sfzzrkyj" column="SFZZRKYJ" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<select id="selectTJksbglById" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="selectTJksbglById" parameterType="java.lang.String" resultMap="BaseResultMap">
@ -140,6 +141,7 @@
<if test="lxdh != null and lxdh != '' ">lxdh,</if> <if test="lxdh != null and lxdh != '' ">lxdh,</if>
<if test="sfjsbryj != null and sfjsbryj != '' ">sfjsbryj,</if> <if test="sfjsbryj != null and sfjsbryj != '' ">sfjsbryj,</if>
<if test="sfzzrkyj != null and sfzzrkyj != '' ">sfzzrkyj,</if> <if test="sfzzrkyj != null and sfzzrkyj != '' ">sfzzrkyj,</if>
<if test="status != null and status != '' ">status,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -205,6 +207,7 @@
<if test="lxdh != null and lxdh != '' ">#{lxdh},</if> <if test="lxdh != null and lxdh != '' ">#{lxdh},</if>
<if test="sfjsbryj != null and sfjsbryj != '' ">#{sfjsbryj},</if> <if test="sfjsbryj != null and sfjsbryj != '' ">#{sfjsbryj},</if>
<if test="sfzzrkyj != null and sfzzrkyj != '' ">#{sfzzrkyj},</if> <if test="sfzzrkyj != null and sfzzrkyj != '' ">#{sfzzrkyj},</if>
<if test="status != null and status != '' ">#{status},</if>
</trim> </trim>
</insert> </insert>
@ -273,6 +276,8 @@
<if test="lxdh != null and lxdh != '' ">lxdh=#{lxdh},</if> <if test="lxdh != null and lxdh != '' ">lxdh=#{lxdh},</if>
<if test="sfjsbryj != null and sfjsbryj != '' ">sfjsbryj=#{sfjsbryj},</if> <if test="sfjsbryj != null and sfjsbryj != '' ">sfjsbryj=#{sfjsbryj},</if>
<if test="sfzzrkyj != null and sfzzrkyj != '' ">sfzzrkyj=#{sfzzrkyj},</if> <if test="sfzzrkyj != null and sfzzrkyj != '' ">sfzzrkyj=#{sfzzrkyj},</if>
<if test="status != null and status != '' ">status=#{status},</if>
</trim> </trim>
where sbbh = #{sbbh} where sbbh = #{sbbh}
</update> </update>

Loading…
Cancel
Save