设备数据修改及登录保存
This commit is contained in:
parent
977986231b
commit
48f4bfeaf4
|
|
@ -1,32 +0,0 @@
|
||||||
package com.ifish7.mq.business.user.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author yan.y
|
|
||||||
* @since 2019-04-09
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class TblLoginRecord {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId(value = "record_id", type = IdType.AUTO)
|
|
||||||
private Integer recordId;
|
|
||||||
|
|
||||||
private String macAddress;
|
|
||||||
|
|
||||||
private LocalDateTime loginTime;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package com.ifish7.mq.business.user.mapper;
|
|
||||||
|
|
||||||
import com.ifish7.mq.business.user.entity.TblLoginRecord;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author yan.y
|
|
||||||
* @since 2019-04-09
|
|
||||||
*/
|
|
||||||
public interface TblLoginRecordMapper extends BaseMapper<TblLoginRecord> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package com.ifish7.mq.business.user.service;
|
|
||||||
|
|
||||||
import com.ifish7.mq.business.user.entity.TblLoginRecord;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author yan.y
|
|
||||||
* @since 2019-04-09
|
|
||||||
*/
|
|
||||||
public interface ITblLoginRecordService extends IService<TblLoginRecord> {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
package com.ifish7.mq.business.user.service.impl;
|
|
||||||
|
|
||||||
import com.ifish7.mq.business.user.entity.TblLoginRecord;
|
|
||||||
import com.ifish7.mq.business.user.mapper.TblLoginRecordMapper;
|
|
||||||
import com.ifish7.mq.business.user.service.ITblLoginRecordService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author yan.y
|
|
||||||
* @since 2019-04-09
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class TblLoginRecordServiceImpl extends ServiceImpl<TblLoginRecordMapper, TblLoginRecord> implements ITblLoginRecordService {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -2,11 +2,17 @@ package com.ifish7.mq.queues.event;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ifish7.mq.business.device.entity.TblDevice;
|
import com.ifish7.mq.business.device.entity.TblDevice;
|
||||||
|
import com.ifish7.mq.business.device.entity.TblLoginRecord;
|
||||||
import com.ifish7.mq.business.device.service.ITblDeviceService;
|
import com.ifish7.mq.business.device.service.ITblDeviceService;
|
||||||
|
import com.ifish7.mq.business.device.service.ITblLoginRecordService;
|
||||||
import com.ifish7.mq.business.device.service.impl.TblDeviceServiceImpl;
|
import com.ifish7.mq.business.device.service.impl.TblDeviceServiceImpl;
|
||||||
|
import com.ifish7.mq.business.device.service.impl.TblLoginRecordServiceImpl;
|
||||||
import com.ifish7.mq.utils.AppBeans;
|
import com.ifish7.mq.utils.AppBeans;
|
||||||
import lombok.extern.log4j.Log4j;
|
import lombok.extern.log4j.Log4j;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: yan.y
|
* @author: yan.y
|
||||||
* @Description: 设备信息事件
|
* @Description: 设备信息事件
|
||||||
|
|
@ -44,4 +50,122 @@ public class DeviceInfoEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备登录更新
|
||||||
|
* {
|
||||||
|
* "eventProcess": "deviceLoginSaveOrUpdate",
|
||||||
|
* "eventName": "com.ifish7.mq.queues.event.DeviceInfoEvent",
|
||||||
|
* "eventBody": {
|
||||||
|
* "entity" : "com.ifish7.mq.business.device.entity.TblDevice",
|
||||||
|
* "data" : {
|
||||||
|
* "macAddress" : "5ccf7f006686",
|
||||||
|
* "deviceIp" : "172.16.119.128",
|
||||||
|
* "hardwareType" : "02",
|
||||||
|
* "softwareVersion" : "02"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* @param eventEntity 事件体
|
||||||
|
*/
|
||||||
|
private void deviceLoginSaveOrUpdate(Object eventEntity){
|
||||||
|
log.info("DeviceInfoEvent eventEntity : " + eventEntity);
|
||||||
|
try {
|
||||||
|
TblDevice device = (TblDevice) eventEntity;
|
||||||
|
ITblDeviceService deviceService = AppBeans.getBean(TblDeviceServiceImpl.class);
|
||||||
|
TblDevice tblDevice = deviceService.getOne(new QueryWrapper<TblDevice>().lambda().eq(TblDevice::getMacAddress, device.getMacAddress()));
|
||||||
|
//更新
|
||||||
|
if (tblDevice != null) {
|
||||||
|
Integer loginCount = tblDevice.getLoginCount();
|
||||||
|
tblDevice.setLoginCount(loginCount != null ? ++ loginCount : 1);
|
||||||
|
tblDevice.setFactoryCode(device.getFactoryCode());
|
||||||
|
tblDevice.setHardwareType(device.getHardwareType());
|
||||||
|
tblDevice.setSoftwareVersion(device.getSoftwareVersion());
|
||||||
|
tblDevice.setDeviceIp(device.getDeviceIp());
|
||||||
|
tblDevice.setLoginTime(LocalDateTime.now());
|
||||||
|
deviceService.updateById(tblDevice);
|
||||||
|
} else {
|
||||||
|
Integer loginCount = device.getLoginCount();
|
||||||
|
device.setLoginCount(loginCount != null ? ++ loginCount : 1);
|
||||||
|
device.setLoginTime(LocalDateTime.now());
|
||||||
|
device.setCreateDate(LocalDate.now());
|
||||||
|
device.setCreateTime(LocalDateTime.now());
|
||||||
|
deviceService.save(device);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备登录记录保存
|
||||||
|
* {
|
||||||
|
* "eventProcess": "deviceLoginLogSave",
|
||||||
|
* "eventName": "com.ifish7.mq.queues.event.DeviceInfoEvent",
|
||||||
|
* "eventBody": {
|
||||||
|
* "entity" : "com.ifish7.mq.business.device.entity.TblLoginRecord",
|
||||||
|
* "data" : {
|
||||||
|
* "macAddress" : "12345"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* @param eventEntity 事件体
|
||||||
|
*/
|
||||||
|
private void deviceLoginLogSave(Object eventEntity) {
|
||||||
|
log.info("DeviceInfoEvent eventEntity : " + eventEntity);
|
||||||
|
try {
|
||||||
|
TblLoginRecord loginRecord = (TblLoginRecord) eventEntity;
|
||||||
|
loginRecord.setLoginTime(LocalDateTime.now());
|
||||||
|
ITblLoginRecordService loginRecordService = AppBeans.getBean(TblLoginRecordServiceImpl.class);
|
||||||
|
loginRecordService.save(loginRecord);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备登录更新
|
||||||
|
* {
|
||||||
|
* "eventProcess": "deviceSdkUpdate",
|
||||||
|
* "eventName": "com.ifish7.mq.queues.event.DeviceInfoEvent",
|
||||||
|
* "eventBody": {
|
||||||
|
* "entity" : "com.ifish7.mq.business.device.entity.TblDevice",
|
||||||
|
* "data" : {
|
||||||
|
* "macAddress" : "5ccf7f006686",
|
||||||
|
* "isUpgrade" : "1",
|
||||||
|
* "upgradeTime" : "2019-04-10 14:55:00",
|
||||||
|
* "sdkVersion" : "17",
|
||||||
|
* "sdkTime" : "2019-04-10",
|
||||||
|
* "number1" : "1",
|
||||||
|
* "number2" : "2",
|
||||||
|
* "number3" : "3",
|
||||||
|
* "number4" : "4",
|
||||||
|
* "number5" : "5"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* @param eventEntity 事件体
|
||||||
|
*/
|
||||||
|
private void deviceSdkUpdate(Object eventEntity){
|
||||||
|
log.info("DeviceInfoEvent eventEntity : " + eventEntity);
|
||||||
|
try {
|
||||||
|
TblDevice device = (TblDevice) eventEntity;
|
||||||
|
ITblDeviceService deviceService = AppBeans.getBean(TblDeviceServiceImpl.class);
|
||||||
|
TblDevice tblDevice = deviceService.getOne(new QueryWrapper<TblDevice>().lambda().eq(TblDevice::getMacAddress, device.getMacAddress()));
|
||||||
|
//更新
|
||||||
|
if (tblDevice != null) {
|
||||||
|
tblDevice.setIsUpgrade(device.getIsUpgrade());
|
||||||
|
tblDevice.setUpgradeTime(device.getUpgradeTime());
|
||||||
|
tblDevice.setSdkVersion(device.getSdkVersion());
|
||||||
|
tblDevice.setSdkTime(device.getSdkTime());
|
||||||
|
tblDevice.setNumber1(device.getNumber1());
|
||||||
|
tblDevice.setNumber2(device.getNumber2());
|
||||||
|
tblDevice.setNumber3(device.getNumber3());
|
||||||
|
tblDevice.setNumber4(device.getNumber4());
|
||||||
|
tblDevice.setNumber5(device.getNumber5());
|
||||||
|
deviceService.updateById(tblDevice);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class IntelligentHeatingRodEvent {
|
||||||
* }
|
* }
|
||||||
* @param eventEntity 事件体
|
* @param eventEntity 事件体
|
||||||
*/
|
*/
|
||||||
private void intelligentHeatingRodSaveOrUpdate(Object eventEntity){
|
private void intelligentHeatingRodSaveOrUpdate(Object eventEntity) {
|
||||||
log.info("intelligentHeatingRodSaveOrUpdate eventEntity : " + eventEntity);
|
log.info("intelligentHeatingRodSaveOrUpdate eventEntity : " + eventEntity);
|
||||||
try {
|
try {
|
||||||
TblDeviceHeater deviceHeater = (TblDeviceHeater) eventEntity;
|
TblDeviceHeater deviceHeater = (TblDeviceHeater) eventEntity;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
<?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.ifish7.mq.business.user.mapper.TblLoginRecordMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
Loading…
Reference in New Issue