车辆信息状态
This commit is contained in:
parent
c381315892
commit
c1a17a839b
@ -123,4 +123,12 @@ public class DeviceInformationController {
|
|||||||
List<StatisticsInformationDTO> list = informationService.getDeviceNumber();
|
List<StatisticsInformationDTO> list = informationService.getDeviceNumber();
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getInformationList")
|
||||||
|
@Operation(summary = "获得所有设备信息(含最后通讯时间)")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:query')")
|
||||||
|
public CommonResult<List<DeviceInformationRespVO>> getInformationList(@Valid DeviceInformationPageReqVO pageReqVO) {
|
||||||
|
List<DeviceInformationDO> list = informationService.getInformationList(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(list, DeviceInformationRespVO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.path;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.path.PathPlanningService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 同步信息给路径规划")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/path/planning")
|
||||||
|
@Validated
|
||||||
|
public class PathPlanningController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PathPlanningService pathPlanningService;
|
||||||
|
|
||||||
|
@PutMapping("/synchronousPoint")
|
||||||
|
@Operation(summary = "同步全部的点位信息")
|
||||||
|
@PreAuthorize("@ss.hasPermission('robot:information:synchronousPoint')")
|
||||||
|
public CommonResult<String> synchronousPoint() {
|
||||||
|
pathPlanningService.synchronousPoint();
|
||||||
|
return success("同步完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,6 +33,9 @@ public class RobotInformationPageReqVO extends PageParam {
|
|||||||
@Schema(description = "mac地址")
|
@Schema(description = "mac地址")
|
||||||
private String macAddress;
|
private String macAddress;
|
||||||
|
|
||||||
|
@Schema(description = "车辆状态类型(待命:standby, 任务中:inTask, 锁定:doLock, 离线:offline, 充电中:charge, 故障:fault)")
|
||||||
|
private String robotStatisticsType;
|
||||||
|
|
||||||
@Schema(description = "上传图片附件", example = "https://www.iocoder.cn")
|
@Schema(description = "上传图片附件", example = "https://www.iocoder.cn")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.enums.robot.information;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆分页-车辆状态
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum RobotStatisticsTypeEnum {
|
||||||
|
|
||||||
|
STANDBY("standby","待命"),
|
||||||
|
INTASK("inTask","任务中"),
|
||||||
|
DOLOCK("doLock","锁定"),
|
||||||
|
OFFLINE("offline","离线"),
|
||||||
|
CHARGE("charge","充电中"),
|
||||||
|
FAULT("fault","故障");
|
||||||
|
/**
|
||||||
|
* 类型
|
||||||
|
*/
|
||||||
|
private final String type;
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
}
|
@ -100,4 +100,10 @@ public interface DeviceInformationService {
|
|||||||
*/
|
*/
|
||||||
List<StatisticsInformationDTO> getDeviceNumber();
|
List<StatisticsInformationDTO> getDeviceNumber();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看全部设备
|
||||||
|
* @param pageReqVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DeviceInformationDO> getInformationList(@Valid DeviceInformationPageReqVO pageReqVO);
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,39 @@ public class DeviceInformationServiceImpl implements DeviceInformationService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceInformationDO> getInformationList(DeviceInformationPageReqVO dto) {
|
||||||
|
|
||||||
|
List<DeviceInformationDO> deviceInformationDOS = informationMapper.selectList(new LambdaQueryWrapper<DeviceInformationDO>()
|
||||||
|
.like(dto.getDeviceNo() != null, DeviceInformationDO::getDeviceNo, dto.getDeviceNo())
|
||||||
|
.eq(dto.getDeviceType() != null, DeviceInformationDO::getDeviceType, dto.getDeviceType())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(deviceInformationDOS)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo 需要设置设备通讯的时间
|
||||||
|
for (DeviceInformationDO deviceInformationDO : deviceInformationDOS) {
|
||||||
|
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME +deviceInformationDO.getMacAddress();
|
||||||
|
Object object = redisUtil.get(deviceKey);
|
||||||
|
if (ObjectUtil.isEmpty(object)) {
|
||||||
|
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.OFF_LINE.getType());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
LocalDateTime curTimeLDT = LocalDateTime.parse((String)object, df);
|
||||||
|
deviceInformationDO.setDeviceLastTime(curTimeLDT);
|
||||||
|
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.ON_LINE.getType());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("查询设备最后通讯时间异常 :{}",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deviceInformationDOS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mapBindDeviceInfo(MapBindDeviceInfoDTO dto) {
|
public void mapBindDeviceInfo(MapBindDeviceInfoDTO dto) {
|
||||||
DeviceInformationDO deviceInformationDO = informationMapper.selectById(dto.getDeviceInfoId());
|
DeviceInformationDO deviceInformationDO = informationMapper.selectById(dto.getDeviceInfoId());
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.path;
|
||||||
|
|
||||||
|
public interface PathPlanningService {
|
||||||
|
void synchronousPoint();
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.path;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步信息给车辆
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class PathPlanningServiceImpl implements PathPlanningService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步全部的点位信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void synchronousPoint() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
|||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotModelMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotModelMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||||
|
import cn.iocoder.yudao.module.system.enums.robot.information.RobotStatisticsTypeEnum;
|
||||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -150,7 +151,49 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
|||||||
targetList.stream().forEach(v -> {
|
targetList.stream().forEach(v -> {
|
||||||
setMsgAndRobotStatus(v);
|
setMsgAndRobotStatus(v);
|
||||||
});
|
});
|
||||||
dataPage.setList(targetList);
|
|
||||||
|
if (ObjectUtil.isNotEmpty(pageReqVO.getRobotStatisticsType())) {
|
||||||
|
List<RobotInformationPageRespVO> resultList = new ArrayList<>();
|
||||||
|
for (RobotInformationPageRespVO v : targetList) {
|
||||||
|
if (RobotStatisticsTypeEnum.STANDBY.getType().equals(pageReqVO.getRobotStatisticsType())
|
||||||
|
&& v.getRobotTaskStatus().equals(0)) {
|
||||||
|
resultList.add(v);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotStatisticsTypeEnum.INTASK.getType().equals(pageReqVO.getRobotStatisticsType())
|
||||||
|
&& v.getRobotTaskStatus().equals(1)) {
|
||||||
|
resultList.add(v);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotStatisticsTypeEnum.CHARGE.getType().equals(pageReqVO.getRobotStatisticsType())
|
||||||
|
&& v.getRobotTaskStatus().equals(2)) {
|
||||||
|
resultList.add(v);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotStatisticsTypeEnum.DOLOCK.getType().equals(pageReqVO.getRobotStatisticsType())
|
||||||
|
&& v.getRobotEssenceStatus().equals(1)) {
|
||||||
|
resultList.add(v);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotStatisticsTypeEnum.OFFLINE.getType().equals(pageReqVO.getRobotStatisticsType())
|
||||||
|
&& v.getOnlineStatus().equals(1)) {
|
||||||
|
resultList.add(v);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RobotStatisticsTypeEnum.FAULT.getType().equals(pageReqVO.getRobotStatisticsType())
|
||||||
|
&& v.getRobotEssenceStatus().equals(2)) {
|
||||||
|
resultList.add(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataPage.setList(resultList);
|
||||||
|
}else {
|
||||||
|
dataPage.setList(targetList);
|
||||||
|
}
|
||||||
|
|
||||||
return dataPage;
|
return dataPage;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user