zhanghua
2023-04-04 90599c1af35eb139710e1472d9c2acbab5a8eb07
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package com.ycl.controller.cockpit.statisticsEvents;
 
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ycl.api.CommonResult;
import com.ycl.entity.cockpitManage.TeamConstruction;
import com.ycl.entity.cockpitManage.TeamIndex;
import com.ycl.service.apidata.IApiDataService;
import com.ycl.service.cockpitManage.ITeamConstructionService;
import com.ycl.service.equipment.IOrgGridService;
import com.ycl.service.video.impl.IVideoPointService;
import com.ycl.util.CheckApiUtil;
import com.ycl.vo.cockpit.CockpitVO;
import com.ycl.vo.cockpit.statisticsEvents.GridMapVO;
import com.ycl.vo.cockpit.statisticsEvents.StatisticsEventsVO;
import com.ycl.vo.equipment.VideoPointVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author Lyq
 * @version 1.0
 * @date 2022/10/26
 */
@Api(tags = "驾驶舱数据接口-综合决策")
@RestController
@RequestMapping("/api/data")
public class StatisticsEventsController {
    @Resource
    private CheckApiUtil checkApiUtil;
 
    private IVideoPointService videoPointService;
 
    private ITeamConstructionService teamConstructionService;
 
    private IOrgGridService orgGridService;
 
 
    private IApiDataService iApiDataService;
 
    @Autowired
    public void setIApiDataService(IApiDataService apiDataService) {
        this.iApiDataService = apiDataService;
    }
 
    @Autowired
    public void setTeamConstructionService(ITeamConstructionService teamConstructionService) {
        this.teamConstructionService = teamConstructionService;
    }
 
    @Autowired
    public void setVideoPointService(IVideoPointService videoPointService) {
        this.videoPointService = videoPointService;
    }
 
    @Autowired
    public void setOrgGridService(IOrgGridService orgGridService) {
        this.orgGridService = orgGridService;
    }
 
    @ApiOperation(value = "执法事件")
    @GetMapping("/law_enforcement_event")
    public CommonResult<List<StatisticsEventsVO.LawEnforcementEventVO>> detection(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        List<StatisticsEventsVO.LawEnforcementEventVO> lawEnforcementEventVOS = new ArrayList<>();
        StatisticsEventsVO.LawEnforcementEventVO a = null;
        for (int i = 0; i < 4; i++) {
            a = new StatisticsEventsVO.LawEnforcementEventVO();
            a.setName("团结屯");
            a.setMonth("10");
            a.setCityManagementCount(10);
            a.setEnforcementEventCount(10);
            lawEnforcementEventVOS.add(a);
        }
        return CommonResult.success(lawEnforcementEventVOS);
    }
 
    @ApiOperation(value = "物联感知")
    @GetMapping("/lot")
    public CommonResult<List<StatisticsEventsVO.LotVO>> lot(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        List<StatisticsEventsVO.LotVO> lotVOS = iApiDataService.listLot(params.getStreetId(), params.getBeginTime(), params.getEndTime());
 
        return CommonResult.success(lotVOS);
    }
 
    @ApiOperation(value = "执法队伍")
    @GetMapping("/team")
    public CommonResult<StatisticsEventsVO.TeamVO> team(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        StatisticsEventsVO.TeamVO teamVO = new StatisticsEventsVO.TeamVO();
        teamVO.setAll(30);
        teamVO.setAssistant(10);
        teamVO.setOfficer(10);
        teamVO.setSecondOfficer(1);
        teamVO.setOffline(10);
        teamVO.setOnline(20);
        return CommonResult.success(teamVO);
    }
 
    @ApiOperation(value = "网格员")
    @GetMapping("/grid_member")
    public CommonResult<List<StatisticsEventsVO.GridMemberVO>> gridMember(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        List<StatisticsEventsVO.GridMemberVO> gridMemberVOS = new ArrayList<>();
        StatisticsEventsVO.GridMemberVO a = null;
        for (int i = 0; i < 4; i++) {
            a = new StatisticsEventsVO.GridMemberVO();
            a.setRatio(new BigDecimal("0.20").setScale(4, RoundingMode.HALF_UP));
            a.setName("团结屯");
            a.setCount(10);
            gridMemberVOS.add(a);
        }
        return CommonResult.success(gridMemberVOS);
    }
 
    @ApiOperation(value = "指数体征")
    @GetMapping("/index_signs")
    public CommonResult<StatisticsEventsVO.IndexSignsVO> indexSigns(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        StatisticsEventsVO.IndexSignsVO indexSignsVO = new StatisticsEventsVO.IndexSignsVO();
        indexSignsVO.setEvent(1);
        indexSignsVO.setGridMember(20);
        indexSignsVO.setCompletePercentage(new BigDecimal("0.60").setScale(4, RoundingMode.HALF_UP));
        indexSignsVO.setEquipment(30);
        indexSignsVO.setAccuracy(new BigDecimal("0.80").setScale(4, RoundingMode.HALF_UP));
        indexSignsVO.setTrigger(10);
        indexSignsVO.setLot(30);
        indexSignsVO.setLotOnline(10);
        indexSignsVO.setCityData(10);
        indexSignsVO.setEvaluationData(10);
        return CommonResult.success(indexSignsVO);
    }
 
 
    @ApiOperation(value = "top10")
    @GetMapping("/top10")
    public CommonResult<List<StatisticsEventsVO.Top10VO>> top10(@Validated CockpitVO params) {
//        checkApiUtil.cockpit(params);
//        List<StatisticsEventsVO.Top10VO> ls = new ArrayList<>();
//        ls.add(new StatisticsEventsVO.Top10VO("xx中队", 100.0));
//        ls.add(new StatisticsEventsVO.Top10VO("xx中队", 90.0));
//        ls.add(new StatisticsEventsVO.Top10VO("xx中队", 80.0));
//        ls.add(new StatisticsEventsVO.Top10VO("xx中队", 70.0));
//        return CommonResult.success(ls);
        String beginTime = params.getBeginTime();
        String endTime = params.getEndTime();
        List<StatisticsEventsVO.Top10VO> res = iApiDataService.listTop10(beginTime, endTime);
        return CommonResult.success(res);
    }
 
 
    @ApiOperation(value = "AI算法")
    @GetMapping("/arithmetic_event")
    public CommonResult<List<StatisticsEventsVO.ArithmeticVO>> arithmeticEvent(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        List<StatisticsEventsVO.ArithmeticVO> ls = iApiDataService.arithmeticEvent(params.getStreetId(), params.getBeginTime(), params.getEndTime());
 
        return CommonResult.success(ls);
    }
 
 
    @ApiOperation(value = "城市体征看板")
    @GetMapping("/city_panel")
    public CommonResult<StatisticsEventsVO.CityPanelVo> cityPanel(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
 
        StatisticsEventsVO.CityPanelVo vo = new StatisticsEventsVO.CityPanelVo(92, true, 22, false, 12, true,
                22, false, 34, true, 99, false, 9, true,
                34, false, 6, true);
 
        return CommonResult.success(vo);
    }
 
 
    @ApiOperation(value = "点位")
    @GetMapping("/video_point")
    public CommonResult<List<VideoPointVo>> videoPoint(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        IPage<VideoPointVo> page = videoPointService.getList(null, null, 1, 500);
        return CommonResult.success(page.getRecords());
    }
 
    @ApiOperation(value = "网格地图")
    @GetMapping("/grid_map")
    public CommonResult<List<GridMapVO>> gridMap(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
 
        List<GridMapVO> list = orgGridService.statisticsGridMap(params.getBeginTime(), params.getEndTime());
        return CommonResult.success(list);
    }
 
    @ApiOperation(value = "队伍建设")
    @GetMapping("/team_construction")
    public CommonResult<List<TeamConstruction>> teamConstruction(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        LambdaQueryWrapper<TeamConstruction> queryWrapper = new LambdaQueryWrapper<TeamConstruction>().eq(TeamConstruction::getStatus, 1).eq(TeamConstruction::getIsDelete, 0);
        List<TeamConstruction> list = teamConstructionService.list(queryWrapper);
        return CommonResult.success(list);
    }
 
 
    @ApiOperation(value = "中队指数体征")
    @GetMapping("/team_index")
    public CommonResult<List<TeamIndex>> teamIndex(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
 
        // LambdaQueryWrapper<TeamConstruction> queryWrapper = new LambdaQueryWrapper<TeamConstruction>().eq(TeamConstruction::getStatus, 1).eq(TeamConstruction::getIsDelete, 0);
        // List<TeamConstruction> list = teamConstructionService.list(queryWrapper);
        // List<TeamIndex> teamIndexList = BeanUtil.copyToList(list, TeamIndex.class);
        // teamIndexList.forEach(o -> {
        //     o.setStepTimely(0.0);
        //     o.setStepDelayed(0.0);
        //     o.setStepOvertime(0.0);
        //     o.setHandleTimely(0.0);
        //     o.setHandleDelayed(0.0);
        //     o.setHandleOvertime(0.0);
        //     o.setNoHandle(0.0);
        // });
        List<TeamIndex> teamIndexList = teamConstructionService.teamIndex(params.getBeginTime(), params.getEndTime());
        teamIndexList.forEach(o -> {
 
            o.setAllocation(20 * ((double) o.getPunctualityCount() / (double) o.getAllCount())
                    + 18 * ((double) o.getOverCount() / (double) o.getAllCount())
                    + 15 * ((double) o.getNoHandleCount() / (double) o.getAllCount()));
            o.setHandle(20 * ((double) o.getPunctualityCount() / (double) o.getAllCount())
                    + 5 * ((double) o.getOverCount() / (double) o.getAllCount())
                    - 2 * ((double) o.getNoHandleCount() / (double) o.getAllCount()));
 
            o.setOnline(0.0);
            o.setDuration(0.0);
            o.setDistance(0.0);
        });
        return CommonResult.success(teamIndexList);
    }
}