diff --git a/inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/service/impl/BasedataPatrolPointServiceImpl.java b/inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/service/impl/BasedataPatrolPointServiceImpl.java index 40ad4e0..7cacf22 100644 --- a/inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/service/impl/BasedataPatrolPointServiceImpl.java +++ b/inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/service/impl/BasedataPatrolPointServiceImpl.java @@ -253,47 +253,52 @@ public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointServi BasedataPatrolPointPreset basedataPatrolpointPreset = new BasedataPatrolPointPreset(); basedataPatrolpointPreset.setPatrolPointId(patrolPoint.getPatrolPointId()); JSONArray presetJsonArray = this.modelPatrolPointPresetHandle(basedataPatrolpointPreset); - String video_pos = null; + String video_pos = ""; if (!presetJsonArray.isEmpty()) { - String presetData = presetJsonArray.getJSONObject(0).getString("device_code"); - if(presetData == null || presetData.indexOf("#") == -1) { - video_pos = ""; - } else { - video_pos = presetData.substring(0, presetData.indexOf("#")); + for (int j = 0; j < presetJsonArray.size(); ++j) { + JSONObject presetJsonObject = presetJsonArray.getJSONObject(j); + String deviceCode = presetJsonObject.getString("device_code"); + if (null != deviceCode && deviceCode.indexOf("#") != -1) { + presetJsonObject.put("device_code", deviceCode.substring(0, deviceCode.indexOf("#"))); + } } - } else { - video_pos = ""; + video_pos = presetJsonArray.toJSONString(); } - modelItem.setStation_name(station_name); - modelItem.setStation_code(station_id); - modelItem.setArea_id(areaId.toString()); - modelItem.setArea_name(area_name); - modelItem.setBay_id(""); - modelItem.setBay_name(""); - modelItem.setMain_device_id(main_device_id); - modelItem.setMain_device_name(main_device_name); - modelItem.setComponent_id(component_id); - modelItem.setComponent_name(component_name); - modelItem.setDevice_id(device_id); - modelItem.setDevice_name(device_name); - modelItem.setDevice_type(device_type); + modelItem.setStation_name(nullToEmpty(station_name)); + modelItem.setStation_code(nullToEmpty(station_id)); + modelItem.setArea_id(nullToEmpty(areaId.toString())); + modelItem.setArea_name(nullToEmpty(area_name)); + modelItem.setBay_id(nullToEmpty(areaId.toString())); + modelItem.setBay_name(nullToEmpty(area_name)); + modelItem.setMain_device_id(nullToEmpty(main_device_id)); + modelItem.setMain_device_name(nullToEmpty(main_device_name)); + modelItem.setComponent_id(nullToEmpty(component_id)); + modelItem.setComponent_name(nullToEmpty(component_name)); + modelItem.setDevice_id(nullToEmpty(device_id)); + modelItem.setDevice_name(nullToEmpty(device_name)); + modelItem.setDevice_type(nullToEmpty(device_type)); modelItem.setMeter_type(""); modelItem.setAppearance_type(""); modelItem.setSave_type_list(""); - modelItem.setRecognition_type_list(algSubtypeIds); - modelItem.setPhase(phase); - modelItem.setDevice_info(device_info); - modelItem.setData_type(""); + modelItem.setRecognition_type_list(nullToEmpty(algSubtypeIds)); + modelItem.setPhase(nullToEmpty(phase)); + modelItem.setDevice_info(nullToEmpty(device_info)); + modelItem.setData_type("1"); modelItem.setLower_value(""); modelItem.setUpper_value(""); - modelItem.setVideo_pos(video_pos); + modelItem.setVideo_pos(nullToEmpty(video_pos)); modelItem.setPoint_type(""); modelItem.setLabel_attri(""); + if(hasChinese(main_device_id) || hasChinese(component_id) || hasChinese(device_id)) { + continue; + } + if(device_type == null || device_type.equals("10000")){ continue; } + items.add(modelItem); } @@ -305,6 +310,17 @@ public class BasedataPatrolPointServiceImpl implements IBasedataPatrolPointServi } } + private String nullToEmpty(String str) { + return null == str ? "" : str; + } + + private boolean hasChinese(String str) { + if (str == null || str.isEmpty()) { + return false; + } + return str.matches(".*[\u4e00-\u9fa5].*"); + } + public String xml(DevicePointModelItem devicePointModelItem, Long[] deviceIds) { DevicePointModel devicePointModel = new DevicePointModel(); List items = new ArrayList<>();