caojianbin
8 months ago
16 changed files with 880 additions and 1 deletions
@ -0,0 +1,144 @@
@@ -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<String> list = (List<String>) paramsArray[0];
|
||||
|
||||
// if (StringUtils.isNotEmpty(list) && list.size()>0){
|
||||
// builder.append("共有:"+list.size()+"条:");
|
||||
// for (String s : list) {
|
||||
// builder.append("<br/>"+s+"<br/>").append(",");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
s=(String) paramsArray[0]; |
||||
// builder.append("<br/>"+s+"<br/>");
|
||||
} |
||||
// info.setOperationDescribe(builder.toString());
|
||||
info.setOperationDescribe(s); |
||||
|
||||
} |
||||
|
||||
private void argsArrayTwoToString(Object[] paramsArray, FactoryLogInfo info, Object jsonResult) { |
||||
List<DeviceDTO> userList = Collections.emptyList(); |
||||
StringBuilder builder =new StringBuilder(); |
||||
if (paramsArray != null && paramsArray.length > 0) { |
||||
try { |
||||
|
||||
MultipartFile file = (MultipartFile) paramsArray[0]; |
||||
if (StringUtils.isNotNull(file)) { |
||||
ExcelUtil<DeviceDTO> util = new ExcelUtil<DeviceDTO>(DeviceDTO.class); |
||||
userList = util.importExcel(file.getInputStream()); |
||||
if (StringUtils.isNotEmpty(userList) && userList.size()>0){ |
||||
for (DeviceDTO deviceDTO : userList) { |
||||
builder.append("<br/>"+deviceDTO.getImei()+"<br/>").append(","); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} catch (Exception e) { |
||||
logg.info("参数异常:{}", e.getMessage()); |
||||
} |
||||
} |
||||
info.setOperationDescribe(builder.toString()); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,63 @@
@@ -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()))); |
||||
} |
||||
} |
@ -0,0 +1,84 @@
@@ -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<List<TotalTypeDto>> queryDeviceTotal() throws ParseException { |
||||
List<TotalTypeDto> list=new ArrayList<>(); |
||||
//注册总数
|
||||
int registerCount = userService.count(); |
||||
list.add(addTotal("1", registerCount)); |
||||
//今日注册数
|
||||
Date startTime = DateUtil.getDayBegin(); |
||||
Date endTime = DateUtil.getDayEnd(); |
||||
LambdaQueryWrapper<User> 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<VersionRatioHistory> versionRatioHistoryList = userService.monthActiveCount(currentDate, preMonthDate); |
||||
TotalTypeDto totalTypeDto=new TotalTypeDto(); |
||||
totalTypeDto.setType("4"); |
||||
totalTypeDto.setList(versionRatioHistoryList); |
||||
list.add(totalTypeDto); |
||||
//前一个月每天用户的注册数
|
||||
List<RegisterDto> 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; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
@@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @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)); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,92 @@
@@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @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; |
||||
|
||||
|
||||
} |
@ -0,0 +1,13 @@
@@ -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; |
||||
} |
@ -0,0 +1,34 @@
@@ -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; |
||||
} |
@ -0,0 +1,38 @@
@@ -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<MemberInfoVO> memberInfoVOS; |
||||
} |
@ -0,0 +1,26 @@
@@ -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; |
||||
} |
@ -0,0 +1,33 @@
@@ -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<com.ecell.internationalize.system.entity.vo.TelephoneBookVO> books; |
||||
@ApiModelProperty(example = "闹钟") |
||||
private List<com.ecell.internationalize.system.entity.vo.AlarmVO> alarms; |
||||
@ApiModelProperty(example = "上课禁用时段") |
||||
private List<com.ecell.internationalize.system.entity.vo.DisableVO> disables; |
||||
@ApiModelProperty(example = "安全围栏") |
||||
private List<com.ecell.internationalize.system.entity.vo.SafetyRailVO> safetyRail; |
||||
} |
@ -0,0 +1,44 @@
@@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author ${author} |
||||
* @since 2022-07-15 |
||||
*/ |
||||
public interface DeviceUserInfoMapper extends BaseMapper<DeviceUserInfo> { |
||||
/** |
||||
* 查询设备基本信息 |
||||
* @param page |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
Page<DeviceUserInfo> queryDeviceUserInfo(@Param("page") Page page, @Param("dto") DeviceUserPageDTO dto); |
||||
|
||||
/** |
||||
* 查询设备家庭信息 |
||||
* @param page |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
Page<DeviceUserInfoVO> queryPageFamilyList(@Param("page") Page page, @Param("dto") DeviceUserPageDTO dto); |
||||
|
||||
/** |
||||
* 根据imei查询绑定表 |
||||
* @param imei |
||||
* @return |
||||
*/ |
||||
List<MemberInfoVO> queryMemberInfoByImei(@Param("imei") String imei); |
||||
} |
@ -0,0 +1,21 @@
@@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务类 |
||||
* </p> |
||||
* |
||||
* @author ${author} |
||||
* @since 2022-07-15 |
||||
*/ |
||||
public interface DeviceUserInfoService extends IService<DeviceUserInfo> { |
||||
|
||||
IPage queryPageList(DeviceUserPageDTO dto); |
||||
|
||||
IPage queryPageFamilyList(DeviceUserPageDTO dto); |
||||
} |
@ -0,0 +1,42 @@
@@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 定时开关机 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author ${author} |
||||
* @since 2022-09-21 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
public class DeviceTimeSwitchAppServiceImpl extends ServiceImpl<DeviceTimeSwitchAppMapper, DeviceTimeSwitchApp> 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); |
||||
} |
||||
} |
@ -0,0 +1,140 @@
@@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author ${author} |
||||
* @since 2022-07-15 |
||||
*/ |
||||
@Service |
||||
public class DeviceUserInfoServiceImpl extends ServiceImpl<DeviceUserInfoMapper, DeviceUserInfo> implements DeviceUserInfoService { |
||||
@Autowired |
||||
RedisService redisService; |
||||
|
||||
@Override |
||||
public IPage queryPageList(DeviceUserPageDTO dto) { |
||||
Page page =new Page(dto.getCurrent(),dto.getPageSize()); |
||||
Page<DeviceUserInfo> deviceUserInfoPage = baseMapper.queryDeviceUserInfo(page, dto); |
||||
convertIPage(deviceUserInfoPage); |
||||
return page; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 设备家庭成员 |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public IPage queryPageFamilyList(DeviceUserPageDTO dto) { |
||||
//获取当前用户
|
||||
Map<String, String> 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<DeviceUserInfoVO> 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<DeviceUserInfo> records = page.getRecords(); |
||||
List<DeviceUserInfo> 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<DeviceUserInfoVO> records = page.getRecords(); |
||||
List<DeviceUserInfoVO> collect = records.stream().map(s->{ |
||||
//管理员的手机号码不为空就说明此imei绑定了
|
||||
if (StringUtils.isNotEmpty(s.getAdminPhone())){ |
||||
//根据imei查询绑定表成员
|
||||
List<MemberInfoVO> 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;
|
||||
// }
|
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.ecell.internationalize.system.mapper.DeviceUserInfoMapper"> |
||||
<select id="queryDeviceUserInfo" resultType="com.ecell.internationalize.system.entity.DeviceUserInfo"> |
||||
select d.imei ,a.sex, a.name,a.phone as devicePhone, a.image as url, d.firstLoginTime,d.lastLoginTime, l.addr,l.battery,l.step_number as |
||||
recentSteps, f.firm_name as firmName,d.create_time as importTime,w.device_model_name as deviceModelName from |
||||
( |
||||
select imei,firm_id,agent_id,device_model_id,create_time,firstLoginTime,lastLoginTime from device_info where audit_status='2' and del_flag |
||||
='1' |
||||
<if test="dto.firmId !=null and dto.firmId != '' "> |
||||
and firm_id=#{dto.firmId} |
||||
</if> |
||||
<if test="dto.agentId !=null and dto.agentId != '' "> |
||||
and agent_id=#{dto.agentId} |
||||
</if> |
||||
<if test="dto.imei != null and dto.imei !='' "> |
||||
and imei =#{dto.imei} |
||||
</if> |
||||
group by imei |
||||
) d |
||||
INNER JOIN firm_manage f on d.firm_id =f.firm_id |
||||
INNER JOIN device_model_info w on d.device_model_id = w.device_model_id |
||||
LEFT JOIN device_owner_info_app a on d.imei =a.imei |
||||
LEFT JOIN latest_location_app l on d.imei =l.imei |
||||
<where> |
||||
<if test="dto.phone != null and dto.phone !='' "> |
||||
and a.phone =#{dto.phone} |
||||
</if> |
||||
</where> |
||||
|
||||
</select> |
||||
|
||||
<select id="queryPageFamilyList" resultType="com.ecell.internationalize.system.entity.vo.DeviceUserInfoVO"> |
||||
select d.imei ,a.sex,a.phone,u.relation as adminName,u.relation_image_id as adminUrl,u.phone as adminPhone,a.image as url from |
||||
( |
||||
select imei from device_info where audit_status='2' and del_flag |
||||
='1' |
||||
<if test="dto.firmId !=null and dto.firmId != '' "> |
||||
and firm_id=#{dto.firmId} |
||||
</if> |
||||
<if test="dto.agentId !=null and dto.agentId != '' "> |
||||
and agent_id=#{dto.agentId} |
||||
</if> |
||||
<if test="dto.imei != null and dto.imei !='' "> |
||||
and imei =#{dto.imei} |
||||
</if> |
||||
group by imei |
||||
) d |
||||
LEFT JOIN (select imei,relation,relation_image_id,phone from user_device_bind_app where identity='2') u ON d.imei = u.imei |
||||
LEFT JOIN device_owner_info_app a on d.imei =a.imei |
||||
<where> |
||||
<if test="dto.phone != null and dto.phone !='' "> |
||||
and a.phone =#{dto.phone} |
||||
</if> |
||||
</where> |
||||
|
||||
</select> |
||||
|
||||
<select id="queryMemberInfoByImei" resultType="com.ecell.internationalize.system.entity.vo.MemberInfoVO"> |
||||
select relation as name,relation_image_id as imageUrl, phone from user_device_bind_app where imei =#{imei} and identity='1' |
||||
</select> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue