|
@@ -0,0 +1,143 @@
|
|
|
+package com.ruoyi.web.controller.system;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.enums.BusinessType;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.LocationUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.system.domain.TShouhuanAlarmList;
|
|
|
+import com.ruoyi.system.domain.TSosSolve;
|
|
|
+import com.ruoyi.system.domain.dto.*;
|
|
|
+import com.ruoyi.system.service.ITDeviceListService;
|
|
|
+import com.ruoyi.system.service.ITShouhuanAlarmListService;
|
|
|
+import com.ruoyi.system.service.ITSosSolveService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.text.NumberFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 数据大屏Controller
|
|
|
+ *
|
|
|
+ * @author zhengjie
|
|
|
+ * @date 2023-09-08
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/display")
|
|
|
+public class TDataDisplayController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private ITShouhuanAlarmListService tShouhuanAlarmListService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITDeviceListService tDeviceListService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LocationUtils locationUtils;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询SOS预警处理列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(DataAlarmListDto dataAlarmListDto)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ List<DataAlarmListDto> list = tShouhuanAlarmListService.selectTShouhuanAlarmList(dataAlarmListDto);
|
|
|
+ List<AlarmListDto> alarmListDtoList = new ArrayList<>();
|
|
|
+ for (DataAlarmListDto dto : list){
|
|
|
+ AlarmListDto alarmListDto = new AlarmListDto();
|
|
|
+ alarmListDto.setName(dto.getName());
|
|
|
+ alarmListDto.setTelno(dto.getTel_one());
|
|
|
+ alarmListDto.setLocation(getCounterLocation(dto.getGps_long() + "," + dto.getGps_lat()));
|
|
|
+ alarmListDto.setAlarmMessage(tDeviceListService.checkMessage(dto.getAlarm_type()));
|
|
|
+ alarmListDto.setCreatetime(dto.getCreatetime());
|
|
|
+ alarmListDtoList.add(alarmListDto);
|
|
|
+ }
|
|
|
+ return getDataTable(alarmListDtoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 总数
|
|
|
+ */
|
|
|
+ @GetMapping("/count")
|
|
|
+ public AjaxResult count()
|
|
|
+ {
|
|
|
+ return success(tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 总数
|
|
|
+ */
|
|
|
+ @GetMapping("/alarm")
|
|
|
+ public AjaxResult alarm()
|
|
|
+ {
|
|
|
+ AlarmStatusDto dto = new AlarmStatusDto();
|
|
|
+ dto.setAlarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
|
|
|
+ dto.setUn_alarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOS() - tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
|
|
|
+ dto.setAlarmRailSolve(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve());
|
|
|
+ dto.setUn_alarmRailSolve(tShouhuanAlarmListService.selectTShouhuanAlarmRail() - tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve());
|
|
|
+ dto.setAlarmHeartSolve(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve());
|
|
|
+ dto.setUn_alarmHeartSolve(tShouhuanAlarmListService.selectTShouhuanAlarmHeart() - tShouhuanAlarmListService.selectTShouhuanAlarmHeartSolve());
|
|
|
+ dto.setAlarmFallSolve(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve());
|
|
|
+ dto.setUn_alarmFallSolve(tShouhuanAlarmListService.selectTShouhuanAlarmFall() - tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve());
|
|
|
+ dto.setAlarmLowSolve(tShouhuanAlarmListService.selectTShouhuanAlarmLowSolve());
|
|
|
+ dto.setUn_alarmLowSolve(tShouhuanAlarmListService.selectTShouhuanAlarmLow() - tShouhuanAlarmListService.selectTShouhuanAlarmLowSolve());
|
|
|
+ dto.setAlarmStatusSolve(tShouhuanAlarmListService.selectTShouhuanAlarmStatus());
|
|
|
+ dto.setUn_alarmStatusSolve(tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve());
|
|
|
+ return success(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 总数
|
|
|
+ */
|
|
|
+ @GetMapping("/percent")
|
|
|
+ public AjaxResult percent()
|
|
|
+ {
|
|
|
+ AlarmPercentDto dto = new AlarmPercentDto();
|
|
|
+ dto.setAlarmSOS(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmSOS()));
|
|
|
+ dto.setAlarmRail(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmRail()));
|
|
|
+ dto.setAlarmFall(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmFall()));
|
|
|
+ int statusSum = tShouhuanAlarmListService.selectTShouhuanAlarmStatus() + tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve();
|
|
|
+ dto.setAlarmStauts(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmStatus(),statusSum));
|
|
|
+ int alarmAll = tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmOtherSolve();
|
|
|
+ dto.setAlarmAll(checkPercent(alarmAll,tShouhuanAlarmListService.selectTShouhuanAlarmListCount()));
|
|
|
+ return success(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 逆地理编码
|
|
|
+ * @param location
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getCounterLocation(String location){
|
|
|
+
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("location", location);
|
|
|
+ logger.info("获取逆地理编码,请求的参数为:{}", params);
|
|
|
+ JSONObject map = locationUtils.getCounterLocation(params);
|
|
|
+ LocationDto locationDto = com.alibaba.fastjson2.JSONObject.parseObject(String.valueOf(map), LocationDto.class);
|
|
|
+ logger.info("获取逆地理编码,返回的请求结果为:{}", map);
|
|
|
+ return locationDto.getFormatted_address();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算百分比
|
|
|
+ */
|
|
|
+ public String checkPercent(int num1, int num2){
|
|
|
+ NumberFormat numberFormat = NumberFormat.getInstance();
|
|
|
+ numberFormat.setMaximumFractionDigits(2);
|
|
|
+ String result = numberFormat.format((float)num1/(float)num2*100);
|
|
|
+ return result + "%";
|
|
|
+ }
|
|
|
+}
|