From f8233c1215fcd8569d933c9ae7ab8377bed6f809 Mon Sep 17 00:00:00 2001 From: 18616268358 <1440265357@qq.com> Date: Wed, 10 May 2023 17:51:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?#20230510=20=E6=AC=A3=E5=BD=B1=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=B9=B3=E5=8F=B0=E8=A3=85=E7=BD=AE=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TerminalGPSController.java | 15 ++++++++++++- .../model/TerminalGpsModel.java | 4 ++++ .../xymanager_common/vo/TerminalGpsVo.java | 17 ++++++++++++++ .../xymanager_common/vo/TerminalIdVo.java | 3 +++ .../dao/TerminalPositionsDao.java | 4 ++++ .../mappers/TerminalPositionsDao.xml | 7 ++++++ .../impl/TerminalGpsServiceImpl.java | 22 +++++++++++++++++++ .../impl/TerminalServiceImpl.java | 4 ++-- .../service/TerminalGpsService.java | 2 ++ 9 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalGpsVo.java diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java index 731454f..59d1e88 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java @@ -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 getTermGPS(@RequestBody @Validated TerminalIdVo vo) { ServiceBody 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("/getTermGPS") + @Log(title = "轮询获取GPS位置", type = "查询") + public ResponseReult getReturnedTermGPS(@RequestBody @Validated TerminalGpsVo vo) { + ServiceBody serviceBody = terminalGpsService.getReturnedGPS(vo); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalGpsModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalGpsModel.java index be1dc5b..ba4c416 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalGpsModel.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalGpsModel.java @@ -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; + } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalGpsVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalGpsVo.java new file mode 100644 index 0000000..31d5dd7 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalGpsVo.java @@ -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; +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdVo.java index fdbc712..dacb1bd 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdVo.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdVo.java @@ -14,4 +14,7 @@ public class TerminalIdVo { @ApiModelProperty(value = "装置编号", example = "123455") private Integer termid; + + @ApiModelProperty(value = "图像监测装置 ID", example = "123455") + private String cmdId; } diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPositionsDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPositionsDao.java index dc0ca1b..bbafa04 100644 --- a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPositionsDao.java +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPositionsDao.java @@ -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); } \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml b/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml index 8ed0237..467d5b0 100644 --- a/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml +++ b/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml @@ -18,4 +18,11 @@ from terminal_positions where term_id = #{termId,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalGpsServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalGpsServiceImpl.java index 5cd123f..04478ec 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalGpsServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalGpsServiceImpl.java @@ -3,8 +3,10 @@ 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; @@ -12,6 +14,7 @@ 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; @@ -23,6 +26,7 @@ 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; @@ -95,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)) { @@ -102,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())); } @@ -114,5 +122,19 @@ public class TerminalGpsServiceImpl implements TerminalGpsService { } + @Override + public ServiceBody 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); + } + } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java index 0e1be99..0bac858 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java @@ -197,11 +197,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); diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalGpsService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalGpsService.java index dfcfa9d..5b84561 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalGpsService.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalGpsService.java @@ -27,4 +27,6 @@ public interface TerminalGpsService { */ ServiceBody getTermGPS(TerminalIdVo vo); + ServiceBody getReturnedGPS(TerminalGpsVo vo); + } From 0bbb59f7cda24bd82fd9128c35d2f0fd2be746f9 Mon Sep 17 00:00:00 2001 From: 18616268358 <1440265357@qq.com> Date: Wed, 10 May 2023 17:55:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?#20230510=20=E6=AC=A3=E5=BD=B1=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=B9=B3=E5=8F=B0=E8=A3=85=E7=BD=AE=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shxy/xymanager_admin/controller/TerminalGPSController.java | 2 +- .../src/main/resources/mappers/TerminalPositionsDao.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java index 59d1e88..5a8ea40 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalGPSController.java @@ -57,7 +57,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") + @RequestMapping("/getTermGPSPosition") @Log(title = "轮询获取GPS位置", type = "查询") public ResponseReult getReturnedTermGPS(@RequestBody @Validated TerminalGpsVo vo) { ServiceBody serviceBody = terminalGpsService.getReturnedGPS(vo); diff --git a/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml b/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml index 467d5b0..a30a219 100644 --- a/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml +++ b/xymanager_dao/src/main/resources/mappers/TerminalPositionsDao.xml @@ -19,7 +19,7 @@ where term_id = #{termId,jdbcType=INTEGER} - select update_time updateTime from terminal_positions