|
|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.xueyi.common.core.constant.basic.BaseConstants; |
|
|
|
import com.xueyi.common.core.constant.basic.SecurityConstants; |
|
|
|
import com.xueyi.common.core.constant.basic.SqlConstants; |
|
|
|
import com.xueyi.common.core.constant.digitalman.MessageConstants; |
|
|
|
import com.xueyi.common.core.web.result.AjaxResult; |
|
|
|
@@ -17,14 +18,18 @@ import com.xueyi.common.security.annotation.RequiresPermissions; |
|
|
|
import com.xueyi.common.web.entity.controller.BaseController; |
|
|
|
import com.xueyi.common.web.utils.DateUtils; |
|
|
|
import com.xueyi.message.api.transfer.feign.RemoteTransferService; |
|
|
|
import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo; |
|
|
|
import com.xueyi.system.api.device.feign.RemoteDeviceTenantMergeService; |
|
|
|
import com.xueyi.system.api.digitalmans.domain.dto.DmDigitalmanWorktimeDto; |
|
|
|
import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; |
|
|
|
import com.xueyi.system.api.digitalmans.domain.dto.DmSyncDigitalmanDto; |
|
|
|
import com.xueyi.system.api.digitalmans.domain.po.DmDigitalmanExtPo; |
|
|
|
import com.xueyi.system.api.digitalmans.domain.po.DmManDevicePo; |
|
|
|
import com.xueyi.system.api.digitalmans.feign.RemoteDigitalmanService; |
|
|
|
import com.xueyi.system.device.service.impl.DmDeviceTenantMergeServiceImpl; |
|
|
|
import com.xueyi.system.digitalmans.domain.dto.DmDigitalmanDto; |
|
|
|
import com.xueyi.system.digitalmans.domain.dto.DmDigitalmanExtDto; |
|
|
|
import com.xueyi.system.digitalmans.domain.model.DmDigitalmanExtConverter; |
|
|
|
import com.xueyi.system.digitalmans.domain.query.DmDigitalmanExtQuery; |
|
|
|
import com.xueyi.system.digitalmans.domain.query.DmDigitalmanQuery; |
|
|
|
import com.xueyi.system.digitalmans.mapper.DmManDeviceMapper; |
|
|
|
@@ -83,6 +88,9 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm |
|
|
|
@Autowired |
|
|
|
private DmDeviceLogFileMapper deviceLogFileMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RemoteDeviceTenantMergeService remoteDeviceTenantMergeService; |
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(DmDigitalmanController.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@@ -91,15 +99,25 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm |
|
|
|
@Autowired |
|
|
|
private IDmDigitalmanExtService dmDigitalmanExtService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDmDigitalmanService dmDigitalmanService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDmSkillService dmSkillService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDmModelService dmModelService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DmDigitalmanExtConverter dmDigitalmanExtConverter; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RemoteTransferService remoteTransferService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RemoteDigitalmanService remoteDigitalmanService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String, Serializable> redisTemplate; |
|
|
|
|
|
|
|
@@ -266,11 +284,18 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm |
|
|
|
String network = heartBeatObj.getString("wifi_rssi"); |
|
|
|
String cpu_max = heartBeatObj.getString("cpuinfo_max_freq"); |
|
|
|
String cpu_scaling = heartBeatObj.getString("scaling_cur_freq"); |
|
|
|
String ipAddr = heartBeatObj.getString("ip"); |
|
|
|
String cpu = Double.valueOf(cpu_scaling) / Double.valueOf(cpu_max) * 100 + ""; |
|
|
|
String memoryTotal = heartBeatObj.getString("memory_total"); |
|
|
|
Double memoryFree = Double.valueOf(heartBeatObj.getString("memory_free")); |
|
|
|
String memory = (Double.valueOf(memoryTotal) - memoryFree) / Double.valueOf(memoryTotal) * 100 + ""; |
|
|
|
String occurTime = ""; |
|
|
|
DmDigitalmanExtPo extPo = dmDigitalmanService.selectExt(devId); |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(ipAddr)) { |
|
|
|
extPo.setIpAddr(ipAddr); |
|
|
|
dmDigitalmanExtService.update(dmDigitalmanExtConverter.mapperDto(extPo)); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
occurTime = DateUtils.formatDate(DateUtils.parseLongToDate(timestamp),"HH:mm"); |
|
|
|
@@ -298,14 +323,14 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm |
|
|
|
|
|
|
|
@PostMapping("/api/mqtt/log-upload") |
|
|
|
public void logUpload(@RequestBody(required = true) String message) { |
|
|
|
JSONObject heartBeatObj = JSONObject.parseObject(message); |
|
|
|
String devId = heartBeatObj.getString("devId"); |
|
|
|
String timestamp = heartBeatObj.getString("timestamp"); |
|
|
|
String fileName = heartBeatObj.getString("file_name"); |
|
|
|
String path = heartBeatObj.getString("path"); |
|
|
|
String type = heartBeatObj.getString("type"); |
|
|
|
Integer level = heartBeatObj.getInteger("level"); |
|
|
|
Integer uploadType = heartBeatObj.getInteger("upload_type"); |
|
|
|
JSONObject uploadObj = JSONObject.parseObject(message); |
|
|
|
String devId = uploadObj.getString("devId"); |
|
|
|
String timestamp = uploadObj.getString("timestamp"); |
|
|
|
String fileName = uploadObj.getString("file_name"); |
|
|
|
String path = uploadObj.getString("path"); |
|
|
|
String type = uploadObj.getString("type"); |
|
|
|
Integer level = uploadObj.getInteger("level"); |
|
|
|
Integer uploadType = uploadObj.getInteger("upload_type"); |
|
|
|
|
|
|
|
|
|
|
|
DmExceptionLogDto exceptionLogDto = new DmExceptionLogDto(); |
|
|
|
@@ -341,4 +366,29 @@ public class DmDigitalmanController extends BaseController<DmDigitalmanQuery, Dm |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/inner-api/devInfo/{devId}") |
|
|
|
public R<DmDigitalmanExtPo> devInnerInfo(@PathVariable(required = true) String devId) { |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(devId)) { |
|
|
|
DmDigitalmanExtPo po = dmDigitalmanService.selectExt(devId); |
|
|
|
return R.ok(po); |
|
|
|
} |
|
|
|
return R.fail("请检查请求参数"); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/api/devInfo/{devId}") |
|
|
|
public R<DmDigitalmanExtPo> devInfo(@PathVariable(required = true) String devId) { |
|
|
|
if (StringUtils.isNotEmpty(devId)){ |
|
|
|
DeviceTenantSourceMergeVo vo = remoteDeviceTenantMergeService.selectDeviceTenantSourceMerge(devId); |
|
|
|
if (null!= vo){ |
|
|
|
return remoteDigitalmanService.devInfo(devId, vo.getTenantId(), vo.getSourceSlave(), SecurityConstants.INNER); |
|
|
|
} else { |
|
|
|
return R.fail("devId可能不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return R.fail("请检查请求参数"); |
|
|
|
} |
|
|
|
} |