Conflicts:
	xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalGpsServiceImpl.java
jni
liuguijing 2 years ago
commit 22c948f0ca

@ -45,7 +45,7 @@ public class TerminalGPSController extends BaseController {
@ApiOperation(value = "获取GPS位置", notes = "获取GPS位置接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTermGPS")
@Log(title = "获取GPS位置", type = "修改")
@Log(title = "获取GPS位置", type = "查询")
public ResponseReult<TerminalGpsModel> getTermGPS(@RequestBody @Validated TerminalIdVo vo) {
ServiceBody<TerminalGpsModel> serviceBody = terminalGpsService.getTermGPS(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
@ -55,4 +55,17 @@ public class TerminalGPSController extends BaseController {
}
}
@ApiOperation(value = "轮询获取GPS位置", notes = "获取GPS位置接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTermGPSPosition")
@Log(title = "轮询获取GPS位置", type = "查询")
public ResponseReult<TerminalGpsModel> getReturnedTermGPS(@RequestBody @Validated TerminalGpsVo vo) {
ServiceBody<TerminalGpsModel> serviceBody = terminalGpsService.getReturnedGPS(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
}

@ -1,5 +1,6 @@
package com.shxy.xymanager_common.model;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -30,4 +31,7 @@ public class TerminalGpsModel implements Serializable {
@ApiModelProperty(value = "修改时间", example = "123456")
private Date updatetime;
@ApiModelProperty(value = "请求时间", example = "123456")
private DateTime queryTime;
}

@ -0,0 +1,17 @@
package com.shxy.xymanager_common.vo;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "查询GPS对象", description = "查询GPS对象描述")
public class TerminalGpsVo {
@ApiModelProperty(value = "装置编号", example = "123455")
private Integer termid;
@ApiModelProperty(value = "查询时间", example = "123455")
private DateTime queryTime;
}

@ -14,4 +14,7 @@ public class TerminalIdVo {
@ApiModelProperty(value = "装置编号", example = "123455")
private Integer termid;
@ApiModelProperty(value = "图像监测装置 ID", example = "123455")
private String cmdId;
}

@ -2,6 +2,10 @@ package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.entity.TerminalPositions;
import java.math.BigInteger;
public interface TerminalPositionsDao {
TerminalPositions selectByPrimaryKey(Integer termId);
BigInteger getUpdateTime(Integer termId);
}

@ -18,4 +18,11 @@
from terminal_positions
where term_id = #{termId,jdbcType=INTEGER}
</select>
<select id="getUpdateTime" resultType="java.math.BigInteger">
select
update_time updateTime
from terminal_positions
where term_id = #{termId,jdbcType=INTEGER}
</select>
</mapper>

@ -1,23 +1,39 @@
package com.shxy.xymanager_service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.TerminalInfoDto;
import com.shxy.xymanager_common.entity.TerminalPositions;
import com.shxy.xymanager_common.entity.TerminalStatus;
import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.TerminalGpsModel;
import com.shxy.xymanager_common.model.TerminalListModel;
import com.shxy.xymanager_common.model.TerminalModel;
import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.ProcessExecUtils;
import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.TerminalPositionsDao;
import com.shxy.xymanager_dao.dao.TerminalStatusDao;
import com.shxy.xymanager_dao.dao.TerminalsDao;
import com.shxy.xymanager_service.interaction.Cma;
import com.shxy.xymanager_service.service.TerminalGpsService;
import com.shxy.xymanager_service.service.TerminalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -83,6 +99,9 @@ public class TerminalGpsServiceImpl implements TerminalGpsService {
TerminalGpsModel model = new TerminalGpsModel();
// Cma cma = new Cma("47.96.238.157", 6891);
// boolean b = cma.requestGpsInfo(vo.getTermid().toString());
DateTime now = DateTime.now();
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=gpsinfo --cmdid="+vo.getCmdId();
ProcessExecUtils.exec(cmd);
TerminalPositions bean = terminalPositionsDao.selectByPrimaryKey(vo.getTermid());
if (!BeanUtil.isEmpty(bean)) {
@ -90,6 +109,7 @@ public class TerminalGpsServiceImpl implements TerminalGpsService {
model.setLongitude(bean.getLongitude());
model.setLatitude(bean.getLatitude());
model.setTermid(bean.getTermId());
model.setQueryTime(now);
BigInteger updatetime = MyDateUtils.TimeSecond2MillSecond(bean.getUpdateTime().longValue());
model.setUpdatetime(MyDateUtils.date(updatetime.longValue()));
}
@ -102,5 +122,19 @@ public class TerminalGpsServiceImpl implements TerminalGpsService {
}
@Override
public ServiceBody<TerminalGpsModel> getReturnedGPS(TerminalGpsVo vo) {
BigInteger updatedTime = terminalPositionsDao.getUpdateTime(vo.getTermid());
BigInteger queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime());
Boolean hasNew =updatedTime.compareTo(queryTime)<0?false:true;
TerminalGpsModel model = new TerminalGpsModel();
if(hasNew) {
TerminalPositions bean = terminalPositionsDao.selectByPrimaryKey(vo.getTermid());
BigInteger updatetime = MyDateUtils.TimeSecond2MillSecond(bean.getUpdateTime().longValue());
model.setUpdatetime(MyDateUtils.date(updatetime.longValue()));
}
return Asserts.success(null);
}
}

@ -198,11 +198,11 @@ public class TerminalServiceImpl implements TerminalService {
TerminalModel model = new TerminalModel();
TerminalInfoDto dto = terminalsDao.getTerminalInfo(termId);
if(null!=dto) {
String wsUpdateTime = MyDateUtils.TimeSecondToDate(dto.getWsUpdateTime());
BigInteger updatetime = MyDateUtils.TimeSecond2MillSecond(dto.getWsUpdateTime().longValue());
BeanUtils.copyProperties(dto, model);
DateTime now = DateTime.now();
model.setQueryTime(now);
model.setWsUpdateTime(wsUpdateTime);
model.setWsUpdateTime(MyDateUtils.date(updatetime.longValue()).toString());
}
return Asserts.success(model);

@ -26,4 +26,6 @@ public interface TerminalGpsService {
*/
ServiceBody<TerminalGpsModel> getTermGPS(TerminalIdVo vo);
ServiceBody<TerminalGpsModel> getReturnedGPS(TerminalGpsVo vo);
}

Loading…
Cancel
Save