diff --git a/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-core/src/main/java/com/ecell/internationalize/common/core/utils/poi/ExcelUtil.java b/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-core/src/main/java/com/ecell/internationalize/common/core/utils/poi/ExcelUtil.java index 23223bc..1bc4921 100644 --- a/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-core/src/main/java/com/ecell/internationalize/common/core/utils/poi/ExcelUtil.java +++ b/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-core/src/main/java/com/ecell/internationalize/common/core/utils/poi/ExcelUtil.java @@ -35,7 +35,7 @@ import java.util.stream.Collectors; /** * @author borui */ -public class ExcelUtil { +public class ExcelUtil { private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); public static final String FORMULA_REGEX_STR = "=|-|\\+|@"; diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/aspect/FactoryImeiLog.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/aspect/FactoryImeiLog.java new file mode 100644 index 0000000..f8b93f9 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/aspect/FactoryImeiLog.java @@ -0,0 +1,144 @@ +package com.ecell.internationalize.system.aspect; +import com.ecell.internationalize.common.core.domain.UserLogin; +import com.ecell.internationalize.common.core.utils.StringUtils; +import com.ecell.internationalize.common.core.utils.ip.IpUtils; +import com.ecell.internationalize.common.core.utils.poi.ExcelUtil; +import com.ecell.internationalize.common.core.utils.uuid.UUID; +import com.ecell.internationalize.common.security.utils.SecurityUtils; +import com.ecell.internationalize.system.annotation.FactoryLog; +import com.ecell.internationalize.system.constant.DeviceModelConstants; +import com.ecell.internationalize.system.entity.FactoryLogInfo; +import com.ecell.internationalize.system.entity.dto.DeviceDTO; +import com.ecell.internationalize.system.service.impl.FactoryLogInfoServiceImpl; +import com.ecell.internationalize.system.utils.HttpServletUtil; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +@Component +@Aspect +public class FactoryImeiLog { + private static final Logger logg = LoggerFactory.getLogger(FactoryImeiLog.class); + @Autowired + private FactoryLogInfoServiceImpl factoryLogInfoServiceImpl; + /** + * 处理完请求后执行 + * + * @param joinPoint 切点 + */ + @AfterReturning(pointcut = "@annotation(factoryLog)", returning = "jsonResult") + public void doAfterReturning(JoinPoint joinPoint, FactoryLog factoryLog, Object jsonResult) + { + handleLog(joinPoint, factoryLog, null, jsonResult); + } + + protected void handleLog(final JoinPoint joinPoint, FactoryLog controllerLog, final Exception e, Object jsonResult){ + try { + // *========数据库日志=========*// + FactoryLogInfo info =new FactoryLogInfo(); + info.setImeiDelId(UUID.fastUUID().toString(true)); + info.setCreateTime(new Date()); + // 请求的地址 + String ip = IpUtils.getIpAddr(HttpServletUtil.getRequest()); + info.setIp(ip); + String username = SecurityUtils.getUsername(); + UserLogin userLogin = SecurityUtils.getUserLogin(); + if (StringUtils.isNotEmpty(userLogin.getRoles()) && userLogin.getRoles().size()>0){ + info.setUserRole(Arrays.toString(userLogin.getRoles().toArray(new String[0]))); + }else { + info.setUserRole(""); + } + if (StringUtils.isNotBlank(username)) + { + info.setLoginAccount(username); + } + // 处理设置注解上的参数 + getControllerMethodDescription(joinPoint, controllerLog, info, jsonResult); + // 保存数据库 + //imeiLogInfoService.save(info); + factoryLogInfoServiceImpl.saveDelImeiLog(info); + }catch (Exception exp){ + // 记录本地异常日志 + logg.error("==通知异常=="); + logg.error("异常信息:{}", exp.getMessage()); + + exp.printStackTrace(); + + + } + + } + + + + private void getControllerMethodDescription(JoinPoint joinPoint, FactoryLog controllerLog, FactoryLogInfo info, Object jsonResult) { + if (DeviceModelConstants.ZERO.equals(controllerLog.unBingType())){ + info.setUnbinding(DeviceModelConstants.UNBING_MODE_ZERO); + argsArrayToString(joinPoint.getArgs(),info); + }else { + info.setUnbinding(DeviceModelConstants.UNBING_MODE_ONE); + //根据导入的imei进行删除 + argsArrayTwoToString(joinPoint.getArgs(),info,jsonResult); + + } + + + } + + private void argsArrayToString(Object[] paramsArray, FactoryLogInfo info) { + // StringBuilder builder =new StringBuilder(); + String s=null; + if (paramsArray != null && paramsArray.length > 0){ + // List list = (List) paramsArray[0]; + +// if (StringUtils.isNotEmpty(list) && list.size()>0){ +// builder.append("共有:"+list.size()+"条:"); +// for (String s : list) { +// builder.append("
"+s+"
").append(","); +// } +// +// } + s=(String) paramsArray[0]; +// builder.append("
"+s+"
"); + } +// info.setOperationDescribe(builder.toString()); + info.setOperationDescribe(s); + + } + + private void argsArrayTwoToString(Object[] paramsArray, FactoryLogInfo info, Object jsonResult) { + List userList = Collections.emptyList(); + StringBuilder builder =new StringBuilder(); + if (paramsArray != null && paramsArray.length > 0) { + try { + + MultipartFile file = (MultipartFile) paramsArray[0]; + if (StringUtils.isNotNull(file)) { + ExcelUtil util = new ExcelUtil(DeviceDTO.class); + userList = util.importExcel(file.getInputStream()); + if (StringUtils.isNotEmpty(userList) && userList.size()>0){ + for (DeviceDTO deviceDTO : userList) { + builder.append("
"+deviceDTO.getImei()+"
").append(","); + } + } + + } + } catch (Exception e) { + logg.info("参数异常:{}", e.getMessage()); + } + } + info.setOperationDescribe(builder.toString()); + } + + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/config/ExceptionAdviceConfig.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/config/ExceptionAdviceConfig.java new file mode 100644 index 0000000..a583725 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/config/ExceptionAdviceConfig.java @@ -0,0 +1,63 @@ +package com.ecell.internationalize.system.config; +import com.ecell.internationalize.common.core.exception.ServiceException; +import com.ecell.internationalize.common.core.utils.locale.LocaleUtil; +import com.ecell.internationalize.common.core.web.domain.AjaxResult; +import com.ecell.internationalize.common.system.constant.ExceptionResultConstant; +import com.ecell.internationalize.common.system.constant.FieldConstant; +import com.ecell.internationalize.common.system.constant.ServiceExceptionResultConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.validation.ObjectError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * 统一异常处理 + * @Title: ExceptionAdviceConfig + * @Author: liy + * @Date: 2022/7/8 13:47 + * @Version:1.0 + */ + +@RestControllerAdvice +public class ExceptionAdviceConfig { + private static final Logger logger = LoggerFactory.getLogger(ExceptionAdviceConfig.class); + /** + * 接口入参校验异常处理 + * @Author: liy + * @Date: 2022/7/8 13:53 + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + public AjaxResult methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { + // 从异常对象中拿到ObjectError对象 + ObjectError objectError = e.getBindingResult().getAllErrors().get(0); + logger.error("接口参数校验异常信息:{}",objectError.getDefaultMessage()); + // 校验结果进行转换调用国际化配置资源 + return AjaxResult.error(LocaleUtil.getMessage(ExceptionResultConstant.RESULT_MAP.get(objectError.getDefaultMessage()))); + } + /** + * 全局异常处理,配置国际化 + * @Author: liy + * @Date: 2022/7/8 13:53 + */ + @ExceptionHandler(Exception.class) + public AjaxResult exceptionHandler(Exception e) { + e.printStackTrace(); + logger.error("异常错误信息:{}",e.getCause().getMessage()); + return AjaxResult.error( LocaleUtil.getMessage(FieldConstant.MESSAGES_ERROR)); + } + + + /** + * 全局异常处理,配置国际化 + * @Author: liy + * @Date: 2022/7/8 13:53 + */ + @ExceptionHandler(ServiceException.class) + public AjaxResult serviceException(ServiceException e) { + e.printStackTrace(); + logger.error("异常错误信息:{}",e.getMessage()); + return AjaxResult.error(e.getCode(),LocaleUtil.getMessage(ServiceExceptionResultConstant.RESULT_MSG_MAP.get(e.getMessage()))); + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/DeviceTotalController.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/DeviceTotalController.java new file mode 100644 index 0000000..5a38aee --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/DeviceTotalController.java @@ -0,0 +1,84 @@ +package com.ecell.internationalize.system.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ecell.internationalize.common.core.utils.DateUtils; +import com.ecell.internationalize.common.system.entity.User; +import com.ecell.internationalize.common.system.entity.VersionRatioHistory; +import com.ecell.internationalize.system.entity.dto.RegisterDto; +import com.ecell.internationalize.system.entity.dto.TotalTypeDto; +import com.ecell.internationalize.system.service.UserService; +import com.ecell.internationalize.system.utils.DateUtil; +import com.ecell.internationalize.system.utils.Rest; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @Title: DeviceTotalController + * @Author: liy + * @Date: 2022/11/2 15:14 + * @Description: + * @Version:1.0 + */ +@Api(value="实时大屏统计",tags={"实时大屏统计接口"}) +@RestController +@RequestMapping("/device_total") +public class DeviceTotalController { + @Autowired + private UserService userService; + @ApiOperation("实时大屏用户信息统计") + @GetMapping + public Rest> queryDeviceTotal() throws ParseException { + List list=new ArrayList<>(); + //注册总数 + int registerCount = userService.count(); + list.add(addTotal("1", registerCount)); + //今日注册数 + Date startTime = DateUtil.getDayBegin(); + Date endTime = DateUtil.getDayEnd(); + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.ge(User::getCreateTime,startTime); + lambdaQueryWrapper.le(User::getCreateTime,endTime); + int currentCount = userService.count(lambdaQueryWrapper); + list.add(addTotal("2", currentCount)); + //今日活跃数 + int activeCount=userService.activeCount(startTime,endTime); + list.add(addTotal("3", activeCount)); + //前一个月每天的用户活跃数 + SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd"); + String currentDate=simpleDateFormat.format(startTime); + LocalDateTime localDate=LocalDateTime.now().minus(30, ChronoUnit.DAYS); + Date preDate=simpleDateFormat.parse(localDate.toString()); + String preMonthDate=simpleDateFormat.format(preDate); + System.out.println("当前日期的第三十天的日期为:"+preMonthDate); + List versionRatioHistoryList = userService.monthActiveCount(currentDate, preMonthDate); + TotalTypeDto totalTypeDto=new TotalTypeDto(); + totalTypeDto.setType("4"); + totalTypeDto.setList(versionRatioHistoryList); + list.add(totalTypeDto); + //前一个月每天用户的注册数 + List monthRegisterCount= userService.monthRegisterCount(currentDate,preMonthDate); + TotalTypeDto registerTotal=new TotalTypeDto(); + registerTotal.setType("5"); + registerTotal.setRegisterList(monthRegisterCount); + list.add(registerTotal); + return Rest.ok(list); + } + public TotalTypeDto addTotal(String type,Integer count){ + TotalTypeDto totalTypeDto=new TotalTypeDto(); + totalTypeDto.setType(type); + totalTypeDto.setTotal(count); + return totalTypeDto; + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/DeviceUserInfoController.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/DeviceUserInfoController.java new file mode 100644 index 0000000..8e41c23 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/DeviceUserInfoController.java @@ -0,0 +1,42 @@ +package com.ecell.internationalize.system.controller; +import com.ecell.internationalize.common.core.utils.locale.LocaleUtil; +import com.ecell.internationalize.common.core.web.domain.AjaxResult; +import com.ecell.internationalize.common.system.constant.FieldConstant; +import com.ecell.internationalize.system.entity.dto.DeviceUserPageDTO; +import com.ecell.internationalize.system.service.DeviceUserInfoService; +import io.swagger.annotations.Api; +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; + +/** + *

+ * 前端控制器 + *

+ * + * @author ${author} + * @since 2022-07-15 + */ +@Api(value="设备基本信息",tags={"设备基本信息接口"}) +@RestController +@RequestMapping("/device-user-info") +public class DeviceUserInfoController { + @Autowired + private DeviceUserInfoService deviceUserInfoService; + + @PostMapping ("/page/list") + public AjaxResult queryPageList(@RequestBody DeviceUserPageDTO dto){ + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS), deviceUserInfoService.queryPageList(dto)); + + } + + @PostMapping("/page/family") + public AjaxResult queryPageFamilyList(@RequestBody DeviceUserPageDTO dto){ + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS), deviceUserInfoService.queryPageFamilyList(dto)); + + } + +} + diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/DeviceUserInfo.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/DeviceUserInfo.java new file mode 100644 index 0000000..773a747 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/DeviceUserInfo.java @@ -0,0 +1,92 @@ +package com.ecell.internationalize.system.entity; + +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; + +/** + *

+ * + *

+ * + * @author ${author} + * @since 2022-07-15 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="DeviceUserInfo对象", description="") +public class DeviceUserInfo implements Serializable { + +private static final long serialVersionUID=1L; + + @ApiModelProperty(value = "id") + private String deviceUserId; + + @ApiModelProperty(value = "设备imei") + private String imei; + + @ApiModelProperty(value = "sex性别") + private String sex; + + @ApiModelProperty(value = "设备名称") + private String name; + + @ApiModelProperty(value = "设备头像url") + private String url; + + @ApiModelProperty(value = "用户手机号码") + private String devicePhone; + + @ApiModelProperty(value = "位置") + private String addr; + + @ApiModelProperty(value = "(0.是离线,1.是在线)") + private String status; + + @ApiModelProperty(value = "今日步数") + private Integer recentSteps; + + @ApiModelProperty(value = "手表电量") + private String battery; + + @ApiModelProperty(value = "厂商名称") + private String firmName; + + @ApiModelProperty(value = "厂商id") + private String firmId; + + @ApiModelProperty(value = "型号名称") + private String deviceModelName; + + @ApiModelProperty(value = "设备型号id") + private String deviceModelId; + + @ApiModelProperty(value = "导入系统时间") + private Date importTime; + + @ApiModelProperty(value = "首次登录系统时间") + private Date firstLoginTime; + + @ApiModelProperty(value = "最后一次登录时间") + private Date lastLoginTime; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "修改时间") + private Date updateTime; + + @ApiModelProperty(value = "创建人") + private String createUser; + + @ApiModelProperty(value = "修改人") + private String updateUser; + + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/dto/DeviceUserBingInfo.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/dto/DeviceUserBingInfo.java new file mode 100644 index 0000000..0643bdd --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/dto/DeviceUserBingInfo.java @@ -0,0 +1,13 @@ +package com.ecell.internationalize.system.entity.dto; + +import lombok.Data; + +/** + * @author borui + */ +@Data +public class DeviceUserBingInfo { + private String id; + private String imei; + private String userId; +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/dto/DeviceUserPageDTO.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/dto/DeviceUserPageDTO.java new file mode 100644 index 0000000..3fa8aa8 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/dto/DeviceUserPageDTO.java @@ -0,0 +1,34 @@ +package com.ecell.internationalize.system.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@ApiModel(description = "用户设备分页对象") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DeviceUserPageDTO { + @ApiModelProperty("设备imei ") + private String imei; + + @ApiModelProperty(value = "设备手机号") + private String phone; + + @ApiModelProperty(value = "厂商id") + private String firmId; + + @ApiModelProperty(value = "厂商名称") + private String firmName; + + @ApiModelProperty(value = "代理商id") + private String agentId; + + @ApiModelProperty(value = "每页展示的条数") + private Integer pageSize; + + @ApiModelProperty(value = "当前的页码") + private Integer current; +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/DeviceUserInfoVO.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/DeviceUserInfoVO.java new file mode 100644 index 0000000..426bf81 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/DeviceUserInfoVO.java @@ -0,0 +1,38 @@ +package com.ecell.internationalize.system.entity.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author borui + */ +@Data +@ApiModel(value="DeviceUserInfoVO对象", description="设备家庭信息") +public class DeviceUserInfoVO { + @ApiModelProperty(value = "设备imei") + private String imei; + + @ApiModelProperty(value = "sex性别") + private String sex; + + @ApiModelProperty(value = "设备头像url") + private String url; + + @ApiModelProperty(value = "设备手机号码") + private String phone; + + @ApiModelProperty(value = "管理员昵称") + private String adminName; + + @ApiModelProperty(value = "管理员电话") + private String adminPhone; + + @ApiModelProperty(value = "管理员头像") + private Integer adminUrl; + + @ApiModelProperty(value = "成员信息") + private List memberInfoVOS; +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/DisableVO.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/DisableVO.java new file mode 100644 index 0000000..36176ee --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/DisableVO.java @@ -0,0 +1,26 @@ +package com.ecell.internationalize.system.entity.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author borui + */ +@Data +public class DisableVO { + + @ApiModelProperty(example = "开始响铃时间") + private String alarmStartTime; + + @ApiModelProperty(example = "重复星期数为'0', '1'组成的 7 位长度字符串, 表示周一至周日是否有效 eg: '0000011' 周六日有效, '1110000' 为周一二三有效") + private String alarmWeek; + + @ApiModelProperty(example = "是否开启 0关闭,1开启,默认1") + private String alarmStatus; + + @ApiModelProperty(example = "设备imei") + private String imei; + + @ApiModelProperty(example = "结束响铃时间") + private String alarmEndTime; +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/EquipmentFunctionVO.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/EquipmentFunctionVO.java new file mode 100644 index 0000000..2b4c0c8 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/EquipmentFunctionVO.java @@ -0,0 +1,33 @@ +package com.ecell.internationalize.system.entity.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author borui + */ +@Data +public class EquipmentFunctionVO { + @ApiModelProperty(example = "设备imei") + private String imei; + @ApiModelProperty(example = "陌生来电状态,0.关闭,1.开启") + private String rejectStrange; + @ApiModelProperty(example = "定位模式") + private int positioningInterval ; + @ApiModelProperty(example = "第一个sos号码") + private String sosPhoneOne; + @ApiModelProperty(example = "第二个sos号码") + private String sosPhoneTwo; + @ApiModelProperty(example = "第三个sos号码") + private String sosPhoneThree; + @ApiModelProperty(example = "电话本") + private List books; + @ApiModelProperty(example = "闹钟") + private List alarms; + @ApiModelProperty(example = "上课禁用时段") + private List disables; + @ApiModelProperty(example = "安全围栏") + private List safetyRail; +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/DeviceUserInfoMapper.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/DeviceUserInfoMapper.java new file mode 100644 index 0000000..7b3f780 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/DeviceUserInfoMapper.java @@ -0,0 +1,44 @@ +package com.ecell.internationalize.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ecell.internationalize.system.entity.DeviceUserInfo; +import com.ecell.internationalize.system.entity.dto.DeviceUserPageDTO; +import com.ecell.internationalize.system.entity.vo.DeviceUserInfoVO; +import com.ecell.internationalize.system.entity.vo.MemberInfoVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author ${author} + * @since 2022-07-15 + */ +public interface DeviceUserInfoMapper extends BaseMapper { + /** + * 查询设备基本信息 + * @param page + * @param dto + * @return + */ + Page queryDeviceUserInfo(@Param("page") Page page, @Param("dto") DeviceUserPageDTO dto); + + /** + * 查询设备家庭信息 + * @param page + * @param dto + * @return + */ + Page queryPageFamilyList(@Param("page") Page page, @Param("dto") DeviceUserPageDTO dto); + + /** + * 根据imei查询绑定表 + * @param imei + * @return + */ + List queryMemberInfoByImei(@Param("imei") String imei); +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/DeviceUserInfoService.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/DeviceUserInfoService.java new file mode 100644 index 0000000..54c82d0 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/DeviceUserInfoService.java @@ -0,0 +1,21 @@ +package com.ecell.internationalize.system.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ecell.internationalize.system.entity.DeviceUserInfo; +import com.ecell.internationalize.system.entity.dto.DeviceUserPageDTO; + +/** + *

+ * 服务类 + *

+ * + * @author ${author} + * @since 2022-07-15 + */ +public interface DeviceUserInfoService extends IService { + + IPage queryPageList(DeviceUserPageDTO dto); + + IPage queryPageFamilyList(DeviceUserPageDTO dto); +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/DeviceTimeSwitchAppServiceImpl.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/DeviceTimeSwitchAppServiceImpl.java new file mode 100644 index 0000000..9b78319 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/impl/DeviceTimeSwitchAppServiceImpl.java @@ -0,0 +1,42 @@ +package com.ecell.internationalize.system.service.api.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ecell.internationalize.common.core.context.SecurityContextHolder; +import com.ecell.internationalize.common.core.utils.SpringUtils; +import com.ecell.internationalize.common.issue.entity.BootOff; +import com.ecell.internationalize.common.issue.issue.IssueInstructions; +import com.ecell.internationalize.system.entity.api.DeviceTimeSwitchApp; +import com.ecell.internationalize.system.mapper.api.DeviceTimeSwitchAppMapper; +import com.ecell.internationalize.system.service.api.DeviceTimeSwitchAppService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + *

+ * 定时开关机 服务实现类 + *

+ * + * @author ${author} + * @since 2022-09-21 + */ +@Service +@Slf4j +public class DeviceTimeSwitchAppServiceImpl extends ServiceImpl implements DeviceTimeSwitchAppService { + @Override + public void sendToKafka(DeviceTimeSwitchApp deviceTimeSwitchApp) { + BootOff bootOff=new BootOff(); + bootOff.setImei(deviceTimeSwitchApp.getImei()); + bootOff.setOpenid(SecurityContextHolder.getStringUserId()); + bootOff.setIdent("12345678"); + bootOff.setTime(System.currentTimeMillis()); + bootOff.setType("setBootOff"); + bootOff.setVender("20000"); + bootOff.setStartTime(deviceTimeSwitchApp.getStartTime()); + bootOff.setEndTime(deviceTimeSwitchApp.getEndTime()); + bootOff.setStatus(Integer.valueOf(deviceTimeSwitchApp.getStatus())); + IssueInstructions issueInstructions = SpringUtils.getBean(IssueInstructions.class); + //3.调用方法缓存入redis,开始指令下发 + issueInstructions.emitDeviceDemand("setBootOff",deviceTimeSwitchApp.getImei(),bootOff); + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/DeviceUserInfoServiceImpl.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/DeviceUserInfoServiceImpl.java new file mode 100644 index 0000000..d313495 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/DeviceUserInfoServiceImpl.java @@ -0,0 +1,140 @@ +package com.ecell.internationalize.system.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ecell.internationalize.common.core.utils.StringUtils; +import com.ecell.internationalize.common.redis.service.RedisService; +import com.ecell.internationalize.common.security.utils.SecurityUtils; +import com.ecell.internationalize.system.constant.DeviceModelConstants; +import com.ecell.internationalize.system.entity.DeviceUserInfo; +import com.ecell.internationalize.system.entity.dto.DeviceUserPageDTO; +import com.ecell.internationalize.system.entity.vo.DeviceUserInfoVO; +import com.ecell.internationalize.system.entity.vo.MemberInfoVO; +import com.ecell.internationalize.system.mapper.DeviceUserInfoMapper; +import com.ecell.internationalize.system.service.DeviceUserInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + *

+ * 服务实现类 + *

+ * + * @author ${author} + * @since 2022-07-15 + */ +@Service +public class DeviceUserInfoServiceImpl extends ServiceImpl implements DeviceUserInfoService { + @Autowired + RedisService redisService; + + @Override + public IPage queryPageList(DeviceUserPageDTO dto) { + Page page =new Page(dto.getCurrent(),dto.getPageSize()); + Page deviceUserInfoPage = baseMapper.queryDeviceUserInfo(page, dto); + convertIPage(deviceUserInfoPage); + return page; + + } + + /** + * 设备家庭成员 + * @param dto + * @return + */ + @Override + public IPage queryPageFamilyList(DeviceUserPageDTO dto) { + //获取当前用户 + Map map = SecurityUtils.getFirmIdOrSecondFirmId(SecurityUtils.getUserLogin()); + if (StringUtils.isNotEmpty(map)) { + //是厂商 + if (StringUtils.isNotEmpty(map.get("firmFlag")) && DeviceModelConstants.ONE.equals(map.get("firmFlag"))) { + dto.setFirmId(map.get("firmId")); + } else { + //代理商 + dto.setAgentId(map.get("firmId")); + } + } + //根据imei + + Page page =new Page(dto.getCurrent(),dto.getPageSize()); + Page deviceUserInfoVOPage = baseMapper.queryPageFamilyList(page, dto); + convertIPageFamilyInfo(deviceUserInfoVOPage); + return deviceUserInfoVOPage; + } + + + /*** + * 转换 + * @return + */ + private void convertIPage(IPage page){ + if (StringUtils.isNotNull(page) && page.getRecords().size()>0){ + //设备型号id + List records = page.getRecords(); + List collect = records.stream().map(s->{ + try { + Object onlineStatus = Optional.ofNullable(redisService.getCacheMapValue(s.getImei(), "onlineStatus")).orElse(DeviceModelConstants.ZERO); + s.setStatus(onlineStatus.toString()); + }catch (Exception e){ + s.setStatus(DeviceModelConstants.ZERO); + } + + return s; + }).collect(Collectors.toList()); + + page.setRecords(collect); + + } + + } + + /*** + * 转换 + * @return + */ + private void convertIPageFamilyInfo(IPage page){ + if (StringUtils.isNotNull(page) && page.getRecords().size()>0){ + //设备型号id + List records = page.getRecords(); + List collect = records.stream().map(s->{ + //管理员的手机号码不为空就说明此imei绑定了 + if (StringUtils.isNotEmpty(s.getAdminPhone())){ + //根据imei查询绑定表成员 + List memberInfoVOS = baseMapper.queryMemberInfoByImei(s.getImei()); + s.setMemberInfoVOS(memberInfoVOS); + } + + return s; + }).collect(Collectors.toList()); + + page.setRecords(collect); + + } + + } +// + + + + + +// +// private DeviceUserInfo getDeviceUserInfo(DeviceUserInfo info){ +// if (StringUtils.isNotNull(info)){ +// //根据厂商id 查询厂商名称 +// if(StringUtils.isNotNull(firmManageMapper.selectById(info.getFirmId()))){ +// info.setFirmName(firmManageMapper.selectById(info.getFirmId()).getFirmName()); +// } +// +// } +// +// return info; +// } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/DeviceUserInfoMapper.xml b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/DeviceUserInfoMapper.xml new file mode 100644 index 0000000..361922e --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/DeviceUserInfoMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + +