Commit 431f4572 authored by huangcb's avatar huangcb

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/esv/datacenter/iot/module/devicemodel/dto/DeviceInstanceDto.java
parents ecdf0715 d098668d
......@@ -5,6 +5,7 @@ import com.esv.datacenter.iot.common.exception.EException;
import com.esv.datacenter.iot.common.response.ECode;
import com.esv.datacenter.iot.common.response.EResponse;
import com.esv.datacenter.iot.common.validator.groups.*;
import com.esv.datacenter.iot.common.vo.PageResultVO;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceInstanceForm;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceInstanceService;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceTypeService;
......@@ -99,8 +100,9 @@ public class DeviceInstanceController {
* @createTime 2020/08/07 14:08
**/
@PostMapping("/list")
public EResponse list(@RequestBody @Validated(ValidatorList.class) DeviceInstanceForm form) throws EException {
return EResponse.ok(deviceInstanceService.getInstance4Page(form));
public EResponse<PageResultVO> list(@RequestBody @Validated(ValidatorList.class) DeviceInstanceForm form) {
PageResultVO pageResultVO = deviceInstanceService.getInstance4Page(form);
return EResponse.ok(pageResultVO);
}
/**
......
......@@ -16,7 +16,7 @@ import java.util.Date;
public class DeviceInstanceDto {
/**
*
* 主键
*/
private Long id;
/**
......@@ -47,6 +47,15 @@ public class DeviceInstanceDto {
* 通信ID
**/
private String communicationId;
/**
* 在线状态
**/
private Integer onlineState;
/**
* 在线状态更新时间
**/
private Date onlineUpdateTime;
/**
* 创建者
*/
......
......@@ -27,7 +27,7 @@ public class DeviceInstanceForm {
/**
* 设备类型ID
*/
@NotNull(message = "[设备类型ID]不能为空", groups = {ValidatorInsert.class, ValidatorList.class, ValidatorListById.class})
// @NotNull(message = "[设备类型ID]不能为空", groups = {ValidatorInsert.class, ValidatorList.class, ValidatorListById.class})
private Long deviceTypeId;
/**
* 设备名称
......@@ -51,6 +51,10 @@ public class DeviceInstanceForm {
*/
@Length(max = 200, message = "[设备型号]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorList.class})
private String deviceModel;
/**
* 在线状态
*/
private Integer onlineState;
/**
* 页码
......
......@@ -174,15 +174,20 @@ public class DeviceInstanceServiceImpl extends ServiceImpl<DeviceInstanceDao, De
@Override
public void changeDeviceOnlineState(List<String> communicationIdList) {
// 将在线设备状态修改为1
UpdateWrapper<DeviceInstanceEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.isNotNull("communication_id");
updateWrapper.in("communication_id", communicationIdList);
updateWrapper.ne("online_state", 1);
DeviceInstanceEntity entity = new DeviceInstanceEntity();
entity.setOnlineUpdateTime(new Date());
entity.setOnlineState(1);
baseMapper.update(entity, updateWrapper);
// 将不在线设备状态修改为0
updateWrapper = new UpdateWrapper<>();
updateWrapper.isNotNull("communication_id");
updateWrapper.notIn("communication_id", communicationIdList);
updateWrapper.ne("online_state", 0);
entity.setOnlineState(0);
baseMapper.update(entity, updateWrapper);
}
......
......@@ -4,6 +4,8 @@ import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* @description:
* @author: huangchaobin@esvtek.com
......@@ -41,6 +43,20 @@ public class DeviceInstanceVO {
* 设备型号
*/
private String deviceModel;
/**
* 通信ID
**/
private String communicationId;
/**
* 在线状态
**/
private Integer onlineState;
/**
* 在线状态更新时间
**/
private Date onlineUpdateTime;
/**
* 创建者
*/
......
......@@ -58,7 +58,9 @@ public class DeviceStateScheduleTask {
}
log.info("clientId list: {}", JSON.toJSONString(clientIdList));
if (!clientIdList.isEmpty()) {
deviceInstanceService.changeDeviceOnlineState(clientIdList);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<!-- <include resource="org/springframework/boot/logging/logback/base.xml"/>-->
<springProperty scope="context" name="LOG_FILE_NAME" source="spring.application.name"/>
......
......@@ -39,6 +39,9 @@
<if test="queryObj.deviceModel != null">
and a.device_model like CONCAT('%', #{queryObj.deviceModel}, '%')
</if>
<if test="queryObj.onlineState != null">
and a.online_state = #{queryObj.onlineState}
</if>
ORDER BY a.name ASC
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment