设备开关修改
This commit is contained in:
parent
874d05f423
commit
e1f40c02fa
|
|
@ -27,6 +27,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tar" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.ifish7.mq.queues.event;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.ifish7.mq.business.device.entity.TblDevice;
|
||||||
|
import com.ifish7.mq.business.device.service.ITblDeviceService;
|
||||||
|
import com.ifish7.mq.business.device.service.impl.TblDeviceServiceImpl;
|
||||||
|
import com.ifish7.mq.queues.event.support.EventSupport;
|
||||||
|
import com.ifish7.mq.utils.AppBeans;
|
||||||
|
import lombok.extern.log4j.Log4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: yan.y
|
||||||
|
* @Description: 设备信息事件
|
||||||
|
* @Date: Created in 09:34 2019-04-10
|
||||||
|
* @Modified by:
|
||||||
|
*/
|
||||||
|
@Log4j
|
||||||
|
public class DeviceInfoEvent extends EventSupport {
|
||||||
|
|
||||||
|
|
||||||
|
public void updateWarnOnoff() {
|
||||||
|
log.info("DeviceInfoEvent eventBody : " + eventBody);
|
||||||
|
TblDevice device = (TblDevice) this.eventEntity;
|
||||||
|
ITblDeviceService deviceService = AppBeans.getBean(TblDeviceServiceImpl.class);
|
||||||
|
TblDevice tblDevice = deviceService.getOne(new QueryWrapper<TblDevice>().lambda().eq(TblDevice::getMacAddress, device.getMacAddress()));
|
||||||
|
tblDevice.setOnOff(device.getOnOff());
|
||||||
|
deviceService.updateById(tblDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.ifish7.mq.queues.event;
|
package com.ifish7.mq.queues.event;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ifish7.mq.business.device.entity.TblDeviceHeater;
|
import com.ifish7.mq.business.device.entity.TblDeviceHeater;
|
||||||
import com.ifish7.mq.business.device.service.ITblDeviceHeaterService;
|
import com.ifish7.mq.business.device.service.ITblDeviceHeaterService;
|
||||||
|
|
@ -32,16 +30,13 @@ public class IntelligentHeatingRodEvent extends EventSupport {
|
||||||
* "heaterGatheringTime": "08",
|
* "heaterGatheringTime": "08",
|
||||||
* "heaterGatheringDate": "2019-04-09"
|
* "heaterGatheringDate": "2019-04-09"
|
||||||
* }
|
* }
|
||||||
** }
|
* }
|
||||||
* }
|
* }
|
||||||
* @param eventBody
|
|
||||||
*/
|
*/
|
||||||
public void intelligentHeatingRodSaveOrUpdate(String eventBody){
|
public void intelligentHeatingRodSaveOrUpdate(){
|
||||||
log.info("eventBody : " + eventBody);
|
log.info("intelligentHeatingRodSaveOrUpdate eventBody : " + eventBody);
|
||||||
JSONObject json = JSON.parseObject(eventBody);
|
|
||||||
String entity = json.getString("entity");
|
|
||||||
try {
|
try {
|
||||||
TblDeviceHeater deviceHeater = (TblDeviceHeater) JSON.parseObject(json.getString("data"), Class.forName(entity));
|
TblDeviceHeater deviceHeater = (TblDeviceHeater) super.eventEntity;
|
||||||
//获取service
|
//获取service
|
||||||
ITblDeviceHeaterService deviceHeaterService = AppBeans.getBean(TblDeviceHeaterServiceImpl.class);
|
ITblDeviceHeaterService deviceHeaterService = AppBeans.getBean(TblDeviceHeaterServiceImpl.class);
|
||||||
//查询
|
//查询
|
||||||
|
|
@ -58,7 +53,7 @@ public class IntelligentHeatingRodEvent extends EventSupport {
|
||||||
//新增
|
//新增
|
||||||
deviceHeaterService.save(deviceHeater);
|
deviceHeaterService.save(deviceHeater);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (Exception e) {
|
||||||
log.info(e.getMessage(),e);
|
log.info(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ifish7.mq.queues.event.support;
|
package com.ifish7.mq.queues.event.support;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.log4j.Log4j;
|
import lombok.extern.log4j.Log4j;
|
||||||
|
|
||||||
|
|
@ -22,16 +24,32 @@ public class EventSupport {
|
||||||
//事件体
|
//事件体
|
||||||
protected String eventBody;
|
protected String eventBody;
|
||||||
|
|
||||||
|
//事件体对象
|
||||||
|
protected Object eventEntity;
|
||||||
|
|
||||||
//事件处理
|
//事件处理
|
||||||
public void process() {
|
public void process() {
|
||||||
try {
|
try {
|
||||||
|
parseEventEntity();
|
||||||
Class<?> eventClazz = Class.forName(this.eventName);
|
Class<?> eventClazz = Class.forName(this.eventName);
|
||||||
Method method = eventClazz.getMethod(this.eventProcess, Class.forName("java.lang.String"));
|
Method method = eventClazz.getMethod(this.eventProcess);
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(eventClazz.newInstance(),this.eventBody);
|
method.invoke(eventClazz.newInstance());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info(e.getMessage(),e);
|
log.info(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void parseEventEntity(){
|
||||||
|
JSONObject json = JSON.parseObject(eventBody);
|
||||||
|
String entity = json.getString("entity");
|
||||||
|
try {
|
||||||
|
this.eventEntity = JSON.parseObject(json.getString("data"),Class.forName(entity));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
jdbc.driver=com.mysql.jdbc.Driver
|
jdbc.driver=com.mysql.jdbc.Driver
|
||||||
jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
|
#jdbc.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
|
||||||
#jdbc.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
|
jdbc.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
|
||||||
jdbc.username=root
|
#jdbc.username=root
|
||||||
jdbc.password=123456
|
#jdbc.password=123456
|
||||||
#jdbc.username=ifish
|
#jdbc.username=ifish
|
||||||
#jdbc.password=ifish7pwd
|
#jdbc.password=ifish7pwd
|
||||||
#jdbc.username=root
|
jdbc.username=root
|
||||||
#jdbc.password=ifish7mysql
|
jdbc.password=ifish7mysql
|
||||||
#jdbc.testWhileIdle=true
|
#jdbc.testWhileIdle=true
|
||||||
jdbc.validationQuery=SELECT * FROM DUAL
|
jdbc.validationQuery=SELECT * FROM DUAL
|
||||||
initialSize=1
|
initialSize=1
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<!-- Spring和mybatis的配置文件 -->
|
<!-- Spring和mybatis的配置文件 -->
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>contextConfigLocation</param-name>
|
<param-name>contextConfigLocation</param-name>
|
||||||
<param-value>classpath:spring-mq.xml</param-value>
|
<param-value>classpath:spring-main.xml</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue