JudgmentService.java
7.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.common.enums.TypeConverseEunm;
import cn.com.glsx.admin.modules.mapper.VehicleMapper;
import cn.com.glsx.admin.modules.model.export.JudgmentExport;
import cn.com.glsx.admin.modules.model.param.JudgmentSearch;
import cn.com.glsx.admin.modules.remote.RemoteStuJudgeAlarmService;
import cn.com.glsx.alarm.services.model.StuJudgeAlarmDto;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.StringUtils;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 大数据研判 service
*
* @author yll
*/
@Slf4j
@Service
public class JudgmentService extends AbstractCommonService {
@Autowired
private RemoteStuJudgeAlarmService remoteStuJudgeAlarmService;
@Autowired
private VehicleMapper vehicleMapper;
/**
* 查询大数据研判数据列表
*
* @param search
* @return
*/
public PageInfo findJudgmentList(JudgmentSearch search) {
setOrgCheckedAuth(search);
List<JudgmentExport> judgmentList = vehicleMapper.findJudgmentList(search);
if (CollectionUtil.isEmpty(judgmentList)) {
return new PageInfo<>();
}
log.info("查询大数据研判数据列表的条数" + judgmentList.size());
List<String> snList = judgmentList.stream().map(JudgmentExport::getSn).collect(Collectors.toList());
PageInfo stuJudgeAlarmListByPage = remoteStuJudgeAlarmService.searchStuJudgeAlarmListByPage(snList, search);
List<StuJudgeAlarmDto> stuJudgeAlarmList = JSON.parseArray(JSON.toJSONString(stuJudgeAlarmListByPage.getList()), StuJudgeAlarmDto.class);
if (CollectionUtil.isEmpty(stuJudgeAlarmList)) {
return new PageInfo<>();
}
Map<String, JudgmentExport> judgmentExportMap = judgmentList.stream().filter(judExport -> StringUtils.isNotBlank(judExport.getSn())).collect(Collectors.toMap(JudgmentExport::getSn, Function.identity(), (v1, v2) -> v1));
List<JudgmentExport> judgmentExportList = Lists.newArrayList();
stuJudgeAlarmList.forEach(stuJudgeAlarm -> {
if (StringUtils.isBlank(stuJudgeAlarm.getSn())) {
return;
}
JudgmentExport judgmentExportTemp = judgmentExportMap.get(stuJudgeAlarm.getSn());
if (judgmentExportTemp != null) {
JudgmentExport judgmentExport = new JudgmentExport();
BeanUtils.copyProperties(judgmentExportTemp, judgmentExport);
judgmentExport.setSourceStr(TypeConverseEunm.SourceEnum.getStrBySourceType(judgmentExport.getSource()));
judgmentExport.setAlarmType(stuJudgeAlarm.getAlarmType());
judgmentExport.setAlarmTypeStr(TypeConverseEunm.AlarmTypeEnum.getStrByAlarmType(stuJudgeAlarm.getAlarmType()));
judgmentExport.setAlarmStatus(stuJudgeAlarm.getAlarmStatus());
judgmentExport.setAlarmStatusStr(TypeConverseEunm.AlarmStatusEnum.getStrByAlarmStatus(stuJudgeAlarm.getAlarmStatus()));
judgmentExport.setGeoCode(stuJudgeAlarm.getGeoCode());
judgmentExport.setAlarmAddress(stuJudgeAlarm.getAlarmAddress());
judgmentExport.setAlarmBeginTime(stuJudgeAlarm.getAlarmBeginTime());
judgmentExport.setAlarmEndTime(stuJudgeAlarm.getAlarmEndTime());
if (TypeConverseEunm.AlarmStatusEnum.TAKE_EFFECT.getAlarmStatus().equals(stuJudgeAlarm.getAlarmStatus())) {
// 如果警情为生效警情 则将失效时间设备为 --
judgmentExport.setAlarmEndTime("--");
}
judgmentExport.setAlarmLng(stuJudgeAlarm.getAlarmLng());
judgmentExport.setAlarmLat(stuJudgeAlarm.getAlarmLat());
judgmentExport.setAlarmAddress(stuJudgeAlarm.getAlarmAddress());
judgmentExport.setAlarmCount(stuJudgeAlarm.getAlarmCount());
judgmentExport.setAlarmLevel(stuJudgeAlarm.getAlarmLevel());
judgmentExportList.add(judgmentExport);
}
});
stuJudgeAlarmListByPage.setList(judgmentExportList);
return stuJudgeAlarmListByPage;
}
public List<JudgmentExport> exportJudgmentList(JudgmentSearch search) {
setOrgCheckedAuth(search);
List<JudgmentExport> judgmentList = vehicleMapper.findJudgmentList(search);
if (ObjectUtil.isNull(judgmentList)) {
return null;
}
log.info("查询大数据研判数据列表的条数" + judgmentList.size());
List<String> snList = judgmentList.stream().map(JudgmentExport::getSn).collect(Collectors.toList());
List<StuJudgeAlarmDto> stuJudgeAlarmDtoList = remoteStuJudgeAlarmService.searchStuJudgeAlarmDataList(snList, search);
if (CollectionUtil.isEmpty(stuJudgeAlarmDtoList)) {
return null;
}
Map<String, JudgmentExport> judgmentExportMap = judgmentList.stream().filter(judgement -> StringUtils.isNotBlank(judgement.getSn())).collect(Collectors.toMap(JudgmentExport::getSn, Function.identity(), (v1, v2) -> v1));
List<JudgmentExport> judgmentExportList = Lists.newArrayList();
stuJudgeAlarmDtoList.forEach(stuJudgeAlarm -> {
if (StringUtils.isBlank(stuJudgeAlarm.getSn())) {
return;
}
JudgmentExport judgmentExportTemp = judgmentExportMap.get(stuJudgeAlarm.getSn());
if (judgmentExportTemp != null) {
JudgmentExport judgmentExport = new JudgmentExport();
BeanUtils.copyProperties(judgmentExportTemp, judgmentExport);
judgmentExport.setSourceStr(TypeConverseEunm.SourceEnum.getStrBySourceType(judgmentExport.getSource()));
judgmentExport.setAlarmType(stuJudgeAlarm.getAlarmType());
judgmentExport.setAlarmTypeStr(TypeConverseEunm.AlarmTypeEnum.getStrByAlarmType(stuJudgeAlarm.getAlarmType()));
judgmentExport.setAlarmStatus(stuJudgeAlarm.getAlarmStatus());
judgmentExport.setAlarmStatusStr(TypeConverseEunm.AlarmStatusEnum.getStrByAlarmStatus(stuJudgeAlarm.getAlarmStatus()));
judgmentExport.setGeoCode(stuJudgeAlarm.getGeoCode());
judgmentExport.setAlarmAddress(stuJudgeAlarm.getAlarmAddress());
judgmentExport.setAlarmBeginTime(stuJudgeAlarm.getAlarmBeginTime());
judgmentExport.setAlarmEndTime(stuJudgeAlarm.getAlarmEndTime());
if (TypeConverseEunm.AlarmStatusEnum.TAKE_EFFECT.getAlarmStatus().equals(stuJudgeAlarm.getAlarmStatus())) {
// 如果警情为生效警情 则将失效时间设备为 --
judgmentExport.setAlarmEndTime("--");
}
judgmentExport.setAlarmLng(stuJudgeAlarm.getAlarmLng());
judgmentExport.setAlarmLat(stuJudgeAlarm.getAlarmLat());
judgmentExport.setAlarmAddress(stuJudgeAlarm.getAlarmAddress());
judgmentExport.setAlarmCount(stuJudgeAlarm.getAlarmCount());
judgmentExport.setAlarmLevel(stuJudgeAlarm.getAlarmLevel());
judgmentExportList.add(judgmentExport);
}
});
return judgmentExportList;
}
}