debug ajm问题

This commit is contained in:
xufangming 2025-04-23 17:51:34 +08:00
parent 71d0d4db74
commit 949a91de20
4 changed files with 61 additions and 56 deletions
.idea/inspectionProfiles
nxgx-ifsm-base/src/main/java/com/rootcloud/domain/service

@ -1,6 +1,13 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SizeReplaceableByIsEmpty" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredTypes">
<set>
<option value="java.util.List" />
</set>
</option>
</inspection_tool>
<inspection_tool class="SpringJavaConstructorAutowiringInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="SpringJavaInjectionPointsAutowiringInspection" enabled="false" level="ERROR" enabled_by_default="false" />
</profile>

@ -694,8 +694,7 @@ public class DeviceAlarmServiceImpl implements DeviceAlarmService {
Map<String, Object> deviceCodeAlarmCount = getDeviceCodeAlarmCount(appDeviceAlarmParam);
Object pageTotal = deviceRuleAlarmCount.get("pageTotal");
Object pageTotal1 = deviceCodeAlarmCount.get("pageTotal");
int i = Integer.parseInt(pageTotal.toString()) + Integer.valueOf(pageTotal1.toString());
return i;
return Integer.parseInt(pageTotal.toString()) + Integer.valueOf(pageTotal1.toString());
/*//规则报警
HttpRequest ruleAlarmRequest = HttpRequest.get(domain + alaramUri);
Map<String,Object> ruleAlarmMap = new HashMap<>();

@ -29,7 +29,6 @@ import com.rootcloud.domain.dao.gkjk.NxJeDeviceDao;
import com.rootcloud.domain.dto.DeviceVO;
import com.rootcloud.domain.entity.*;
import com.rootcloud.domain.entity.base.ModelPropertyEntity;
import com.rootcloud.domain.entity.device.NxDeviceEntity;
import com.rootcloud.domain.entity.device.NxDeviceLocationEntity;
import com.rootcloud.domain.mapper.ModelPropertyMapper;
import com.rootcloud.domain.mapper.NxDeviceLocationMapper;
@ -39,12 +38,13 @@ import com.rootcloud.domain.model.WorkStatusMonitorModel;
import com.rootcloud.domain.service.device.DeviceAlarmService;
import com.rootcloud.domain.service.ds.ModelPropertySyncService;
import com.rootcloud.domain.service.gkjk.NxJeDeviceService;
import com.rootcloud.vo.device.*;
import com.rootcloud.vo.device.DeviceHistorySituationVO;
import com.rootcloud.vo.device.DeviceStatusVO;
import com.rootcloud.vo.device.DeviceTypeVO;
import com.rootcloud.vo.resp.OtherDeviceResp;
import com.rootcloud.vo.rest.DevicePropertyValueParam;
import com.rootcloud.vo.rest.DeviceTrendParam;
import groovy.util.logging.Slf4j;
import jline.internal.Log;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.BeanUtils;
@ -148,12 +148,12 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("startTime", stTime);
paramMap.put("endTime", enTime);
paramMap.put("skip",skip);
paramMap.put("limit",limit);
paramMap.put("sort","desc");
paramMap.put("skip", skip);
paramMap.put("limit", limit);
paramMap.put("sort", "desc");
//调用第三方接口获取历史工况数据信息列表
List<DeviceHistorySituationVO> deviceHistorySituationVO = callHistoryInterface1(historySituationAO.getDeviceId(), null, paramMap);
Log.info("历史工况数据查询数据:"+deviceHistorySituationVO.size());
log.info("历史工况数据查询数据:{}", deviceHistorySituationVO.size());
Map<String, Object> countMap = new HashMap<>(16);
countMap.put("startTime", stTime);
countMap.put("endTime", enTime);
@ -184,14 +184,14 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
for (String key : work.keySet()) {
//筛选实时工况中是否存在boolean类型数据
List<WorkStatusMonitorModel> workStatusMonitorModels = work.get(key).stream().filter(e ->
Objects.equals("boolean", e.getPropertyDataType()) || Objects.equals("Boolean", e.getPropertyDataType()))
Objects.equals("boolean", e.getPropertyDataType()) || Objects.equals("Boolean", e.getPropertyDataType()))
.collect(Collectors.toList());
if (null != workStatusMonitorModels && workStatusMonitorModels.size() > 0) {
//存在boolean类型将其放到设备检测中
noWork.put(key, workStatusMonitorModels);
//过滤掉布尔类型重新赋值实时工况
List<WorkStatusMonitorModel> workStatusMonitorModels1 = work.get(key).stream().filter(e ->
!Objects.equals("boolean", e.getPropertyDataType()) && !Objects.equals("Boolean", e.getPropertyDataType()))
!Objects.equals("boolean", e.getPropertyDataType()) && !Objects.equals("Boolean", e.getPropertyDataType()))
.collect(Collectors.toList());
if (null != workStatusMonitorModels1 && workStatusMonitorModels1.size() > 0) {
work.put(key, workStatusMonitorModels1);
@ -218,7 +218,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
groupByTypeMap.put(ResourceUtil.getI18nMessage("60012"), noWork);
item.setGroupByTypeMap(groupByTypeMap);
});
Log.info("历史工况数据最终返回数据:"+deviceHistorySituationVOPageInfo.getList().size());
log.info("历史工况数据最终返回数据:{}", deviceHistorySituationVOPageInfo.getList().size());
return JsonResult.success(deviceHistorySituationVOPageInfo);
}
@ -238,12 +238,12 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("startTime", stTime);
paramMap.put("endTime", enTime);
paramMap.put("limit",6000);
paramMap.put("sort","desc");
paramMap.put("timeZone",historySituationAO.getTimeZone());
paramMap.put("limit", 6000);
paramMap.put("sort", "desc");
paramMap.put("timeZone", historySituationAO.getTimeZone());
//调用第三方接口获取历史工况数据信息列表
List<DeviceHistorySituationVO> deviceHistorySituationVO = callHistoryInterface1(historySituationAO.getDeviceId(), jeDeviceEntity.getModelId(), paramMap);
Log.info("导出查询数据:"+deviceHistorySituationVO.size());
log.info("导出查询数据:{}", deviceHistorySituationVO.size());
return JsonResult.success(deviceHistorySituationVO);
}
@ -334,7 +334,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
request.header("Content-Type", "application/json");
HttpResponse response = request.execute();
String result = response.body();
// Log.info("平台实时工况接口返回数据:{}", result);
log.info("平台实时工况接口返回数据:{}", result);
JSONObject jsonObject = JSONObject.parseObject(result);
JSONArray array = jsonObject.getJSONArray("payload");
@ -602,7 +602,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
}
@Override
public IPage<DeviceVO> devicePage(String queryData, String isCare, int page, int size, String userId,String syZhid) {
public IPage<DeviceVO> devicePage(String queryData, String isCare, int page, int size, String userId, String syZhid) {
//查询设备位置
List<NxDeviceLocationEntity> allDeviceLocation = deviceLocationMapper.findAllDeviceLocation();
@ -642,19 +642,19 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
khmc.append("'").append(dto.getKhglKhmc()).append("',");
}
khmc = new StringBuilder(khmc.substring(0, khmc.length() - 1));
result = nxJeDeviceDao.devicePage(pageParam, queryData, isCare, khmc.toString(), null,UserContext.getTenantId());
result = nxJeDeviceDao.devicePage(pageParam, queryData, isCare, khmc.toString(), null, UserContext.getTenantId());
} else if (user.getRolenames().contains("客户") || user.getRolenames().contains("客户领导")) {
HashMap<String, String> req = new HashMap<>();
req.put("userId",user.getUserid());
req.put("userId", user.getUserid());
String join = "";
List<String> kmcList = nxOrderMapper.getKmcList(req);
if(kmcList.size()>0){
for (String khmc:kmcList) {
join+="'"+khmc+"'"+",";
if (kmcList.size() > 0) {
for (String khmc : kmcList) {
join += "'" + khmc + "'" + ",";
}
join = join.substring(0,join.length()-1);
join = join.substring(0, join.length() - 1);
}
result = nxJeDeviceDao.devicePage(pageParam, queryData, isCare, join, null,UserContext.getTenantId());
result = nxJeDeviceDao.devicePage(pageParam, queryData, isCare, join, null, UserContext.getTenantId());
}
if (CollectionUtils.isNotEmpty(result.getRecords())) {
Map<String, NxDeviceLocationEntity> finalDeviceLocationMap = deviceLocationMap;
@ -667,7 +667,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
if (nxDeviceLocationEntity != null) {
String gps = nxDeviceLocationEntity.getLongitude() + "," + nxDeviceLocationEntity.getLatitude();
//获取经纬度返回地址
if(org.apache.commons.lang3.StringUtils.isNotBlank(gps)){
if (org.apache.commons.lang3.StringUtils.isNotBlank(gps)) {
v.setDeviceAddress(gaoDeAPIUtils.getAddressByJwd(gps));
}
}
@ -921,17 +921,17 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
});
//构建查询排序title条件
HashMap<String, String> req = new HashMap<>();
req.put("deviceSblx",jeDeviceEntity.getDeviceSblx());
req.put("deviceSbxh",jeDeviceEntity.getDeviceSbxh());
req.put("deviceSblx", jeDeviceEntity.getDeviceSblx());
req.put("deviceSbxh", jeDeviceEntity.getDeviceSbxh());
if (monitor) {
mpeWrapper.and(wq -> {
wq.eq(ModelPropertyEntity::getPropertyDataType, "boolean")
.or().eq(ModelPropertyEntity::getPropertyDataType, "Boolean");
});
req.put("workingConditionType","2");
req.put("workingConditionType", "2");
} else {
mpeWrapper.ne(ModelPropertyEntity::getPropertyDataType, "boolean").ne(ModelPropertyEntity::getPropertyDataType, "Boolean");
req.put("workingConditionType","1");
req.put("workingConditionType", "1");
}
List<ModelPropertyEntity> entities = modelPropertyMapper.selectList(mpeWrapper);
this.callInterface(jeDeviceEntity.getNxJeDeviceId(), jeDeviceEntity.getModelId(), entities, monitor);
@ -945,13 +945,13 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
List<String> titles = modelPropertyMapper.getWorkingTitle(req);
LinkedHashMap<String, List<WorkStatusMonitorModel>> linkedHashMap = new LinkedHashMap<>();
titles.forEach(item->{
titles.forEach(item -> {
List<WorkStatusMonitorModel> list = collect.get(item);
if(list!=null){
linkedHashMap.put(item,collect.get(item));
if (list != null) {
linkedHashMap.put(item, collect.get(item));
}
});
log.debug("entities元素数量:"+entities.size()+"models元素数量:"+models.size());
log.info("entities元素数量:{}models元素数量:{}", entities.size(), models.size());
return linkedHashMap;
}
@ -968,10 +968,9 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
headers.put("Authorization", "Bearer " + tokenUtil.getToken());
try {
String resp = HttpClientUtil.sendHttp(HttpRequestMethedEnum.HttpGet, reqUrl + "/realtime-manage/v1/realtime/models/" + modelId + "/things/" + deviceId, null, headers);
//Log.info("平台实时工况接口返回数据:{}", resp);
log.info("callInterface平台实时工况接口返回数据:{}", resp);
JSONObject jsonObject = JSONObject.parseObject(resp);
JSONArray array = jsonObject.getJSONArray("payload");
if (array == null || array.size() == 0) {
//throw new BusinessException(StatusCodeEnum.DEVICE_WORK_STATUS_NOT_EXIST.getRet(), StatusCodeEnum.DEVICE_WORK_STATUS_NOT_EXIST.getMessage());
throw new BusinessException(StatusCodeEnum.DEVICE_WORK_STATUS_NOT_EXIST.getRet(), ResourceUtil.getI18nMessage("13508"));
@ -1021,7 +1020,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
request.header("Content-Type", "application/json");
HttpResponse response = request.execute();
if (response.getStatus() != HttpStatus.HTTP_OK) {
log.error("调用平台接口出错" + response);
log.error("调用平台接口出错{}", response);
//throw new BusinessException(StatusCodeEnum.FAIL_CALL_INTERFACE.getRet(), StatusCodeEnum.FAIL_CALL_INTERFACE.getMessage());
throw new BusinessException(StatusCodeEnum.FAIL_CALL_INTERFACE.getRet(), ResourceUtil.getI18nMessage("40000"));
}
@ -1049,13 +1048,13 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
} catch (Exception e) {
System.out.println("调用平台历史工况信息error");
log.error("查询历史工况数据报错" + e);
log.error("查询历史工况数据报错{}", String.valueOf(e));
}
return resultList;
}
public Integer queryHistoryCount(String deviceId, String modelId, Map<String, Object> paramMap){
public Integer queryHistoryCount(String deviceId, String modelId, Map<String, Object> paramMap) {
NxJeDeviceEntity jeDeviceEntity = this.getById(deviceId);
if (ObjectUtils.isEmpty(jeDeviceEntity)) {
return 0;
@ -1063,7 +1062,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
if (StringUtils.isBlank(modelId)) {
modelId = jeDeviceEntity.getModelId();
}
HttpRequest request = HttpRequest.get(reqUrl + "historian-manage/v1/historian/models/" + modelId + "/things/" + deviceId+"/count");
HttpRequest request = HttpRequest.get(reqUrl + "historian-manage/v1/historian/models/" + modelId + "/things/" + deviceId + "/count");
request.form(paramMap);
//Log.info("请求4.0接口AccessToken:"+ tokenUtil.getToken());
request.header("Authorization", "Bearer " + tokenUtil.getToken());
@ -1071,7 +1070,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
request.header("Content-Type", "application/json");
HttpResponse response = request.execute();
String result = response.body();
Log.info("查询条数",result);
log.info("查询条数{}", result);
JSONObject jsonObject = JSONObject.parseObject(result);
return jsonObject.getJSONObject("payload").getInteger("count");
}
@ -1132,12 +1131,12 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
situationVO.setDeviceSbxhName(jeDeviceEntity.getDeviceSbxhName() == null ? "" : jeDeviceEntity.getDeviceSbxhName());
}
//时间格式化处理
// situationVO.setUpdateTime(DateUtil.reverseHandlerTime(list.get(i).get("time").toString()));
// situationVO.setUpdateTime(DateUtil.reverseHandlerTime(list.get(i).get("time").toString()));
int timeZone = 0;
if( paramMap.get("timeZone")!=null){
timeZone = Integer.valueOf( paramMap.get("timeZone").toString());
if (paramMap.get("timeZone") != null) {
timeZone = Integer.valueOf(paramMap.get("timeZone").toString());
}
situationVO.setUpdateTime(DateUtil.handlerTimeNoUTC(list.get(i).get("time").toString(),timeZone));
situationVO.setUpdateTime(DateUtil.handlerTimeNoUTC(list.get(i).get("time").toString(), timeZone));
situationVO.setMap(list.get(i));
Map<String, Object> stringObjectMap = list.get(i);
@ -1187,8 +1186,8 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
//计算开始时间和结束时间之间
float v = 0;
try {
String date1 = times[0].replace("T"," ").replace("Z","");
String date2 = times[1].replace("T"," ").replace("Z","");
String date1 = times[0].replace("T", " ").replace("Z", "");
String date2 = times[1].replace("T", " ").replace("Z", "");
v = DateUtil.dayDiff(date1, date2);
} catch (ParseException e) {
e.printStackTrace();
@ -1218,8 +1217,8 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
List<Map<String, Object>> listMap = callHistoryInterface(deviceId, modelId, paramMap);
List<Map<String, Object>> resultListMap = new ArrayList<>();
if (v > 1) {
if (!listMap.isEmpty() && listMap.size() > 0) {
Log.info("需要处理的times[0]:{}", times[0]);
if (!listMap.isEmpty()) {
log.info("需要处理的times[0]:{}", times[0]);
SimpleDateFormat localDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
@ -1227,7 +1226,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
String strDate = dateTime.format(date);
longTime = DateUtil.getTimesByString(strDate);
} catch (ParseException e) {
Log.info("时间转换异常,times[0]:{},longTime:{}", times[0], longTime);
log.info("时间转换异常,times[0]:{},longTime:{}", times[0], longTime);
e.printStackTrace();
}
Long finalLongTime = longTime;
@ -1244,18 +1243,18 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
Date date = originalFormat.parse(times[0]);
flagTimeString = targetFormat.format(date);
} catch (ParseException e) {
Log.info("时间转换异常,resultTime:{},flagTimeString:{}", resultTime, flagTimeString);
log.info("时间转换异常,resultTime:{},flagTimeString:{}", resultTime, flagTimeString);
e.printStackTrace();
}
}
Long itemTime = 0L;
Long flagTime = 0L;
try {
Log.info("queryDevicesData resultTime:{}, flagTimeString:{}", resultTime, flagTimeString);
log.info("queryDevicesData resultTime:{}, flagTimeString:{}", resultTime, flagTimeString);
itemTime = stf.parse(resultTime).getTime();
flagTime = DateUtil.getTimesByString(flagTimeString);
} catch (ParseException e) {
Log.info("时间转换异常,resultTime:{},flagTimeString:{},itemTime:{},flagTime:{}", resultTime, flagTimeString, itemTime, flagTime);
log.info("时间转换异常,resultTime:{},flagTimeString:{},itemTime:{},flagTime:{}", resultTime, flagTimeString, itemTime, flagTime);
//e.printStackTrace();
}
//当前元素大于已存最大时间差值
@ -1281,7 +1280,7 @@ public class NxJeDeviceServiceImpl extends ServiceImpl<NxJeDeviceDao, NxJeDevice
}
} else if (finalV > 21) {
if (l % (20 * 60 * 1000) == 0 || l == 0 || chaTime > (20 * 60 * 1000)) {
if (item.get("time")!=null) {
if (item.get("time") != null) {
resultListMap.add(item);
}
}

@ -1539,7 +1539,7 @@ public class ServicePlanServiceImpl extends ServiceImpl<ServicePlanDao, ServiceP
map.put("assigeeId", outletsVO.getUserIds());
map.put("submitType", "to_submit");
Map<String, String> headers = new HashMap<>();
headers.put("authorization", "iTshDNZhNO6BkTjZIba");
headers.put("authorization", login.getAccess_token());
log.info("订单创建日志-authorization[{}]",login.getAccess_token());
// headers.put("authorization", "Hpq9v3R1hoCTVTaVD0p");
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");