From c98bb582d6a313940310a5e05bc80bafe386e3a2 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Thu, 19 Aug 2021 15:25:12 +0800 Subject: [PATCH] 走航车轨迹 --- screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java | 22 + screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml | 19 + screen-api/src/main/java/com/moral/api/entity/SpecialDevice.java | 83 +++++ screen-api/src/main/java/com/moral/api/mapper/HistorySecondSpecialMapper.java | 21 + screen-common/src/main/java/com/moral/util/GeodesyUtils.java | 25 + screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java | 38 ++ screen-api/src/main/java/com/moral/api/service/HistorySecondSpecialService.java | 16 + screen-api/src/main/java/com/moral/api/controller/OrganizationController.java | 52 +++ screen-api/src/main/java/com/moral/api/entity/HistorySecondSpecial.java | 55 +++ /dev/null | 174 ------------ screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml | 3 screen-api/src/main/java/com/moral/api/controller/DeviceController.java | 100 +++++++ screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java | 16 + screen-api/src/main/java/com/moral/api/service/impl/HistorySecondSpecialServiceImpl.java | 20 + screen-api/src/main/resources/mapper/HistorySecondSpecialMapper.xml | 24 + screen-api/src/main/java/com/moral/api/controller/SpecialDeviceController.java | 55 +++ screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java | 97 ++++++ screen-common/src/main/java/com/moral/constant/Constants.java | 10 18 files changed, 650 insertions(+), 180 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/controller/DeviceController.java b/screen-api/src/main/java/com/moral/api/controller/DeviceController.java index 0e277e7..1c32fd9 100644 --- a/screen-api/src/main/java/com/moral/api/controller/DeviceController.java +++ b/screen-api/src/main/java/com/moral/api/controller/DeviceController.java @@ -2,18 +2,31 @@ import com.moral.api.entity.Sensor; import com.moral.api.pojo.vo.alarm.AlarmLevelVO; +import com.moral.api.service.DeviceService; +import com.moral.api.service.HistoryDailyService; +import com.moral.api.service.HistoryHourlyService; import com.moral.api.service.OrganizationUnitAlarmService; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; +import com.moral.util.WebUtils; + import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; /** * @ClassName AlarmController @@ -32,12 +45,97 @@ @Autowired OrganizationUnitAlarmService organizationUnitAlarmService; + @Autowired + private HistoryHourlyService historyHourlyService; + + @Autowired + private HistoryDailyService historyDailyService; + + @Autowired + private DeviceService deviceService; + @GetMapping("queryAlarmByMac") - public ResultMessage queryAlarmByMac(String mac){ + public ResultMessage queryAlarmByMac(String mac) { List<Sensor> sensors = organizationUnitAlarmService.queryAlarmLevel(mac); AlarmLevelVO vo = AlarmLevelVO.convert(sensors); return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); } + /** + * @param request ������������ + * @return ������������������������������������ + */ + @GetMapping("getHourlyAqi") + @ApiOperation(value = "���������������AQI", notes = "���������������AQI") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String") + }) + public ResultMessage getHourlyAqi(HttpServletRequest request) { + Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + if (!params.containsKey("mac")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + Map<String, Object> response = historyHourlyService.getHourlyAqiByMac(params.get("mac").toString()); + return ResultMessage.ok(response); + } + /** + * @param request ������������ + * @return ������������������������������������ + */ + @GetMapping("getMonthAvg") + @ApiOperation(value = "������������������������������������", notes = "������������������������������������") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "sensorCode", value = "���������code", required = true, paramType = "query", dataType = "String") + }) + public ResultMessage getMonthAvg(HttpServletRequest request) { + Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + if (!params.containsKey("mac") || !params.containsKey("sensorCode")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + Map<String, Object> response = historyDailyService.getMonthAvg(params); + return ResultMessage.ok(response); + } + + /** + * @param params ������������ + * @return ������������������������������������ + */ + @PostMapping("getMacSensors") + @ApiOperation(value = "������������mac���������������", notes = "������������mac���������������") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "macs", value = "������mac���������������������", required = true, paramType = "query", dataType = "List") + }) + public ResultMessage getMacSensors(@RequestBody Map<String, Object> params) { + if (!params.containsKey("macs")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + Map<String, Object> response = deviceService.getSensorsByMac(params); + return ResultMessage.ok(response); + } + + /** + * @param params ������������ + * @return ������������������������������������ + */ + @PostMapping("getTrendChartData") + @ApiOperation(value = "���������������������������������", notes = "���������������������������������.") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "macs", value = "������mac���������������������", required = true, paramType = "body", dataType = "list"), + @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "body", dataType = "String"), + @ApiImplicitParam(name = "type", value = "���������������������day���,������month���,������year���", required = true, paramType = "body", dataType = "String"), + @ApiImplicitParam(name = "times", value = "���������������������2021-07-29������������2021-07������������2021������������������������", required = true, paramType = "body", dataType = "List") + }) + public ResultMessage getTrendChartData(@RequestBody Map<String, Object> params) { + if (!params.containsKey("macs") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("times")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + List<Map<String, Object>> response = deviceService.getTrendChartData(params); + return ResultMessage.ok(response); + } } diff --git a/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java b/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java index ce0faaa..7b5ae9c 100644 --- a/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java +++ b/screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java @@ -4,11 +4,17 @@ import com.moral.api.pojo.form.device.MonitorPointQueryForm; import com.moral.api.pojo.vo.monitorPoint.MonitorPointsVO; import com.moral.api.pojo.vo.monitorPoint.StateControllerStationVO; +import com.moral.api.service.HistoryFiveMinutelyService; import com.moral.api.service.MonitorPointService; import com.moral.api.service.OrganizationService; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; +import com.moral.util.WebUtils; + import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; @@ -17,6 +23,9 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; /** * @ClassName DeviceController @@ -35,8 +44,11 @@ @Autowired MonitorPointService monitorPointService; + @Autowired + private HistoryFiveMinutelyService historyFiveMinutelyService; + @GetMapping("queryMonitorPoints") - public ResultMessage queryMonitorPointsAndDevices(MonitorPointQueryForm form){ + public ResultMessage queryMonitorPointsAndDevices(MonitorPointQueryForm form) { //������������������������ if (!form.valid()) return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), @@ -51,15 +63,35 @@ } @GetMapping("queryStateControlStation") - public ResultMessage queryStateControlStation(Integer regionCode){ + public ResultMessage queryStateControlStation(Integer regionCode) { List<MonitorPoint> monitorPoints = monitorPointService.queryStateControlStationByRegionCode(regionCode); //������������������������ StateControllerStationVO vo = StateControllerStationVO.convert(monitorPoints); - return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo); + return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); } + /** + * @param request ������������ + * @return ������������������������������������ + */ + @GetMapping("getWindData") + @ApiOperation(value = "������������������", notes = "������������������") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "monitorPointIds", value = "������id", required = true, paramType = "query", dataType = "String") + }) + public ResultMessage getWindData(HttpServletRequest request) { + Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + if (!params.containsKey("monitorPointIds")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + String[] monitorPointIds = params.remove("monitorPointIds").toString().split(","); + params.put("monitorPointIds", monitorPointIds); + List<Object> response = historyFiveMinutelyService.getAreaWindData(params); + return ResultMessage.ok(response); + } } diff --git a/screen-api/src/main/java/com/moral/api/controller/OrganizationController.java b/screen-api/src/main/java/com/moral/api/controller/OrganizationController.java new file mode 100644 index 0000000..ad7a6b0 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/controller/OrganizationController.java @@ -0,0 +1,52 @@ +package com.moral.api.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import com.moral.api.service.SysAreaService; +import com.moral.constant.ResponseCodeEnum; +import com.moral.constant.ResultMessage; +import com.moral.util.WebUtils; + +@Slf4j +@Api(tags = {"������"}) +@RestController +@CrossOrigin(origins = "*", maxAge = 3600) +@RequestMapping("/organization") +public class OrganizationController { + + @Autowired + private SysAreaService sysAreaService; + + /** + * @param request ������������ + * @return ������������������������������������ + */ + @GetMapping("getMapPath") + @ApiOperation(value = "������������������������������", notes = "������������������������������") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "organizationId", value = "������id", required = true, paramType = "query", dataType = "String") + }) + public ResultMessage getMapPath(HttpServletRequest request) { + Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + if (!params.containsKey("organizationId")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + List<Map<String, Object>> response = sysAreaService.getMapPath(Integer.parseInt(params.get("organizationId").toString())); + return ResultMessage.ok(response); + } +} diff --git a/screen-api/src/main/java/com/moral/api/controller/SpecialDeviceController.java b/screen-api/src/main/java/com/moral/api/controller/SpecialDeviceController.java new file mode 100644 index 0000000..ae6cf8d --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/controller/SpecialDeviceController.java @@ -0,0 +1,55 @@ +package com.moral.api.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import com.moral.api.service.SpecialDeviceService; +import com.moral.constant.ResponseCodeEnum; +import com.moral.constant.ResultMessage; +import com.moral.util.WebUtils; + +@Slf4j +@Api(tags = {"������������"}) +@RestController +@CrossOrigin(origins = "*", maxAge = 3600) +@RequestMapping("/specialDevice") +public class SpecialDeviceController { + + @Autowired + private SpecialDeviceService specialDeviceService; + + /** + * @param request ������������ + * @return ������������������������������������ + */ + @GetMapping("carTrajectory") + @ApiOperation(value = "���������������", notes = "���������������") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), + @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "sensorCode", value = "���������code", required = true, paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "time", value = "���������2021-08-18", required = true, paramType = "query", dataType = "String") + }) + public ResultMessage carTrajectory(HttpServletRequest request) { + Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); + if (!params.containsKey("mac") || !params.containsKey("sensorCode") || !params.containsKey("time")) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + List<Map<String, Object>> response = specialDeviceService.carTrajectory(params); + return ResultMessage.ok(response); + } + +} diff --git a/screen-api/src/main/java/com/moral/api/controller/WebController.java b/screen-api/src/main/java/com/moral/api/controller/WebController.java deleted file mode 100644 index 7562116..0000000 --- a/screen-api/src/main/java/com/moral/api/controller/WebController.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.moral.api.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import com.moral.api.service.DeviceService; -import com.moral.api.service.HistoryDailyService; -import com.moral.api.service.HistoryFiveMinutelyService; -import com.moral.api.service.HistoryHourlyService; -import com.moral.api.service.SysAreaService; -import com.moral.constant.ResponseCodeEnum; -import com.moral.constant.ResultMessage; -import com.moral.util.WebUtils; - -/** - * web��������� - * - * @author moral - * @version v1.0 - */ -@Slf4j -@Api(tags = {"web���������"}) -@RestController -@RequestMapping("/web") -public class WebController { - - @Autowired - private HistoryHourlyService historyHourlyService; - - @Autowired - private HistoryDailyService historyDailyService; - - @Autowired - private HistoryFiveMinutelyService historyFiveMinutelyService; - - @Autowired - private DeviceService deviceService; - - @Autowired - private SysAreaService sysAreaService; - - /** - * @param request ������������ - * @return ������������������������������������ - */ - @GetMapping("getHourlyAqi") - @ApiOperation(value = "���������������AQI", notes = "���������������AQI") - @ApiImplicitParams(value = { - @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), - @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String") - }) - public ResultMessage getHourlyAqi(HttpServletRequest request) { - Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); - if (!params.containsKey("mac")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); - } - Map<String, Object> response = historyHourlyService.getHourlyAqiByMac(params.get("mac").toString()); - return ResultMessage.ok(response); - } - - /** - * @param request ������������ - * @return ������������������������������������ - */ - @GetMapping("getMonthAvg") - @ApiOperation(value = "������������������������������������", notes = "������������������������������������") - @ApiImplicitParams(value = { - @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), - @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "query", dataType = "String") - }) - public ResultMessage getMonthAvg(HttpServletRequest request) { - Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); - if (!params.containsKey("mac") || !params.containsKey("sensorCode")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); - } - Map<String, Object> response = historyDailyService.getMonthAvg(params); - return ResultMessage.ok(response); - } - - /** - * @param request ������������ - * @return ������������������������������������ - */ - @GetMapping("getWindData") - @ApiOperation(value = "������������������", notes = "������������������") - @ApiImplicitParams(value = { - @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), - @ApiImplicitParam(name = "monitorPointIds", value = "������id", required = true, paramType = "query", dataType = "String") - }) - public ResultMessage getWindData(HttpServletRequest request) { - Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); - if (!params.containsKey("monitorPointIds")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); - } - String[] monitorPointIds = params.remove("monitorPointIds").toString().split(","); - params.put("monitorPointIds", monitorPointIds); - List<Object> response = historyFiveMinutelyService.getAreaWindData(params); - return ResultMessage.ok(response); - } - - /** - * @param params ������������ - * @return ������������������������������������ - */ - @PostMapping("getMacSensors") - @ApiOperation(value = "������������mac������������������", notes = "������������mac������������������") - @ApiImplicitParams(value = { - @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), - @ApiImplicitParam(name = "macs", value = "������mac���������������������", required = true, paramType = "query", dataType = "List") - }) - public ResultMessage getMacSensors(@RequestBody Map<String,Object> params) { - if (!params.containsKey("macs")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); - } - Map<String, Object> response = deviceService.getSensorsByMac(params); - return ResultMessage.ok(response); - } - - /** - * @param params ������������ - * @return ������������������������������������ - */ - @PostMapping("getTrendChartData") - @ApiOperation(value = "���������������������������������", notes = "���������������������������������.") - @ApiImplicitParams(value = { - @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), - @ApiImplicitParam(name = "macs", value = "������mac���������������������", required = true, paramType = "body", dataType = "list"), - @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "body", dataType = "String"), - @ApiImplicitParam(name = "type", value = "���������������������day���,������month���,������year���", required = true, paramType = "body", dataType = "String"), - @ApiImplicitParam(name = "times", value = "���������������������2021-07-29������������2021-07������������2021������������������������", required = true, paramType = "body", dataType = "List") - }) - public ResultMessage getTrendChartData(@RequestBody Map<String,Object> params) { - if (!params.containsKey("macs") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("times")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); - } - List<Map<String, Object>> response = deviceService.getTrendChartData(params); - return ResultMessage.ok(response); - } - - /** - * @param request ������������ - * @return ������������������������������������ - */ - @GetMapping("getMapPath") - @ApiOperation(value = "������������������������������", notes = "������������������������������") - @ApiImplicitParams(value = { - @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), - @ApiImplicitParam(name = "organizationId", value = "������id", required = true, paramType = "query", dataType = "String") - }) - public ResultMessage getMapPath(HttpServletRequest request) { - Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); - if (!params.containsKey("organizationId")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); - } - List<Map<String, Object>> response = sysAreaService.getMapPath(Integer.parseInt(params.get("organizationId").toString())); - return ResultMessage.ok(response); - } - -} diff --git a/screen-api/src/main/java/com/moral/api/entity/HistorySecondSpecial.java b/screen-api/src/main/java/com/moral/api/entity/HistorySecondSpecial.java new file mode 100644 index 0000000..e422fdb --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/entity/HistorySecondSpecial.java @@ -0,0 +1,55 @@ +package com.moral.api.entity; + +import com.baomidou.mybatisplus.extension.activerecord.Model; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * <p> + * ������������������������ + * </p> + * + * @author moral + * @since 2021-08-18 + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class HistorySecondSpecial extends Model<HistorySecondSpecial> { + + private static final long serialVersionUID = 1L; + + /** + * ������mac + */ + private String mac; + + /** + * ������������ + */ + private Date time; + + /** + * ������ + */ + private String value; + + /** + * ���������������������id + */ + private Integer organizationId; + + /** + * ������������ + */ + private Date batch; + + + @Override + protected Serializable pkVal() { + return null; + } + +} diff --git a/screen-api/src/main/java/com/moral/api/entity/SpecialDevice.java b/screen-api/src/main/java/com/moral/api/entity/SpecialDevice.java new file mode 100644 index 0000000..c561375 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/entity/SpecialDevice.java @@ -0,0 +1,83 @@ +package com.moral.api.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * <p> + * + * </p> + * + * @author moral + * @since 2021-08-18 + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class SpecialDevice extends Model<SpecialDevice> { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * ������������ + */ + private String name; + + /** + * mac��� + */ + private String mac; + + /** + * ���������id���������������������������������manage_account + */ + private String operateIds; + + /** + * ������������������id + */ + private Integer organizationId; + + /** + * ������������������id + */ + private Integer deviceVersionId; + + /** + * ��������������������������������������� + */ + private String specialType; + + /** + * ������������ + */ + private Date createTime; + + /** + * ������������ + */ + private Date updateTime; + + /** + * ������������,0���������������1��������� + */ + private String isDelete; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/screen-api/src/main/java/com/moral/api/mapper/HistorySecondSpecialMapper.java b/screen-api/src/main/java/com/moral/api/mapper/HistorySecondSpecialMapper.java new file mode 100644 index 0000000..c35423e --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/mapper/HistorySecondSpecialMapper.java @@ -0,0 +1,21 @@ +package com.moral.api.mapper; + +import java.util.List; +import java.util.Map; + +import com.moral.api.entity.HistorySecondSpecial; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * <p> + * ������������������������ Mapper ������ + * </p> + * + * @author moral + * @since 2021-08-18 + */ +public interface HistorySecondSpecialMapper extends BaseMapper<HistorySecondSpecial> { + + List<Map<String, Object>> getSpecialDeviceData(Map<String, Object> params); + +} diff --git a/screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java b/screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java new file mode 100644 index 0000000..92fa648 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java @@ -0,0 +1,16 @@ +package com.moral.api.mapper; + +import com.moral.api.entity.SpecialDevice; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * <p> + * Mapper ������ + * </p> + * + * @author moral + * @since 2021-08-18 + */ +public interface SpecialDeviceMapper extends BaseMapper<SpecialDevice> { + +} diff --git a/screen-api/src/main/java/com/moral/api/service/HistorySecondSpecialService.java b/screen-api/src/main/java/com/moral/api/service/HistorySecondSpecialService.java new file mode 100644 index 0000000..91be635 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/service/HistorySecondSpecialService.java @@ -0,0 +1,16 @@ +package com.moral.api.service; + +import com.moral.api.entity.HistorySecondSpecial; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * <p> + * ������������������������ ��������� + * </p> + * + * @author moral + * @since 2021-08-18 + */ +public interface HistorySecondSpecialService extends IService<HistorySecondSpecial> { + +} diff --git a/screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java b/screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java new file mode 100644 index 0000000..c88087b --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java @@ -0,0 +1,22 @@ +package com.moral.api.service; + +import java.util.List; +import java.util.Map; + +import com.moral.api.entity.SpecialDevice; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * <p> + * ��������� + * </p> + * + * @author moral + * @since 2021-08-18 + */ +public interface SpecialDeviceService extends IService<SpecialDevice> { + + //��������������� + List<Map<String, Object>> carTrajectory(Map<String, Object> params); + +} diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistorySecondSpecialServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistorySecondSpecialServiceImpl.java new file mode 100644 index 0000000..52b80c0 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/service/impl/HistorySecondSpecialServiceImpl.java @@ -0,0 +1,20 @@ +package com.moral.api.service.impl; + +import com.moral.api.entity.HistorySecondSpecial; +import com.moral.api.mapper.HistorySecondSpecialMapper; +import com.moral.api.service.HistorySecondSpecialService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * <p> + * ������������������������ ��������������� + * </p> + * + * @author moral + * @since 2021-08-18 + */ +@Service +public class HistorySecondSpecialServiceImpl extends ServiceImpl<HistorySecondSpecialMapper, HistorySecondSpecial> implements HistorySecondSpecialService { + +} diff --git a/screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java new file mode 100644 index 0000000..7b0bdc8 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java @@ -0,0 +1,97 @@ +package com.moral.api.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.moral.api.entity.HistorySecondSpecial; +import com.moral.api.entity.Sensor; +import com.moral.api.entity.SpecialDevice; +import com.moral.api.entity.SysDictData; +import com.moral.api.mapper.HistorySecondSpecialMapper; +import com.moral.api.mapper.SpecialDeviceMapper; +import com.moral.api.service.HistorySecondSpecialService; +import com.moral.api.service.SensorService; +import com.moral.api.service.SpecialDeviceService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.moral.api.service.SysDictDataService; +import com.moral.constant.Constants; +import com.moral.util.DateUtils; +import com.moral.util.GeodesyUtils; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * <p> + * ��������������� + * </p> + * + * @author moral + * @since 2021-08-18 + */ +@Service +public class SpecialDeviceServiceImpl extends ServiceImpl<SpecialDeviceMapper, SpecialDevice> implements SpecialDeviceService { + + @Autowired + private HistorySecondSpecialMapper historySecondSpecialMapper; + + @Autowired + private SensorService sensorService; + + @Autowired + private SysDictDataService sysDictDataService; + + private final static Double dis = 50d; + + @Override + public List<Map<String, Object>> carTrajectory(Map<String, Object> params) { + params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); + + //��������������������� + /*QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>(); + queryWrapper.select("default_unit_key").eq("code", sensorCode); + String defaultUnitKey = sensorService.getOne(queryWrapper).getDefaultUnitKey(); + QueryWrapper<SysDictData> sysDictDataQueryWrapper = new QueryWrapper<>(); + sysDictDataQueryWrapper.select("dataValue").eq("dict_type_id", 14).eq("dataKey", defaultUnitKey); + String sensorUnit = sysDictDataService.getOne(sysDictDataQueryWrapper).getDataValue(); + + params.put("sensorUnit", sensorUnit);*/ + //������������������������������������ + List<Map<String, Object>> data = historySecondSpecialMapper.getSpecialDeviceData(params); + data.removeIf(o -> { + //������ + double lng = Double.parseDouble(o.get(Constants.SENSOR_CODE_LON).toString()); + //������ + double lat = Double.parseDouble(o.get(Constants.SENSOR_CODE_LAT).toString()); + return lng < 70 || lng > 150 || lat > 60 || lat < 20; + }); + return filterData(data); + } + + //������������������������ + private List<Map<String, Object>> filterData(List<Map<String, Object>> data) { + List<Map<String, Object>> result = new ArrayList<>(); + result.add(data.remove(0)); + for (Map<String, Object> map : data) { + boolean flag = true; + for (Map<String, Object> resultMap : result) { + double lng1 = Double.parseDouble(map.get(Constants.SENSOR_CODE_LON).toString()); + double lat1 = Double.parseDouble(map.get(Constants.SENSOR_CODE_LAT).toString()); + double lng2 = Double.parseDouble(resultMap.get(Constants.SENSOR_CODE_LON).toString()); + double lat2 = Double.parseDouble(resultMap.get(Constants.SENSOR_CODE_LAT).toString()); + double distance = GeodesyUtils.getDistance(lat1, lng1, lat2, lng2); + if (distance < dis) { + flag = false; + } + } + if (flag) { + result.add(map); + } + } + return result; + } +} diff --git a/screen-api/src/main/resources/mapper/HistorySecondSpecialMapper.xml b/screen-api/src/main/resources/mapper/HistorySecondSpecialMapper.xml new file mode 100644 index 0000000..207f6a3 --- /dev/null +++ b/screen-api/src/main/resources/mapper/HistorySecondSpecialMapper.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.moral.api.mapper.HistorySecondSpecialMapper"> + + <!-- ������������������������ --> + <resultMap id="BaseResultMap" type="com.moral.api.entity.HistorySecondSpecial"> + <result column="mac" property="mac"/> + <result column="time" property="time"/> + <result column="value" property="value"/> + <result column="organization_id" property="organizationId"/> + <result column="batch" property="batch"/> + </resultMap> + + <select id="getSpecialDeviceData" resultType="java.util.Map"> + SELECT JSON_UNQUOTE(`value`->'$.${sensorCode}') AS '${sensorCode}', + JSON_UNQUOTE(`value`->'$.flylon') AS 'flylon', + JSON_UNQUOTE(`value`->'$.flylat') AS 'flylat', + DATE_FORMAT(`time`, #{dateFormat}) AS 'time' + FROM `history_second_special` + WHERE mac = #{mac} + AND `time` LIKE #{time}"%" + </select> + +</mapper> \ No newline at end of file diff --git a/screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml b/screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml new file mode 100644 index 0000000..452b9f0 --- /dev/null +++ b/screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.moral.api.mapper.SpecialDeviceMapper"> + + <!-- ������������������������ --> + <resultMap id="BaseResultMap" type="com.moral.api.entity.SpecialDevice"> + <id column="id" property="id"/> + <result column="name" property="name"/> + <result column="mac" property="mac"/> + <result column="operate_ids" property="operateIds"/> + <result column="organization_id" property="organizationId"/> + <result column="device_version_id" property="deviceVersionId"/> + <result column="special_type" property="specialType"/> + <result column="create_time" property="createTime"/> + <result column="update_time" property="updateTime"/> + <result column="is_delete" property="isDelete"/> + </resultMap> + +</mapper> \ No newline at end of file diff --git a/screen-common/src/main/java/com/moral/constant/Constants.java b/screen-common/src/main/java/com/moral/constant/Constants.java index a7ec5d1..fc89082 100644 --- a/screen-common/src/main/java/com/moral/constant/Constants.java +++ b/screen-common/src/main/java/com/moral/constant/Constants.java @@ -174,6 +174,16 @@ * */ public static final String SENSOR_CODE_NO2 = "a21004"; + /* + * ������ code + * */ + public static final String SENSOR_CODE_LON = "flylon"; + + /* + * ������ code + * */ + public static final String SENSOR_CODE_LAT = "flylat"; + /** * The Constant NULL_VALUE. */ diff --git a/screen-common/src/main/java/com/moral/util/GeodesyUtils.java b/screen-common/src/main/java/com/moral/util/GeodesyUtils.java new file mode 100644 index 0000000..41ceb5f --- /dev/null +++ b/screen-common/src/main/java/com/moral/util/GeodesyUtils.java @@ -0,0 +1,25 @@ +package com.moral.util; + +import org.gavaghan.geodesy.Ellipsoid; +import org.gavaghan.geodesy.GeodeticCalculator; +import org.gavaghan.geodesy.GeodeticCurve; +import org.gavaghan.geodesy.GlobalCoordinates; + +import org.springframework.stereotype.Component; + +@Component +public class GeodesyUtils { + /** + * @param lat1 ��������������� + * @param lng1 ��������������� + * @param lat2 ��������������� + * @param lng2 ��������������� + * @return ������������������������������������������������������WGS84��������� + */ + public static double getDistance(double lat1, double lng1, double lat2, double lng2) { + GlobalCoordinates source = new GlobalCoordinates(lat1, lng1); + GlobalCoordinates target = new GlobalCoordinates(lat2, lng2); + GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, source, target); + return geoCurve.getEllipsoidalDistance(); + } +} diff --git a/screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml b/screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml index 5bb04ba..a422955 100644 --- a/screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml +++ b/screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml @@ -67,8 +67,7 @@ <select id="selectOrgByMac" resultType="com.moral.api.entity.Organization"> SELECT area_code, city_code FROM organization - WHERE organization_id = - (SELECT organization_id FROM special_device WHERE mac = #{mac}) + WHERE id = (SELECT organization_id FROM special_device WHERE mac = #{mac}) </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0