代码优化
This commit is contained in:
parent
64b9f1ba55
commit
2adf8fc0f0
@ -166,6 +166,9 @@ public class Mcs8Call implements PoliceCameraManufacturer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus() {
|
public void updateStatus() {
|
||||||
|
if (configIsBlank()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<PoliceCameraItem> itemList = policeCameraItemService.list(new LambdaQueryWrapper<PoliceCameraItem>()
|
List<PoliceCameraItem> itemList = policeCameraItemService.list(new LambdaQueryWrapper<PoliceCameraItem>()
|
||||||
.eq(PoliceCameraItem::getProjectSn, config.getProjectSn()));
|
.eq(PoliceCameraItem::getProjectSn, config.getProjectSn()));
|
||||||
Integer page = 1;
|
Integer page = 1;
|
||||||
@ -190,5 +193,11 @@ public class Mcs8Call implements PoliceCameraManufacturer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean configIsBlank() {
|
||||||
|
return StrUtil.isBlank(config.getIp())
|
||||||
|
|| StrUtil.isBlank(config.getPort())
|
||||||
|
|| StrUtil.isBlank(config.getAccount())
|
||||||
|
|| StrUtil.isBlank(config.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,10 @@ import com.zhgd.xmgl.modules.bigdanger.entity.BigDangerCatalog;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "BigDangerCatalogVo实体类", description = "BigDangerCatalogVo实体类")
|
@ApiModel(value = "BigDangerCatalogVo实体类", description = "BigDangerCatalogVo实体类")
|
||||||
public class BigDangerCatalogVo extends BigDangerCatalog {
|
public class BigDangerCatalogVo extends BigDangerCatalog {
|
||||||
|
private List<BigDangerCatalogVo> children;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import com.zhgd.xmgl.modules.bigdanger.entity.vo.BigDangerCatalogVo;
|
|||||||
import com.zhgd.xmgl.modules.bigdanger.mapper.BigDangerCatalogMapper;
|
import com.zhgd.xmgl.modules.bigdanger.mapper.BigDangerCatalogMapper;
|
||||||
import com.zhgd.xmgl.modules.bigdanger.service.IBigDangerCatalogService;
|
import com.zhgd.xmgl.modules.bigdanger.service.IBigDangerCatalogService;
|
||||||
import com.zhgd.xmgl.util.*;
|
import com.zhgd.xmgl.util.*;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -101,6 +102,8 @@ public class BigDangerCatalogServiceImpl extends ServiceImpl<BigDangerCatalogMap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONArray treeList(HashMap<String, Object> paramMap) {
|
public JSONArray treeList(HashMap<String, Object> paramMap) {
|
||||||
return ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(this.queryList(paramMap))), "id", "parentId", "children");
|
String catalogName = MapUtils.getString(paramMap, "catalogName");
|
||||||
|
paramMap.put("catalogName", null);
|
||||||
|
return TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(this.queryList(paramMap))), "id", "parentId", "children", "catalogName", catalogName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.zhgd.xmgl.task;
|
package com.zhgd.xmgl.task;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@ -113,8 +114,9 @@ public class TunnelBoringMachineTask {
|
|||||||
.body();
|
.body();
|
||||||
List<String> list = Arrays.asList("螺机CH4", "螺机H2S", "螺机CO", "螺机CO2", "螺机NO2");
|
List<String> list = Arrays.asList("螺机CH4", "螺机H2S", "螺机CO", "螺机CO2", "螺机NO2");
|
||||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||||
if (jsonObject != null || jsonObject.getInteger("code") == 200) {
|
if (jsonObject != null && jsonObject.getInteger("code") == 200) {
|
||||||
JSONArray data = jsonObject.getJSONArray("data");
|
JSONArray data = jsonObject.getJSONArray("data");
|
||||||
|
if (CollUtil.isNotEmpty(data)) {
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
JSONObject obj = data.getJSONObject(i);
|
JSONObject obj = data.getJSONObject(i);
|
||||||
String name = obj.getString("name");
|
String name = obj.getString("name");
|
||||||
@ -158,6 +160,7 @@ public class TunnelBoringMachineTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0/20 * * * * ?")
|
@Scheduled(cron = "0/20 * * * * ?")
|
||||||
@RequestMapping("getTunnelBoringMachineData")
|
@RequestMapping("getTunnelBoringMachineData")
|
||||||
@ -184,7 +187,7 @@ public class TunnelBoringMachineTask {
|
|||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||||
if (jsonObject != null || jsonObject.getInteger("code") == 200) {
|
if (jsonObject != null && jsonObject.getInteger("code") == 200) {
|
||||||
TunnelBoringMachineCurrentData tunnelBoringMachineCurrentData = new TunnelBoringMachineCurrentData();
|
TunnelBoringMachineCurrentData tunnelBoringMachineCurrentData = new TunnelBoringMachineCurrentData();
|
||||||
tunnelBoringMachineCurrentData.setDeviceSn(tunnelBoringMachine.getDevSn());
|
tunnelBoringMachineCurrentData.setDeviceSn(tunnelBoringMachine.getDevSn());
|
||||||
tunnelBoringMachineCurrentData.setProjectSn(tunnelBoringMachine.getProjectSn());
|
tunnelBoringMachineCurrentData.setProjectSn(tunnelBoringMachine.getProjectSn());
|
||||||
|
|||||||
@ -222,7 +222,13 @@ public class TreeUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保留原方法的重载版本(兼容旧代码)
|
* list转tree,保留树形结构
|
||||||
|
*
|
||||||
|
* @param arr
|
||||||
|
* @param id
|
||||||
|
* @param pid
|
||||||
|
* @param child
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JSONArray listToTree(JSONArray arr, String id, String pid, String child) {
|
public static JSONArray listToTree(JSONArray arr, String id, String pid, String child) {
|
||||||
return buildTree(arr, id, pid, child);
|
return buildTree(arr, id, pid, child);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user