From faa4232667f87b22c207ffa590f4cbe22131a468 Mon Sep 17 00:00:00 2001 From: caojianbin <1910336823> Date: Thu, 28 Mar 2024 17:27:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=9B=BD=E9=99=85=E5=8C=96,?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=A8=A1=E5=9D=97=E9=83=A8=E5=88=86=E5=BC=80?= =?UTF-8?q?=E5=8F=913?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/api/ApiController.java | 46 +++++++ .../controller/api/ApiOutwardController.java | 137 +++++++++++++++++++++ .../system/entity/api/ApiLastLocationInfo.java | 7 ++ .../system/entity/api/ApiLocaltionDTO.java | 23 ++++ .../system/entity/api/ApiOutward.java | 67 ++++++++++ .../system/entity/api/dto/ApiOutwardPage.java | 24 ++++ .../system/entity/api/vo/ApiDeviceInfo.java | 47 +++++++ .../system/entity/api/vo/ApiDeviceStep.java | 34 +++++ .../system/entity/api/vo/ApiDeviceTemp.java | 34 +++++ .../system/mapper/api/ApiFirmMapper.java | 41 ++++++ .../system/mapper/api/ApiOutwardMapper.java | 16 +++ .../system/service/api/ApiFirmService.java | 32 +++++ .../system/service/api/ApiOutwardService.java | 16 +++ .../service/api/impl/ApiFirmServiceImpl.java | 131 ++++++++++++++++++++ .../system/mapper/api/ApiFirmMapper.xml | 28 +++++ .../system/mapper/api/ApiOutwardMapper.xml | 25 ++++ 16 files changed, 708 insertions(+) create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiController.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiOutwardController.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLastLocationInfo.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLocaltionDTO.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiOutward.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/dto/ApiOutwardPage.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceInfo.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceStep.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceTemp.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiFirmService.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiOutwardService.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/ApiFirmServiceImpl.java create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.xml create mode 100644 ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.xml diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiController.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiController.java new file mode 100644 index 0000000..e30734c --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiController.java @@ -0,0 +1,46 @@ +package com.ecell.internationalize.system.controller.api; +import com.ecell.internationalize.common.core.web.domain.R; +import com.ecell.internationalize.system.entity.api.LocationPO; +import com.ecell.internationalize.system.service.api.ApiFirmService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +@RestController +@RequestMapping("/api") +public class ApiController { + @Autowired + ApiFirmService apiFirmService; + + /** + * 根据imei查询设备信息 + * @param imei + * @return + */ + @GetMapping("/device/info/{imei}") + public R queryDeviceInfoByImei(@PathVariable(value = "imei") String imei){ + + return R.ok(apiFirmService.queryDeviceInfoByImei(imei),"操作成功"); + } + + + /** + * 根据条件查询设备轨迹信息 + * @param + * @return + */ + @PostMapping ("/device/locationList") + public R queryDeviceLocaltionList(@RequestBody LocationPO po){ + + return R.ok(apiFirmService.queryDeviceLocaltionList(po),"操作成功"); + } + + /** + * 下发刷新定位 + * @param imei + * @return + */ + @GetMapping ("/device/getLocation/{imei}") + public R getDeviceLocaltion(@PathVariable(value = "imei") String imei){ + + return R.ok(apiFirmService.getDeviceLocaltion(imei),"操作成功"); + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiOutwardController.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiOutwardController.java new file mode 100644 index 0000000..35d33a2 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/api/ApiOutwardController.java @@ -0,0 +1,137 @@ +package com.ecell.internationalize.system.controller.api; + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ecell.internationalize.common.core.context.SecurityContextHolder; +import com.ecell.internationalize.common.core.utils.locale.LocaleUtil; +import com.ecell.internationalize.common.core.utils.uuid.UUID; +import com.ecell.internationalize.common.core.web.domain.AjaxResult; +import com.ecell.internationalize.common.core.web.domain.R; +import com.ecell.internationalize.common.redis.service.RedisService; +import com.ecell.internationalize.common.system.annotation.SystemLog; +import com.ecell.internationalize.common.system.constant.FieldConstant; +import com.ecell.internationalize.system.entity.FirmManage; +import com.ecell.internationalize.system.entity.api.ApiOutward; +import com.ecell.internationalize.system.entity.api.dto.ApiOutwardPage; +import com.ecell.internationalize.system.service.FirmManageService; +import com.ecell.internationalize.system.service.api.ApiOutwardService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +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.Date; + +/** + *

+ * API对外开放接口 + *

+ * + * @author ${author} + * @since 2023-03-07 + */ +@RestController +@Api(value="API对外开放接口",tags={"API对外开放接口"}) +@RequestMapping("/api_outward") +public class ApiOutwardController { + @Autowired + private ApiOutwardService apiOutwardService; + @Autowired + private RedisService redisService; + @Autowired + private FirmManageService firmManageService; + /** + * 条件分页查询 + * @Author liy + * @Date 2022/7/14 16:38 + * @param apiOutwardPage 分页条件查询体 + * @Return AjaxResult + */ + @ApiOperation("APPID和APPKEY条件分页查询") + @PostMapping("api/list") + public R> queryAllByPage(@RequestBody ApiOutwardPage apiOutwardPage){ + Page page=new Page<>(apiOutwardPage.getCurrent(),apiOutwardPage.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.orderByDesc(ApiOutward::getCreateTime); + IPage selectPage = apiOutwardService.getBaseMapper().selectPage(page, lambdaQueryWrapper); + + if (null!=selectPage) { + for (ApiOutward apiOutward : selectPage.getRecords()) { + LambdaQueryWrapper firm=new LambdaQueryWrapper<>(); + //厂商 + if (FieldConstant.MATH_ONE.equals(apiOutward.getFirmFlag())) { + firm.eq(FirmManage::getFirmId,apiOutward.getFirmId()); + } + //代理商 + if (FieldConstant.SECOND_FLAG.equals(apiOutward.getFirmFlag())) { + firm.eq(FirmManage::getParentId,apiOutward.getSecondFirmId()); + } + FirmManage firmManage = firmManageService.getBaseMapper().selectOne(firm); + apiOutward.setFirmName(firmManage.getFirmName()); + } + } + return R.ok(selectPage); + } + + /** + * 新增 + * @Author liy + * @Date 2023/3/7 16:38 + * @param apiOutward API + * @Return AjaxResult + */ + @ApiOperation("生成APPid和APPkey") + @PostMapping("api/save") + public AjaxResult save(@RequestBody @ApiParam("API类") ApiOutward apiOutward) { + int appId = Integer.parseInt(String.valueOf(System.currentTimeMillis()).substring(0,10)); + String appKey= UUID.fastUUID().toString(true); + apiOutward.setAppId(appId); + apiOutward.setAppKey(appKey); + apiOutward.setCreateTime(new Date()); + apiOutward.setCreateUser(SecurityContextHolder.getUserName()); + apiOutward.setId(UUID.fastUUID().toString(true)); + apiOutward.setStatus(FieldConstant.OPERATOR_SUCCESS); + apiOutwardService.getBaseMapper().insert(apiOutward); + redisService.setCacheObject(appId+"_"+appKey, apiOutward); + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS)); + } + /** + * 删除 + * @Author liy + * @Date 2023/3/7 16:38 + * @param apiOutward 实体类 + * @Return AjaxResult + */ + @ApiOperation("删除APPid和APPkey") + @PostMapping("api/del") + public AjaxResult del(@RequestBody @ApiParam("API类") ApiOutward apiOutward){ + System.out.println("删除之前redis中的数据:"+redisService.getCacheObject(apiOutward.getAppId()+"_"+apiOutward.getAppKey())); + apiOutwardService.getBaseMapper().deleteById(apiOutward); + redisService.deleteObject(apiOutward.getAppId()+"_"+apiOutward.getAppKey()); + System.out.println("删除之后redis中的数据:"+redisService.getCacheObject(apiOutward.getAppId()+"_"+apiOutward.getAppKey())); + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS)); + } + + /** + * 修改状态 + * @Author liy + * @Date 2023/3/8 16:38 + * @param apiOutward 实体类 + * @Return AjaxResult + */ + @ApiOperation("修改启用/禁用状态") + @SystemLog(msg =FieldConstant.ACTIVITY_BANNER_BANNER,operation = FieldConstant.ACTIVITY_BANNER_PUBLISH) + @PostMapping("api/changeStatus") + public AjaxResult changeStatusOrDelUser(@RequestBody @ApiParam(name="状态",value="传整个对象,修改其中status字段,(0:禁用,1:=启用)",required=true) ApiOutward apiOutward){ + apiOutwardService.getBaseMapper().updateById(apiOutward); + redisService.setCacheObject(apiOutward.getAppId()+"_"+apiOutward.getAppKey(), apiOutward); + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS)); + } +} + diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLastLocationInfo.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLastLocationInfo.java new file mode 100644 index 0000000..a35818c --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLastLocationInfo.java @@ -0,0 +1,7 @@ +package com.ecell.internationalize.system.entity.api; + +/** + * @author borui + */ +public class ApiLastLocationInfo { +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLocaltionDTO.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLocaltionDTO.java new file mode 100644 index 0000000..862bfaf --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiLocaltionDTO.java @@ -0,0 +1,23 @@ +package com.ecell.internationalize.system.entity.api; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author borui + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApiLocaltionDTO implements Serializable { + private static final long serialVersionUID=1L; + private Integer total; + private Integer pageTotal; + private Integer size; + private List list; + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiOutward.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiOutward.java new file mode 100644 index 0000000..883e895 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/ApiOutward.java @@ -0,0 +1,67 @@ +package com.ecell.internationalize.system.entity.api; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * API对外开放接口表 + *

+ * + * @author ${author} + * @since 2023-03-07 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="ApiOutward对象", description="API对外开放接口表") +public class ApiOutward implements Serializable { + +private static final long serialVersionUID=1L; + + @ApiModelProperty(example = "主键Id(新增不需要传)") + private String id; + + @ApiModelProperty(example = "APPID") + private Integer appId; + + @ApiModelProperty(example = "APPKEY") + private String appKey; + + @ApiModelProperty(example = "状态(0:禁用 , 1:启用)") + private String status; + + @ApiModelProperty(example = "厂商Id") + private String firmId; + + @ApiModelProperty(example = "标识(1:厂商:2:代理商)") + private String firmFlag; + + @ApiModelProperty(example = "代理商Id") + private String secondFirmId; + + @ApiModelProperty(example = "创建人(新增不需要传)") + private String createUser; + + @ApiModelProperty(example = "创建时间(新增不需要传)") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + @ApiModelProperty(example = "发起请求秒数(如一分钟多少次,单位为秒)") + private Integer second; + + @ApiModelProperty(example = "发起请求次数(如多少分钟100次)") + private Integer frequency; + + @ApiModelProperty(example = "厂商/代理商名称",hidden = true) + @TableField(exist = false) + private String firmName; +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/dto/ApiOutwardPage.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/dto/ApiOutwardPage.java new file mode 100644 index 0000000..b75b19e --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/dto/ApiOutwardPage.java @@ -0,0 +1,24 @@ +package com.ecell.internationalize.system.entity.api.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Title: ApiOutwardPage + * @Author: liy + * @Date: 2023/3/8 14:56 + * @Description: + * @Version:1.0 + */ +@Data +public class ApiOutwardPage { +// @ApiModelProperty(example = "厂商/代理商名称") +// private String firmName; + + @ApiModelProperty(example = "每页展示的条数") + private Integer pageSize; + + @ApiModelProperty(example = "当前的页码") + private Integer current; +} + diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceInfo.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceInfo.java new file mode 100644 index 0000000..52124f8 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceInfo.java @@ -0,0 +1,47 @@ +package com.ecell.internationalize.system.entity.api.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + *

+ * 设备步数 + *

+ * + * @author liy + * @since 2022-07-11 + */ +@Data +public class ApiDeviceInfo { + +private static final long serialVersionUID=1L; + /** + * 日期 + */ + @ApiModelProperty(example = "日期") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date date; + + /** + * 手机号 + */ + @ApiModelProperty(example = "手机号") + private String phone; + + /** + * 姓名 + */ + @ApiModelProperty(example = "姓名") + private String name; + + + /** + * 手机号 + */ + @ApiModelProperty(example = "身份") + private String identity; + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceStep.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceStep.java new file mode 100644 index 0000000..6d1628d --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceStep.java @@ -0,0 +1,34 @@ +package com.ecell.internationalize.system.entity.api.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + *

+ * 设备步数 + *

+ * + * @author liy + * @since 2022-07-11 + */ +@Data +public class ApiDeviceStep { + +private static final long serialVersionUID=1L; + /** + * 设备iMei + */ + @ApiModelProperty(example = "日期") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date date; + + /** + * 姓名 + */ + @ApiModelProperty(example = "步数") + private Integer num; + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceTemp.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceTemp.java new file mode 100644 index 0000000..f716240 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/vo/ApiDeviceTemp.java @@ -0,0 +1,34 @@ +package com.ecell.internationalize.system.entity.api.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + *

+ * 设备步数 + *

+ * + * @author liy + * @since 2022-07-11 + */ +@Data +public class ApiDeviceTemp { + +private static final long serialVersionUID=1L; + /** + * 设备iMei + */ + @ApiModelProperty(example = "日期") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date date; + + /** + * 姓名 + */ + @ApiModelProperty(example = "步数") + private String data; + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.java new file mode 100644 index 0000000..1da2e69 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.java @@ -0,0 +1,41 @@ +package com.ecell.internationalize.system.mapper.api; +import com.ecell.internationalize.system.entity.api.ApiLastLocationInfo; +import com.ecell.internationalize.system.entity.api.ApiTrackInfo; +import com.ecell.internationalize.system.entity.api.FirmDeviceInfo; +import com.ecell.internationalize.system.entity.api.LocationPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author borui + */ +public interface ApiFirmMapper { + /** + * 根据imei查询设备拥有者信息 + * @param imei + * @return + */ + FirmDeviceInfo queryDeviceOwnerByImei(@Param("imei") String imei); + + /** + * 根据imei查询最新位置信息 + * @param imei + * @return + */ + ApiLastLocationInfo queryLastLocationInfoByImei(@Param("imei")String imei); + + /** + * 查询轨迹总数 + * @param po + * @return + */ + Integer queryDeviceLocaltionCount( @Param("po") LocationPO po); + + /** + * 查询轨迹信息 + * @param po + * @return + */ + List queryDeviceLocaltionInfo(@Param("po") LocationPO po); +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.java new file mode 100644 index 0000000..2dc6198 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.java @@ -0,0 +1,16 @@ +package com.ecell.internationalize.system.mapper.api; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ecell.internationalize.system.entity.api.ApiOutward; + +/** + *

+ * API对外开放接口表 Mapper 接口 + *

+ * + * @author ${author} + * @since 2023-03-07 + */ +public interface ApiOutwardMapper extends BaseMapper { + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiFirmService.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiFirmService.java new file mode 100644 index 0000000..5fca5bc --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiFirmService.java @@ -0,0 +1,32 @@ +package com.ecell.internationalize.system.service.api; +import com.ecell.internationalize.system.entity.api.FirmDeviceInfo; +import com.ecell.internationalize.system.entity.api.LocationPO; + +import java.util.Map; + +/** + * @author borui + */ +public interface ApiFirmService { + /** + * 根据imei 查询设备信息 + * @param imei + * @return + */ + FirmDeviceInfo queryDeviceInfoByImei(String imei); + + /** + * 查询轨迹数据 + * @param po + * @return + */ + Object queryDeviceLocaltionList(LocationPO po); + + /** + * + * 获取位置 + * @param imei + * @return + */ + Map getDeviceLocaltion(String imei); +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiOutwardService.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiOutwardService.java new file mode 100644 index 0000000..b376258 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/ApiOutwardService.java @@ -0,0 +1,16 @@ +package com.ecell.internationalize.system.service.api; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ecell.internationalize.system.entity.api.ApiOutward; + +/** + *

+ * API对外开放接口表 服务类 + *

+ * + * @author ${author} + * @since 2023-03-07 + */ +public interface ApiOutwardService extends IService { + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/ApiFirmServiceImpl.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/ApiFirmServiceImpl.java new file mode 100644 index 0000000..8e3c064 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/ApiFirmServiceImpl.java @@ -0,0 +1,131 @@ +package com.ecell.internationalize.system.service.api.impl; +import com.ecell.internationalize.common.core.exception.ServiceException; +import com.ecell.internationalize.common.core.utils.StringUtils; +import com.ecell.internationalize.system.constant.DeviceModelConstants; +import com.ecell.internationalize.system.entity.api.*; +import com.ecell.internationalize.system.entity.dto.sendInstructionDTO; +import com.ecell.internationalize.system.mapper.api.ApiFirmMapper; +import com.ecell.internationalize.system.service.api.ApiFirmService; +import com.ecell.internationalize.system.service.impl.DeviceInfoServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + + +/** + * @author borui + */ +@Service +public class ApiFirmServiceImpl implements ApiFirmService { + @Resource + private ApiFirmMapper apiFirmMapper; + + @Autowired + private DeviceInfoServiceImpl deviceInfoService; + + @Override + public FirmDeviceInfo queryDeviceInfoByImei(String imei) { + FirmDeviceInfo firmDeviceInfo = queryDeviceOwnerByImei(imei); + if (StringUtils.isNotNull(firmDeviceInfo)){ + ApiLastLocationInfo apiLastLocationInfo = queryLastLocationInfoByImei(imei); + if (StringUtils.isNotNull(apiLastLocationInfo)){ + firmDeviceInfo.setApiLastLocationInfo(apiLastLocationInfo); + } + + } + + return firmDeviceInfo; + } + + /** + * 查询轨迹数据 + * @param po + * @return + */ + @Override + public Object queryDeviceLocaltionList(LocationPO po) { + if (!StringUtils.isNotEmpty(po.getImei())||!StringUtils.isNotEmpty(po.getStartTime())||!StringUtils.isNotEmpty(po.getEndTime())){ + throw new ServiceException("messages.parameter.error"); + } + ApiLocaltionDTO apiLocaltionDTO =new ApiLocaltionDTO<>(); + + if (po.getPage()<=0){ + po.setPage(1); + } + if (po.getNum()<=0){ + po.setNum(20); + } + int count = queryDeviceLocaltionCount(po); + if (count>0){ + int pageCount = getPageCount(count, po.getNum()); + int startTotal = (po.getPage()-1)*(po.getNum()); + po.setStartTotal(startTotal); + //查询轨迹信息 + + apiLocaltionDTO.setSize(po.getNum()); + apiLocaltionDTO.setPageTotal(pageCount); + apiLocaltionDTO.setTotal(count); + List apiTrackInfos = queryDeviceLocaltionInfo(po); + apiLocaltionDTO.setList(apiTrackInfos); + + } + + return apiLocaltionDTO; + } + + /** + * 下发指令获取位置信息 + * @param imei + * @return + */ + @Override + public Map getDeviceLocaltion(String imei) { + if (!StringUtils.isNotEmpty(imei)){ + throw new ServiceException("messages.parameter.error"); + } + sendInstructionDTO dto =new sendInstructionDTO(); + dto.setImei(imei); + dto.setType(DeviceModelConstants.ONE); + Map map = deviceInfoService.sendInstructions(dto); + + return map; + } + + /** + * 根据imei查询设备拥有者信息 + */ + private FirmDeviceInfo queryDeviceOwnerByImei(String imei){ + return apiFirmMapper.queryDeviceOwnerByImei(imei); + + } + /** + * 根据imei查询位置,体温心率最新信息 + */ + private ApiLastLocationInfo queryLastLocationInfoByImei(String imei){ + return apiFirmMapper.queryLastLocationInfoByImei(imei); + } + + /** + * 查询轨迹总数 + * @param po + * @return + */ + private int queryDeviceLocaltionCount(LocationPO po){ + return apiFirmMapper.queryDeviceLocaltionCount(po); + } + + /** + * 查询轨迹信息 + * @param po + * @return + */ + private List queryDeviceLocaltionInfo(LocationPO po){ + return apiFirmMapper.queryDeviceLocaltionInfo(po); + } + private int getPageCount(int total,int pageSize){ + return total % pageSize== 0 ? (total/pageSize):(total/pageSize)+1; + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.xml b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.xml new file mode 100644 index 0000000..8b87a19 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiFirmMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.xml b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.xml new file mode 100644 index 0000000..babe9d9 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/api/ApiOutwardMapper.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + id, app_id, app_key, status, firm_id, firm_flag, second_firm_id, create_user, create_time,frequency,second + + +