Commit a97d4879 authored by kongfm's avatar kongfm

根据任务id 经纬度 返回距离事故电梯距离

parent 809b6dfb
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.tzs.api.mapper;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* 派遣任务 Mapper 接口
......@@ -11,4 +12,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface DispatchTaskMapper extends BaseMapper<DispatchTask> {
String returnDistanceByTaskId(@Param("taskId") Long taskId, @Param("lon")String lon, @Param("lat")String lat);
}
......@@ -16,4 +16,6 @@ public interface IDispatchTaskService {
Boolean createDispatchTask(DispatchTaskDto dispatchTaskDto, AgencyUserModel sendUser);
DispatchTaskDto getTaskInfo(String orgTypeCode, Long alertId);
String returnDistanceByTaskId(Long taskId, String longitude, String latitude);
}
......@@ -2,4 +2,34 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.api.mapper.DispatchTaskMapper">
<select id="returnDistanceByTaskId" resultType="java.lang.String">
select
(
ACOS(
SIN(
(#{lat} * PI()) / 180
) * SIN(
(
el.latitude * PI()
) / 180
) + COS(
(#{lat} * PI()) / 180
) * COS(
(
el.latitude * PI()
) / 180
) * COS(
(#{lon} * PI()) / 180 - (
el.longitude * PI()
) / 180
)
) * 6371000
) AS distance
from tz_dispatch_task ta
left JOIN tz_alert_called al on al.sequence_nbr = ta.alert_id
left JOIN tcb_elevator el on el.sequence_nbr = al.equipment_id
where ta.sequence_nbr = #{taskId}
</select>
</mapper>
......@@ -13,19 +13,19 @@
(
ACOS(
SIN(
(#{lat} * 3.1415) / 180
(#{lat} * PI()) / 180
) * SIN(
(
tcb_rescue_station.latitude * PI()
) / 180
) + COS(
(#{lat} * 3.1415) / 180
(#{lat} * PI()) / 180
) * COS(
(
tcb_rescue_station.latitude * PI()
) / 180
) * COS(
(#{lon} * 3.1415) / 180 - (
(#{lon} * PI()) / 180 - (
tcb_rescue_station.longitude * PI()
) / 180
)
......
......@@ -5,13 +5,16 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.WechatAccessDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.WechatRelation;
import com.yeejoin.amos.boot.module.tzs.api.service.IDispatchTaskService;
import com.yeejoin.amos.boot.module.tzs.api.service.IWechatService;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.WechatRelationServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.SmsRecordModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,7 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.w3c.dom.Node;
......@@ -62,6 +67,9 @@ public class WechatController extends BaseController {
@Autowired
WechatRelationServiceImpl wechatRelationServiceImpl;
@Autowired
IDispatchTaskService dispatchTaskService;
/**
......@@ -182,7 +190,7 @@ public class WechatController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getOpenIdTel/{code}")
@ApiOperation(httpMethod = "GET", value = "根据微信code获取openId和手机号接口", notes = "根据微信code获取openId和手机号接口")
public ResponseModel<WechatAccessDto> getAccessToken(@PathVariable String code) {
public ResponseModel<WechatAccessDto> getOpenIdTel(@PathVariable String code) {
WechatAccessDto wechatAccessDto = new WechatAccessDto();
String openId = wechatService.getOpenId(code);
if(StringUtils.isNotEmpty(openId)) {
......@@ -195,6 +203,32 @@ public class WechatController extends BaseController {
return ResponseHelper.buildResponse(wechatAccessDto);
}
/**
* 根据任务id 经纬度 返回现在距离任务距离
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/returnDistance")
@ApiOperation(httpMethod = "POST", value = "根据任务id 经纬度 返回现在距离任务距离", notes = "根据任务id 经纬度 返回现在距离任务距离")
public ResponseModel<String> returnDistance(@ApiParam(value = "任务id", required = true) @RequestParam(name = "taskId") Long taskId,
@ApiParam(value = "经度", required = true) @RequestParam(name = "longitude") String longitude,
@ApiParam(value = "纬度", required = true) @RequestParam(name = "latitude") String latitude) {
if (ValidationUtil.isEmpty(taskId)
|| ValidationUtil.isEmpty(longitude)
|| ValidationUtil.isEmpty(latitude)){
throw new BadRequest("参数校验失败.");
}
String distance = dispatchTaskService.returnDistanceByTaskId(taskId,longitude,latitude);
return ResponseHelper.buildResponse(distance);
}
/**
* 创建验证码
* @return
*/
public static String getrandom(){
String code = "";
Random random = new Random();
......
......@@ -27,7 +27,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
* @date 2021-09-22
*/
@RestController
@Api(tags = "openId与手机号对应关系")
@Api(tags = "openId与手机号对应关系API")
@RequestMapping(value = "/wechat-relation")
public class WechatRelationController extends BaseController {
......
......@@ -168,6 +168,11 @@ public class DispatchTaskServiceImpl extends BaseService<DispatchTaskDto,Dispatc
return dispatchTaskDto;
}
@Override
public String returnDistanceByTaskId(Long taskId, String longitude, String latitude) {
return baseMapper.returnDistanceByTaskId(taskId, longitude, latitude);
}
@Transactional
@Override
public Boolean createDispatchTask(DispatchTaskDto dispatchTaskDto, AgencyUserModel sendUser) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment