|
@@ -10,17 +10,21 @@ import com.jjt.common.core.controller.BaseController;
|
|
|
import com.jjt.common.core.domain.AjaxResult;
|
|
|
import com.jjt.common.core.page.TableDataInfo;
|
|
|
import com.jjt.common.enums.BusinessType;
|
|
|
+import com.jjt.common.utils.DateUtils;
|
|
|
+import com.jjt.common.utils.StringUtils;
|
|
|
import com.jjt.common.utils.poi.ExcelUtil;
|
|
|
+import com.jjt.system.service.ISysConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.time.DayOfWeek;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -40,51 +44,172 @@ public class IndexController extends BaseController {
|
|
|
private IWifiInfoService wifiInfoService;
|
|
|
@Resource
|
|
|
private IVenueInfoService venueInfoService;
|
|
|
+ @Resource
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
|
/**
|
|
|
* 首页信息
|
|
|
*/
|
|
|
@GetMapping("/info")
|
|
|
- public Map<String, Object> info() {
|
|
|
+ public Map<String, Object> info(InfoReq req) {
|
|
|
+ LocalDate nowDate = LocalDate.now();
|
|
|
+ String filter = "";
|
|
|
+ if (req.getFilter() != null) {
|
|
|
+ //为了兼容以前的代码,不至于程序报错,所以这样写
|
|
|
+ filter = req.getFilter();
|
|
|
+ }
|
|
|
+ switch (filter) {
|
|
|
+ case "1":
|
|
|
+ //当天
|
|
|
+ req.setStart(nowDate.toString());
|
|
|
+ req.setStart(nowDate.toString());
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ //本周
|
|
|
+ LocalDate monday = nowDate.with(DayOfWeek.MONDAY);
|
|
|
+ req.setStart(monday.toString());
|
|
|
+ req.setStart(DateUtils.getDate());
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ //本月
|
|
|
+ LocalDate month1 = nowDate.withDayOfMonth(1);
|
|
|
+ req.setStart(month1.toString());
|
|
|
+ req.setStart(nowDate.toString());
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ //本年
|
|
|
+ LocalDate year1 = nowDate.withDayOfYear(1);
|
|
|
+ req.setStart(year1.toString());
|
|
|
+ req.setStart(nowDate.toString());
|
|
|
+ break;
|
|
|
+ /* case "5":
|
|
|
+ //全部
|
|
|
+ req.setStart("");
|
|
|
+ req.setStart("");
|
|
|
+ break;*/
|
|
|
+ case "6":
|
|
|
+ //自定义,直接使用前台传的不管
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ //默认查询全部
|
|
|
+ req.setStart("");
|
|
|
+ req.setStart("");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("beginTime", req.getStart());
|
|
|
+ params.put("endTime", req.getEnd());
|
|
|
+
|
|
|
Map<String, Object> map = new HashMap<>(16);
|
|
|
List deviceInfos = deviceInfoService.selectDeviceInfoList(new DeviceInfo());
|
|
|
map.put("deviceNO", deviceInfos.size());
|
|
|
- List<WifiInfo> wifiInfos = wifiInfoService.selectWifiInfoList(new WifiInfo());
|
|
|
- List wifis = wifiInfos.stream()
|
|
|
+
|
|
|
+ //查询wifi数
|
|
|
+ WifiInfo wifiInfo = new WifiInfo();
|
|
|
+ wifiInfo.setParams(params);
|
|
|
+
|
|
|
+ List<WifiInfo> wifiInfos = wifiInfoService.selectWifiInfoList(wifiInfo);
|
|
|
+ List<WifiInfo> illegalWifi = wifiInfos.stream()
|
|
|
.filter(bean -> bean.getIsIllegal().equals("Y"))
|
|
|
.collect(Collectors.toList());
|
|
|
map.put("totalWifiNO", wifiInfos.size());
|
|
|
- map.put("wifiNO", wifis.size());
|
|
|
- List<BluetoothInfo> bluetoothInfos = bluetoothInfoService.selectBluetoothInfoList(new BluetoothInfo());
|
|
|
- List blues = bluetoothInfos.stream()
|
|
|
+ map.put("wifiNO", illegalWifi.size());
|
|
|
+
|
|
|
+ //查询蓝牙数
|
|
|
+ BluetoothInfo bluetoothInfo = new BluetoothInfo();
|
|
|
+ bluetoothInfo.setParams(params);
|
|
|
+ List<BluetoothInfo> bluetoothInfos = bluetoothInfoService.selectBluetoothInfoList(bluetoothInfo);
|
|
|
+
|
|
|
+ List<BluetoothInfo> illegalBlue = bluetoothInfos.stream()
|
|
|
.filter(bean -> bean.getIsIllegal().equals("Y"))
|
|
|
.collect(Collectors.toList());
|
|
|
map.put("totalBluetoothNO", bluetoothInfos.size());
|
|
|
- map.put("bluetoothNO", blues.size());
|
|
|
+ map.put("bluetoothNO", illegalBlue.size());
|
|
|
List venueInfos = venueInfoService.selectVenueInfoList(new VenueInfo());
|
|
|
map.put("venueNO", venueInfos.size());
|
|
|
+ Integer precision = Integer.parseInt(configService.selectConfigByKey("custom.precision"));
|
|
|
+ Map<String, List<WifiInfo>> wifiGroups = wifiInfos.stream().collect(Collectors.groupingBy(info -> fetchGroupWifi(info, precision)));
|
|
|
+ Map<String, List<BluetoothInfo>> blueGroups = bluetoothInfos.stream().collect(Collectors.groupingBy(info -> fetchGroupBlue(info, precision)));
|
|
|
+
|
|
|
+
|
|
|
List<InfoVO> infoVOS = new ArrayList<>();
|
|
|
- InfoVO vo = new InfoVO();
|
|
|
- vo.setBluetooth(12);
|
|
|
- vo.setTotalBluetooth(100);
|
|
|
- vo.setTotalWifi(300);
|
|
|
- vo.setWifi(15);
|
|
|
- vo.setLat("30.593938");
|
|
|
- vo.setLng("104.243116");
|
|
|
- infoVOS.add(vo);
|
|
|
- vo = new InfoVO();
|
|
|
- vo.setBluetooth(5);
|
|
|
- vo.setTotalBluetooth(15);
|
|
|
- vo.setWifi(21);
|
|
|
- vo.setTotalWifi(400);
|
|
|
- vo.setLat("30.546");
|
|
|
- vo.setLng("104.113");
|
|
|
+ InfoVO vo;
|
|
|
+ for (String s : wifiGroups.keySet()) {
|
|
|
+ vo = new InfoVO();
|
|
|
+ String[] ss = s.split("#");
|
|
|
+ vo.setLat(ss[0]);
|
|
|
+ vo.setLng(ss[1]);
|
|
|
+
|
|
|
+ vo.setTotalWifi(wifiGroups.get(s).size());
|
|
|
+ List<WifiInfo> wifiList = wifiGroups.get(s).stream()
|
|
|
+ .filter(bean -> bean.getIsIllegal().equals("Y"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setWifi(wifiList.size());
|
|
|
+ if (blueGroups.get(s) != null) {
|
|
|
+ //如果相同坐标下还有恶意蓝牙
|
|
|
+ vo.setTotalBluetooth(blueGroups.get(s).size());
|
|
|
+ List<BluetoothInfo> blueList = bluetoothInfos.stream()
|
|
|
+ .filter(bean -> bean.getIsIllegal().equals("Y"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setBluetooth(blueList.size());
|
|
|
+ } else {
|
|
|
+ vo.setTotalBluetooth(0);
|
|
|
+ vo.setBluetooth(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vo.getWifi() >= 0 || vo.getBluetooth() > 0) {
|
|
|
+ infoVOS.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String s : blueGroups.keySet()) {
|
|
|
+ vo = new InfoVO();
|
|
|
+ String[] ss = s.split("#");
|
|
|
+ vo.setLat(ss[0]);
|
|
|
+ vo.setLng(ss[1]);
|
|
|
+ vo.setWifi(0);
|
|
|
+ vo.setTotalWifi(0);
|
|
|
+ vo.setTotalBluetooth(blueGroups.get(s).size());
|
|
|
+ List<BluetoothInfo> blueList = bluetoothInfos.stream()
|
|
|
+ .filter(bean -> bean.getIsIllegal().equals("Y"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setBluetooth(blueList.size());
|
|
|
+
|
|
|
+ if (vo.getWifi() >= 0 || vo.getBluetooth() > 0) {
|
|
|
+ infoVOS.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
map.put("info", infoVOS);
|
|
|
- infoVOS.add(vo);
|
|
|
+
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 组装分组条件
|
|
|
+ */
|
|
|
+ private static String fetchGroupWifi(WifiInfo info, int precision) {
|
|
|
+ BigDecimal lat = new BigDecimal(info.getLat());
|
|
|
+ BigDecimal lng = new BigDecimal(info.getLng());
|
|
|
+ lat = lat.setScale(precision, RoundingMode.HALF_UP);
|
|
|
+ lng = lng.setScale(precision, RoundingMode.HALF_UP);
|
|
|
+ String key = lat + "#" + lng;
|
|
|
+ return key;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装分组条件
|
|
|
+ */
|
|
|
+ private static String fetchGroupBlue(BluetoothInfo info, int precision) {
|
|
|
+ BigDecimal lat = new BigDecimal(info.getLat());
|
|
|
+ BigDecimal lng = new BigDecimal(info.getLng());
|
|
|
+ lat = lat.setScale(precision, RoundingMode.HALF_UP);
|
|
|
+ lng = lng.setScale(precision, RoundingMode.HALF_UP);
|
|
|
+ String key = lat + "#" + lng;
|
|
|
+ return key;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 首页信息
|
|
|
*/
|
|
|
@GetMapping("/top")
|
|
@@ -105,4 +230,13 @@ public class IndexController extends BaseController {
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页信息
|
|
|
+ */
|
|
|
+ @GetMapping("/realTimeInfo")
|
|
|
+ public List<RealTimeInfoVO> realTimeInfo() {
|
|
|
+ List<RealTimeInfoVO> list = wifiInfoService.selectRealTimeInfoList();
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|