|
@@ -89,52 +89,47 @@ public class ConsumeService implements ApplicationListener<ContextRefreshedEvent
|
|
|
while (true) {
|
|
|
// 间隔30秒拉取一次数据
|
|
|
ConsumerRecords<Integer, String> records = consumer.poll(Constants.WAIT_TIME);
|
|
|
- // 数据解析、处理、入库
|
|
|
if (records != null && records.count() > 0) {
|
|
|
for (ConsumerRecord<Integer, String> record : records) {
|
|
|
JSONObject message = JSONObject.parseObject(record.value());
|
|
|
-// log.info(message.toJSONString());
|
|
|
- // 获取[ORIFIELD]节点数据,该节点数据格式与布控资源表有关,表结构不同,数据格式不同
|
|
|
- JSONObject oriField = message.getJSONObject("ORIFIELD");
|
|
|
- // 考虑到[ORIFIELD]节点数据格式不统一,此处不进行解析,数据域统一入库,并以接口形式同步到用户域后,由前端业务针对不同的资源表进行定制化解析
|
|
|
- String warningInfoJSONStr = oriField.toJSONString();
|
|
|
- // 解析[UNICTRL]节点,该节点数据为统一格式,与布控资源表无关
|
|
|
JSONObject uniCtrl = message.getJSONObject("UNICTRL");
|
|
|
- String clueId = uniCtrl.getString("U_CLUEID"); // 样例:clueId:120000_59275350793392128_D201005_13502082832
|
|
|
+ String clueId = uniCtrl.getString("U_CLUEID");
|
|
|
String[] clueIdStrArr = clueId.split("_");
|
|
|
String taskId = clueIdStrArr[Constants.NUM_1];
|
|
|
String clueType = clueIdStrArr[Constants.NUM_2];
|
|
|
String clue = clueIdStrArr[Constants.NUM_3];
|
|
|
String resourceId = uniCtrl.getString("U_RESID");
|
|
|
- // 如果线索类型是手机号
|
|
|
- if(clueCodePhone.equals(clueType) && "134B102".equals(resourceId)){
|
|
|
+ // 每张布控资源表对应的命中数据JSON对象
|
|
|
+ JSONObject oriField = message.getJSONObject("ORIFIELD");
|
|
|
+ String warningInfoJSONStr = oriField.toJSONString();
|
|
|
+ // 命中时间不采用原始预警数据中的【截获时间】,而采用该服务消费到当前数据时的自然时间作为命中时间
|
|
|
+ String captureTime = TimeTool.timeStampToDateString(TimeTool.getNowTimeStamp());
|
|
|
+ if(Constants.TABLE_AUTH_RES_ID.equals(resourceId)){
|
|
|
+ // 1. ========================= 过滤基站号为空的数据
|
|
|
String baseStationId = oriField.getString("BASE_STATION_ID");
|
|
|
- // 1. ========================= 过滤基站号为空的数据 =========================
|
|
|
if(StringUtils.isBlank(baseStationId)){
|
|
|
continue;
|
|
|
}
|
|
|
+ // 2. ========================= 过滤不在布控区域范围的数据
|
|
|
List<Map<String, Object>> ctrlAreaInfoList = ctrlDao.queryCtrlAreaInfo(taskId);
|
|
|
if(ctrlAreaInfoList.size() > 0){
|
|
|
String lon = oriField.getString("LONGITUDE");
|
|
|
String lat = oriField.getString("LATITUDE");
|
|
|
- // 2. ========================= 过滤不在布控区域范围的数据 =========================
|
|
|
- // 不采用原始预警数据中的"截获时间",而使用当前时间作为"截获时间"
|
|
|
- String captureTime = TimeTool.timeStampToDateString(TimeTool.getNowTimeStamp());
|
|
|
for (Map<String, Object> ctrlAreaInfo : ctrlAreaInfoList) {
|
|
|
Integer areaGeoType = (Integer) ctrlAreaInfo.get("area_geo_type");
|
|
|
JSONArray location = JSON.parseArray((String) ctrlAreaInfo.get("location"));
|
|
|
// ****** 说明:如果出现布控区域范围存在重叠,并且命中点位也恰巧出现在重叠区域的极端情况,目前则只保存一份数据
|
|
|
- // 布控区域是圆形
|
|
|
+ // 布控区域是圆形时
|
|
|
if(Constants.NUM_0 == areaGeoType){
|
|
|
JSONObject loc = location.getJSONObject(0);
|
|
|
String centerLon = loc.getString("lon");
|
|
|
String centerLat = loc.getString("lat");
|
|
|
String radius = loc.getString("radius");
|
|
|
if(GeoUtils.isPointInCircle(Double.valueOf(lat), Double.valueOf(lon), Double.valueOf(centerLat), Double.valueOf(centerLon), Double.valueOf(radius))){
|
|
|
- warningInfoList.add(new Object[]{taskId, clue, clueType, warningInfoJSONStr, captureTime});
|
|
|
+ warningInfoList.add(new Object[]{taskId, resourceId, clue, clueType, warningInfoJSONStr, captureTime});
|
|
|
break;
|
|
|
}
|
|
|
- } else { // 布控区域是一般多边形
|
|
|
+ } else { // 布控区域是一般多边形时
|
|
|
List<Coordinate> coordinates = new ArrayList<>();
|
|
|
for (Object obj : location) {
|
|
|
JSONObject loc = (JSONObject) obj;
|
|
@@ -143,20 +138,20 @@ public class ConsumeService implements ApplicationListener<ContextRefreshedEvent
|
|
|
coordinates.add(new Coordinate(Double.valueOf(vertexLon), Double.valueOf(vertexLat)));
|
|
|
}
|
|
|
if(GeoUtils.isPointInPolygon(coordinates, new Coordinate(Double.valueOf(lon), Double.valueOf(lat)))){
|
|
|
- warningInfoList.add(new Object[]{taskId, clue, clueType, warningInfoJSONStr, captureTime});
|
|
|
+ warningInfoList.add(new Object[]{taskId, resourceId, clue, clueType, warningInfoJSONStr, captureTime});
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ warningInfoList.add(new Object[]{taskId, resourceId, clue, clueType, warningInfoJSONStr, captureTime});
|
|
|
}
|
|
|
- // 原始预警数据中的"截获时间"
|
|
|
-// String captureTime = TimeTool.timeStampToDateString(Long.valueOf(oriField.getString("CAPTURE_TIME")));
|
|
|
- // 生成预警信息编号
|
|
|
- String warningMsgId = String.valueOf(generator.nextId());
|
|
|
}
|
|
|
- // ========================= 3.批量入库符合判断条件的预警数据 =========================
|
|
|
- ctrlDao.batchInsertWarningInfo(warningInfoList);
|
|
|
+ // ========================= 批量入库符合条件的预警数据
|
|
|
+ if(warningInfoList.size() > 0){
|
|
|
+ ctrlDao.batchInsertWarningInfo(warningInfoList);
|
|
|
+ }
|
|
|
log.info("【QBEQSJYCTRL - 消费者服务】 当次消费的数据量:{},符合条件的数据量:{}", records.count(), warningInfoList.size());
|
|
|
warningInfoList.clear();
|
|
|
}
|