更新运维系统设备列表页面增加设备工作状态

This commit is contained in:
panshuling321 2022-03-04 14:44:51 +08:00
parent fc568b6542
commit d4c0394293
2 changed files with 50 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package com.xhpc.workorder.service.impl;
import cn.hutool.core.util.StrUtil;
import com.xhpc.common.core.exception.CustomException;
import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import com.xhpc.workorder.domain.XhpcWorkStationDomain;
import com.xhpc.workorder.mapper.XhpcStationDeviceMapper;
@ -26,9 +27,52 @@ public class WorkStationServiceImpl implements WorkStationService {
@Resource
XhpcWorkStationMapper stationMapper;
@Resource
RedisService redisService;
private int getTerminalStatus(String serialNumber) {
//0离线 1故障 2空闲 3充电 4 已插枪 5未知
// Integer status =5;
//终端状态用 redis数据
if(!"".equals(serialNumber) && serialNumber!=null){
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+serialNumber);
if(cacheMap !=null && cacheMap.get("status") !=null){
if ("离线".equals(cacheMap.get("status").toString())){
return 0;
}else if("故障".equals(cacheMap.get("status").toString())){
return 1;
}else if("空闲".equals(cacheMap.get("status").toString())){
if("".equals(cacheMap.get("vehicleGunStatus").toString())){
return 4;
}else{
return 2;
}
}else{
//充电桩
return 3;
}
}
return 5;
}else{
return 5;
}
}
@Override
public List<Map<String, Object>> getStationDevice(Map<String, Object> params){
return deviceMapper.selectStationGunDeviceListByParams(params);
List<Map<String, Object>> deviceList = deviceMapper.selectStationGunDeviceListByParams(params);
for(Map<String, Object> map : deviceList){
//状态
int pileSerialNumber = getTerminalStatus(map.get("gunSerialNumber").toString());
map.put("workStatus",pileSerialNumber);
}
return deviceList;
}

View File

@ -45,10 +45,14 @@
d2.serial_number as 'gunSerialNumber',
d2.brand_model as 'gunBrandModel',
d2.current_type as 'gunCurrentType',
d2.sorted as 'gunSorted'
d2.sorted as 'gunSorted',
t.status as 'status',
t.work_status as 'workStatus',
t.charging_pile_id as 'chargingPileId'
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
LEFT JOIN xhpc_station_device d2 on d2.parent_device_id=d1.device_id
LEFT JOIN xhpc_terminal t on t.serial_number = d2.serial_number
WHERE s.del_flag=0 and d1.del_flag=0 and d1.device_type='PILE'
<if test="params.stationName!=null and params.stationName != ''">
and s.name like concat('%', #{params.stationName}, '%')