commit e4c94ade2778a6fefe2e3c9898c8920639b4f48d Author: mingming666888 <1604312598@qq.com> Date: Thu Jan 8 16:22:26 2026 +0800 Initial commit diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..284455e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..4837d2f --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..fcdb674 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..67e1e61 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..6bf27cb --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RequestMappingsPanelOrder0": "0", + "RequestMappingsPanelOrder1": "1", + "RequestMappingsPanelWidth0": "75", + "RequestMappingsPanelWidth1": "75", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "last_opened_file_path": "D:/javaProject/ceshiProject/smart_netty", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "run.code.analysis.last.selected.profile": "pProject Default", + "settings.editor.selected.configurable": "MavenSettings", + "spring.configuration.checksum": "e4d6fc2a447bf0856d23d09850674ed3", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1764836974735 + + + + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8564f29 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2018 RuoYi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..02782b7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,232 @@ + + + 4.0.0 + + com.smartlive + smartlive + 3.8.8 + + smartlive + http://www.ruoyi.vip + 智慧生活平台 + + + 3.8.8 + UTF-8 + UTF-8 + 1.8 + 3.1.1 + 5.3.33 + 5.7.12 + 1.2.23 + 1.21 + 3.0.0 + 2.3.3 + 1.4.7 + 2.0.43 + 6.6.1 + 2.13.0 + 4.1.2 + 2.3 + 0.9.1 + 3.5.2 + + + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + org.springframework + spring-framework-bom + ${spring-framework.version} + pom + import + + + + + org.springframework.security + spring-security-bom + ${spring-security.version} + pom + import + + + + + org.springframework.boot + spring-boot-dependencies + 2.5.15 + pom + import + + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + + eu.bitwalker + UserAgentUtils + ${bitwalker.version} + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.boot.version} + + + + + com.github.oshi + oshi-core + ${oshi.version} + + + + + io.springfox + springfox-boot-starter + ${swagger.version} + + + io.swagger + swagger-models + + + + + + + commons-io + commons-io + ${commons.io.version} + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + + + org.apache.velocity + velocity-engine-core + ${velocity.version} + + + + + com.alibaba.fastjson2 + fastjson2 + ${fastjson.version} + + + + + io.jsonwebtoken + jjwt + ${jwt.version} + + + + + pro.fessional + kaptcha + ${kaptcha.version} + + + + + com.smartlive + smartlive-framework + ${smartlive.version} + + + + + com.smartlive + smartlive-system + ${smartlive.version} + + + + + com.smartlive + smartlive-common + ${smartlive.version} + + + com.github.qcloudsms + qcloudsms + 1.0.6 + + + + + + smartlive-admin + smartlive-framework + smartlive-system + smartlive-common + smart-position-watch + + pom + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public + + true + + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public + + true + + + false + + + + + diff --git a/smart-position-watch/.gitignore b/smart-position-watch/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/smart-position-watch/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/smart-position-watch/pom.xml b/smart-position-watch/pom.xml new file mode 100644 index 0000000..f8d40f0 --- /dev/null +++ b/smart-position-watch/pom.xml @@ -0,0 +1,33 @@ + + + + smartlive + com.smartlive + 3.8.8 + + 4.0.0 + + smart-position-watch + + + + com.smartlive + smartlive-system + 3.8.8 + + + org.aspectj + aspectjweaver + + + cn.hutool + hutool-all + 5.8.11 + compile + + + + + diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/Casts.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/Casts.java new file mode 100644 index 0000000..f6bf580 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/Casts.java @@ -0,0 +1,51 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/6/10 + */ +@Data +public class Casts { + /** + * 日期 yyyy-MM-dd格式 + */ + private String date; + /** + * 周几,1-7 周一至周日 + */ + private String week; + /** + * 白天天气 + */ + private String dayweather; + /** + * 夜间天气 + */ + private String nightweather; + /** + * 白天温度,最高气温 + */ + private String daytemp; + /** + * 夜间天气 + */ + private String nighttemp; + /** + * 白天风向 + */ + private String daywind; + /** + * 夜间风向 + */ + private String nightwind; + /** + * 白天风力 + */ + private String daypower; + /** + * 晚上风力 + */ + private String nightpower; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/HeathReportTO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/HeathReportTO.java new file mode 100644 index 0000000..755f3b0 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/HeathReportTO.java @@ -0,0 +1,17 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +@Data +public class HeathReportTO { + + private Long reportId; + + private String empNo; + + private String watchName; + + private String reportTitle; + + private String createTime; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/LocationTO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/LocationTO.java new file mode 100644 index 0000000..bfa7ec5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/LocationTO.java @@ -0,0 +1,97 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; +import java.util.Objects; + +/** + * @author:lilj + * @date:2025/2/6 + */ +@Data +public class LocationTO { + /** + * 经度 + */ + private BigDecimal longitude; + /** + * 纬度 + */ + private BigDecimal latitude; + /** + * 地址信息 + */ + private String address; + + /** + * 定位时间 + */ + private Date createTime; + + /** + * 地址区划信息: + */ + private String areaCode; + + /** + * 高德智能定位返回的是7位小数,系统存储的是6位小数,进行处理 + * @param longitude + */ + public void setLongitude(BigDecimal longitude) { + int scale = 6; // 指定小数位数 + RoundingMode roundingMode = RoundingMode.HALF_UP; // 四舍五入模式 + this.longitude = longitude.setScale(scale, roundingMode); + } + + public void setLatitude(BigDecimal latitude) { + int scale = 6; // 指定小数位数 + RoundingMode roundingMode = RoundingMode.HALF_UP; // 四舍五入模式 + this.latitude = latitude.setScale(scale, roundingMode); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LocationTO that = (LocationTO) o; + //使用compareTo进行比较 + return this.compareBigDecimal(longitude, that.longitude) && this.compareBigDecimal(latitude, that.latitude); + } + + @Override + public int hashCode() { + return Objects.hash(longitude, latitude); + } + + private boolean compareBigDecimal(BigDecimal a, BigDecimal b){ + if(a == b) { + return true; + } + if(a == null || b == null) { + return false; + } + return a.compareTo(b) == 0; + } + + public static void main(String[] args) { + // LocationTO locationTO = new LocationTO(); + // locationTO.setLongitude(new BigDecimal("0.000000")); + // locationTO.setLatitude(new BigDecimal("0.000000")); + // + // LocationTO locationTO1 = new LocationTO(); + // // locationTO1.setLongitude(new BigDecimal("0.000000")); + // // locationTO1.setLatitude(new BigDecimal("1.000000")); + // System.out.println(locationTO.equals(locationTO1)); + + + BigDecimal longitude = new BigDecimal("123.4"); + int scale = 4; // 指定小数位数 + RoundingMode roundingMode = RoundingMode.HALF_UP; // 四舍五入模式 + + BigDecimal roundedLongitude = longitude.setScale(scale, roundingMode); + System.out.println(roundedLongitude); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/PayRequestTO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/PayRequestTO.java new file mode 100644 index 0000000..629cf68 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/PayRequestTO.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; +import org.apache.poi.hpsf.Decimal; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + * 订单请求参数 + */ +@Data +public class PayRequestTO{ + + @NotNull(message = "用户ID不能为空") + private Long userId; + + @NotNull(message = "支付类型不能为空") + private Integer payType; + + @Min(value = 1, message = "商品数量不能小于1") + private Integer num; + + @DecimalMin(value = "0.00", message = "金额不能小于0") + private BigDecimal money; + + @NotNull(message = "商品不能为空") + private Integer watchId; + + @NotNull(message = "地址不能为空") + private Long addressId; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/RuleMatchContext.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/RuleMatchContext.java new file mode 100644 index 0000000..1ec5d75 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/RuleMatchContext.java @@ -0,0 +1,40 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 规则匹配上下文 + */ +@Data +public class RuleMatchContext { + + //"指标类型" + private String indicatorType; + + //"总测量次数" + private Integer totalCount; + + //"异常次数" + private Integer abnormalCount; + + //"过缓次数" + private Integer bradycardiaCount; + + //"过速次数" + private Integer tachycardiaCount; + + //"偏低次数" + private Integer lowCount; + + //"偏高次数" + private Integer highCount; + + //"异常比例" + private BigDecimal abnormalRatio; + + public RuleMatchContext(String indicatorType) { + this.indicatorType = indicatorType; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/StepTO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/StepTO.java new file mode 100644 index 0000000..7f2bae9 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/StepTO.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/2/5 + */ +@Data +public class StepTO { + /** + * 步数对应的哪一天 + */ + private String date; + + /** + * 步数 + */ + private Integer stepCount; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WatchDeviceTO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WatchDeviceTO.java new file mode 100644 index 0000000..a8885bb --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WatchDeviceTO.java @@ -0,0 +1,67 @@ +package com.smartlive.bswatch.TO; + +import com.smartlive.bswatch.enmus.WatchApiEnum; +import com.smartlive.bswatch.entity.WatchDevice; +import com.smartlive.bswatch.netty.watchvo.MessageHeaderVO; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.bswatch.netty.watchvo.req.deviceReq.LoginReq; +import lombok.Data; + +import java.util.Objects; + +/** + * @author:lilj + * @date:2025/2/5 + */ +@Data +public class WatchDeviceTO { + //watch_sign(查询用),protocol_version,rfid,iccid + + private String watchSign; + private String iccid; + private String protocolVersion; + private String rfid; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + WatchDeviceTO that = (WatchDeviceTO) o; + return Objects.equals(watchSign, that.watchSign) && Objects.equals(iccid, that.iccid) && Objects.equals(protocolVersion, that.protocolVersion) && Objects.equals(rfid, that.rfid); + } + + @Override + public int hashCode() { + return Objects.hash(watchSign, iccid, protocolVersion, rfid); + } + + public static WatchDeviceTO messageToWatchDeviceTO(MessageVO messageVO){ + if(messageVO==null || messageVO.getMessageHeader()==null || messageVO.getMessageBody()==null ){ + return null; + } + MessageHeaderVO messageHeaderVO=messageVO.getMessageHeader(); + if(!WatchApiEnum.LOGIN.getApiName().equals(messageVO.getMessageHeader().getApiName())){ + return null; + } + + LoginReq loginReq= (LoginReq) messageVO.getMessageBody(); + WatchDeviceTO watchDeviceTO=new WatchDeviceTO(); + watchDeviceTO.setWatchSign(messageHeaderVO.getWatchSign()); + watchDeviceTO.setIccid(messageHeaderVO.getIccid()); + watchDeviceTO.setProtocolVersion(loginReq.getProtocolVersion()); + watchDeviceTO.setRfid(loginReq.getRfid()); + return watchDeviceTO; + } + + public static WatchDeviceTO watchDeviceToWatchDeviceTO(WatchDevice watchDevice){ + if(watchDevice==null){ + return null; + } + WatchDeviceTO watchDeviceTO=new WatchDeviceTO(); + watchDeviceTO.setWatchSign(watchDevice.getWatchSign()); + watchDeviceTO.setIccid(watchDevice.getIccid()); + watchDeviceTO.setProtocolVersion(watchDevice.getProtocolVersion()); + watchDeviceTO.setRfid(watchDevice.getRfid()); + return watchDeviceTO; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherForecast.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherForecast.java new file mode 100644 index 0000000..24f1320 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherForecast.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/6/10 + */ +@Data +public class WeatherForecast { + /** + * 市 + */ + private String city; + /** + * 区划编码 + */ + private String adcode; + /** + * 省 + */ + private String province; + /** + * 发布时间 + */ + private String reporttime; + + /** + * 天气预报 + */ + private List casts; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherLive.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherLive.java new file mode 100644 index 0000000..f22eef8 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherLive.java @@ -0,0 +1,47 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/6/10 + */ +@Data +public class WeatherLive { + /** + * 省 + */ + private String province; + /** + * 市 + */ + private String city; + /** + * 区划编码 + */ + private String adcode; + /** + * 天气:汉字描述 + */ + private String weather; + /** + * 温度 + */ + private String temperature; + /** + * 风向 + */ + private String winddirection; + /** + * 风力 + */ + private String windpower; + /** + * 湿度 + */ + private String humidity; + /** + * 数据发布时间:yyyy-MM-dd HH:mm:ss格式 + */ + private String reporttime; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherTO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherTO.java new file mode 100644 index 0000000..4b1ae3a --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/TO/WeatherTO.java @@ -0,0 +1,23 @@ +package com.smartlive.bswatch.TO; + +import lombok.Data; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/6/10 + */ +@Data +public class WeatherTO { + //"status": "1", + // "count": "1", + // "info": "OK", + // "infocode": "10000", + private String status; + private String count; + private String info; + private String infocode; + private List forecasts; + private List lives; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/annotation/BindValidateAno.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/annotation/BindValidateAno.java new file mode 100644 index 0000000..1ea24b5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/annotation/BindValidateAno.java @@ -0,0 +1,35 @@ +package com.smartlive.bswatch.annotation; + +/** + * @author:lilj + * @date:2025/2/12 + */ + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 设备绑定校验注解 + */ +@Target(java.lang.annotation.ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface BindValidateAno { + /** + * 方法名 + * @return + */ + String methodName() default ""; + + /** + * 服务名 + * @return + */ + String serviceName() default ""; + + /** + * 业务名称 + * @return + */ + String bizName() default ""; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/aop/BindValidAop.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/aop/BindValidAop.java new file mode 100644 index 0000000..7c8fe9a --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/aop/BindValidAop.java @@ -0,0 +1,99 @@ +package com.smartlive.bswatch.aop; + +import com.smartlive.bswatch.annotation.BindValidateAno; +import com.smartlive.common.enums.WatchReturnMessage; +import com.smartlive.bswatch.entity.WatchDevice; +import com.smartlive.bswatch.service.CommonService; +import com.smartlive.bswatch.vo.controllerVO.CommonVO; +import com.smartlive.common.exception.ServiceException; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @author:lilj + * @date:2025/2/12 + */ +@Slf4j +@Aspect +@Component +public class BindValidAop { + @Autowired + private CommonService commonService; + + /** + * 切入点表达式:表示匹配带有注解BindValidateAno的方法 + */ + @Pointcut("@annotation(com.smartlive.bswatch.annotation.BindValidateAno)") + public void pointcut() { + } + + /** + * 环绕通知 + * @param joinPoint + * @return + * @throws Throwable + */ + @Around("pointcut()") + public Object around(ProceedingJoinPoint joinPoint) throws Throwable { + // 获取注解携带参数 + long startTime = System.currentTimeMillis(); + MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); + BindValidateAno bindValidateAno = methodSignature.getMethod().getAnnotation(BindValidateAno.class); + Object result= null; + if(bindValidateAno==null){ + log.info("方法:{}没有注解BindValidateAno,直接放行",methodSignature.getName()); + result= joinPoint.proceed(); + long endTime = System.currentTimeMillis(); + log.info("方法:{}执行时间:{}ms",methodSignature.getName(),endTime-startTime); + return result; + } + + // 解析注解参数 + String serviceName = bindValidateAno.serviceName(); + String methodName = bindValidateAno.methodName(); + String bizName = bindValidateAno.bizName(); + log.info("服务类:{} 方法:{} 注解参数:serviceName:{},methodName:{},bizName:{}",methodSignature.getName(),serviceName,methodName,bizName); + + // 获取方法参数 + Object[] args = joinPoint.getArgs(); + if(args==null || args.length==0){ + log.info("方法:{}没有参数,直接放行",methodSignature.getName()); + result= joinPoint.proceed(); + long endTime = System.currentTimeMillis(); + log.info("方法:{}执行时间:{}ms",methodSignature.getName(),endTime-startTime); + return result; + } + + Object param = args[0]; + if(param==null){ + log.info("方法:{}参数为空,直接放行",methodSignature.getName()); + result= joinPoint.proceed(); + long endTime = System.currentTimeMillis(); + log.info("方法:{}执行时间:{}ms",methodSignature.getName(),endTime-startTime); + } + + if(param instanceof CommonVO){ + CommonVO commonVO = (CommonVO) param; + // 执行逻辑 + // 查询数据库检验有无绑定设备 + String empNo = commonVO.getEmpNo(); + WatchDevice watchDevice = commonService.getWatchDeviceByEmpNo(empNo,commonVO.getWatchSign()); + if(watchDevice==null || watchDevice.getWatchSign()==null){ + log.info("员工编号:{}未绑定设备,抛出EMPLOYEE_UNBIND_DEVICE异常,不执行后续操作",empNo); + throw new ServiceException(WatchReturnMessage.EMPLOYEE_UNBIND_DEVICE); + } + } + + result = joinPoint.proceed(); + long endTime = System.currentTimeMillis(); + log.info("方法:{}执行时间:{}ms",methodSignature.getName(),endTime-startTime); + return result; + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/component/AlipayUtil.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/component/AlipayUtil.java new file mode 100644 index 0000000..d2fb908 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/component/AlipayUtil.java @@ -0,0 +1,192 @@ +package com.smartlive.bswatch.component; + +import com.alibaba.fastjson2.JSON; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeAppPayModel; +import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.request.AlipayTradeAppPayRequest; +import com.alipay.api.request.AlipayTradePagePayRequest; +import com.alipay.api.request.AlipayTradeQueryRequest; +import com.alipay.api.request.AlipayTradeRefundRequest; +import com.alipay.api.response.AlipayTradeAppPayResponse; +import com.alipay.api.response.AlipayTradePagePayResponse; +import com.alipay.api.response.AlipayTradeQueryResponse; +import com.alipay.api.response.AlipayTradeRefundResponse; +import com.smartlive.bswatch.config.AlipayConfig; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +@Slf4j +@Component +public class AlipayUtil { + + @Autowired + private AlipayConfig alipayConfig; + + private AlipayClient alipayClient; + + /** + * 获取支付宝客户端 + */ + private AlipayClient getAlipayClient() { + if (alipayClient == null) { + alipayClient = new DefaultAlipayClient( + alipayConfig.getGateway(), + alipayConfig.getAppId(), + alipayConfig.getPrivateKey(), + alipayConfig.getFormat(), + alipayConfig.getCharset(), + alipayConfig.getPublicKey(), + alipayConfig.getSignType() + ); + } + return alipayClient; + } + + /** + * 创建支付宝支付订单 + */ + public String createOrder(String outTradeNo, String subject, + BigDecimal totalAmount, String body) throws AlipayApiException { + + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + + // 设置异步回调地址 + request.setNotifyUrl(alipayConfig.getNotifyUrl()); + + + // 设置业务参数 + // 设置业务参数 + AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); + model.setOutTradeNo(outTradeNo); + model.setSubject(subject); + model.setBody(body); + model.setTotalAmount(totalAmount.toString()); + model.setProductCode(alipayConfig.getProductCode()); + model.setTimeoutExpress(alipayConfig.getTimeoutExpress()); + + request.setBizModel(model); + + + // 生成支付订单信息 + AlipayTradeAppPayResponse response = getAlipayClient().sdkExecute(request); + + if (response.isSuccess()) { + log.info("支付宝APP支付订单创建成功,订单号:{}", outTradeNo); + return response.getBody(); + } else { + log.error("支付宝支付订单创建失败: {}", response.getSubMsg()); + throw new AlipayApiException(response.getSubMsg()); + } + } + + /** + * 查询支付宝订单 + */ + public Map queryOrder(String outTradeNo) throws AlipayApiException { + AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); + + Map bizContent = new HashMap<>(); + bizContent.put("out_trade_no", outTradeNo); + request.setBizContent(JSON.toJSONString(bizContent)); + + AlipayTradeQueryResponse response = getAlipayClient().execute(request); + + Map result = new HashMap<>(); + if (response.isSuccess()) { + result.put("tradeStatus", response.getTradeStatus()); + result.put("tradeNo", response.getTradeNo()); + result.put("totalAmount", response.getTotalAmount()); + result.put("buyerUserId", response.getBuyerUserId()); + result.put("buyerLogonId", response.getBuyerLogonId()); + } else { + result.put("errorMsg", response.getSubMsg()); + } + + return result; + } + + /** + * 支付宝退款 + */ + public boolean refund(String outTradeNo, String refundAmount, + String refundReason) throws AlipayApiException { + + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + + Map bizContent = new HashMap<>(); + bizContent.put("out_trade_no", outTradeNo); + bizContent.put("refund_amount", refundAmount); + bizContent.put("refund_reason", refundReason); + + request.setBizContent(JSON.toJSONString(bizContent)); + + AlipayTradeRefundResponse response = getAlipayClient().execute(request); + + return response.isSuccess(); + } + + /** + * 验证支付宝回调签名 + */ + public boolean verifyCallback(HttpServletRequest request) { + try { + // 获取支付宝POST过来的反馈信息 + Map params = new HashMap<>(); + Map requestParams = request.getParameterMap(); + + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { + String name = iter.next(); + String[] values = requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; + } + params.put(name, valueStr); + } + + // 验证签名 + boolean signVerified = AlipaySignature.rsaCheckV1( + params, + alipayConfig.getPublicKey(), + alipayConfig.getCharset(), + alipayConfig.getSignType() + ); + + return signVerified; + + } catch (AlipayApiException e) { + log.error("支付宝回调签名验证失败", e); + return false; + } + } + + /** + * 处理支付宝回调参数 + */ + public Map processCallbackParams(HttpServletRequest request) { + Map params = new HashMap<>(); + + // 获取所有参数 + Map requestParams = request.getParameterMap(); + for (String key : requestParams.keySet()) { + String[] values = requestParams.get(key); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; + } + params.put(key, valueStr); + } + + return params; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/component/WechatPayUtil.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/component/WechatPayUtil.java new file mode 100644 index 0000000..ae6ddf3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/component/WechatPayUtil.java @@ -0,0 +1,225 @@ +package com.smartlive.bswatch.component; + +import com.smartlive.bswatch.config.WechatPayConfig; +import com.wechat.pay.java.core.Config; +import com.wechat.pay.java.core.RSAAutoCertificateConfig; +import com.wechat.pay.java.service.payments.app.AppService; +import com.wechat.pay.java.service.payments.app.model.Amount; +import com.wechat.pay.java.service.payments.app.model.PrepayRequest; +import com.wechat.pay.java.service.payments.app.model.PrepayResponse; +import com.wechat.pay.java.service.payments.model.Transaction; +import com.wechat.pay.java.core.notification.NotificationConfig; +import com.wechat.pay.java.core.notification.NotificationParser; +import com.wechat.pay.java.core.notification.RequestParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.math.BigDecimal; +import java.util.*; + +@Slf4j +@Component +public class WechatPayUtil { + + @Autowired + private WechatPayConfig wechatAppConfig; + + private AppService appService; + + private NotificationParser notificationParser; + + /** + * 获取微信APP支付服务 + */ + private AppService getAppService() { + if (appService == null) { + Config config = new RSAAutoCertificateConfig.Builder() + .merchantId(wechatAppConfig.getMchId()) + .privateKey(wechatAppConfig.getPrivateKey()) + .merchantSerialNumber(wechatAppConfig.getMchSerialNo()) + .apiV3Key(wechatAppConfig.getApiV3Key()) + .build(); + appService = new AppService.Builder().config(config).build(); + } + return appService; + } + + /** + * 获取通知解析器 + */ + private NotificationParser getNotificationParser() { + if (notificationParser == null) { + NotificationConfig config = new RSAAutoCertificateConfig.Builder() + .merchantId(wechatAppConfig.getMchId()) + .privateKey(wechatAppConfig.getPrivateKey()) + .merchantSerialNumber(wechatAppConfig.getMchSerialNo()) + .apiV3Key(wechatAppConfig.getApiV3Key()) + .build(); + notificationParser = new NotificationParser(config); + } + return notificationParser; + } + + /** + * 创建微信APP支付订单 + */ + public Map createAppOrder(String outTradeNo, String description, + BigDecimal totalAmount) throws Exception { + + AppService service = getAppService(); + + PrepayRequest request = new PrepayRequest(); + request.setAppid(wechatAppConfig.getAppId()); + request.setMchid(wechatAppConfig.getMchId()); + request.setDescription(description); + request.setOutTradeNo(outTradeNo); + request.setNotifyUrl(wechatAppConfig.getNotifyUrl()); + + // 设置金额(单位:分) + Amount amount = new Amount(); + amount.setTotal(totalAmount.multiply(new BigDecimal("100")).intValue()); + request.setAmount(amount); + + // 调用预支付API + PrepayResponse response = service.prepay(request); + + // 生成调起微信APP的参数 + return generateAppPayParams(response.getPrepayId()); + } + + /** + * 生成调起微信APP支付的参数 + */ + private Map generateAppPayParams(String prepayId) { + Map params = new HashMap<>(); + + String appId = wechatAppConfig.getAppId(); + String partnerId = wechatAppConfig.getMchId(); + String nonceStr = generateNonceStr(); + String timeStamp = String.valueOf(System.currentTimeMillis() / 1000); + String packageValue = "Sign=WXPay"; + + // 构造签名参数 + params.put("appid", appId); + params.put("partnerid", partnerId); + params.put("prepayid", prepayId); + params.put("package", packageValue); + params.put("noncestr", nonceStr); + params.put("timestamp", timeStamp); + + // 生成签名 + String sign = generateSign(params); + params.put("sign", sign); + + return params; + } + + /** + * 生成签名(V3版本使用RSA签名) + */ + private String generateSign(Map params) { + try { + // 构造签名字符串 + List keys = new ArrayList<>(params.keySet()); + Collections.sort(keys); + + StringBuilder signStr = new StringBuilder(); + for (String key : keys) { + if ("sign".equals(key)) { + continue; + } + String value = params.get(key); + if (value != null && !value.trim().isEmpty()) { + signStr.append(key).append("=").append(value).append("&"); + } + } + + if (signStr.length() > 0) { + signStr.setLength(signStr.length() - 1); + } + + log.debug("微信APP支付签名字符串:{}", signStr.toString()); + + // 使用RSA签名 + java.security.PrivateKey privateKey = loadPrivateKey(wechatAppConfig.getPrivateKey()); + java.security.Signature signature = java.security.Signature.getInstance("SHA256withRSA"); + signature.initSign(privateKey); + signature.update(signStr.toString().getBytes("UTF-8")); + + byte[] signBytes = signature.sign(); + return Base64.getEncoder().encodeToString(signBytes); + + } catch (Exception e) { + log.error("生成微信APP支付签名失败", e); + throw new RuntimeException("生成签名失败"); + } + } + + /** + * 加载私钥 + */ + private java.security.PrivateKey loadPrivateKey(String privateKeyContent) throws Exception { + String privateKeyPEM = privateKeyContent + .replace("-----BEGIN PRIVATE KEY-----", "") + .replace("-----END PRIVATE KEY-----", "") + .replaceAll("\\s+", ""); + + byte[] keyBytes = Base64.getDecoder().decode(privateKeyPEM); + java.security.spec.PKCS8EncodedKeySpec keySpec = + new java.security.spec.PKCS8EncodedKeySpec(keyBytes); + java.security.KeyFactory keyFactory = java.security.KeyFactory.getInstance("RSA"); + return keyFactory.generatePrivate(keySpec); + } + + /** + * 生成随机字符串 + */ + private String generateNonceStr() { + return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32); + } + + /** + * 处理微信支付回调 + */ + public Transaction handleNotify(HttpServletRequest httpRequest) { + try { + // 构建请求参数 + RequestParam requestParam = new RequestParam.Builder() + .serialNumber(httpRequest.getHeader("Wechatpay-Serial")) + .nonce(httpRequest.getHeader("Wechatpay-Nonce")) + .signature(httpRequest.getHeader("Wechatpay-Signature")) + .timestamp(httpRequest.getHeader("Wechatpay-Timestamp")) + .signType(httpRequest.getHeader("Wechatpay-Signature-Type")) + .body(getRequestBody(httpRequest)) + .build(); + + // 验证签名并解析通知 + NotificationParser parser = getNotificationParser(); + return parser.parse(requestParam, Transaction.class); + + } catch (Exception e) { + log.error("处理微信支付回调失败", e); + throw new RuntimeException("处理微信支付回调失败:" + e.getMessage()); + } + } + + /** + * 获取请求体 + */ + private String getRequestBody(HttpServletRequest request) { + StringBuilder stringBuilder = new StringBuilder(); + try (BufferedReader reader = request.getReader()) { + String line; + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + } + } catch (Exception e) { + log.error("读取请求体失败", e); + } + return stringBuilder.toString(); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/config/AlipayConfig.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/AlipayConfig.java new file mode 100644 index 0000000..07fd5e5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/AlipayConfig.java @@ -0,0 +1,45 @@ +package com.smartlive.bswatch.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Data +@Component +@ConfigurationProperties(prefix = "alipay") +public class AlipayConfig { + + // 应用ID + private String appId; + + // 商户私钥 + private String privateKey; + + // 支付宝公钥 + private String publicKey; + + // 支付宝网关 + private String gateway = "https://openapi.alipay.com/gateway.do"; + + // 编码格式 + private String charset = "UTF-8"; + + // 签名算法类型 + private String signType = "RSA2"; + + // 异步通知地址 + private String notifyUrl; + + // 格式 + private String format = "json"; + + // 超时时间(分钟) + private String timeoutExpress = "30m"; + + /** + * 获取产品码 + */ + public String getProductCode() { + return "QUICK_MSECURITY_PAY"; // APP支付产品码 + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/config/ApiEntityMap.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/ApiEntityMap.java new file mode 100644 index 0000000..cdc194f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/ApiEntityMap.java @@ -0,0 +1,32 @@ +package com.smartlive.bswatch.config; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +import com.smartlive.bswatch.enmus.WatchApiEnum; +import com.smartlive.bswatch.netty.watchvo.resp.commonResp.ErrorResp; +import com.smartlive.bswatch.netty.watchvo.resp.deviceResp.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * Api名称与实体类class对象映射关系 + */ +public class ApiEntityMap { + public static Map map = new HashMap<>(); + static { + map.put(WatchApiEnum.LOGIN.getApiName(), LoginResp.class); + map.put(WatchApiEnum.GET_BUTTON.getApiName(), NormalButtonResp.class); + map.put(WatchApiEnum.GET_INCOME_CALL.getApiName(), IncomeCallResp.class); + map.put(WatchApiEnum.GET_CLASS_MODEL.getApiName(), ClassModelResp.class); + map.put(WatchApiEnum.GET_STUDENT_INFO.getApiName(), StudentInfoResp.class); + map.put(WatchApiEnum.ERROR_RESP.getApiName(), ErrorResp.class); + + map.put(WatchApiEnum.SET_REDAY_MODE.getApiName(), SetRedayModeResp.class); + map.put(WatchApiEnum.SET_LOCATION_MODE.getApiName(), SetLocationModelResp.class); + + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/config/TestConfig.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/TestConfig.java new file mode 100644 index 0000000..36f3159 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/TestConfig.java @@ -0,0 +1,17 @@ +package com.smartlive.bswatch.config; + +import com.alibaba.fastjson2.JSONObject; +import lombok.Data; +import org.springframework.stereotype.Component; + +/** + * @author:lilj + * @date:2025/1/20 + */ +public class TestConfig { + + // 通过接口控制实际响应数据 + public static boolean realResp = true; + public static Object paramObject; + public static String bizType; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/config/WechatPayConfig.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/WechatPayConfig.java new file mode 100644 index 0000000..6839978 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/config/WechatPayConfig.java @@ -0,0 +1,72 @@ +package com.smartlive.bswatch.config; + + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Data +@Component +@ConfigurationProperties(prefix = "wechat.app") +public class WechatPayConfig { + // 应用ID(APP) + private String appId; + + // 商户号 + private String mchId; + + // API v3密钥(32位) + private String apiV3Key; + + // 商户证书序列号 + private String mchSerialNo; + + // 商户私钥文件路径(PKCS8格式) + private String privateKeyPath; + + // 私钥内容(二选一) + private String privateKeyContent; + + // 异步通知地址 + private String notifyUrl; + + // 交易类型 + private String tradeType = "APP"; // APP支付固定为APP + + // 签名类型 + private String signType = "RSA"; + + // 是否使用沙箱环境 + private boolean sandbox = false; + + // 沙箱API密钥 + private String sandboxApiKey; + + /** + * 获取商户私钥 + */ + public String getPrivateKey() { + if (privateKeyContent != null && !privateKeyContent.trim().isEmpty()) { + return privateKeyContent.trim(); + } + + if (privateKeyPath != null && !privateKeyPath.trim().isEmpty()) { + try { + java.nio.file.Path path = java.nio.file.Paths.get(privateKeyPath); + if (!java.nio.file.Files.exists(path)) { + // 尝试从classpath加载 + path = java.nio.file.Paths.get( + Thread.currentThread().getContextClassLoader() + .getResource(privateKeyPath).toURI() + ); + } + return new String(java.nio.file.Files.readAllBytes(path)).trim(); + } catch (Exception e) { + throw new RuntimeException("读取微信支付私钥文件失败", e); + } + } + + throw new RuntimeException("微信支付私钥未配置"); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/AddressController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/AddressController.java new file mode 100644 index 0000000..a4a020f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/AddressController.java @@ -0,0 +1,85 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.entity.Address; +import com.smartlive.bswatch.service.AddressService; +import com.smartlive.common.core.controller.BaseController; +import com.smartlive.common.core.domain.AjaxResult; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/address") +public class AddressController extends BaseController { + + @Resource + private AddressService addressService; + + /** + * 添加地址 + */ + @PostMapping("/add") + public AjaxResult addAddress(@Valid @RequestBody Address address) { + boolean result = addressService.addAddress(address); + if (result) { + return success("地址添加成功"); + } + return error("地址添加失败"); + } + + /** + * 修改地址 + */ + @PostMapping("/update") + public AjaxResult updateAddress(@Valid @RequestBody Address address) { + boolean result = addressService.updateAddress(address); + if (result) { + return success("地址修改成功"); + } + return error("地址修改失败"); + } + + /** + * 删除地址 + */ + @RequestMapping("/delete") + public AjaxResult deleteAddress(@RequestParam Long addressId) { + boolean result = addressService.deleteAddress(addressId); + if (result) { + return success("地址删除成功"); + } + return error("地址删除失败"); + } + + /** + * 获取用户地址列表 + */ + @GetMapping("/list") + public AjaxResult getAddressList(@RequestParam Long userId) { + List
addressList = addressService.getAddressList(userId); + return success(addressList); + } + + /** + * 设置默认地址 + */ + @GetMapping("/setDefault") + public AjaxResult setDefaultAddress(@RequestParam Long addressId, @RequestParam Long userId) { + boolean result = addressService.setDefaultAddress(addressId, userId); + if (result) { + return success("默认地址设置成功"); + } + return error("默认地址设置失败"); + } + + /** + * 获取用户默认地址 + */ + @GetMapping("/default") + public AjaxResult getDefaultAddress(@RequestParam Long userId) { + Address defaultAddress = addressService.getDefaultAddress(userId); + return success(defaultAddress); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/AppPaymentController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/AppPaymentController.java new file mode 100644 index 0000000..1021178 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/AppPaymentController.java @@ -0,0 +1,159 @@ +package com.smartlive.bswatch.controller.common; + + +import com.smartlive.bswatch.TO.PayRequestTO; +import com.smartlive.bswatch.service.AlipayService; +import com.smartlive.bswatch.service.WechatService; +import com.smartlive.common.core.domain.AjaxResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/pay") + +public class AppPaymentController { + + @Resource + private AlipayService alipayService; + + @Resource + private WechatService wechatService; + + /** + * APP支付统一下单接口 + */ + @PostMapping("/create") + public AjaxResult createPayOrder(@Validated @RequestBody PayRequestTO request) { + log.info("收到APP支付请求:{}", request); + + + try { + Map result; + + // 根据支付类型调用不同服务 + if (1==request.getPayType()) { + // 支付宝APP支付 + result = alipayService.createAlipayAppOrder( + request.getUserId(), + request.getWatchId(), + request.getMoney(), + request.getNum(), + request.getAddressId() + ); + + if (Boolean.TRUE.equals(result.get("success"))) { + String message = (String) result.get("message"); + String orderInfo = (String) result.get("alipayOrderInfo"); + return AjaxResult.success(message, orderInfo); + + } else { + String message = (String) result.get("message"); + return AjaxResult.error(message); + } + + } else if (2==request.getPayType()) { + // 微信APP支付 + result = wechatService.createWechatAppOrder( + request.getUserId(), + request.getWatchId(), + request.getMoney(), + request.getNum(), + request.getAddressId() + ); + + if (Boolean.TRUE.equals(result.get("success"))) { + @SuppressWarnings("unchecked") + Map payParams = (Map) result.get("payParams"); + String message = (String) result.get("message"); + return AjaxResult.success(message, payParams); + } else { + String message = (String) result.get("message"); + return AjaxResult.error(message); + } + + } else { + return AjaxResult.error("不支持的支付类型"); + } + + } catch (Exception e) { + log.error("创建APP支付订单失败", e); + return AjaxResult.error("创建APP支付订单失败"); + } + + } + + /** + * 支付宝APP支付回调通知 + */ + @PostMapping("/notify/alipay") + public String alipayNotify(HttpServletRequest request, HttpServletResponse httpResponse) { + log.info("接收支付宝APP支付异步通知"); + + try { + String result = alipayService.handleAlipayNotify(request); + + // 设置响应 + if ("success".equals(result)) { + httpResponse.setStatus(200); + } else { + httpResponse.setStatus(500); + } + + return result; + + } catch (Exception e) { + log.error("处理支付宝回调异常", e); + httpResponse.setStatus(500); + return "failure"; + } + } + + /** + * 微信APP支付回调通知 + */ + @PostMapping("/notify/wechat") + public String wechatNotify(HttpServletRequest request, HttpServletResponse httpResponse) { + log.info("接收微信APP支付异步通知"); + + try { + String result = wechatService.handleWechatNotify(request); + + // 设置响应 + if (result.contains("SUCCESS")) { + httpResponse.setStatus(200); + } else { + httpResponse.setStatus(500); + } + + return result; + + } catch (Exception e) { + log.error("处理微信支付回调异常", e); + httpResponse.setStatus(500); + return "{\"code\": \"FAIL\", \"message\": \"处理异常\"}"; + } + } + + /** + * APP支付退款 + */ + @PostMapping("/refund") + public Map refund(@RequestParam String orderNo, + @RequestParam BigDecimal refundAmount, + @RequestParam String refundReason) { + log.info("APP支付退款,订单号:{},退款金额:{}", orderNo, refundAmount); + + // 这里需要根据订单号判断支付渠道 + // 简化处理,先调用支付宝退款 + return alipayService.refund(orderNo, refundAmount, refundReason); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/HealthReportController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/HealthReportController.java new file mode 100644 index 0000000..ef84185 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/HealthReportController.java @@ -0,0 +1,43 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.entity.WatchHealthReport; +import com.smartlive.bswatch.service.IWatchHealthReportService; +import com.smartlive.common.core.domain.AjaxResult; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/watch/report") +public class HealthReportController { + + + @Resource + private IWatchHealthReportService watchHealthReportService; + + @RequestMapping("generate") + public AjaxResult generate(String empNo,String watchSign,String watchName, String startDate, String endDate) { + watchHealthReportService.generateWeeklyReport(empNo,watchName,watchSign, startDate, endDate); + + return AjaxResult.success(); + } + @RequestMapping("getReport") + public AjaxResult getReport(Long reportId) { + WatchHealthReport watchHealthReport = watchHealthReportService.getWeeklyReport(reportId); + + return AjaxResult.success(watchHealthReport); + } + @RequestMapping("getReportHistory") + public AjaxResult getReportHistory(String watchSign, String time) { + return AjaxResult.success(watchHealthReportService.getReportHistory(watchSign, time)); + } + @RequestMapping("batchGenerate") + public AjaxResult batchGenerate(String reportDate) { + watchHealthReportService.batchGenerateWeeklyReports(reportDate); + + return AjaxResult.success(); + } + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/LocationController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/LocationController.java new file mode 100644 index 0000000..b4db705 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/LocationController.java @@ -0,0 +1,62 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchLocationService; +import com.smartlive.common.validator.group.QueryValidate; +import com.smartlive.bswatch.vo.controllerVO.LocationQueryVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.enums.WatchReturnMessage; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author:lilj + * @date:2025/2/13 + */ + +/** + * 实现功能: + * 1. 获取实时定位: 发送实时定位命令; 查询实时定位信息. + * 2. 获取历史轨迹: 发送历史轨迹命令; 查询历史轨迹信息. + */ +@RequestMapping("/watch/location") +@RestController +public class LocationController { + + @Autowired + private IWatchLocationService locationService; + + + @RequestMapping("/sendLocationCommond") + public AjaxResult sendLocationCommond(@Validated(QueryValidate.class) LocationQueryVO locationQueryVO) { + return locationService.sendLocationCommond(locationQueryVO); + } + + /** + * 获取实时定位信息 + */ + @RequestMapping("/getCurrentLocationInfo") + public AjaxResult getCurrentLocationInfo(@Validated(QueryValidate.class) LocationQueryVO locationQueryVO) { + if(locationQueryVO == null|| StringUtils.isBlank(locationQueryVO.getEmpNo())){ + return AjaxResult.error(WatchReturnMessage.EMPNO_NOT_NULL); + } + return locationService.getCurrentLocationInfo(locationQueryVO); + } + + /** + * 获取历史轨迹信息 + */ + @GetMapping("locationTrack") + public AjaxResult locationTrack(@Validated(QueryValidate.class) LocationQueryVO locationQueryVO) { + if(locationQueryVO == null|| StringUtils.isBlank(locationQueryVO.getEmpNo())){ + return AjaxResult.error(WatchReturnMessage.EMPNO_NOT_NULL); + } + return locationService.lcoationTrack(locationQueryVO); + } + + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/SosPhoneController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/SosPhoneController.java new file mode 100644 index 0000000..ed6efa0 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/SosPhoneController.java @@ -0,0 +1,85 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchSosService; +import com.smartlive.common.validator.group.InsertValidate; +import com.smartlive.common.validator.group.UpdateValidate; +import com.smartlive.bswatch.vo.controllerVO.SosPhoneVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/2/10 + */ + + +/** + * sos与白名单电话 + */ +@RequestMapping("/watch/sosPhone") +@RestController +public class SosPhoneController { + @Autowired + private IWatchSosService watchSosService; + + @GetMapping("/list") + public AjaxResult list(SosPhoneVO sosPhoneVo) { + if(sosPhoneVo==null){ + return AjaxResult.error("请指定查询条件"); + } + if(StringUtils.isBlank(sosPhoneVo.getEmpNo())){ + return AjaxResult.error("人员id不能为空"); + } + if(StringUtils.isBlank(sosPhoneVo.getWatchSign())){ + return AjaxResult.error("腕表唯一标识不能为空"); + } + return watchSosService.qeuryByVO(sosPhoneVo); + } + + + // 生成sos的增删改查方法 + @GetMapping("/add") + public AjaxResult add(@Validated(InsertValidate.class) SosPhoneVO sosPhoneVo) { + return watchSosService.saveSosPhone(sosPhoneVo) ? AjaxResult.success() : AjaxResult.error(); + } + + // SOS更新方法 + @GetMapping("/update") + public AjaxResult update(@Validated(UpdateValidate.class) SosPhoneVO sosPhoneVo) { + return watchSosService.updateSosPhone(sosPhoneVo) ? AjaxResult.success() : AjaxResult.error(); + } + + // sos删除方法 + + /** + * 删除sos号码 + * @param id + * @return + */ + @GetMapping("/delete") + public AjaxResult delete(Integer id) { + if(id==null){ + return AjaxResult.error("请指定要删除的sos号码"); + } + List idList = java.util.Arrays.asList(id); + return watchSosService.deleteByIds(idList) ? AjaxResult.success() : AjaxResult.error(); + } + + // sos删除方法 + @GetMapping("/deleteBatch") + public AjaxResult deleteBatch(Integer[] ids) { + if(ids==null || ids.length==0){ + return AjaxResult.error("请指定要删除的sos号码"); + } + List idList = java.util.Arrays.asList(ids); + return watchSosService.deleteByIds(idList) ? AjaxResult.success() : AjaxResult.error(); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchEmpPhoneController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchEmpPhoneController.java new file mode 100644 index 0000000..0f3a3cb --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchEmpPhoneController.java @@ -0,0 +1,72 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchEmpPhoneService; +import com.smartlive.common.validator.group.InsertValidate; +import com.smartlive.common.validator.group.UpdateValidate; +import com.smartlive.bswatch.vo.controllerVO.WatchEmpPhoneVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author:lilj + * @date:2025/2/10 + */ + +@RequestMapping("watch/empPhone") +@RestController +public class WatchEmpPhoneController { + @Autowired + private IWatchEmpPhoneService empPhoneService; + + /** + * 查询亲情电话话信息 + * + * @param empPhoneVO + * @return + */ + @RequestMapping("selectEmpPhone") + public AjaxResult selectEmpPhone(WatchEmpPhoneVO empPhoneVO) { + if(empPhoneVO==null){ + return AjaxResult.error("请指定查询条件"); + } + if(StringUtils.isBlank(empPhoneVO.getEmpNo())){ + return AjaxResult.error("人员id不能为空"); + } + if(StringUtils.isBlank(empPhoneVO.getWatchSign())){ + return AjaxResult.error("腕表唯一标识不能为空"); + } + return empPhoneService.selectEmpPhone(empPhoneVO); + } + + /** + * 设置为亲情电话 + */ + @GetMapping("updateEmpPhone") + public AjaxResult updateEmphone(@Validated(UpdateValidate.class) WatchEmpPhoneVO empPhoneVO){ + return empPhoneService.updateEmphone(empPhoneVO); + } + + /** + * 新增亲情电话 + */ + @GetMapping("addEmpPhone") + public AjaxResult addEmpPhone(@Validated(InsertValidate.class) WatchEmpPhoneVO empPhoneVO){ + return empPhoneService.addEmpPhone(empPhoneVO); + } + + /** + * 删除亲情电话 + */ + @GetMapping("delete") + public AjaxResult delete(Integer id){ + return empPhoneService.deleteById(id); + } + + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchFenceController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchFenceController.java new file mode 100644 index 0000000..dfc7dd3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchFenceController.java @@ -0,0 +1,88 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchFenceService; +import com.smartlive.common.validator.group.InsertValidate; +import com.smartlive.common.validator.group.UpdateValidate; +import com.smartlive.bswatch.vo.controllerVO.WatchFenceVO; +import com.smartlive.common.core.domain.AjaxResult; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Arrays; +import java.util.List; + +/** + * @author:lilj + * @date:2025/2/13 + */ + +/** + * 腕表电子围栏 + */ +@RequestMapping("/watch/fence") +@RestController +public class WatchFenceController { + @Autowired + private IWatchFenceService watchFenceService; + + /** + * 查询电子围栏 + */ + @GetMapping("/list") + public AjaxResult fenceList(WatchFenceVO fenceVO) { + if(fenceVO==null){ + return AjaxResult.error("请指定查询的参数"); + } + if(StringUtils.isBlank(fenceVO.getEmpNo())){ + return AjaxResult.error("人员id不能为空"); + } + if(StringUtils.isBlank(fenceVO.getWatchSign())){ + return AjaxResult.error("腕表唯一标识不能为空"); + } + return watchFenceService.listVO(fenceVO); + } + + /** + * 增删改查 + */ + @GetMapping("/add") + public AjaxResult addFence(@Validated(InsertValidate.class) WatchFenceVO fenceVO) { + return watchFenceService.saveVO(fenceVO); + } + + /** + * 更新电子围栏 + */ + @GetMapping("/update") + public AjaxResult updateFence(@Validated(UpdateValidate.class) WatchFenceVO fenceVO) { + return watchFenceService.updateVO(fenceVO); + } + + /** + * 删除电子围栏 + */ + @GetMapping("/delete") + public AjaxResult deleteFence(Long id) { + if(id==null){ + return AjaxResult.error("请指定要删除的电子围栏"); + } + return watchFenceService.delete(id); + } + + /** + * 批量删除电子围栏 + */ + @GetMapping("/deleteBatch") + public AjaxResult deleteFence(Long[] ids) { + if(ids==null || ids.length==0){ + return AjaxResult.error("请指定要删除的电子围栏"); + } + List idList = Arrays.asList(ids); + return watchFenceService.deleteBatch(idList); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchHealthController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchHealthController.java new file mode 100644 index 0000000..f650792 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchHealthController.java @@ -0,0 +1,58 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchHealthService; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author:lilj + * @date:2025/2/14 + */ + +/** + * 腕表健康数据查询 + */ +@RequestMapping("/watch/health") +@RestController +public class WatchHealthController { + + @Autowired + private IWatchHealthService watchHealthService; + + + @GetMapping("/heart") + public AjaxResult heartRate(@Validated HealthQueryVO healthQueryVO){ + return watchHealthService.queryHeartBeat(healthQueryVO); + } + + @GetMapping("/temperature") + public AjaxResult temperature(@Validated HealthQueryVO healthQueryVO){ + return watchHealthService.queryTemperature(healthQueryVO); + } + + @GetMapping("/bloodOxy") + public AjaxResult bloodOxy(@Validated HealthQueryVO healthQueryVO){ + return watchHealthService.queryBloodOxy(healthQueryVO); + } + + @GetMapping("/step") + public AjaxResult selectStep(@Validated HealthQueryVO healthQueryVO) { + return watchHealthService.queryStep(healthQueryVO); + } + + @GetMapping("/pressure") + public AjaxResult selectPressure(@Validated HealthQueryVO healthQueryVO) { + return watchHealthService.queryPressure(healthQueryVO); + } + + @GetMapping("/sleep") + public AjaxResult selectSleep(@Validated HealthQueryVO healthQueryVO) { + return watchHealthService.querySleep(healthQueryVO); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchSetController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchSetController.java new file mode 100644 index 0000000..ddc2b14 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchSetController.java @@ -0,0 +1,125 @@ +package com.smartlive.bswatch.controller.common; + +/** + * @author:lilj + * @date:2025/2/14 + */ + +import com.smartlive.bswatch.costant.WatchConstant; +import com.smartlive.bswatch.service.IWatchSkipService; +import com.smartlive.bswatch.service.IWatchDeviceService; +import com.smartlive.bswatch.vo.controllerVO.WatchDeviceVO; +import com.smartlive.bswatch.vo.controllerVO.WatchSkipVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.validator.group.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotBlank; + +/** + * 腕表模式设置: + */ + +@RequestMapping("/watch/set") +@RestController +public class WatchSetController { + + /** + * 查询当前腕表的模式信息 + */ + + @Autowired + private IWatchDeviceService watchDeviceService; + + @Autowired + private IWatchSkipService watchSkipService; + + + /** + * 设备当前信息 + * @param watchSign + * @return + */ + @RequestMapping("/watchInfo") + public AjaxResult queryWatchMode(@NotBlank String watchSign){ + return watchDeviceService.queryWatchInfo(watchSign); + } + + + /** + * 设备绑定信息修改: + * 1.设备唯一标识 + * 2. empNo + * 3. 手机号信息修改 + */ + @RequestMapping("/bindDevice") + public AjaxResult bindDevice(@Validated(WatchBindGroup.class) WatchDeviceVO watchDeviceVO){ + return watchDeviceService.bindDevice(watchDeviceVO); + } + + /** + * 腕表解绑 + */ + @GetMapping("/unbindDevice") + public AjaxResult unbindDevice(@NotBlank String empNo,@NotBlank String watchSign){ + return watchDeviceService.unbindDevice(empNo,watchSign); + } + + /** + * 腕表模式切换 + */ + @GetMapping("/modeChange") + public AjaxResult modeChange(@Validated(WatchModeChangeGroup.class) WatchDeviceVO watchDeviceVO){ + return watchDeviceService.modeChange(watchDeviceVO); + } + + /** + * 腕表待机模式时间段设置 + */ + @GetMapping("/setRedayTime") + public AjaxResult setRedayTime(@Validated(RedayModeGroup.class) WatchDeviceVO watchDeviceVO){ + watchDeviceVO.setWatchMode(WatchConstant.WATCH_MODE_REDAY); + // 参数处理: + String start = watchDeviceVO.getStartTime().replaceAll(":", ""); + String end = watchDeviceVO.getEndTime().replaceAll(":", ""); + watchDeviceVO.setRedayTime(start + "-" + end); + return watchDeviceService.modeChange(watchDeviceVO); + } + + /** + * 腕表定位信息上传频率设置 + */ + @GetMapping("/setLocationFreq") + public AjaxResult setLocationFreq(@Validated(LocationFreqGroup.class) WatchDeviceVO watchDeviceVO){ + return watchDeviceService.setLocationFreq(watchDeviceVO); + } + + + /** + * 查询蓝牙跳绳信息 + */ + @GetMapping("/querySkip") + public AjaxResult querySkip(@NotBlank(message = "人员编号不能为空") String empNo,@NotBlank(message = "设备唯一标识不能为空") String watchSign){ + return watchSkipService.querySkip(empNo,watchSign); + } + + /** + * 绑定跳绳 + */ + @PostMapping("/bindSkip") + public AjaxResult bindSkip(@Validated(InsertValidate.class) @RequestBody WatchSkipVO watchSkipVO){ + return watchSkipService.bindSkip(watchSkipVO); + } + + + /** + * 解绑跳绳 + */ + @GetMapping("/unbindSkip") + public AjaxResult unbindSkip(@NotBlank(message = "人员编号不能为空") String empNo,@NotBlank(message = "设备唯一标识不能为空") String watchSign){ + return watchSkipService.unbindSkip(empNo,watchSign); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchWarnController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchWarnController.java new file mode 100644 index 0000000..68a9df3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchWarnController.java @@ -0,0 +1,26 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchWarnService; +import com.smartlive.bswatch.vo.controllerVO.WatchWarnVO; +import com.smartlive.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author:lilj + * @date:2025/2/13 + */ +@RequestMapping("/watch/warn") +@RestController +public class WatchWarnController { + @Autowired + private IWatchWarnService watchWarnService; + + @GetMapping("/list") + public AjaxResult warnList(@Validated WatchWarnVO watchWarnVO) { + return watchWarnService.queryVO(watchWarnVO); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchWhiteController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchWhiteController.java new file mode 100644 index 0000000..2e388d6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/common/WatchWhiteController.java @@ -0,0 +1,79 @@ +package com.smartlive.bswatch.controller.common; + +import com.smartlive.bswatch.service.IWatchWhiteService; +import com.smartlive.common.validator.group.InsertValidate; +import com.smartlive.common.validator.group.UpdateValidate; +import com.smartlive.bswatch.vo.controllerVO.WatchWhiteVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/2/11 + */ +@RequestMapping("watch/white") +@RestController +public class WatchWhiteController { + @Autowired + private IWatchWhiteService watchWhiteService; + // 增删改查 + + // 白名单查询 + @RequestMapping("list") + public AjaxResult list(WatchWhiteVO watchWhiteVO) { + if(watchWhiteVO==null){ + return AjaxResult.error("请指定查询条件"); + } + if(StringUtils.isBlank(watchWhiteVO.getEmpNo())){ + return AjaxResult.error("人员id不能为空"); + } + if(StringUtils.isBlank(watchWhiteVO.getWatchSign())){ + return AjaxResult.error("腕表唯一标识不能为空"); + } + return watchWhiteService.queryByVO(watchWhiteVO); + } + + // // 白名单添加 + // @PostMapping("add") + // public AjaxResult add(@Validated(InsertValidate.class) @RequestBody WatchWhitePhoneAddVO watchWhitePhoneAddVO) { + // return watchWhiteService.add(watchWhitePhoneAddVO); + // } + + // 白名单添加 + @PostMapping("addWhitePhone") + public AjaxResult addWhitePhone(@Validated(InsertValidate.class) @RequestBody WatchWhiteVO watchWhiteVO) { + return watchWhiteService.addWhitePhone(watchWhiteVO); + } + + // 白名单修改 + @GetMapping("update") + public AjaxResult update(@Validated(UpdateValidate.class) WatchWhiteVO watchWhiteVO) { + return watchWhiteService.updateWithVO(watchWhiteVO); + } + + // 白名单删除 + @GetMapping("delete") + public AjaxResult delete(Integer id) { + if(id==null){ + return AjaxResult.error("请指定要删除的白名单限制电话"); + } + List idList = java.util.Arrays.asList(id); + return watchWhiteService.removeWithIds(idList); + } + + // 白名单删除 + @GetMapping("deleteBatch") + public AjaxResult deleteBatch(Integer[] ids) { + if(ids==null || ids.length==0){ + return AjaxResult.error("请指定要删除的白名单电话"); + } + List idList = java.util.Arrays.asList(ids); + return watchWhiteService.removeWithIds(idList); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/utilController/CommandController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/utilController/CommandController.java new file mode 100644 index 0000000..9199bb3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/utilController/CommandController.java @@ -0,0 +1,239 @@ +package com.smartlive.bswatch.controller.utilController; + +import com.alibaba.fastjson2.JSONObject; +import com.smartlive.bswatch.enmus.WatchApiEnum; +import com.smartlive.bswatch.utils.WatchMsgSendUtil; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.bswatch.vo.commandVO.*; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.enums.WatchReturnMessage; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@RequestMapping("watch/command") +@RestController +public class CommandController { + + /** + * 设置可呼入号码: + * 默认一周七天,限制白名单以外号码呼入;时间段建表,学校自己设置从学校中取出 + * 删除与添加号码拆分成两个功能. + * 白名单20个号码. + * @param + * @return + * @throws Exception + */ + @RequestMapping("addPhone") + public AjaxResult addPhone(@RequestBody WhitePhoneVO addPhoneVO) throws Exception { + //删除号码@添加号码和时段@呼入限制@周期 + addPhoneVO.setApiName(WatchApiEnum.SET_INCOMING_CALL.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(addPhoneVO); + //向腕表发送指令 + WatchMsgSendUtil.sendCommand(messageVO); + // 接收腕表响应 + String result = WatchMsgSendUtil.getCommandResult(addPhoneVO.getWatchSign(),addPhoneVO.getApiName()); + if ("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_WHITE_PHONE_ERROR.getCode(), WatchReturnMessage.SET_WHITE_PHONE_ERROR.getInfo()); + } + + + @RequestMapping("delPhones") + public AjaxResult delPhones(@RequestBody WhitePhoneVO delPhoneVO) throws Exception { + delPhoneVO.setApiName(WatchApiEnum.SET_INCOMING_CALL.getApiName()); + + // 构建vo: + MessageVO messageVO = WatchMsgSendUtil.buildMsgVO(delPhoneVO); + //向腕表发送指令 + WatchMsgSendUtil.sendCommand(messageVO); + // 接收腕表响应 + String result = WatchMsgSendUtil.getCommandResult(delPhoneVO.getWatchSign(), delPhoneVO.getApiName()); + if ("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_WHITE_PHONE_ERROR.getCode(), WatchReturnMessage.SET_WHITE_PHONE_ERROR.getInfo()); + } + + + @RequestMapping("/setButton") + public AjaxResult setButton(@RequestBody NormalButtonVO normalButtonVO) throws Exception { + normalButtonVO.setApiName(WatchApiEnum.SET_NORMAL_BUTTON.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(normalButtonVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(normalButtonVO.getWatchSign(),normalButtonVO.getApiName()); + if ("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_BUTTON_ERROR.getCode(), WatchReturnMessage.SET_BUTTON_ERROR.getInfo()); + + } + + /** + * 实时位置获取 + * @param currentPositionVO + * @return + * @throws Exception + */ + @RequestMapping("getCurrentPosition") + public AjaxResult getCurrentPosition(@RequestBody CommonNoParamVO currentPositionVO) throws Exception { + currentPositionVO.setApiName(WatchApiEnum.LOCATION_INFO_GET.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(currentPositionVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(currentPositionVO.getWatchSign(),currentPositionVO.getApiName()); + try{ + CurrentPositionRespVO currentPositionRespVO = JSONObject.parseObject(result, CurrentPositionRespVO.class); + if(currentPositionRespVO==null){ + return AjaxResult.error(WatchReturnMessage.GET_POSITION_ERROR.getCode(), WatchReturnMessage.GET_POSITION_ERROR.getInfo()); + } + return AjaxResult.success("获取成功",currentPositionRespVO); + }catch (Exception e){ + return AjaxResult.error(WatchReturnMessage.GET_POSITION_ERROR.getCode(), WatchReturnMessage.GET_POSITION_ERROR.getInfo()); + } + + } + + /** + * 安全防护 + * @param callVO + * @return + * @throws Exception + */ + @RequestMapping("requestCall") + public AjaxResult requestCall(@RequestBody RequestCallVO callVO) throws Exception { + callVO.setApiName(WatchApiEnum.REQUEST_CALL.getApiName()); + callVO.setConrent("1"); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(callVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(callVO.getWatchSign(),callVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("请求成功"); + } + return AjaxResult.error(WatchReturnMessage.REQUEST_CALL_ERROR.getCode(), WatchReturnMessage.REQUEST_CALL_ERROR.getInfo()); + } + + @RequestMapping("frequencyLocationSet") + public AjaxResult frequencyLocationSet(@RequestBody FrequencyLocationVO frequencyLocationVO) throws Exception { + frequencyLocationVO.setApiName(WatchApiEnum.FREQUENCY_LOCATION_SET.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(frequencyLocationVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(frequencyLocationVO.getWatchSign(),frequencyLocationVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.FREQUENCY_LOCATION_SET_ERROR.getCode(), WatchReturnMessage.FREQUENCY_LOCATION_SET_ERROR.getInfo()); + } + + @RequestMapping("setHeartBeat") + public AjaxResult setHeartBeat(@RequestBody HeartBeatVO heartBeatVO) throws Exception { + heartBeatVO.setApiName(WatchApiEnum.SET_HEARTBEAT.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(heartBeatVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(heartBeatVO.getWatchSign(),heartBeatVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_HEARTBEAT_ERROR.getCode(), WatchReturnMessage.SET_HEARTBEAT_ERROR.getInfo()); + + } + + @RequestMapping("setClassModel") + public AjaxResult setClassModel(@RequestBody ClassModelVO classModelVO) throws Exception { + classModelVO.setApiName(WatchApiEnum.SET_CLASS_MODEL.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(classModelVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(classModelVO.getWatchSign(),classModelVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_CLASS_MODEL_ERROR.getCode(), WatchReturnMessage.SET_CLASS_MODEL_ERROR.getInfo()); + } + @RequestMapping("sendSms") + public AjaxResult sendSms(@RequestBody SendSmsVO sendSmsVO) throws Exception { + sendSmsVO.setApiName(WatchApiEnum.SEND_SMS.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(sendSmsVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(sendSmsVO.getWatchSign(),sendSmsVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("发送成功"); + } + return AjaxResult.error(WatchReturnMessage.SEND_SMS_ERROR.getCode(), WatchReturnMessage.SEND_SMS_ERROR.getInfo()); + } + + @RequestMapping("setStudentInfo") + public AjaxResult setStudentInfo(@RequestBody StudentInfoVO studentInfoVO) throws Exception { + studentInfoVO.setApiName(WatchApiEnum.SET_STUDENT_INFO.getApiName()); + // 构建vo: + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(studentInfoVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(studentInfoVO.getWatchSign(),studentInfoVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_STUDENT_INFO_ERROR); + } + + + @RequestMapping("sendTestCommand") + public AjaxResult sendTestCommand(String apiName,String command,String watchSign) throws Exception { + command=command.replaceAll(" ","+"); + if(StringUtils.isBlank(watchSign)){ + return AjaxResult.error("设备IMEI为空"); + } + MessageVO messageVO = WatchMsgSendUtil.buildMsgVO(watchSign,"89860120801609197568",apiName,command); + WatchMsgSendUtil.sendCommand(messageVO); + // 接收腕表响应 + String result = WatchMsgSendUtil.getCommandResult("865593070205859", apiName); + if ("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error("设置失败,请稍后再试"); + } + + + /** + * 设置待机模式 + */ + @RequestMapping("setRedayMode") + public AjaxResult setRedayMode(@RequestBody SetRedayModeVO setRedayModeVO) throws Exception { + setRedayModeVO.setApiName(WatchApiEnum.SET_REDAY_MODE.getApiName()); + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(setRedayModeVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(setRedayModeVO.getWatchSign(),setRedayModeVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_REDAY_MODE_ERROR); + } + + /** + * 设置待机模式 + */ + @RequestMapping("setLoactionMode") + public AjaxResult setLoactionMode(@RequestBody SetLocationModelVO setLocationModelVO) throws Exception { + setLocationModelVO.setApiName(WatchApiEnum.SET_LOCATION_MODE.getApiName()); + MessageVO messageVO =WatchMsgSendUtil.buildMsgVO(setLocationModelVO); + WatchMsgSendUtil.sendCommand(messageVO); + String result = WatchMsgSendUtil.getCommandResult(setLocationModelVO.getWatchSign(),setLocationModelVO.getApiName()); + if("0".equals(result)){ + return AjaxResult.successMsg("设置成功"); + } + return AjaxResult.error(WatchReturnMessage.SET_LOCATION_MODEL_ERROR); + } + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/utilController/UtilController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/utilController/UtilController.java new file mode 100644 index 0000000..a595f2b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/utilController/UtilController.java @@ -0,0 +1,164 @@ +package com.smartlive.bswatch.controller.utilController; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.smartlive.bswatch.config.ApiEntityMap; +import com.smartlive.bswatch.config.TestConfig; +import com.smartlive.bswatch.entity.WatchDevice; +import com.smartlive.bswatch.netty.event.TestEvent; +import com.smartlive.bswatch.netty.publisher.TestPublisher; +import com.smartlive.bswatch.service.CommonService; +import com.smartlive.bswatch.service.IDeviceUploadService; +import com.smartlive.bswatch.utils.CardAesUtil; +import com.smartlive.bswatch.utils.WatchMsgParseUtil; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.common.core.domain.AjaxResult; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@RequestMapping("watch/util") +@RestController +public class UtilController { + @Autowired + private IDeviceUploadService deviceUploadService; + + @Autowired + private TestPublisher testPublisher; + + + @Autowired + private CommonService commonService; + + // 加解密 + @RequestMapping("enAndDe") + public AjaxResult enAndDe(@RequestBody String content) throws Exception { + JSONObject jsonObject = JSON.parseObject(content); + String msg = jsonObject.getString("msg"); + String type = jsonObject.getString("type"); + + if (StringUtils.isBlank(msg)) { + return AjaxResult.error("参数为空"); + } + + if ("en".equals(type)) { + String enStr = new String(CardAesUtil.encryptBsj(msg.getBytes())); + return AjaxResult.success("加密成功", enStr); + } + + if ("de".equals(type)) { + String deStr = CardAesUtil.decryptBsj(msg); + return AjaxResult.success("解密成功", deStr); + } + return AjaxResult.error("参数错误"); + } + + @RequestMapping("/toMsgVO") + public AjaxResult toMsgVO(@RequestBody String msg) throws Exception { + if (StringUtils.isBlank(msg)) { + return AjaxResult.error("参数为空"); + } + JSONObject jsonObject = JSON.parseObject(msg); + msg = jsonObject.getString("msg"); + return AjaxResult.success("转换成功", WatchMsgParseUtil.getMsg(msg)); + } + + @RequestMapping("/modifyParam") + public AjaxResult modifyParam(Map map) throws Exception { + + return AjaxResult.success(); + } + + @RequestMapping("/setConfig") + public AjaxResult setConfig(@RequestBody Map cfg) throws Exception { + TestConfig.realResp = (Boolean) cfg.get("realResp"); + Object paramObject = cfg.get("paramObject"); + TestConfig.bizType = (String) cfg.get("bizType"); + TestConfig.paramObject = JSON.to(ApiEntityMap.map.get(TestConfig.bizType), paramObject); + return AjaxResult.success(cfg); + } + + @RequestMapping("/getSysTime") + public AjaxResult getSysTime() throws Exception { + Date now = new Date(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return AjaxResult.success(format.format(now)); + } + + @RequestMapping("/saveDevice") + public AjaxResult saveDevice(String msg) throws Exception { + String message = "issnCSpq6oIfYo4ig+AFWJuKlhZW8Gi03TCBb/aodbZzCUE9vwwYw/QT30ZhAyRtucs+Zq+gH4/mng30KWqDK0fiz2rU+5s2d70BzLujhAhzdgn/fA6esMT7IiEeNzWfsY/5DpVsx1WSAxG2gL8jeeTEXen0HxCt2rCOZhOLxxw=#kdsjafjalsdjg#170"; + MessageVO messageVO = WatchMsgParseUtil.getMsg(message); + deviceUploadService.login(messageVO); + return AjaxResult.success(); + } + + @RequestMapping("/saveStep") + public AjaxResult saveStep(String msg) throws Exception { + String message = "issnCSpq6oIfYo4ig+AFWJuKlhZW8Gi03TCBb/aodbZjRd/3xafcZnyG75kc4qQdtW2atrrQug/TlLOLWL4aom1WKdkMdzsgpvJ3k6ScA3zwf+z6ky6Qy92HOM69tNs4JTBfzAVL6WnvTgGdeAJDBg==#kdsjafjalsdjg#170"; + MessageVO messageVO = WatchMsgParseUtil.getMsg(message); + deviceUploadService.recordStep(messageVO); + return AjaxResult.success(); + } + + @RequestMapping("/saveHealth") + public AjaxResult saveHealth(String msg) throws Exception { + String message = "issnCSpq6oIfYo4ig+AFWJuKlhZW8Gi03TCBb/aodbZilxhnxd39gWWphBLQVGDsalFYrg22LlGXzYcXAQmFNxhs9A7WuBdh7Jw0057zrNZ32V/52RxyuLbXH4cSDUOsS/Zs2xsiFXuRtcYOGQpvwg==#kdsjafjalsdjg#170"; + MessageVO messageVO = WatchMsgParseUtil.getMsg(message); + deviceUploadService.recordHealth(messageVO); + return AjaxResult.success(); + } + + /** + * 测试springBoot事件 + */ + @RequestMapping("/testEvent") + public AjaxResult testEvent(String msg) throws Exception { + TestEvent testEvent = new TestEvent(this, msg); + System.out.println("当前线程:" + Thread.currentThread().getName()); + testPublisher.publish(msg); + return AjaxResult.success("事件发布成功"); + } + + + /** + * 测试缓存功能 + */ + @RequestMapping("/testCache") + public AjaxResult testCache(String type, String watchSign, String empNo) throws Exception { + watchSign = StringUtils.isBlank(watchSign) ? "865593070205859" : watchSign; + empNo = StringUtils.isBlank(empNo) ? "TC1336019032" : empNo; + + // 清除缓存 + if ("0".equals(type)) { + commonService.cacheEvictDeviceByWatchSign(watchSign); + return AjaxResult.success("根据empNo ---> 清除缓存成功"); + } + // 查询设备信息 + if ("1".equals(type)) { + WatchDevice watchDeviceByWatchSign = commonService.getWatchDeviceByWatchSign(watchSign); + return AjaxResult.success(watchDeviceByWatchSign); + } + + if ("2".equals(type)) { + commonService.cacheEvictDeviceByEmpNo(empNo,watchSign); + return AjaxResult.success("根据empNo ---> 清除缓存成功"); + } + + if ("3".equals(type)) { + WatchDevice watchDevice = commonService.getWatchDeviceByEmpNo(empNo,watchSign); + return AjaxResult.success(watchDevice); + } + return AjaxResult.error("未知类型的消息"); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchClassModeController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchClassModeController.java new file mode 100644 index 0000000..c5eec14 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchClassModeController.java @@ -0,0 +1,54 @@ +package com.smartlive.bswatch.controller.web; + +import com.smartlive.bswatch.service.IWatchClassModelService; +import com.smartlive.common.validator.group.InsertValidate; +import com.smartlive.common.validator.group.UpdateValidate; +import com.smartlive.bswatch.vo.controllerVO.WatchClassModelVO; +import com.smartlive.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * @author:lilj + * @date:2025/2/14 + */ +@RequestMapping("/watch/classMode") +@RestController +public class WatchClassModeController { + @Autowired + private IWatchClassModelService watchClassModelService; + + /** + * 查询 + * @param classModelVO + * @return + */ + @RequestMapping("/list") + public AjaxResult list(WatchClassModelVO classModelVO) { + return watchClassModelService.queryVO(classModelVO); + } + + /** + * 增加数据 + */ + @PostMapping("/add") + public AjaxResult add(@Validated(InsertValidate.class) @RequestBody WatchClassModelVO classModelVO) { + return watchClassModelService.saveVO(classModelVO); + } + /** + * 修改数据 + */ + @PostMapping("/update") + public AjaxResult update(@Validated(UpdateValidate.class) @RequestBody WatchClassModelVO classModelVO) { + return watchClassModelService.updateVO(classModelVO); + } + + /** + * 删除数据 + */ + @RequestMapping("/delete") + public AjaxResult delete(Integer id) { + return watchClassModelService.delete(id); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchOperationController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchOperationController.java new file mode 100644 index 0000000..f9cefd7 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchOperationController.java @@ -0,0 +1,59 @@ +package com.smartlive.bswatch.controller.web; + +import com.smartlive.bswatch.service.IWatchDeviceService; +import com.smartlive.bswatch.vo.controllerVO.WatchOperationAddVO; +import com.smartlive.bswatch.vo.controllerVO.WatchOperationVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotBlank; + +/** + * @author:lilj + * @date:2025/3/19 + */ + +/** + * 设备管理接口: + * 查询 + * 修改 + * 新增 + * 删除 + */ +@RestController +@RequestMapping("/watch/operation") +public class WatchOperationController { + + /** + * 查询腕表设备信息 + * @return + */ + @Autowired + private IWatchDeviceService watchDeviceService; + + // 查询 + @RequestMapping("/query") + public AjaxResult query(WatchOperationVO watchOperationVO) { + if(StringUtils.isNotBlank(watchOperationVO.getEmpName())){ + watchOperationVO.setEmpName(watchOperationVO.getEmpName()); + } + return watchDeviceService.queryWatches(watchOperationVO); + } + + // 新增 + @PostMapping("/add") + public AjaxResult add(@RequestBody @Validated WatchOperationAddVO watchOperationAddVO) { + return watchDeviceService.addWatch(watchOperationAddVO); + } + + // 删除 + @GetMapping("/delete") + public AjaxResult delete(@NotBlank(message = "腕表id不能为空") Long deviceId) { + return watchDeviceService.deleteWatch(deviceId); + } + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchWhitePeriodController.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchWhitePeriodController.java new file mode 100644 index 0000000..7324a06 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/controller/web/WatchWhitePeriodController.java @@ -0,0 +1,56 @@ +package com.smartlive.bswatch.controller.web; + +import com.smartlive.bswatch.service.IWatchWhitePeriodService; +import com.smartlive.common.validator.group.InsertValidate; +import com.smartlive.common.validator.group.UpdateValidate; +import com.smartlive.bswatch.vo.controllerVO.WatchWhitePeriodVO; +import com.smartlive.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * @author:lilj + * @date:2025/2/11 + */ +@RequestMapping("watch/whitePeriod") +@RestController +public class WatchWhitePeriodController { + @Autowired + private IWatchWhitePeriodService watchWhitePeriodService; + + // 增删改查 + /** + * 查询 + */ + @RequestMapping("list") + public AjaxResult list(WatchWhitePeriodVO watchWhitePeriodVO) { + return watchWhitePeriodService.queryByVO(watchWhitePeriodVO); + } + + @PostMapping("add") + public AjaxResult add(@Validated(InsertValidate.class) @RequestBody WatchWhitePeriodVO watchWhitePeriodVO) { + return watchWhitePeriodService.saveWithVO(watchWhitePeriodVO); + } + + @PostMapping("update") + public AjaxResult update(@Validated(UpdateValidate.class) @RequestBody WatchWhitePeriodVO watchWhitePeriodVO) { + return watchWhitePeriodService.updateWithVO(watchWhitePeriodVO); + } + + @GetMapping("delete") + public AjaxResult delete(Integer id){ + if(id==null){ + return AjaxResult.error("请指定要删除的白名单限制周期"); + } + return watchWhitePeriodService.removeWithIds(java.util.Arrays.asList(id)); + } + + @GetMapping("deleteBatch") + public AjaxResult deleteBatch(Integer[] ids){ + if(ids==null || ids.length==0){ + return AjaxResult.error("请指定要删除的白名单限制周期"); + } + return watchWhitePeriodService.removeWithIds(java.util.Arrays.asList(ids)); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/costant/CacheConstant.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/costant/CacheConstant.java new file mode 100644 index 0000000..878b78d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/costant/CacheConstant.java @@ -0,0 +1,35 @@ +package com.smartlive.bswatch.costant; + +import com.smartlive.bswatch.enmus.WatchApiEnum; + +import java.util.concurrent.TimeUnit; + +/** + * @author:lilj + * @date:2025/2/5 + */ + +// 分隔符 +public interface CacheConstant { + String CACHE_SEPARATOR="_"; + String WATCH_DEVICE_INFO_KEY= WatchApiEnum.LOGIN.getApiName(); + String STEP_KEY= WatchApiEnum.REPORT_HEARTBEAT.getApiName(); + String DEVICE_STATUS_KEY = WatchApiEnum.DEVICE_STATUS.getApiName(); + String REPORT_LOCATION_INFO_KEY=WatchApiEnum.REPORT_LOCATION_INFO.getApiName(); + /** + * 普通命令缓存60s + */ + Integer COMMON_CACHE_TTL=60; + TimeUnit COMMON_CACHE_TTL_UNIT=TimeUnit.SECONDS; + + /** + * 缓存有效时间:命令key缓存时间 + */ + int LOCATION_CACHE_TIME = 20; + + /** + * 缓存时间单位:命令key缓存时间单位 + */ + TimeUnit LOCATION_CACHE_TIME_UNIT = TimeUnit.MINUTES; + String WATCH_WARN_KEY = "watchWarn"; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/costant/WatchConstant.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/costant/WatchConstant.java new file mode 100644 index 0000000..e96bea0 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/costant/WatchConstant.java @@ -0,0 +1,117 @@ +package com.smartlive.bswatch.costant; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * @author:lilj + * @date:2025/1/21 + */ +public interface WatchConstant { + + /** + * 全周 + */ + String ALL_PERIOD = "0+1+2+3+4+5+6"; + /** + * 全天 + */ + String ALL_TIME = "0000-2359"; + + /** + * =默认待机时间段 + */ + String REDAY_TIME = "2300-0600"; + + + /** + * 获取命令执行结果的循环次数 + */ + // TODO: 演示用降低循环次数以及休眠时间 + // int LOOP_COUNT = 20; + + /** + * 每次循环休眠的时间数:单位毫秒 + */ + // int LOOP_SLEEP_TIME = 500; + + // 演示设置为命令等待时间最长为2s + int LOOP_COUNT = 20; + int LOOP_SLEEP_TIME = 100; + + + // 1.下发请求 + // 2.下发响应 + // 3.上报请求 + // 4.上报响应 + String MSG_TYPE_DOWN_REQ = "1"; + String MSG_TYPE_DOWN_RESP = "2"; + String MSG_TYPE_UP_REQ = "3"; + String MSG_TYPE_UP_RESP = "4"; + + /** + * 课堂模式sos是否可以呼入: 0 否 1是 + */ + String SOS_CALL_IN = "0"; + /** + * 课堂模式sos是否可以呼出: 0 否 1 是 + */ + String SOS_CALL_ON = "0"; + + /** + * 学生性别 + */ + String STUDENT_MALE = "1"; + String STUDENT_FEMALE = "2"; + String STUDENT_UNKNOWN = "3"; + + /** + * 图片url + */ + String STUDENT_MALE_AVATAR = "http://download.zhengfankeji.com/upload/technology/stuImg/male.png"; + String STUDENT_FEMALE_AVATAR = "http://download.zhengfankeji.com/upload/technology/stuImg/female.png"; + String STUDENT_DEFAULT_AVATAR = "http://download.zhengfankeji.com/upload/technology/stuImg/default.png"; + + + /** + * 腕表模式设置 + * 0: 待机模式: 待机模式下,设备不连接平台,只可使用拨打电话,接听电话和收发短信;待机模式结束,自动切换为之前模式,如设备处于实时模式则延时至实时 + * 模式结束进入待机模式 + * 1: 省电模式: 主动定位,保持正常心跳,设备不主动上报位置 + * 2: 平衡模式: 平衡模式下设备可主动定位,保持正常心跳,设备每 20 分钟为基准,上报一次当前位置 + * 3: 实时模式: 设备与平台保持正常心跳,每 3 分钟上报一次位置信息。 + * 每次切换模式后立即上报一次当前位置。 + */ + Integer WATCH_MODE_REDAY = 0; + Integer WATCH_MODE_POWER_SAVE = 1; + Integer WATCH_MODE_BALANCE = 2; + Integer WATCH_MODE_IMMEDIATE = 3; + + /** + * 白名单电话最大数量 + */ + int WATCH_WHITE_MAX_COUNT = 20; + + /** + * 定时定位频率设置 + */ + int WATCH_LOCATION_FREQUENCY_MIN = 5; + + int WATCH_LOCATION_FREQUENCY_MIDDLE = 10; + + int WATCH_LOCATION_FREQUENCY_MAX = 20; + + int WATCH_LOCATION_FREQUENCY_DEFAULT =20; + + String LOGIN_PREFIX = "watch_login:"; + + // 禁用电话的学校id + final Set DISABLE_PHONE_ORGI_IDS = new HashSet(){ + { + // add(20230); + // 建安区三高 吧 + // add(56861); + } + }; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/enmus/PowerEnum.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/enmus/PowerEnum.java new file mode 100644 index 0000000..a240dfc --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/enmus/PowerEnum.java @@ -0,0 +1,30 @@ +package com.smartlive.bswatch.enmus; + +import lombok.Getter; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Getter +public enum PowerEnum { + + // 上报类型(1=缺电报警; 2=关机报警 ; 3=自 + // 动关机报警 ; 4=开机报警,5=设备充电,6=电 + // 源已断开 7=设备电量已充满) + POOR_ALARM("1", "缺电报警"), + CLOSE_ALARM("2", "关机报警"), + AUTO_CLOSE_ALARM("3", "自动关机报警"), + OPEN_ALARM("4", "开机报警"), + CHARGE_ALARM("5", "设备充电"), + DIS_POWER_ALARM("6", "电源已断开"), + FULL_POWER_ALARM("7", "设备电量已充满"); + + private String powerType; + private String desc; + + PowerEnum(String powerType, String desc) { + this.powerType = powerType; + this.desc = desc; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/enmus/WatchApiEnum.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/enmus/WatchApiEnum.java new file mode 100644 index 0000000..9dc799d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/enmus/WatchApiEnum.java @@ -0,0 +1,69 @@ +package com.smartlive.bswatch.enmus; + + +import lombok.Getter; + +import java.util.HashMap; + +/** + * @author:lilj + * @date:2025/1/18 + */ +@Getter +public enum WatchApiEnum { + // 设备请求平台,拉取配置数据 + LOGIN("DEVICE_LOGIN","设备登录"), + GET_BUTTON("GET_NORMAL_BUTTON","按键获取"), + GET_INCOME_CALL("GET_INCOMING_CALL","呼入电话获取"), + GET_CLASS_MODEL("GET_CLASS_MODEL","课堂模式获取"), + ERROR_RESP("ERROR_RESP","错误响应"), + GET_SMS_PORT("GET_SMS_PORT","短信端口获取"), + GET_WEATHER_NOW("GET_WEATHER_NOW","获取实时天气"), + GET_WEATHER_FORCAST("GET_WEATHER_FORCAST","获取未来天气"), + GET_WEATHER_INFO("GET_WEATHER_INFO","获取天气信息"), + GET_STUDENT_INFO("GET_STUDENT_INFO","学生信息获取"), + DEVICE_STATUS("DEVICE_STATUS","设备状态上报"), + GET_BALANCE_INFO("GET_BALANCE_INFO", "获取设备绑定人员余额信息"), + + // 设备上传数据到平台 + ALARM_POWER("ALARM_POWER","电量上报"), + REPORT_HEARTBEAT("REPORT_HEARTBEAT","心跳请求,携带电量与步数"), + REPORT_LOCATION_INFO("REPORT_LOCATION_INFO","位置数据上传"), + REPORT_CALL_LOG("REPORT_CALL_LOG","通话记录上传"), + GET_SKIP_MAC("GET_SKIP_MAC","获取跳绳蓝牙MAC"), + REPORT_HEART_HEALTH("REPORT_HEART_HEALTH","心率健康上报"), + REPORT_SMS_READ("REPORT_SMS_READ","短信读取上报"), + REPORT_SOS("REPORT_SOS","sos上报"), + REPORT_SLEEP_DATA("REPORT_SLEEP_DATA","睡眠数据上报"), + + // 平台下发,设备响应接口 + SET_INCOMING_CALL("SET_INCOMING_CALL","设置呼入电话"), + SET_NORMAL_BUTTON("SET_NORMAL_BUTTON","设置按键"), + LOCATION_INFO_GET("LOCATION_INFO_GET","实时位置获取"), + REQUEST_CALL("REQUEST_CALL","安全防护"), + FREQUENCY_LOCATION_SET("FREQUENCY_LOCATION_SET","定时上报位置频率设置"), + SET_HEARTBEAT("SET_HEARTBEAT","设备心跳频率设置"), + SET_CLASS_MODEL("SET_CLASS_MODEL","设置课堂模式"), + SEND_SMS("SEND_SMS","发送短信"), + SET_STUDENT_INFO("SET_STUDENT_INFO","设置学生信息"), + SET_REDAY_MODE("SET_REDAY_MODE","设置待机模式"), + SET_LOCATION_MODE("SET_LOCATION_MODE","设置定位模式"), + ; + + private static HashMap map = new HashMap<>(); + + private String apiName; + private String desc; + private WatchApiEnum (String apiName,String desc){ + this.apiName = apiName; + this.desc = desc; + } + public static WatchApiEnum getByApiName(String apiName){ + if(map.size() == 0){ + for (WatchApiEnum watachApiEnum : values()) { + map.put(watachApiEnum.apiName,watachApiEnum); + } + } + return map.get(apiName); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Address.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Address.java new file mode 100644 index 0000000..7b3784e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Address.java @@ -0,0 +1,46 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.util.Date; + +@Data +@TableName("order_address") +public class Address { + + @TableId(value = "address_id") + private Long addressId; + + @NotNull(message = "用户ID不能为空") + private Long userId; + + @NotBlank(message = "收货人姓名不能为空") + private String consignee; + + @NotBlank(message = "联系电话不能为空") + @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确") + private String phone; + + @NotBlank(message = "地区信息不能为空") + private String region; + + @NotBlank(message = "详细地址不能为空") + private String detailedAddress; + + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + //状态 1默认,0非默认 + private Integer status; + //删除标志 0正常,1删除 + private Integer delFlag; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Employee.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Employee.java new file mode 100644 index 0000000..d3b7218 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Employee.java @@ -0,0 +1,158 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 员工表 + *

+ * + * @author lilj + * @since 2025-02-06 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class Employee implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 学号 + */ + private String empNo; + + /** + * 姓名 + */ + private String name; + + /** + * 组织id + */ + private Integer organiId; + + /** + * 部门id + */ + private Integer deptId; + + /** + * 是否有权限 1:表示有 0:表示没有 + */ + private Boolean isAccess; + + /** + * 删除标识 + */ + private Boolean delFlag; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 物理卡号 + */ + private String telId; + + /** + * 视频公话是否授权:1、表示有 0、表示没有 + */ + private String status; + + /** + * 0 -正常 1-挂失卡 + */ + private Integer icCardStatus; + + /** + * 0 -正常 1-挂失卡 + */ + private String simCardStatus; + + /** + * 性别3:未知 + */ + private String sex; + + /** + * 人员编号 + */ + private Integer personNo; + + /** + * SIM卡ICCID, 插卡式使用 + */ + private Integer phoneCardNo; + + /** + * 人脸url + */ + private String facePhoto; + + /** + * 人脸特征 + */ + private String feature; + + /** + * 过期时间 + */ + private Date expireDate; + + /** + * 年级id + */ + private Integer gradeId; + + /** + * 班级id + */ + private Integer classId; + + /** + * 年级名称 + */ + private String gradeName; + + /** + * 班级名称 + */ + private String className; + + /** + * 校名 + */ + private String deptName; + + /** + * 授权版本号 + */ + private String authVer; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Meal.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Meal.java new file mode 100644 index 0000000..195a399 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Meal.java @@ -0,0 +1,107 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-04-01 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class Meal implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 物理编号 + */ + @TableField("phyId") + private String phyId; + + /** + * 逻辑卡号 + */ + @TableField("cardId") + private Integer cardId; + + /** + * 开始时间 + */ + @TableField("begTime") + private Date begTime; + + /** + * 结束时间 + */ + @TableField("endTime") + private Date endTime; + + /** + * 余额 + */ + @TableField("balance") + private Double balance; + + /** + * 补贴 + */ + @TableField("subsidy") + private Double subsidy; + + /** + * 状态 + */ + @TableField("status") + private Integer status; + + /** + * 缁鐎? + */ + @TableField("type") + private Integer type; + + /** + * 创建时间 + */ + @TableField("createTime") + private Date createTime; + + /** + * 创建人 + */ + @TableField("operator") + private String operator; + + /** + * 机构 + */ + @TableField("school") + private String school; + + /** + * 用户id + */ + @TableField("empId") + private Integer empId; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/OrderWatch.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/OrderWatch.java new file mode 100644 index 0000000..f82d0f3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/OrderWatch.java @@ -0,0 +1,52 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@TableName("order_watch") +public class OrderWatch { + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + + private Long userId; + + private String tradeNo; + + private Integer payType; + + + private BigDecimal credit; + + private Integer isPass; + + private Integer status; + + private String payNo; + + private Integer watchId; + + private String watchName; + + private BigDecimal watchPrice; + + private Integer watchNum; + + private String watchImage; + + private String adress; + + private String trackNum; + + private Date orderTime; + + @TableField(fill = FieldFill.INSERT) + private Date createdTime; + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updatedTime; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/SysOrgani.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/SysOrgani.java new file mode 100644 index 0000000..8cd4c0c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/SysOrgani.java @@ -0,0 +1,163 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 组织表 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class SysOrgani implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 组织id + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 组织名称 + */ + private String name; + + /** + * 组织简称,至多8个字符. + */ + private String simpleName; + + /** + * 组织类型1幼教,2小学,3初中,4高中,5企业,6教育局,7完全学校,8完全中校,9九年义务教育学校,10培训机构 + */ + private String type; + + /** + * 省code + */ + private String province; + + /** + * 市code + */ + private String city; + + /** + * 区code + */ + private String district; + + /** + * 详细地址 + */ + private String detaild; + + /** + * 状态(正常0,停用1) + */ + private Integer status; + + /** + * 补卡金额 + */ + private Double rmoney; + + /** + * 补卡事项 + */ + private String rmoneyNote; + + /** + * 家校沟通服务:0:未开通,1:开通 + */ + private Integer jxPass; + + /** + * 亲情电话服务:0:未开通,1:开通 + */ + private Integer qqPass; + + /** + * 学费缴纳服务,0:未开通,1:开通,默认0 + */ + private Integer xfPass; + + /** + * 监控服务:0:关闭,1:开通 + */ + private Integer jkPass; + + /** + * 电子学生证服务:0:关闭,1:开通 + */ + private Integer postPass; + + /** + * 餐卡服务:0:未开通,1:开通 + */ + private Integer ckPass; + + /** + * 补卡服务:0:未开通,1:开通 + */ + private Integer bkPass; + + /** + * 水卡服务:0:未开通,1:开通 + */ + private Integer skPass; + + /** + * 餐卡微信充值服务:0:未开通,1:开通 + */ + private Integer ckWxPass; + + /** + * 餐卡支付宝充值服务:0:未开通,1:开通 + */ + private Integer ckZfbPass; + + /** + * 水卡微信充值服务:0:未开通,1:开通 + */ + private Integer skWxPass; + + /** + * 水卡支付宝充值服务:0:未开通,1:开通 + */ + private Integer skZfbPass; + + /** + * 删除标志(0:正常,1:已删除) + */ + private Integer delFlag; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchCallRecord.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchCallRecord.java new file mode 100644 index 0000000..5fdd197 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchCallRecord.java @@ -0,0 +1,89 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchCallRecord implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 通话记录id + */ + @TableId(value = "record_id", type = IdType.AUTO) + private Long recordId; + + /** + * 本机sim卡iccid + */ + private String iccid; + + /** + * 本机号码 + */ + private String selfPhone; + + /** + * 通信电话 + */ + private String phone; + + /** + * 学号 + */ + private String empNo; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 开始时间 + */ + @TableField(value = "call_begin_time") + private Date startTime; + + /** + * 结束时间 + */ + @TableField(value = "call_end_time") + private Date endTime; + + /** + * 通话时长(秒) + */ + private Integer duration; + + /** + * 通话类型:0 呼入 1 呼出 + */ + private Integer callType; + + /** + * 通话记录上传时间 + */ + private Date createTime; + + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchClassModel.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchClassModel.java new file mode 100644 index 0000000..670f8dc --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchClassModel.java @@ -0,0 +1,66 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 腕表课堂模式表 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchClassModel implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 课堂模式id + */ + @TableId(value = "class_id", type = IdType.AUTO) + private Integer classId; + + /** + * 时间段 + */ + private String times; + + /** + * 周几生效:0周末.1-6:周一到周六 + */ + private String period; + + /** + * 学校id + */ + private Long userId; + + private String watchSign; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + + private Integer effective; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchDevice.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchDevice.java new file mode 100644 index 0000000..c0e75f6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchDevice.java @@ -0,0 +1,132 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchDevice implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 腕表id + */ + @TableId(value = "device_id", type = IdType.AUTO) + private Long deviceId; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 按键数量 + */ + private Integer keyNums; + + /** + * 有无SOS按键:0 无 1有 + */ + private Integer hasSosKey; + + /** + * 暂无明确含义 + */ + private String terminalType; + + /** + * 是否支持区域报警:0 否 1 是 + */ + private Integer hasAreaAlarm; + + /** + * 是否具备设备呼入功能 + */ + private Integer hasCallIn; + + /** + * 协议版本 + */ + private String protocolVersion; + + /** + * rfid:10位 + */ + private String rfid; + + /** + * 设备绑定电话号码 + */ + private String bindPhone; + + /** + * 学号 + */ + private String empNo; + + /** + * SIM卡iccid + */ + private String iccid; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 设备模式: + * 0 待机模式 + * 1 省电模式 + * 2 平衡模式 + * 3 实时模式 + */ + private Integer watchMode; + + /** + * 待机模式时间段: 默认23:00-0600 + */ + private String redayTime; + + @TableField(exist = false) + private String empName; + + private Integer locationFreq; + private Integer workTime; + + /** + * 0 表示刚录入系统 1 表示腕表已经有平台有交互了 + */ + private Integer watchStatus; + + /** + * 腕表备注信息 + */ + private String remark; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchEmpPhone.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchEmpPhone.java new file mode 100644 index 0000000..cf445d9 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchEmpPhone.java @@ -0,0 +1,66 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + *

+ * 员工亲情电话 + *

+ * + * @author lilj + * @since 2025-02-06 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchEmpPhone implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 电话id + */ + @TableId(value = "watch_phone_id", type = IdType.AUTO) + @NotNull(message = "watchPhoneId不能为空") + private Integer watchPhoneId; + + /** + * 手机号 + */ + private String phone; + + /** + * 持有人名称 + */ + private String phoneName; + + /** + * 员工号 + */ + private String empNo; + + /** + * 状态:0可用 + */ + private Integer status; + + private String watchSign; + + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchFence.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchFence.java new file mode 100644 index 0000000..c0d0f77 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchFence.java @@ -0,0 +1,82 @@ +package com.smartlive.bswatch.entity; + +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 腕表安全围栏表 + *

+ * + * @author lilj + * @since 2025-02-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchFence implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 学生标识 + */ + @TableField("emp_no") + private String empNo; + + private String watchSign; + + /** + * 围栏名称 + */ + @TableField("fence_name") + private String fenceName; + + /** + * 围栏地址 + */ + @TableField("fence_address") + private String fenceAddress; + + /** + * 经度 + */ + @TableField("longitude") + private BigDecimal longitude; + + /** + * 纬度 + */ + @TableField("latitude") + private BigDecimal latitude; + + /** + * 安全范围 + */ + @TableField("size") + private Integer size; + + @TableField(value = "create_time", fill = FieldFill.INSERT) + private Date createTime; + + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 逻辑删除字段:0 正常数据;1删除数据 + */ + @TableLogic(value = "0",delval = "1") + private Integer delFlag; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchFloodPressure.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchFloodPressure.java new file mode 100644 index 0000000..476b63c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchFloodPressure.java @@ -0,0 +1,62 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 腕表血压数据表 + *

+ * + * @author lilj + * @since 2025-03-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchFloodPressure implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 心率数据id + */ + @TableId(value = "pressure_id", type = IdType.AUTO) + private Long pressureId; + + /** + * 舒张压 + */ + private String lowPressure; + + /** + * 收缩压 + */ + private String highPressure; + + /** + * 数据上传时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 员工编号 + */ + private String empNo; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchGoods.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchGoods.java new file mode 100644 index 0000000..efbe83d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchGoods.java @@ -0,0 +1,38 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@TableName("watch_goods") +public class WatchGoods { + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @NotBlank(message = "腕表名称不能为空") + private String watchName; + + @DecimalMin(value = "0.00", message = "价格不能小于0") + private BigDecimal price; + + private String image; + + private Integer stock; + + private String description; + + private Integer status; + + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHealthReport.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHealthReport.java new file mode 100644 index 0000000..4b9d094 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHealthReport.java @@ -0,0 +1,357 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + *

+ * 健康周报告表 + *

+ * + * @author system + * @since 2025-11-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchHealthReport implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 报告ID + */ + @TableId(value = "report_id", type = IdType.AUTO) + private Long reportId; + + /** + * 员工编号 + */ + @TableField("emp_no") + private String empNo; + + + /** + * 设备唯一标识 + */ + @TableField("watch_sign") + private String watchSign; + /** + * 设备名称 + */ + @TableField("watch_name") + private String watchName; + /** + * 报告标题 + */ + @TableField("report_title") + private String reportTitle; + + /** + * 报告年月 + */ + @TableField("report_date") + private String reportDate; + + /** + * 报告开始日期 + */ + @TableField("start_date") + private String startDate; + + /** + * 报告结束日期 + */ + @TableField("end_date") + private String endDate; + + /** + * 血压测量总次数 + */ + @TableField("bp_total_count") + private Integer bpTotalCount; + + /** + * 血压正常次数 + */ + @TableField("bp_normal_count") + private Integer bpNormalCount; + + /** + * 血压异常次数 + */ + @TableField("bp_abnormal_count") + private Integer bpAbnormalCount; + + /** + * 血压异常比例 + */ + @TableField("bp_abnormal_ratio") + private BigDecimal bpAbnormalRatio; + + /** + * 血压建议文案 + */ + @TableField("bp_advice") + private String bpAdvice; + + /** + * 血压状态 + */ + @TableField("bp_status") + private Integer bpStatus; + + /** + * 血压周数据 + */ + /** + * 心率测量总次数 + */ + @TableField("hr_total_count") + private Integer hrTotalCount; + + /** + * 心率正常次数 + */ + @TableField("hr_normal_count") + private Integer hrNormalCount; + + /** + * 心率异常次数 + */ + @TableField("hr_abnormal_count") + private Integer hrAbnormalCount; + + /** + * 心率过缓次数 + */ + @TableField("hr_bradycardia_count") + private Integer hrBradycardiaCount; + + /** + * 心率过速次数 + */ + @TableField("hr_tachycardia_count") + private Integer hrTachycardiaCount; + + /** + * 心率异常比例 + */ + @TableField("hr_abnormal_ratio") + private BigDecimal hrAbnormalRatio; + + /** + * 心率建议文案 + */ + @TableField("hr_advice") + private String hrAdvice; + + /** + * 心率状态 + */ + @TableField("hr_status") + private Integer hrStatus; + + /** + * 体温测量总次数 + */ + @TableField("temp_total_count") + private Integer tempTotalCount; + + /** + * 体温正常次数 + */ + @TableField("temp_normal_count") + private Integer tempNormalCount; + + /** + * 体温异常次数 + */ + @TableField("temp_abnormal_count") + private Integer tempAbnormalCount; + + /** + * 体温偏低次数 + */ + @TableField("temp_low_count") + private Integer tempLowCount; + + /** + * 体温偏高次数 + */ + @TableField("temp_high_count") + private Integer tempHighCount; + + /** + * 体温异常比例 + */ + @TableField("temp_abnormal_ratio") + private BigDecimal tempAbnormalRatio; + + /** + * 体温建议文案 + */ + @TableField("temp_advice") + private String tempAdvice; + + /** + * 体温状态 + */ + @TableField("temp_status") + private Integer tempStatus; + + /** + * 血氧测量总次数 + */ + @TableField("oxy_total_count") + private Integer oxyTotalCount; + + /** + * 血氧正常次数 + */ + @TableField("oxy_normal_count") + private Integer oxyNormalCount; + + /** + * 血氧异常次数 + */ + @TableField("oxy_abnormal_count") + private Integer oxyAbnormalCount; + + /** + * 血氧异常比例 + */ + @TableField("oxy_abnormal_ratio") + private BigDecimal oxyAbnormalRatio; + + /** + * 血氧建议文案 + */ + @TableField("oxy_advice") + private String oxyAdvice; + + /** + * 血氧状态 + */ + @TableField("oxy_status") + private Integer oxyStatus; + + /** + * 睡眠记录总次数 + */ + @TableField("sleep_total_count") + private Integer sleepTotalCount; + + /** + * 睡眠正常次数 + */ + @TableField("sleep_normal_count") + private Integer sleepNormalCount; + + /** + * 睡眠异常次数 + */ + @TableField("sleep_abnormal_count") + private Integer sleepAbnormalCount; + + /** + * 睡眠异常比例 + */ + @TableField("sleep_abnormal_ratio") + private BigDecimal sleepAbnormalRatio; + + /** + * 睡眠建议文案 + */ + @TableField("sleep_advice") + private String sleepAdvice; + + /** + * 睡眠状态 + */ + @TableField("sleep_status") + private Integer sleepStatus; + + /** + * 整体异常次数 + */ + @TableField("overall_score") + private Integer overallScore; + + /** + * 整体状态 + */ + @TableField("overall_status") + private String overallStatus; + + /** + * 整体健康文案 + */ + @TableField("overall_assessment") + private String overallAssessment; + + /** + * 舒张压 + */ + @TableField(exist = false) + private List lowPressures; + + /** + * 收缩压 + */ + @TableField(exist = false) + private List highPressures; + + /** + * 心率数据 + */ + @TableField(exist = false) + private List heartBeats; + + /** + * 血氧数据 + */ + @TableField(exist = false) + private List oxyDatas; + + /** + * 体温数据 + */ + @TableField(exist = false) + private List temperatureDatas; + + /** + * 睡眠总时长(分钟) + */ + @TableField(exist = false) + private List sleepTotalTimes; + + /** + * 时间 + */ + @TableField(exist = false) + private List times; + + /** + * 报告生成时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + +} \ No newline at end of file diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHealthRules.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHealthRules.java new file mode 100644 index 0000000..756f1f5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHealthRules.java @@ -0,0 +1,104 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 腕表健康规则表 + *

+ * + * @author system + * @since 2025-11-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchHealthRules implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 规则ID + */ + @TableId(value = "rule_id", type = IdType.AUTO) + private Long ruleId; + + /** + * 指标类型: BLOOD_PRESSURE(血压), HEART_RATE(心率), TEMPERATURE(体温), BLOOD_OXYGEN(血氧), SLEEP(睡眠) + */ + private String indicatorType; + + /** + * 规则名称 + */ + private String ruleName; + + /** + * 条件表达式(JSON格式) + */ + private String conditionExpression; + + /** + * 判断标准描述 + */ + private String judgmentCriteria; + + /** + * 建议文案模板 + */ + private String adviceTemplate; + + /** + * 优先级(数字越小优先级越高) + */ + private Integer priority; + + /** + * 状态:1启用,0禁用 + */ + private Integer status; + + /** + * 最小值 + */ + private BigDecimal minValue; + + /** + * 最大值 + */ + private BigDecimal maxValue; + + /** + * 异常类型: NORMAL(正常), ABNORMAL(异常),OCCASIONAL(偶尔异常) + */ + private Integer abnormalType; + + /** + * 阈值比例 + */ + private BigDecimal thresholdRatio; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} \ No newline at end of file diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHeart.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHeart.java new file mode 100644 index 0000000..ffbb3b2 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchHeart.java @@ -0,0 +1,57 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchHeart implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 心率数据id + */ + @TableId(value = "heart_id", type = IdType.AUTO) + private Long heartId; + + /** + * 心率数据 + */ + private Integer heartBeat; + + /** + * 数据上传时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 员工号 + */ + private String empNo; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchLocation.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchLocation.java new file mode 100644 index 0000000..3269886 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchLocation.java @@ -0,0 +1,73 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; + +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchLocation implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 位置信息id + */ + @TableId(value = "location_id", type = IdType.AUTO) + private Long locationId; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 定位模式:0:LBS+wifi 1:GPS + */ + private Integer locationType; + + /** + * 经度 + */ + private BigDecimal longitude; + + /** + * 纬度 + */ + private BigDecimal latitude; + + /** + * 地址名称 + */ + private String address; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + private String empNo; + + private String areaCode; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchModeLog.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchModeLog.java new file mode 100644 index 0000000..919c0b2 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchModeLog.java @@ -0,0 +1,69 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-28 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchModeLog implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 设备模式切换日志id + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 腕表唯一标识 + */ + private String watchSign; + + private String empNo; + + /** + * 切换前模式 + */ + private Integer beforeMode; + + /** + * 切换后模式 + */ + private Integer afterMode; + + /** + * 切换时间 + */ + private Date changeTime; + + /** + * 之前模式工作时间 + */ + private Integer workTime; + + /** + * 日志创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchOxy.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchOxy.java new file mode 100644 index 0000000..8df683b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchOxy.java @@ -0,0 +1,57 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchOxy implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 血氧数据id + */ + @TableId(value = "oxy_id", type = IdType.AUTO) + private Long oxyId; + + /** + * 血氧数据 + */ + private String oxyData; + + /** + * 血氧数据上传时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 员工号 + */ + private String empNo; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchPower.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchPower.java new file mode 100644 index 0000000..76cb58f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchPower.java @@ -0,0 +1,64 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-28 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchPower implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 电量id + */ + @TableId(value = "power_id", type = IdType.AUTO) + private Long powerId; + + /** + * 电量 + */ + private String power; + + /** + * 腕表唯一标识 + */ + private String watchSign; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 上报类型(1=缺电报警; 2=关机报警 ; 3=自 + * 动关机报警 ; 4=开机报警,5=设备充电,6=电 + * 源已断开 7=设备电量已充满) + */ + private String powerType; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSkip.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSkip.java new file mode 100644 index 0000000..a370d2d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSkip.java @@ -0,0 +1,63 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-04-02 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchSkip implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 跳绳id + */ + @TableId(value = "skip_id", type = IdType.AUTO) + private Long skipId; + + /** + * 跳绳mac地址 + */ + private String skipMac; + + /** + * 关联学号 + */ + private String empNo; + + /** + * 关联人员信息 + */ + private String watchSign; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSleep.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSleep.java new file mode 100644 index 0000000..a8ba93c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSleep.java @@ -0,0 +1,83 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 腕表睡眠数据表 + *

+ * + * @author lilj + * @since 2025-03-18 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchSleep implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 睡眠数据id + */ + @TableId(value = "sleep_id", type = IdType.AUTO) + private Long sleepId; + + /** + * 睡眠时间段 + */ + private String sleepPeriod; + + /** + * 睡眠数据上传时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 员工编号 + */ + private String empNo; + + /** + * 睡眠总时长(分钟) + */ + private String sleepTotalTime; + + /** + * 深度睡眠时长 + */ + private String deepSleepTime; + + /** + * 浅度睡眠时长 + */ + private String lightSleepTime; + + /** + * rem睡眠时长 + */ + private String remSleepTime; + + /** + * 清醒时长 + */ + private String wakeTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSos.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSos.java new file mode 100644 index 0000000..3fac3d4 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSos.java @@ -0,0 +1,68 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchSos implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * sos电话id + */ + @TableId(value = "sos_id", type = IdType.AUTO) + private Long sosId; + + /** + * sos电话 + */ + private String sosPhone; + + /** + * 电话联系人 + */ + private String phoneName; + + /** + * 学生标识 + */ + private String empNo; + + /** + * 腕表唯一标识 + */ + private String watchSign; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSosLog.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSosLog.java new file mode 100644 index 0000000..3845d61 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSosLog.java @@ -0,0 +1,58 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 腕表sos报警日志表 + *

+ * + * @author lilj + * @since 2025-03-18 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchSosLog implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * sos上报记录id + */ + @TableId(value = "sos_log_id", type = IdType.AUTO) + private Long sosLogId; + + /** + * sos上报时间 + */ + private Date reportTime; + + /** + * 系统保存时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 员工编号 + */ + private String empNo; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchStep.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchStep.java new file mode 100644 index 0000000..f1d211e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchStep.java @@ -0,0 +1,60 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchStep implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 步数id + */ + @TableId(value = "step_id", type = IdType.AUTO) + private Long stepId; + + /** + * 步数 + */ + private Integer stepCount; + + /** + * 每日日期,精确到日 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + private String empNo; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSysDept.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSysDept.java new file mode 100644 index 0000000..effec72 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchSysDept.java @@ -0,0 +1,72 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 部门表 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("sys_dept") +public class WatchSysDept implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(value = "dept_id", type = IdType.AUTO) + private Integer deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 父部门Id + */ + private Long parentId; + + /** + * 组织id + */ + private Integer organiId; + + /** + * 状态(0正常,1停用) + */ + private Integer status; + + /** + * 删除标志(0正常,1删除) + */ + private Integer delFalg; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchTemperature.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchTemperature.java new file mode 100644 index 0000000..2d73918 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchTemperature.java @@ -0,0 +1,56 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchTemperature implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 体温数据id + */ + @TableId(value = "temperature_id", type = IdType.AUTO) + private Long temperatureId; + + /** + * 体温数据 + */ + private String temperatureData; + + /** + * 体温数据上传时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 设备唯一标识 + */ + private String watchSign; + + + /** + * 员工编号 + */ + private String empNo; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWarn.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWarn.java new file mode 100644 index 0000000..9b5780f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWarn.java @@ -0,0 +1,74 @@ +package com.smartlive.bswatch.entity; + +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 腕表定位警报表 + *

+ * + * @author lilj + * @since 2025-02-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchWarn implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 学号 + */ + private String empNo; + + /** + * 腕表唯一标识 + */ + private String watchSign; + /** + * 报警名称 + */ + private String warnName; + + /** + * 经度 + */ + private BigDecimal longitude; + + /** + * 纬度 + */ + private BigDecimal latitude; + + /** + * 距离:4为小数 + */ + private BigDecimal distance; + + /** + * 报警地点 + */ + private String warnAddress; + + /** + * 报警时间 + */ + private Date warnTime; + + private Long fenceId; + + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWhite.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWhite.java new file mode 100644 index 0000000..cc82c60 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWhite.java @@ -0,0 +1,79 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchWhite implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 白名单id + */ + @TableId(value = "white_id", type = IdType.AUTO) + private Long whiteId; + + /** + * 白名单电话 + */ + private String whitePhone; + + /** + * 电话联系人 + */ + private String phoneName; + + /** + * 设备唯一标识 + */ + private String watchSign; + /** + * 学生学号 + */ + private String empNo; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + + /** + * 时间段1 + */ + + private String time1; + + /** + * 时间段2 + */ + private String time2; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWhitePeriod.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWhitePeriod.java new file mode 100644 index 0000000..a73e9f2 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/WatchWhitePeriod.java @@ -0,0 +1,60 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-02-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class WatchWhitePeriod implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 时间段id + */ + @TableId(value = "period_id", type = IdType.AUTO) + private Long periodId; + + + /** + * 用户id + */ + private String empNo; + + /** + * 设备唯一标识 + */ + private String watchSign; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + + private String period; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Water.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Water.java new file mode 100644 index 0000000..81b9251 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/entity/Water.java @@ -0,0 +1,107 @@ +package com.smartlive.bswatch.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author lilj + * @since 2025-04-01 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class Water implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 物理编号 + */ + @TableField("phyId") + private String phyId; + + /** + * 逻辑卡号 + */ + @TableField("cardId") + private Integer cardId; + + /** + * 开始时间 + */ + @TableField("begTime") + private Date begTime; + + /** + * 结束时间 + */ + @TableField("endTime") + private Date endTime; + + /** + * 余额 + */ + @TableField("balance") + private Double balance; + + /** + * 补贴 + */ + @TableField("subsidy") + private Double subsidy; + + /** + * 状态 + */ + @TableField("status") + private Integer status; + + /** + * 0直饮水,1淋浴,2吹风机 + */ + @TableField("type") + private Integer type; + + /** + * 创建时间 + */ + @TableField("createTime") + private Date createTime; + + /** + * 创建人 + */ + @TableField("operator") + private String operator; + + /** + * 机构 + */ + @TableField("school") + private String school; + + /** + * 用户id + */ + @TableField("empId") + private Integer empId; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/AddressMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/AddressMapper.java new file mode 100644 index 0000000..aae8908 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/AddressMapper.java @@ -0,0 +1,8 @@ +package com.smartlive.bswatch.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.Address; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AddressMapper extends BaseMapper
{ +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/OrderWatchMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/OrderWatchMapper.java new file mode 100644 index 0000000..4e63031 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/OrderWatchMapper.java @@ -0,0 +1,8 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.OrderWatch; +import org.apache.ibatis.annotations.Mapper; +@Mapper +public interface OrderWatchMapper extends BaseMapper { +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchCallRecordMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchCallRecordMapper.java new file mode 100644 index 0000000..021a778 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchCallRecordMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchCallRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchCallRecordMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchClassModelMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchClassModelMapper.java new file mode 100644 index 0000000..0a6458d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchClassModelMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchClassModel; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.WatchClassModelVO; + +import java.util.List; + +/** + *

+ * 腕表课堂模式表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +public interface WatchClassModelMapper extends BaseMapper { + + List queryVO(WatchClassModelVO classModelVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchDeviceMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchDeviceMapper.java new file mode 100644 index 0000000..ccc086b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchDeviceMapper.java @@ -0,0 +1,22 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchDevice; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.WatchOperationVO; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchDeviceMapper extends BaseMapper { + + List queryVO(WatchOperationVO watchOperationVO); + + List getUsedWatchDeviceList(); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchEmpPhoneMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchEmpPhoneMapper.java new file mode 100644 index 0000000..9340543 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchEmpPhoneMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.WatchEmpPhone; +import com.smartlive.bswatch.vo.controllerVO.WatchEmpPhoneVO; + +import java.util.List; + +/** + *

+ * 员工亲情电话 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-06 + */ +public interface WatchEmpPhoneMapper extends BaseMapper { + + List selectEmpPhone(WatchEmpPhoneVO empPhoneVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchEmployeeMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchEmployeeMapper.java new file mode 100644 index 0000000..5936e8d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchEmployeeMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.Employee; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 员工表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-06 + */ +public interface WatchEmployeeMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchFenceMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchFenceMapper.java new file mode 100644 index 0000000..2881804 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchFenceMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchFence; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.WatchFenceVO; + +import java.util.List; + +/** + *

+ * 腕表安全围栏表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-08 + */ +public interface WatchFenceMapper extends BaseMapper { + + List selectQueryVO(WatchFenceVO fenceVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchFloodPressureMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchFloodPressureMapper.java new file mode 100644 index 0000000..79cafb1 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchFloodPressureMapper.java @@ -0,0 +1,28 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.WatchFloodPressure; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.PressureVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * 腕表血压数据表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-03-17 + */ +public interface WatchFloodPressureMapper extends BaseMapper { + + List queryVO(HealthQueryVO healthQueryVO); + + List selectByEmpAndTime(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); + + + List selectLatestPressureByDateRange(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchGoodsMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchGoodsMapper.java new file mode 100644 index 0000000..7adb447 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchGoodsMapper.java @@ -0,0 +1,9 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.WatchGoods; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface WatchGoodsMapper extends BaseMapper { +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHealthReportMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHealthReportMapper.java new file mode 100644 index 0000000..6952404 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHealthReportMapper.java @@ -0,0 +1,23 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.TO.HeathReportTO; +import com.smartlive.bswatch.entity.WatchHealthReport; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +/** + *

+ * 健康周报告表 Mapper 接口 + *

+ * + * @author system + * @since 2025-11-17 + */ +public interface WatchHealthReportMapper extends BaseMapper { + + List getReportByEmpNo(@Param("watchSign") String watchSign, @Param("time") String time); + +} \ No newline at end of file diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHealthRulesMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHealthRulesMapper.java new file mode 100644 index 0000000..ac0faa6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHealthRulesMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.WatchHealthRules; + +/** + *

+ * 腕表健康规则表 Mapper 接口 + *

+ * + * @author system + * @since 2025-11-17 + */ +public interface WatchHealthRulesMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHeartMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHeartMapper.java new file mode 100644 index 0000000..eab0960 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchHeartMapper.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchHeart; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.HeartBeatVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchHeartMapper extends BaseMapper { + + List queryVO(HealthQueryVO healthQueryVO); + + List selectByEmpAndTime(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); + + /** + * 查询指定时间段内每天最新的心率记录 + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param empNo 员工编号 + * @return 每天最新的心率记录列表 + */ + List selectLatestHeartByDateRange(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchLocationMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchLocationMapper.java new file mode 100644 index 0000000..6fe0072 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchLocationMapper.java @@ -0,0 +1,22 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchLocation; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.LocationQueryVO; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchLocationMapper extends BaseMapper { + + List selectLoactionTrack(LocationQueryVO locationQueryVO); + + List selectLoactionTrack2(LocationQueryVO locationQueryVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchModeLogMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchModeLogMapper.java new file mode 100644 index 0000000..0666f6c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchModeLogMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchModeLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-28 + */ +public interface WatchModeLogMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchOxyMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchOxyMapper.java new file mode 100644 index 0000000..d8dbc9a --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchOxyMapper.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchOxy; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.BloodOxyVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchOxyMapper extends BaseMapper { + + List queryVO(HealthQueryVO healthQueryVO); + + List selectByEmpAndTime(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); + + /** + * 查询指定时间段内每天最新的血氧记录 + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param empNo 员工编号 + * @return 每天最新的血氧记录列表 + */ + List selectLatestOxyByDateRange(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchPowerMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchPowerMapper.java new file mode 100644 index 0000000..08590b4 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchPowerMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchPower; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-28 + */ +public interface WatchPowerMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSkipMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSkipMapper.java new file mode 100644 index 0000000..2e7b6c5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSkipMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchSkip; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-04-02 + */ +public interface WatchSkipMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSleepMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSleepMapper.java new file mode 100644 index 0000000..b7deaf1 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSleepMapper.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchSleep; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.SleepVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * 腕表睡眠数据表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-03-18 + */ +public interface WatchSleepMapper extends BaseMapper { + + SleepVO queryVO(HealthQueryVO healthQueryVO); + + List selectByEmpAndTime(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); + + /** + * 查询指定时间段内每天最新的睡眠记录 + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param empNo 员工编号 + * @return 每天最新的睡眠记录列表 + */ + List selectLatestSleepByDateRange(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSosLogMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSosLogMapper.java new file mode 100644 index 0000000..d6457c0 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSosLogMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchSosLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 腕表sos报警日志表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-03-18 + */ +public interface WatchSosLogMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSosMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSosMapper.java new file mode 100644 index 0000000..3f43799 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSosMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchSos; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.SosPhoneVO; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchSosMapper extends BaseMapper { + + List selectQueryVO(SosPhoneVO sosPhoneVo); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchStepMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchStepMapper.java new file mode 100644 index 0000000..43b1f0a --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchStepMapper.java @@ -0,0 +1,19 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchStep; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.WatchStepVO; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchStepMapper extends BaseMapper { + + WatchStepVO queryVO(HealthQueryVO healthQueryVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSysDeptMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSysDeptMapper.java new file mode 100644 index 0000000..1df0f70 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSysDeptMapper.java @@ -0,0 +1,18 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.WatchSysDept; +import com.smartlive.bswatch.vo.commandVO.SysDeptVO; + +/** + *

+ * 部门表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +public interface WatchSysDeptMapper extends BaseMapper { + + SysDeptVO getSysDeptVO(Integer deptId); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSysOrganiMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSysOrganiMapper.java new file mode 100644 index 0000000..5573e05 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchSysOrganiMapper.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.SysOrgani; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 组织表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +public interface WatchSysOrganiMapper extends BaseMapper { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchTemperatureMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchTemperatureMapper.java new file mode 100644 index 0000000..c0996de --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchTemperatureMapper.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchTemperature; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.TemperatureVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchTemperatureMapper extends BaseMapper { + + List queryVO(HealthQueryVO healthQueryVO); + + List selectByEmpAndTime(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); + + /** + * 查询指定时间段内每天最新的体温记录 + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param empNo 员工编号 + * @return 每天最新的体温记录列表 + */ + List selectLatestTemperatureByDateRange(@Param("empNo") String empNo, @Param("startDate") String startDate, @Param("endDate") String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWarnMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWarnMapper.java new file mode 100644 index 0000000..7bd5ac6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWarnMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchWarn; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.WatchWarnVO; + +import java.util.List; + +/** + *

+ * 腕表定位警报表 Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-08 + */ +public interface WatchWarnMapper extends BaseMapper { + + List selectQueryVO(WatchWarnVO watchWarnVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWaterMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWaterMapper.java new file mode 100644 index 0000000..582d3d7 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWaterMapper.java @@ -0,0 +1,17 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.Water; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-04-01 + */ +public interface WatchWaterMapper extends BaseMapper { + + Water queryWater(); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWhiteMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWhiteMapper.java new file mode 100644 index 0000000..5be9a5b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWhiteMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.smartlive.bswatch.entity.WatchWhite; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.vo.controllerVO.WatchWhiteVO; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchWhiteMapper extends BaseMapper { + + List queryByVO(WatchWhiteVO watchWhiteVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWhitePeriodMapper.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWhitePeriodMapper.java new file mode 100644 index 0000000..6c7f8cf --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/mapper/WatchWhitePeriodMapper.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.smartlive.bswatch.entity.WatchWhitePeriod; +import com.smartlive.bswatch.vo.controllerVO.WatchWhitePeriodVO; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface WatchWhitePeriodMapper extends BaseMapper { + + List selectQueryVO(WatchWhitePeriodVO watchWhitePeriodVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/channel/WatchChannelMap.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/channel/WatchChannelMap.java new file mode 100644 index 0000000..419eb01 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/channel/WatchChannelMap.java @@ -0,0 +1,42 @@ +package com.smartlive.bswatch.netty.channel; + +import io.netty.channel.Channel; +import lombok.extern.slf4j.Slf4j; + +import java.util.concurrent.ConcurrentHashMap; + +@Slf4j +public class WatchChannelMap { + + private static ConcurrentHashMap channelHashMap = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap getChannelHashMap() { + return channelHashMap; + } + + public static void addChannel(String sign, Channel context) { + /* log.info("addChannel---待添加的channel,hashCode=" + context.hashCode()); + Channel channel = getChannel(sign); + log.info("addChannel---当前channel有效,hashCode=" + (channel == null ? "null" : channel.hashCode()));*/ + channelHashMap.put(sign, context); + log.info("addChannel---设置新的channel,hashCode=" + context.hashCode()); + } + + public static Channel getChannel(String sign) { + + if (channelHashMap == null || channelHashMap.isEmpty()) { + log.error("channelmap异常"); + return null; + } + // 通道有效性检测 + Channel channel = channelHashMap.get(sign); + // 通道未激活,移除通道 + if (channel != null && !channel.isActive()) { + log.error("channel无效,执行移除操作,hashCode=" + channel.hashCode()); + channelHashMap.remove(sign); + return null; + } + return channel; + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/event/TestEvent.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/event/TestEvent.java new file mode 100644 index 0000000..e8ba1d3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/event/TestEvent.java @@ -0,0 +1,22 @@ +package com.smartlive.bswatch.netty.event; + +import lombok.Data; +import org.springframework.context.ApplicationEvent; + +/** + * @author:lilj + * @date:2025/2/7 + */ +public class TestEvent extends ApplicationEvent { + + private String message; + + public TestEvent(Object source,String message) { + super(source); + this.message = message; + } + + public String getMessage() { + return message; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/event/WatchCommandBatchEvent.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/event/WatchCommandBatchEvent.java new file mode 100644 index 0000000..5da913f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/event/WatchCommandBatchEvent.java @@ -0,0 +1,25 @@ +package com.smartlive.bswatch.netty.event; + +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import org.springframework.context.ApplicationEvent; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/2/11 + */ + +public class WatchCommandBatchEvent extends ApplicationEvent { + + private List messageVOS; + + public WatchCommandBatchEvent(Object source,List messageVOS) { + super(source); + this.messageVOS = messageVOS; + } + + public List getMessage() { + return messageVOS; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/handler/WatchHandler.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/handler/WatchHandler.java new file mode 100644 index 0000000..d65617e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/handler/WatchHandler.java @@ -0,0 +1,723 @@ +package com.smartlive.bswatch.netty.handler; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.smartlive.bswatch.TO.LocationTO; +import com.smartlive.bswatch.config.TestConfig; +import com.smartlive.bswatch.costant.WatchConstant; +import com.smartlive.bswatch.enmus.WatchApiEnum; +import com.smartlive.bswatch.netty.channel.WatchChannelMap; +import com.smartlive.bswatch.netty.watchvo.MessageHeaderVO; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.bswatch.netty.watchvo.req.deviceUpload.PositionUploadReq; +import com.smartlive.bswatch.netty.watchvo.resp.commonResp.CommonUploadResp; +import com.smartlive.bswatch.netty.watchvo.resp.commonResp.ErrorResp; +import com.smartlive.bswatch.netty.watchvo.resp.deviceResp.*; +import com.smartlive.bswatch.netty.watchvo.resp.entity.GPSLocation; +import com.smartlive.bswatch.netty.watchvo.resp.entity.LbsLocation; +import com.smartlive.bswatch.netty.watchvo.resp.entity.WifiLocation; +import com.smartlive.bswatch.service.IDevicePullDataService; +import com.smartlive.bswatch.service.IDeviceUploadService; +import com.smartlive.bswatch.test.entity.WatchCurrentLocationLog; +import com.smartlive.bswatch.test.service.impl.WatchCurrentLocationLogServiceImpl; +import com.smartlive.bswatch.utils.CardAesUtil; +import com.smartlive.bswatch.utils.PositionUtil; +import com.smartlive.bswatch.utils.WatchMsgParseUtil; +import com.smartlive.common.core.redis.RedisCache; +import com.smartlive.common.utils.spring.SpringUtils; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerContext; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import java.io.UnsupportedEncodingException; +import java.text.ParseException; +import java.util.List; + +/** + * @author:lilj + * @date:2025/1/18 + */ +@Slf4j +@Component +public class WatchHandler { + private static final WatchHandler watchHandler = new WatchHandler(); + + private RedisCache redisCache = SpringUtils.getBean(RedisCache.class); + + + // 设备数据上传处理的service + private IDeviceUploadService deviceUploadService = SpringUtils.getBean(IDeviceUploadService.class); + + // 设备拉取数据的service + private IDevicePullDataService devicePullDataService = SpringUtils.getBean(IDevicePullDataService.class); + + private WatchCurrentLocationLogServiceImpl watchCurrentLocationLogServiceImpl = SpringUtils.getBean(WatchCurrentLocationLogServiceImpl.class); + + private static RestTemplate restTemplate = new RestTemplate(); + + // 测试完成后要删除的代码 + private static final String INFOCODE_KEY = "infocode"; + private static final String RESULT_KEY = "result"; + private static final String DESC_KEY = "desc"; + private static final String LOCATION_KEY = "location"; + private static final String REGEOCODE_KEY = "regeocode"; + private static final String ADDRESS_KEY = "formatted_address"; + private static final String AREA_CODE_KEY = "adcode"; + private static final String ADDRESS_COMPONENT_KEY = "addressComponent"; + + + private WatchHandler() { + } + + public static WatchHandler getInstance() { + return watchHandler; + } + + public void dealMsg(ChannelHandlerContext ctx, String msg) throws ParseException { + + // 根据消息判断业务类型 + // 解析消息:自定解密并转换为实体类 + // 已经自动处理异常,如果消息转换出现异常会返回null + MessageVO messageVO = WatchMsgParseUtil.getMsg(msg); + + // 消息解析失败 + if (messageVO == null) { + log.error("消息解析失败,暂不做处理,消息为:" + msg); + return; + } + + if (messageVO.getMessageHeader() == null || messageVO.getMessageHeader().getMsgType() == null) { + log.error("消息头请求类型缺失,暂不做处理,消息为:" + msg); + return; + } + + // 对于非登录请求且设备主动发起的请求,判断是否已经登录. + if (!WatchApiEnum.LOGIN.getApiName().equals(messageVO.getMessageHeader().getApiName()) && + WatchConstant.MSG_TYPE_UP_REQ.equals(messageVO.getMessageHeader().getMsgType())) { + Boolean isLogin = redisCache.getCacheObject(WatchConstant.LOGIN_PREFIX + messageVO.getMessageHeader().getWatchSign()); + if (isLogin == null || !isLogin) { + log.error("设备未登录,断开连接,消息为:" + msg); + ctx.channel().close(); + return; + } + } + // 响应数据 + dealMsg(ctx.channel(), messageVO); + // 错误发生导致链接断开,避免心跳请求间隔过长,导致下发指令长时间失败;因此每次消息处理都尝试保存连接 + Channel channel = ctx.channel(); + WatchChannelMap.addChannel(messageVO.getMessageHeader().getWatchSign(), channel); + } + + /** + * 响应消息解析处理. + * + * @param channel + * @param messageVO + * @throws ParseException + */ + public void dealMsg(Channel channel, MessageVO messageVO) throws ParseException { + try { + WatchApiEnum byApiName = WatchApiEnum.getByApiName(messageVO.getMessageHeader().getApiName()); + switch (byApiName) { + // 设备请求 + case LOGIN: + // 登录请求 + dealLogin(channel, messageVO); + break; + case GET_BUTTON: + // 获取正长按键 + dealGetButton(channel, messageVO); + break; + case GET_INCOME_CALL: + // 获取可呼入号码 + dealIncomeCall(channel, messageVO); + break; + case GET_CLASS_MODEL: + dealGetClassModel(channel, messageVO); + break; + case GET_SMS_PORT: + case GET_SKIP_MAC: + dealGetSkipMac(channel, messageVO); + break; + case GET_WEATHER_NOW: + dealGetWeatherNow(channel, messageVO); + break; + case GET_WEATHER_FORCAST: + case GET_WEATHER_INFO: + case ERROR_RESP: + // 响应数据 + requestCommonResp(channel, messageVO); + break; + case GET_STUDENT_INFO: + dealGetStudentInfo(channel, messageVO); + break; + + + + // 设备数据上传 + // 电量告警 + case ALARM_POWER: + deviceUploadService.recordPower(messageVO); + uploadCommonResp(channel, messageVO); + break; + case REPORT_SMS_READ: + case REPORT_SOS: + deviceUploadService.recordSos(messageVO); + uploadCommonResp(channel, messageVO); + break; + case REPORT_HEART_HEALTH: + deviceUploadService.recordHealth(messageVO); + uploadCommonResp(channel, messageVO); + break; + case REPORT_LOCATION_INFO: + deviceUploadService.recordLocation(messageVO); + uploadCommonResp(channel, messageVO); + break; + // 通话记录上报 + case REPORT_CALL_LOG: + deviceUploadService.recordCallLog(messageVO); + uploadCommonResp(channel, messageVO); + break; + // 心跳请求 + case REPORT_HEARTBEAT: + dealHearBeatReq(channel, messageVO); + break; + case DEVICE_STATUS: + deviceUploadService.recordWatchModeLog(messageVO); + uploadCommonResp(channel, messageVO); + break; + case REPORT_SLEEP_DATA: + deviceUploadService.recordSleep(messageVO); + uploadCommonResp(channel, messageVO); + break; + // 指令下发后设备的响应 + case SET_INCOMING_CALL: + case SET_NORMAL_BUTTON: + case REQUEST_CALL: + case SEND_SMS: + case FREQUENCY_LOCATION_SET: + case SET_HEARTBEAT: + case SET_CLASS_MODEL: + case SET_STUDENT_INFO: + case SET_REDAY_MODE: + case SET_LOCATION_MODE: + log.info("watchHandler收到下发命令后设备的响应:{}", messageVO); + break; + case LOCATION_INFO_GET: + log.info("watchHandler收到下发命令后设备的响应:{}", messageVO); + deviceUploadService.recordLocation(messageVO); + // updateCurrentLocationLog(messageVO); + break; + default: + log.error("未知的腕表消息类型,接口:" + messageVO.getMessageHeader().getApiName()); + } + } catch (Exception e) { + log.error("watchHandler处理消息异常,messageVO:" + messageVO, e); + + // 消息解析成功,做个异常响应 + if (messageVO != null) { + MessageHeaderVO headerVO = messageVO.getMessageHeader(); + // 其他情况不做处理 + if (headerVO != null && headerVO.getMsgType() != null) { + // 1:设备请求消息 2:平台响应消息 出现异常返回异常消息体 + if (WatchConstant.MSG_TYPE_UP_REQ.equals(headerVO.getMsgType()) || WatchConstant.MSG_TYPE_UP_RESP.equals(headerVO.getMsgType())) { + msgExceptionResponse(channel, messageVO); + } + + } + } + } + } + + + /** + * 收到设备获取实时位置的响应处理 + * + * @param messageVO + */ + public void updateCurrentLocationLog(MessageVO messageVO) { + MessageHeaderVO header = messageVO.getMessageHeader(); + WatchCurrentLocationLog watchCurrentLocationLog = new WatchCurrentLocationLog(); + try { + // 实时定位数据获取 + Integer id = redisCache.getCacheObject(header.getApiName() + ":" + header.getBusinessNo()); + Long locationId = Long.valueOf(id); + watchCurrentLocationLog.setLocationId(locationId); + watchCurrentLocationLog.setWatchMsg(JSON.toJSONString(messageVO)); + + if (messageVO.getMessageBody() == null || "1".equals(messageVO.getMessageBody())) { + watchCurrentLocationLog.setWatchMsg("[" + header.toString() + ",1]"); + // 定位失败 + watchCurrentLocationLog.setType(2); + watchCurrentLocationLog.setGaodeMsg("定位失败"); + log.error("获取位置信息定位失败"); + return; + } + PositionUploadReq positionUploadReq = (PositionUploadReq) messageVO.getMessageBody(); + // 尝试获取地址信息 + String posType = positionUploadReq.getPosType(); + if ("1".equals(posType)) { + gpsPosition(positionUploadReq.getGpsLocation(), watchCurrentLocationLog); + } else if ("0".equals(posType)) { + smartPosition(positionUploadReq.getLbsLocation(), positionUploadReq.getWifiLocationList(), watchCurrentLocationLog); + } + + } finally { + if (watchCurrentLocationLog.getLocationId() != null) { + watchCurrentLocationLogServiceImpl.updateById(watchCurrentLocationLog); + } + } + + // watchCurrentLocationLogServiceImpl + } + + // 解析地址信息 + public void gpsPosition(GPSLocation gpsLocation, WatchCurrentLocationLog watchCurrentLocationLog) { + // key:97509bb13f02a18faf682d0f3853635e + // GPS定位key17d09033036d5e2b3d5ccf646727a5ae + String gpsUrl = "https://restapi.amap.com/v3/geocode/regeo"; + String location = gpsLocation.toString(); + String fullUrl = UriComponentsBuilder.fromHttpUrl(gpsUrl) + .queryParam("key", "17d09033036d5e2b3d5ccf646727a5ae") + .queryParam("location", location) + .toUriString(); + log.info("fullUrl:" + fullUrl); + // 发送 GET 请求 + try { + ResponseEntity response = restTemplate.getForEntity(fullUrl, String.class); + watchCurrentLocationLog.setGaodeMsg(response.toString()); + watchCurrentLocationLog.setGaodeUrl(fullUrl); + + if (response.getStatusCode() == HttpStatus.OK) { + String body = response.getBody(); + JSONObject jsonObject = JSONObject.parseObject(body, JSONObject.class); + String infocode = jsonObject.getString(INFOCODE_KEY); + if ("10000".equals(infocode)) { + JSONObject result = jsonObject.getJSONObject(REGEOCODE_KEY); + if (result != null) { + String address = result.getString(ADDRESS_KEY); + JSONObject addressComponent = result.getJSONObject(ADDRESS_COMPONENT_KEY); + String areaCode = null; + if(addressComponent != null){ + areaCode = addressComponent.getString(AREA_CODE_KEY); + } + LocationTO locationTO = PositionUtil.buildLocationTO(gpsLocation.getLongitude(), gpsLocation.getLatitude(), address,areaCode); + + watchCurrentLocationLog.setType(0); + } else { + String errorInfo = "高德GPS定位接口返回的结果为空"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } else { + String errorInfo = "高德GPS定位接口正常,但返回错误信息"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + + } + } else { + String errorInfo = "高德GPS定位接口调用失败"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } catch (RestClientException e) { + String errorInfo = "高德GPS定位接口调用失败:" + e.getMessage(); + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + + } catch (Exception e) { + String errorInfo = "高德GPS定位接口调用失败:" + e.getMessage(); + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + + } + + // 解析地址信息 + public void smartPosition(LbsLocation lbsLocation, List wifiLocationList, WatchCurrentLocationLog watchCurrentLocationLog) { + // 请求示例: + // http://apilocate.amap.com/position?accesstype=0&key=97509bb13f02a18faf682d0f3853635e&bts=460,01,11433,68256005,-56&macs=F4:83:CD:CA:67:3E&macs=F6:96:DE:96:FE:EB&macs=54:35:30:2F:26:BA + String smartUrl = "http://apilocate.amap.com/position"; + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(smartUrl) + .queryParam("accesstype", 0) + .queryParam("key", "122dc1af53c8267b71c869220e25780d") + .queryParam("bts", lbsLocation.toQueryString()); // LBS信息 + if (!CollectionUtils.isEmpty(wifiLocationList)) { + for (WifiLocation wifiLocation : wifiLocationList) { + uriComponentsBuilder.queryParam("macs", wifiLocation.getMac()); + } + } + String fullUrl = uriComponentsBuilder.toUriString(); + log.info("fullUrl:" + fullUrl); + // 发送 GET 请求 + try { + ResponseEntity response = restTemplate.getForEntity(fullUrl, String.class); + + watchCurrentLocationLog.setGaodeMsg(response.toString()); + watchCurrentLocationLog.setGaodeUrl(fullUrl); + if (response.getStatusCode() == HttpStatus.OK) { + String body = response.getBody(); + JSONObject jsonObject = JSONObject.parseObject(body, JSONObject.class); + String infocode = jsonObject.getString(INFOCODE_KEY); + if ("10000".equals(infocode)) { + JSONObject result = jsonObject.getJSONObject(RESULT_KEY); + if (result != null) { + String address = result.getString(DESC_KEY); + String location = result.getString(LOCATION_KEY); + String areaCode = result.getString(AREA_CODE_KEY); + if (location != null && location.contains(",")) { + String[] split = location.split(","); + if (split.length == 2) { + LocationTO locationTO = PositionUtil.buildLocationTO(split[0], split[1], address,areaCode); + watchCurrentLocationLog.setType(0); + } else { + + String errorInfo = "高德智能定位接口返回的位置格式不正确,不予记录"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } else { + String errorInfo = "高德智能定位接口返回的位置为空或格式不正确"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } else { + String errorInfo = "高德智能定位接口返回的结果为空"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } else { + String errorInfo = "高德智能定位接口正常,但返回错误信息"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } else { + String errorInfo = "高德智能定位接口调用失败"; + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } catch (RestClientException e) { + String errorInfo = "高德智能定位接口调用失败:" + e.getMessage(); + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } catch (Exception e) { + String errorInfo = "高德智能定位接口调用失败:" + e.getMessage(); + watchCurrentLocationLog.setErroInfo(errorInfo); + watchCurrentLocationLog.setType(4); + } + } + + private void dealHearBeatReq(Channel channel, MessageVO messageVO) { + try { + WatchChannelMap.addChannel(messageVO.getMessageHeader().getWatchSign(), channel); + // 记录步数数据 + deviceUploadService.recordStep(messageVO); + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + messageVO.setMessageBody("0"); + msgResponse(channel, messageVO); + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + private void dealGetStudentInfo(Channel channel, MessageVO messageVO) { + try { + + MessageHeaderVO header = messageVO.getMessageHeader(); + // 获取按键回复异常 + // StudentInfoResp respVO = StudentInfoResp.defaultResp(); + StudentInfoResp respVO = devicePullDataService.getStudentInfoResp(messageVO); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + if (TestConfig.realResp == true || !messageVO.getMessageHeader().getApiName().equals(TestConfig.bizType)) { + messageVO.setMessageBody(respVO); + } else { + // 使用模拟请求 + respVO = JSON.to(StudentInfoResp.class, TestConfig.paramObject); + messageVO.setMessageBody(respVO); + } + + + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + + /** + * 登录处理 + * + * @param channel + * @param messageVO + */ + private void dealLogin(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + String watchSign = header.getWatchSign(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 执行业务逻辑:缓存信息,数据变动更新,未变动不更新. + // 可能会变动的字段:watch_sign(查询用),protocol_version,rfid,iccid + boolean isSuccess = deviceUploadService.login(messageVO); + // 登录回复 + LoginResp respVO = isSuccess ? LoginResp.successLogin() : LoginResp.failRegister(); + if (isSuccess) { + // 保存设备channel + WatchChannelMap.addChannel(watchSign, channel); + redisCache.setCacheObject(WatchConstant.LOGIN_PREFIX + watchSign, true); + } + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + if (TestConfig.realResp == true || !messageVO.getMessageHeader().getApiName().equals(TestConfig.bizType)) { + messageVO.setMessageBody(respVO); + } else { + // 使用模拟请求 + respVO = JSON.to(LoginResp.class, TestConfig.paramObject); + messageVO.setMessageBody(respVO); + } + + msgResponse(channel, messageVO); + if (!isSuccess) { + // 断开连接 + channel.close(); + } + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + + /** + * 获取按键处理 + * + * @param channel + * @param messageVO + */ + private void dealGetButton(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + // 获取按键回复异常 + // 查询watch_sos以及emp_phone的亲情电话 + // NormalButtonResp respVO = new NormalButtonResp(); + NormalButtonResp respVO = devicePullDataService.getButton(messageVO); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + if (TestConfig.realResp == true || !messageVO.getMessageHeader().getApiName().equals(TestConfig.bizType)) { + messageVO.setMessageBody(respVO); + } else { + // 使用模拟请求 + respVO = JSON.to(NormalButtonResp.class, TestConfig.paramObject); + messageVO.setMessageBody(respVO); + } + + + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + /** + * 获取可呼入号码处理 + * + * @param channel + * @param messageVO + */ + private void dealIncomeCall(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 获取按键回复异常 + // IncomeCallResp respVO = new IncomeCallResp(); + // List times = new ArrayList<>(); + // times.add(WatchConstant.ALL_TIME); + // respVO.addPhoneNode("18639771948", times, "lhs"); + // respVO.setPeriod(WatchConstant.ALL_PERIOD); + // respVO.setIncallLimit("0"); + IncomeCallResp respVO = devicePullDataService.getIncomeCall(messageVO); + + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + if (TestConfig.realResp == true || !messageVO.getMessageHeader().getApiName().equals(TestConfig.bizType)) { + messageVO.setMessageBody(respVO); + } else { + // 使用模拟请求 + respVO = JSON.to(IncomeCallResp.class, TestConfig.paramObject); + messageVO.setMessageBody(respVO); + } + + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + /** + * 获取课堂模式处理 + * + * @param channel + * @param messageVO + */ + private void dealGetClassModel(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 获取按键回复异常 + // ClassModelResp respVO = ClassModelResp.getDefault(); + ClassModelResp respVO = devicePullDataService.getClassModelResp(messageVO); + if (TestConfig.realResp == true || !messageVO.getMessageHeader().getApiName().equals(TestConfig.bizType)) { + messageVO.setMessageBody(respVO); + } else { + // 使用模拟请求 + respVO = JSON.to(ClassModelResp.class, TestConfig.paramObject); + messageVO.setMessageBody(respVO); + } + + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + private void dealGetSkipMac(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 获取按键回复异常 + // ClassModelResp respVO = ClassModelResp.getDefault(); + String mac = devicePullDataService.getSkipMac(messageVO); + // 0 代表无设置 + mac = StringUtils.isBlank(mac) ? "0" : mac; + messageVO.setMessageBody(mac); + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + private void dealGetWeatherNow(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 使用缓存测试用 + String resp = redisCache.getCacheObject("weather_config:weather_info"); + String useCache = redisCache.getCacheObject("weather_config:weather_use_cache"); + if (StringUtils.isNotBlank(resp) && "1".equals(useCache)) { + messageVO.setMessageBody(resp); + msgResponse(channel, messageVO); + return; + } + PositionUploadReq req = (PositionUploadReq) messageVO.getMessageBody(); + WeatherNowResp weatherNowResp = PositionUtil.getWeatherNow(req); + messageVO.setMessageBody(weatherNowResp); + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + public void msgResponse(Channel channel, MessageVO messageVO) throws UnsupportedEncodingException { + String resp = WatchMsgParseUtil.msgResp(messageVO); + log.info("响应数据为:" + resp); + String enResp = new String(CardAesUtil.encryptBsj(resp.getBytes()), "UTF-8"); + log.info("加密响应密文为:" + enResp); + channel.writeAndFlush(enResp); + } + + public void msgExceptionResponse(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 暂不使用,直接返回未设置 + ErrorResp respVO = ErrorResp.UNKNOWN_ERROR; + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + messageVO.setMessageBody(respVO); + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + + } + + /** + * 设备数据上传公用响应 + * + * @param channel + * @param messageVO + */ + private void uploadCommonResp(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + // 获取按键回复正常 + CommonUploadResp respVO = CommonUploadResp.NORMAL; + messageVO.setMessageBody(respVO); + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "接口上传数据回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "上传数据回复异常"); + } + } + + /** + * 设备请求,统一未设置异常响应 + */ + private void requestCommonResp(Channel channel, MessageVO messageVO) { + try { + MessageHeaderVO header = messageVO.getMessageHeader(); + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + + // 暂不使用,直接返回未设置 + ErrorResp respVO = ErrorResp.NO_SETTING; + header.setMsgType(WatchConstant.MSG_TYPE_UP_RESP); + messageVO.setMessageBody(respVO); + msgResponse(channel, messageVO); + + } catch (Exception e) { + String apiName = messageVO.getMessageHeader().getApiName(); + log.error(apiName + "回复异常:" + e.getMessage()); + throw new RuntimeException(apiName + "回复异常"); + } + } + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/EmpPhoneModifyListener.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/EmpPhoneModifyListener.java new file mode 100644 index 0000000..7f963f8 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/EmpPhoneModifyListener.java @@ -0,0 +1,31 @@ +package com.smartlive.bswatch.netty.listener; + +import com.smartlive.bswatch.service.CommonService; +import com.smartlive.common.watchEvent.EmpPhoneModifyEvent; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +/** + * @author:lilj + * @date:2025/2/12 + */ +@Slf4j +@Component +public class EmpPhoneModifyListener implements ApplicationListener { + @Autowired + private CommonService commonService; + @Async + @Override + public void onApplicationEvent(EmpPhoneModifyEvent event) { + String watchSign = event.getWatchSign(); + log.info("收到监听到修改手机号的事件,watchSign:"+watchSign); + + log.info("=========> 开始调用commonService的setButton,下发命令"); + commonService.setButton(watchSign); + log.info("==========> 结束调用commonService的setWhitePhone,下发命令完成"); + + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/TestListener.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/TestListener.java new file mode 100644 index 0000000..0e94fe4 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/TestListener.java @@ -0,0 +1,34 @@ +package com.smartlive.bswatch.netty.listener; + +import com.smartlive.bswatch.netty.event.TestEvent; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +/** + * @author:lilj + * @date:2025/2/7 + */ +@Slf4j +@Component +public class TestListener implements ApplicationListener { + + /** + * 事件异步处理 + * @param event + */ + @Async() + @Override + public void onApplicationEvent(TestEvent event) { + try { + TimeUnit.SECONDS.sleep(10L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + log.info("监听者的线程:"+Thread.currentThread().getName()); + log.info("接收到事件的消息:"+event.getMessage()); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/WatchBatchCommandListener.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/WatchBatchCommandListener.java new file mode 100644 index 0000000..b6fdf52 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/listener/WatchBatchCommandListener.java @@ -0,0 +1,39 @@ +package com.smartlive.bswatch.netty.listener; + +import com.smartlive.bswatch.netty.event.WatchCommandBatchEvent; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.bswatch.utils.WatchMsgSendUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +/** + * @author:lilj + * @date:2025/2/7 + */ +@Slf4j +@Component +public class WatchBatchCommandListener implements ApplicationListener { + + /** + * 事件异步处理 + * @param event + */ + @Async() + @Override + public void onApplicationEvent(WatchCommandBatchEvent event) { + log.info("批量命令监听者的线程:"+Thread.currentThread().getName()); + if(event==null || CollectionUtils.isEmpty(event.getMessage())){ + log.info("批量命令为空,直接跳过"); + return; + } + log.info("开始批量执行命令"); + for (MessageVO messageVO : event.getMessage()){ + WatchMsgSendUtil.sendCommandWithoutException(messageVO); + } + log.info("批量命令执行成功"); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/publisher/TestPublisher.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/publisher/TestPublisher.java new file mode 100644 index 0000000..87f1efd --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/publisher/TestPublisher.java @@ -0,0 +1,25 @@ +package com.smartlive.bswatch.netty.publisher; + +import com.smartlive.bswatch.netty.event.TestEvent; +import lombok.extern.slf4j.Slf4j; +import org.reactivestreams.Publisher; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Component; + +/** + * @author:lilj + * @date:2025/2/7 + */ +@Slf4j +@Component +public class TestPublisher { + @Autowired + private ApplicationEventPublisher publisher; + + public void publish(String message) { + log.info("发布者的线程:"+Thread.currentThread().getName()); + TestEvent testEvent = new TestEvent(this, message); + publisher.publishEvent(testEvent); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/publisher/WatchBatchCommandPublisher.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/publisher/WatchBatchCommandPublisher.java new file mode 100644 index 0000000..04746e6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/publisher/WatchBatchCommandPublisher.java @@ -0,0 +1,28 @@ +package com.smartlive.bswatch.netty.publisher; + +import com.smartlive.bswatch.netty.event.WatchCommandBatchEvent; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/2/11 + */ + +@Slf4j +@Component +public class WatchBatchCommandPublisher { + + @Autowired + private ApplicationEventPublisher publisher; + public void publish(List messageVOS) { + log.info("批量命令发布者的线程:"+Thread.currentThread().getName()); + WatchCommandBatchEvent event = new WatchCommandBatchEvent(this, messageVOS); + publisher.publishEvent(event); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/ConvertCode.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/ConvertCode.java new file mode 100644 index 0000000..808cdb7 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/ConvertCode.java @@ -0,0 +1,214 @@ +package com.smartlive.bswatch.netty.tcp; + +public class ConvertCode { + /** + * @Title:bytes2HexString + * @Description:字节数组转16进制字符串 + * @param b + * 字节数组 + * @return 16进制字符串 + * @throws + */ + public static String bytes2HexString(byte[] b) { + StringBuffer result = new StringBuffer(); + String hex; + for (int i = 0; i < b.length; i++) { + hex = Integer.toHexString(b[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + result.append(hex.toUpperCase()); + } + return result.toString(); + } + /** + * @Title:hexString2Bytes + * @Description:16进制字符串转字节数组 + * @param src 16进制字符串 + * @return 字节数组 + */ + public static byte[] hexString2Bytes(String src) { + int l = src.length() / 2; + byte[] ret = new byte[l]; + for (int i = 0; i < l; i++) { + ret[i] = (byte) Integer + .valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue(); + } + return ret; + } + /** + * @Title:string2HexString + * @Description:字符串转16进制字符串 + * @param strPart 字符串 + * @return 16进制字符串 + */ + public static String string2HexString(String strPart) { + StringBuffer hexString = new StringBuffer(); + for (int i = 0; i < strPart.length(); i++) { + int ch = (int) strPart.charAt(i); + String strHex = Integer.toHexString(ch); + hexString.append(strHex); + } + return hexString.toString(); + } + /** + * @Title:hexString2String + * @Description:16进制字符串转字符串 + * @param src + * 16进制字符串 + * @return 字节数组 + * @throws + */ + public static String hexString2String(String src) { + String temp = ""; + for (int i = 0; i < src.length() / 2; i++) { + //System.out.println(Integer.valueOf(src.substring(i * 2, i * 2 + 2),16).byteValue()); + temp = temp+ (char)Integer.valueOf(src.substring(i * 2, i * 2 + 2),16).byteValue(); + } + return temp; + } + /** + * @Title:char2Byte + * @Description:字符转成字节数据char-->integer-->byte + * @param src + * @return + * @throws + */ + public static Byte char2Byte(Character src) { + return Integer.valueOf((int)src).byteValue(); + } + /** + * @Title:intToHexString + * @Description:10进制数字转成16进制 + * @param a 转化数据 + * @param len 占用字节数 + * @return + * @throws + */ + public static String intToHexString(int a,int len){ + len<<=1; + String hexString = Integer.toHexString(a); + int b = len -hexString.length(); + if(b>0){ + for(int i=0;i1 + 1 xor f7-->f6 + f6 xor 0f-->f9 + .... + 62 xor 84-->e6 + 即,得到的一字节校验码为:e6 + * @return + */ + public static String xor(String strHex_X,String strHex_Y){ + //将x、y转成二进制形式 + String anotherBinary=Integer.toBinaryString(Integer.valueOf(strHex_X,16)); + String thisBinary=Integer.toBinaryString(Integer.valueOf(strHex_Y,16)); + String result = ""; + //判断是否为8位二进制,否则左补零 + if(anotherBinary.length() != 8){ + for (int i = anotherBinary.length(); i <8; i++) { + anotherBinary = "0"+anotherBinary; + } + } + if(thisBinary.length() != 8){ + for (int i = thisBinary.length(); i <8; i++) { + thisBinary = "0"+thisBinary; + } + } + //异或运算 + for(int i=0;i"07dd" + * @param input 需要补位的字符串 + * @param size 补位后的最终长度 + * @param symbol 按symol补充 如'0' + * @return + * N_TimeCheck中用到了 + */ + public static String fill(String input, int size, char symbol) { + while (input.length() < size) { + input = symbol + input; + } + return input; + } + public static String getReply(Integer schoolId,Integer num,Integer volume){ + String prefix = string2HexString("ZF"); + String schoolIds = intToHexString(schoolId, 1); + String nums = intToHexString(num, 1); + if (volume==0){ + return prefix+"20"+schoolIds+nums+"0D0A"; + } + String volumes = intToHexString(volume, 1); + return prefix+"40"+schoolIds+nums+volumes+"0D0A"; + } + public static void main(String args[]) { + String prefix = string2HexString("ZF"); + String schoolId = intToHexString(10, 1); + String num = intToHexString(251, 1); + String vo = intToHexString(3, 1); + String a=prefix+"40"+schoolId+num+vo+"0D0A"; + System.out.println(a); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/MyDecoder.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/MyDecoder.java new file mode 100644 index 0000000..8ac4b7f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/MyDecoder.java @@ -0,0 +1,76 @@ +package com.smartlive.bswatch.netty.tcp; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.ByteToMessageDecoder; + +import java.io.UnsupportedEncodingException; +import java.util.List; + +public class MyDecoder extends ByteToMessageDecoder { + /** + * 正式环境使用UTF8 + * windows端模拟TCP使用的编码是GBK\ + * 需要拼包处理 + */ + public final static String encoding = "UTF-8"; + + public final static String suffix = "#kdsjafjalsdjg#170"; + private final int suffixLength = suffix.getBytes(encoding).length; + private final ByteBuf cumulation = Unpooled.buffer(); + + public MyDecoder() throws UnsupportedEncodingException { + } + + @Override + protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List list) throws Exception { + + // 将接收到的数据累积到cumulation中 + cumulation.writeBytes(byteBuf); + + // 查找结束标志"abc" + int endIndex = indexOf(byteBuf); + if (endIndex != -1) { + // 提取完整的消息 + int messageLength = endIndex+(cumulation.writerIndex() - byteBuf.readerIndex()- cumulation.readerIndex()); + ByteBuf message = cumulation.readBytes(messageLength); + byte[] req = new byte[message.readableBytes()]; + message.readBytes(req); + String enMsg = new String(req, encoding); + // String msg= CardAesUtil.decryptBsj(enMsg); + // System.out.println("腕表解密:" + msg); + list.add(enMsg); + } + } + + /** + * 获取输入字节包含结束标志的索引位置. + * @param byteBuf + * @return + * @throws UnsupportedEncodingException + */ + public int indexOf(ByteBuf byteBuf) throws UnsupportedEncodingException { + int endIndex = -1; + byte[] suffixBytes = suffix.getBytes(encoding); + // 跳过已读的数据 + for (int i = 0; i <= byteBuf.writerIndex() - suffixBytes.length; i++) { + boolean found = true; + for (int j = 0; j < suffixBytes.length; j++) { + if (byteBuf.getByte(i + j) != suffixBytes[j]) { + found = false; + break; + } + } + if (found) { + endIndex = i+suffixBytes.length; + break; + } + } + return endIndex; + } + + public static void main(String[] args) throws UnsupportedEncodingException { + System.out.println("abc".getBytes(encoding).length); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/MyEncoder.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/MyEncoder.java new file mode 100644 index 0000000..69d7631 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/tcp/MyEncoder.java @@ -0,0 +1,46 @@ +package com.smartlive.bswatch.netty.tcp; + +import com.smartlive.bswatch.utils.CardAesUtil; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToByteEncoder; + +public class MyEncoder extends MessageToByteEncoder { + + public static String encoding = "UTF-8"; + @Override + protected void encode(ChannelHandlerContext channelHandlerContext, String s, ByteBuf byteBuf) throws Exception { + //将16进制字符串转为数组 + + byte[] bytes = CardAesUtil.encryptBsj(s.getBytes(encoding)); + System.out.println("加密后的数据:"+new String(bytes,encoding)); + byteBuf.writeBytes(bytes); + } + + /** + + * @Title:hexString2Bytes + + * @Description:16进制字符串转字节数组 + + * @param src 16进制字符串 + + * @return 字节数组 + + */ + + public static byte[] hexString2Bytes(String src) { + + int l = src.length() / 2; + + byte[] ret = new byte[l]; + + for (int i = 0; i < l; i++) { + + ret[i] = (byte) Integer.valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue(); + + } + + return ret; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/MessageHeaderVO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/MessageHeaderVO.java new file mode 100644 index 0000000..bd8e4d5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/MessageHeaderVO.java @@ -0,0 +1,58 @@ +package com.smartlive.bswatch.netty.watchvo; + +import lombok.Data; + +import java.util.Date; + +/** + * @author:lilj + * @date:2025/1/18 + */ + +/** + * 腕表TCP消息头 + */ +@Data +public class MessageHeaderVO { + //[865593070205859,89860120801609197568,202501171655470039,DEVICE_LOGIN,3,20250117165547,23,5@1@1@1@1@16@0070205859] + /** + * 腕表唯一标识 + */ + private String watchSign; + + /** + * ICCID:sim卡ICCID + */ + private String iccid; + + /** + * 腕表交易流水号 + */ + private String businessNo; + + /** + * 接口标识:接口名称 + */ + private String apiName; + + /** + * 报文类型:1.下发请求,2 下发响应;3,上报请求;4.上报响应 + */ + private String msgType; + + /** + * 报文时间:yyyyMMddHHmmss,平台内部时间格式:yyyy:MM:dd HH:mm:ss + */ + private String msgTime; + + /** + * 报文长度:报文长度,字节数 + */ + private Integer msgLength; + + @Override + public String toString() { + return watchSign + "," + iccid + "," + businessNo + "," + apiName + "," + msgType + "," + msgTime + "," + msgLength; + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/MessageVO.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/MessageVO.java new file mode 100644 index 0000000..baa6324 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/MessageVO.java @@ -0,0 +1,15 @@ +package com.smartlive.bswatch.netty.watchvo; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/18 + */ +@Data +public class MessageVO { + private MessageHeaderVO messageHeader; + + private Object messageBody; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/ClassModelReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/ClassModelReq.java new file mode 100644 index 0000000..d554fb8 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/ClassModelReq.java @@ -0,0 +1,13 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@Data +public class ClassModelReq extends SimpleReq { + +} + diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/GetBalanceInfoReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/GetBalanceInfoReq.java new file mode 100644 index 0000000..a7acfea --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/GetBalanceInfoReq.java @@ -0,0 +1,11 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/4/8 + */ +@Data +public class GetBalanceInfoReq extends SimpleReq{ +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/HeartReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/HeartReq.java new file mode 100644 index 0000000..5b051fa --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/HeartReq.java @@ -0,0 +1,24 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +/** + * @author:lilj + * @date:2025/1/20 + */ + +/** + * 设备心跳请求VO + */ +public class HeartReq { + + /** + * 电池电量 + */ + private String battery; + + /** + * 当前步数,没有该项会传0 + */ + private Integer steps; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/IncomeCallReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/IncomeCallReq.java new file mode 100644 index 0000000..e0210a0 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/IncomeCallReq.java @@ -0,0 +1,12 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@Data +public class IncomeCallReq extends SimpleReq { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/LoginReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/LoginReq.java new file mode 100644 index 0000000..53eed55 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/LoginReq.java @@ -0,0 +1,48 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/18 + */ +@Data +public class LoginReq { + /** + * 腕表按键数量 + */ + private Integer keyNums; + + /** + * 有无SOS按键: 0-无 1-有 + */ + private Integer hasSosKey; + + /** + * 暂无类型含义 + */ + private String terminalType; + + + + /** + * 终端是否支持区域报警:0 无; 1 有 + */ + private Integer hasAreaAlarm; + + /** + * 是否具备设备呼入功能:0 无;1 有 + */ + private Integer hasCallIn; + + /** + * 终端协议版本 + */ + private String protocolVersion; + + /** + * RFID:RFID 10进制的,一般是以 13.56M 号码这准号码 + */ + private String rfid; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/NormaButtonReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/NormaButtonReq.java new file mode 100644 index 0000000..f701288 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/NormaButtonReq.java @@ -0,0 +1,13 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@Data +public class NormaButtonReq extends SimpleReq { + // [865593070205859,89860120801609197568,202501201139220185,GET_NORMAL_BUTTON,3,20250120113922,1,1] + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SimpleReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SimpleReq.java new file mode 100644 index 0000000..8915224 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SimpleReq.java @@ -0,0 +1,20 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@Data +public class SimpleReq { + /** + * 目前就传个1 + */ + private String content; + + @Override + public String toString() { + return content; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SkipMacReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SkipMacReq.java new file mode 100644 index 0000000..c3a4834 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SkipMacReq.java @@ -0,0 +1,17 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/20 + */ + +/** + * 获取跳绳蓝牙mac + */ +@Data +public class SkipMacReq extends SimpleReq { + +} + diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SmsPortReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SmsPortReq.java new file mode 100644 index 0000000..7013d30 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/SmsPortReq.java @@ -0,0 +1,8 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +/** + * @author:lilj + * @date:2025/1/21 + */ +public class SmsPortReq extends SimpleReq { +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/StudentInfoReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/StudentInfoReq.java new file mode 100644 index 0000000..6f96bed --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceReq/StudentInfoReq.java @@ -0,0 +1,8 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceReq; + +/** + * @author:lilj + * @date:2025/1/22 + */ +public class StudentInfoReq extends SimpleReq{ +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/CallLogUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/CallLogUploadReq.java new file mode 100644 index 0000000..becb452 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/CallLogUploadReq.java @@ -0,0 +1,40 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CallLogUploadReq { + // 目标电话号码@开始时间!结束时间@通话时长 + // @呼入呼出 + + /** + * 对方电话号 + */ + private String phone; + + /** + * 开始时间 + */ + private String startTime; + /** + * 结束时间 + */ + private String endTime; + + /** + * 通话时长:单位s + */ + private Integer duration; + /** + * 呼入呼出:0呼入,1呼出 + */ + private String callType; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/DeviceStatusUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/DeviceStatusUploadReq.java new file mode 100644 index 0000000..2543e71 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/DeviceStatusUploadReq.java @@ -0,0 +1,45 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/2/8 + */ +@Data +public class DeviceStatusUploadReq { + + //切换前模式@切换后模式@切换时间(格林威治时间到现在毫秒数)@已在之前模式下工作时长(分钟) + //2@3@1738985663000@27 + + + /** + * 切换前模式: + * 0 待机模式 + * 1 省电模式 + * 2 平衡模式 + * 3 实时模式 + */ + private Integer beforeMode; + + /** + * 切换后模式 + * 0 待机模式 + * 1 省电模式 + * 2 平衡模式 + * 3 实时模式 + */ + private Integer afterMode; + + /** + * 切换时间:毫秒 + */ + private Long changeTime; + + /** + * 之前模式工作时间 + */ + private Integer workTime; + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/HeartHealthUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/HeartHealthUploadReq.java new file mode 100644 index 0000000..19bc0d5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/HeartHealthUploadReq.java @@ -0,0 +1,46 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@Data +public class HeartHealthUploadReq { + + //血氧@心率@温度@佩戴状态@上报状态 + // @收缩压@舒张压 + /** + * 血氧 + */ + private String bOxy; + + /** + * 心率 + */ + private Integer heartRate; + /** + * 体温 + */ + private String temperature; + + /** + * 佩戴状态:0 未佩戴 1 佩戴 + */ + private Integer wearStatus; + /** + * 上报状态:0 定时上报 1 主动上报 + */ + private Integer reportStatus; + + /** + * 血压:收缩压 + */ + private String highBloodPressure; + + /** + * 血压:舒张压 + */ + private String lowBloodPressure; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/HeartUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/HeartUploadReq.java new file mode 100644 index 0000000..ab37730 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/HeartUploadReq.java @@ -0,0 +1,23 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +/** + * 心跳请求VO + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class HeartUploadReq { + + private String power; + + private Integer steps; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/PositionUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/PositionUploadReq.java new file mode 100644 index 0000000..3d46b94 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/PositionUploadReq.java @@ -0,0 +1,35 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import com.smartlive.bswatch.netty.watchvo.resp.entity.GPSLocation; +import com.smartlive.bswatch.netty.watchvo.resp.entity.LbsLocation; +import com.smartlive.bswatch.netty.watchvo.resp.entity.WifiLocation; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PositionUploadReq { + // 数据[865593070205859,89860120801609197568,202501211150531680,REPORT_LOCATION_INFO,3,20250121115053,340, + // 2E0.000000N0.000000T00000000000000@ + // 460!1!11433!68256005!-56 + // @wifi1!F4:83:CD:CA:67:3E!-36#wifi2!F6:96:DE:96:FE:EB!-49#wifi3!54:35:30:2F:26:BA!-57#wifi4!F0:A6:54:F9:81:15!-58#wifi5!4C:D0:CB:DE:EA:28!-60#wifi6!80:C5:48:82:14:E4!-60#wifi7!88:25:93:70:B5:C4!-64#wifi8!B4:77:48:CC:51:88!-66#wifi9!54:75:95:D8:0A:51!-66#wifi10!CC:08:FB:EF:1B:55!-71] + + /** + * 使用定位类型:0:LBS+wifi 1:GPS + * 截取响应体第一位得到 + */ + private String posType; + + private GPSLocation gpsLocation; + private List wifiLocationList; + private LbsLocation lbsLocation; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/PowerUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/PowerUploadReq.java new file mode 100644 index 0000000..3290a30 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/PowerUploadReq.java @@ -0,0 +1,27 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PowerUploadReq { + // 4@55% + /** + * 上报类型(1=缺电报警; 2=关机报警 ; 3=自 + * 动关机报警 ; 4=开机报警,5=设备充电,6=电 + * 源已断开 7=设备电量已充满) + */ + private String powerType; + + /** + * 电量百分比 + */ + private String power; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SleepUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SleepUploadReq.java new file mode 100644 index 0000000..f6f40ff --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SleepUploadReq.java @@ -0,0 +1,23 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/3/17 + */ +@Data +public class SleepUploadReq { + + //[35380100360174,898600MFSSYYGXXXXXXP,201805082000001000, + // REPORT_SLEEP_DATA,3,20180528111820,18,2 00-0600@240@120@60] + // 睡眠开始时间-睡眠结束时间@睡眠总时长@深 + // 睡时长@浅睡时长@REM快速眼动时长@清醒时 + private String sleepPeriod; + private String sleepTotalTime; + private String deepSleepTime; + private String lightSleepTime; + private String remSleepTime; + private String wakeTime; + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SmsReadUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SmsReadUploadReq.java new file mode 100644 index 0000000..e1bfb6d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SmsReadUploadReq.java @@ -0,0 +1,21 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@Data +public class SmsReadUploadReq { + + /** + * 消息编号uuid + */ + private String smsUuid; + + /** + * 阅读方式:1 播报已阅;2 屏幕查看已阅; 3 按键已阅;4 其他方式已阅 + */ + private String readType; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SosUploadReq.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SosUploadReq.java new file mode 100644 index 0000000..9d44430 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/req/deviceUpload/SosUploadReq.java @@ -0,0 +1,10 @@ +package com.smartlive.bswatch.netty.watchvo.req.deviceUpload; + +import com.smartlive.bswatch.netty.watchvo.req.deviceReq.SimpleReq; + +/** + * @author:lilj + * @date:2025/1/22 + */ +public class SosUploadReq extends SimpleReq { +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/commonResp/CommonUploadResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/commonResp/CommonUploadResp.java new file mode 100644 index 0000000..d6ff04f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/commonResp/CommonUploadResp.java @@ -0,0 +1,39 @@ +package com.smartlive.bswatch.netty.watchvo.resp.commonResp; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 设备数据上报通用响应类 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CommonUploadResp { + String content; + /** + * 正常 + */ + public static final CommonUploadResp NORMAL = new CommonUploadResp("0"); + /** + * 非平台用户 + */ + public static final CommonUploadResp NO_USER = new CommonUploadResp("1"); + /** + * 未知错误 + */ + public static final CommonUploadResp UNKNOWN_ERROR = new CommonUploadResp("2"); + + + @Override + public String toString() { + return content; + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/commonResp/ErrorResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/commonResp/ErrorResp.java new file mode 100644 index 0000000..ef26785 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/commonResp/ErrorResp.java @@ -0,0 +1,36 @@ +package com.smartlive.bswatch.netty.watchvo.resp.commonResp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +public class ErrorResp { + String content; + /** + * 无设置 + */ + public static final ErrorResp NO_SETTING=new ErrorResp("0"); + /** + * 非平台用户 + */ + public static final ErrorResp NO_USER=new ErrorResp("1"); + /** + * 未知错误 + */ + public static final ErrorResp UNKNOWN_ERROR=new ErrorResp("2"); + + + @Override + public String toString() { + return content; + } + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/ClassModelResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/ClassModelResp.java new file mode 100644 index 0000000..72d4902 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/ClassModelResp.java @@ -0,0 +1,65 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import com.smartlive.bswatch.costant.WatchConstant; +import com.smartlive.bswatch.netty.watchvo.resp.entity.TimePeriod; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +/** + * 响应数据 + * [861755052699870,89860000192198904130,202110111658250002,GE + * T_CLASS_MODEL,4,20211011165826,19,1@1@1=0205-2157!4!1] + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +public class ClassModelResp { + + /** + * SOS是否可以呼入:0 否 1 是 + */ + private String sosCallIn; + + /** + * SOS是否可以拨打:0 否;1 是 + */ + private String sosCallOn; + + List timePeriodList; + + /** + * 全周期全天可呼入呼出SOS + * @return + */ + public static ClassModelResp getDefault() { + ClassModelResp classModelResp = new ClassModelResp(WatchConstant.SOS_CALL_IN,WatchConstant.SOS_CALL_ON,null); + List timePeriodList = new ArrayList<>(); + timePeriodList.add(new TimePeriod("0000-2359", WatchConstant.ALL_PERIOD,"0")); + classModelResp.setTimePeriodList(timePeriodList); + return classModelResp; + } + + @Override + public String toString(){ + StringBuilder sb = new StringBuilder(); + sb.append(sosCallIn).append("@") + .append(sosCallOn).append("@"); + for(int i=0;i0){ + sb.deleteCharAt(sb.length()-1); + } + return sb.toString(); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/FutureWeatherListResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/FutureWeatherListResp.java new file mode 100644 index 0000000..420e28b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/FutureWeatherListResp.java @@ -0,0 +1,41 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import com.smartlive.bswatch.netty.watchvo.resp.commonResp.ErrorResp; +import org.apache.commons.lang3.StringUtils; +import lombok.Data; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@Data +public class FutureWeatherListResp { + private List futureWeatherRespList; + + + // 日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if(CollectionUtils.isEmpty(futureWeatherRespList)){ + // 直接返回未设置 + return ErrorResp.NO_SETTING.toString(); + } + for (FutureWeatherResp futureWeatherResp : futureWeatherRespList) { + sb.append(futureWeatherResp).append("#"); + } + String s= sb.substring(0,sb.length()-1); + if(StringUtils.isBlank(s)){ + return ErrorResp.NO_SETTING.toString(); + } + return s; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/FutureWeatherResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/FutureWeatherResp.java new file mode 100644 index 0000000..07f56a5 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/FutureWeatherResp.java @@ -0,0 +1,43 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +/** + * @author:lilj + * @date:2025/1/22 + */ + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 单个未来天气 + */ +@NoArgsConstructor +@AllArgsConstructor +@Data +public class FutureWeatherResp { + + + // 年月日格式 + private String date; + // 多云 + private String weather; + + // 最低气温 + private String lowTemperature; + + //最高气温 + private String highTemperature; + + + // 日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + // #日期&天气状态@最低温度!最高温度 + + @Override + public String toString() { + return "#" + date + "&" + weather + "@" + lowTemperature + "!" + highTemperature; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/GetBalanceResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/GetBalanceResp.java new file mode 100644 index 0000000..c4ce9bb --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/GetBalanceResp.java @@ -0,0 +1,44 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/4/8 + */ +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetBalanceResp { + private String mealBalance; + private String mealStatus; + private String waterBalance; + private String waterStatus; + + @Override + public String toString() { + return mealBalance + "@" + mealStatus + "@" + waterBalance + "@" + waterStatus; + } + + public static GetBalanceResp errorResp(String status) { + GetBalanceResp getBalanceResp = new GetBalanceResp(); + getBalanceResp.setMealBalance("0.0"); + getBalanceResp.setMealStatus(status); + getBalanceResp.setWaterBalance("0.0"); + getBalanceResp.setWaterStatus(status); + return getBalanceResp; + } + public static GetBalanceResp errorResp() { + GetBalanceResp getBalanceResp = new GetBalanceResp(); + getBalanceResp.setMealBalance("0.0"); + getBalanceResp.setWaterBalance("0.0"); + return getBalanceResp; + } + + public void setStatus(String status){ + this.setWaterStatus(status); + this.setMealStatus(status); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/HeartResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/HeartResp.java new file mode 100644 index 0000000..0f3444f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/HeartResp.java @@ -0,0 +1,8 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +/** + * @author:lilj + * @date:2025/1/20 + */ +public class HeartResp { +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/IncomeCallResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/IncomeCallResp.java new file mode 100644 index 0000000..82629f3 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/IncomeCallResp.java @@ -0,0 +1,103 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import com.smartlive.bswatch.costant.WatchConstant; +import com.smartlive.bswatch.netty.watchvo.resp.entity.AddPhoneNode; +import org.apache.commons.lang3.StringUtils; +import lombok.Data; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/1/20 + */ + +/** + * 格式:删除号码@添加号码和时段@呼入限制@周期 + * 无删除号码可以用0替换. + * + * //[861755052699870,89860000192198904130,202110111628470003,GET_INCOMING_CALL,4,20211011162848,61,15625730592!@1562573059 + * // 5=0000-2359+0000-2359!@2@0+1+2+3+4+5+6@爸爸#妈妈] + */ +@Data +public class IncomeCallResp { + + /** + * 删除号码 + */ + private List delPhones; + + + /** + * 添加号码 + */ + List addPhones; + + /** + * 周期:0 周末,1-6周一到周六,使用+拼接 + */ + private String period; + + /** + * 呼入限制:1 不限制,2 限制白名单以外号码呼入,3 限制所有号码呼入 + */ + private String incallLimit; + + + public void addPhoneNode(String phone, List times,String nickName) { + AddPhoneNode addPhoneNode = new AddPhoneNode(phone, times, nickName); + if(this.addPhones== null){ + this.addPhones = new java.util.ArrayList<>(); + } + this.addPhones.add(addPhoneNode); + } + @Override + public String toString() { + StringBuilder delSb=new StringBuilder(); + StringBuilder addSb=new StringBuilder(); + StringBuilder nickNameSb=new StringBuilder(); + if(CollectionUtils.isEmpty(delPhones)){ + delSb.append("0").append("@"); + }else{ + for (String delPhone : delPhones) { + delSb.append(delPhone).append("!"); + } + delSb.append("@"); + } + if(CollectionUtils.isEmpty(addPhones)){ + addSb.append("0").append("@"); + }else{ + for (AddPhoneNode addPhone : addPhones) { + addSb.append(addPhone).append("!"); + if(StringUtils.isBlank(addPhone.getNickName())){ + nickNameSb.append("#"); + }else{ + nickNameSb.append(addPhone.getNickName()).append("#"); + } + } + // 剔除最后一个! + // addSb.deleteCharAt(addSb.length()-1); + addSb.append("@"); + } + String resp =delSb.append(addSb).append(incallLimit).append("@").append(period).append("@").append(nickNameSb).toString(); + return resp; + } + + /** + * 默认一周;限制非白名单号码呼入 + * @return + */ + public static IncomeCallResp getDefault(){ + IncomeCallResp incomeCallResp = new IncomeCallResp(); + incomeCallResp.setPeriod(WatchConstant.ALL_PERIOD); + incomeCallResp.setIncallLimit("2"); + return incomeCallResp; + } + + public static void main(String[] args) { + IncomeCallResp incomeCallResp = new IncomeCallResp(); + System.out.println(incomeCallResp); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/LoginResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/LoginResp.java new file mode 100644 index 0000000..487c62c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/LoginResp.java @@ -0,0 +1,44 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@NoArgsConstructor +@AllArgsConstructor +@Data +public class LoginResp { + private String replyStatus; + + private String msg; + + /** + * 暂无实际意义字段 + */ + private String thirdPos; + + // 登录成功: 0@0@0 + // 注册成功: 0@端口号@0 + // 注册失败: 1@0@0 + + @Override + public String toString() { + return replyStatus+"@"+thirdPos+"@"+msg; + } + + public static LoginResp successLogin(){ + return new LoginResp("0","0","0"); + } + + public static LoginResp successRegister(String port){ + return new LoginResp("0",port,"0"); + } + public static LoginResp failRegister(){ + return new LoginResp("1","0","0"); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/NormalButtonResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/NormalButtonResp.java new file mode 100644 index 0000000..150fc53 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/NormalButtonResp.java @@ -0,0 +1,65 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import com.smartlive.bswatch.netty.watchvo.resp.entity.Button; +import org.apache.commons.lang3.StringUtils; +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author:lilj + * @date:2025/1/20 + */ +@Data +public class NormalButtonResp { + private final static String NO_USER="1"; + private final static String OTHER_ERROR="2"; + + private Map buttons ; + + public void addButton(String index,String phone,String remark){ + if(buttons == null){ + buttons = new HashMap<>(4); + } + if(buttons.size()>4){ + throw new RuntimeException("SOS号码最多有1个,亲情号最多为3个"); + } + buttons.put(index, new Button(index,phone,remark)); + } + + + /** + * 一个SOS,3个亲情号 + * 应答内容:异常应答:0 无设置 1 非平台用户 2 其他异常 + * 正常应答:按键索引1=手机号1!按键索引2=手机号2!...!联系人备注1#联系人备注2#......... + * 响应示例:[861755052699870,89860000192198904130,202110201626490002,GE + * T_NORMAL_BUTTON,4,20211020162649,48,0=110!1=120!2=173125118 + * 76!3=15985730505!爸爸#妈妈#爷爷#奶奶#] + * [864052060525330,898600E1261986856912,202308231356370001,GE + * T_NORMAL_BUTTON,4,20230823135638,30,0=521!1=520!2=!3=!爸爸# + * 妈妈### + */ + @Override + public String toString(){ + if(buttons == null){ + // 无联系人数据返回空的hashMap,腕表会删掉原有的联系人 + buttons = new HashMap<>(4); + } + StringBuilder phoneSb = new StringBuilder(); + StringBuilder remarkSb = new StringBuilder(); + for(int i=0;i<4;i++){ + Button button = buttons.get(String.valueOf(i)); + if(button==null){ + phoneSb.append(i+"=!"); + remarkSb.append("#"); + }else{ + phoneSb.append(i+"=").append(StringUtils.isBlank(button.getPhone())?"!":button.getPhone()+"!"); + remarkSb.append(StringUtils.isBlank(button.getNickName())?"#":button.getNickName()+"#"); + } + } + phoneSb.append(remarkSb); + return phoneSb.toString(); + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/NowWeatherResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/NowWeatherResp.java new file mode 100644 index 0000000..cb7ee1b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/NowWeatherResp.java @@ -0,0 +1,29 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class NowWeatherResp { + //日期@天气状态@城市名称@当前温度@最低 + // 温度!最高温度 + private String date; + private String weather; + private String cityName; + private String lowTemperature; + private String highTemperature; + + @Override + public String toString(){ + StringBuilder sb = new StringBuilder(); + sb.append(date).append("@").append(weather).append("@").append(cityName).append("@").append(lowTemperature).append("!").append(highTemperature); + return sb.toString(); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/SetLocationModelResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/SetLocationModelResp.java new file mode 100644 index 0000000..389de06 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/SetLocationModelResp.java @@ -0,0 +1,28 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import com.smartlive.bswatch.costant.WatchConstant; +import lombok.Data; + +/** + * @author:lilj + * @date:2025/2/8 + */ +@Data +public class SetLocationModelResp { + /** + * 1. 省电模式 + * 2. 平衡模式 + * 3. 实时模式 + */ + private Integer locationMode; + + /** + * 工作时长:实时模式设置工作时长 + */ + private Integer workTime; + + @Override + public String toString() { + return !WatchConstant.WATCH_MODE_IMMEDIATE.equals(locationMode)? locationMode+"": locationMode+"@"+workTime; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/SetRedayModeResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/SetRedayModeResp.java new file mode 100644 index 0000000..9503b35 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/SetRedayModeResp.java @@ -0,0 +1,21 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/2/8 + */ +@Data +public class SetRedayModeResp { + // 开关:1 开启 0关闭 + private String switchMode; + + // 待机时间段: 0000-0100 + private String period; + + @Override + public String toString() { + return switchMode+ "@"+period; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/StudentInfoResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/StudentInfoResp.java new file mode 100644 index 0000000..933e48e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/StudentInfoResp.java @@ -0,0 +1,57 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import org.apache.commons.lang3.StringUtils; +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@Data +public class StudentInfoResp { + //姓名、班级、学校:UTF-8 编码,最多 8 个。 + // 头像图片 + + /** + * 学生姓名 + */ + private String studentName; + + /** + * 所属班级 + */ + private String studentClass; + + /** + * 所属学校 + */ + private String studentSchool; + /** + * 头像地址:大小为50K + */ + private String studentAvatar; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + dealField(sb,studentName); + dealField(sb,studentClass); + dealField(sb,studentSchool); + sb.append(studentAvatar); + // sb.deleteCharAt(sb.length()-1); + return sb.toString(); + } + + public void dealField(StringBuilder sb, String field){ + if(StringUtils.isBlank(field)){ + sb.append("暂无"); + }else{ + sb.append(field.length()>8?field.substring(0,8):field); + } + sb.append("@"); + } + + public static StudentInfoResp defaultResp(){ + return new StudentInfoResp(); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/WeatherInfoResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/WeatherInfoResp.java new file mode 100644 index 0000000..d33ba9b --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/WeatherInfoResp.java @@ -0,0 +1,25 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/22 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WeatherInfoResp { + //天气状态@最低温度!最高温度 + + private String weather; + private String lowTemperature; + private String highTemperature; + + @Override + public String toString() { + return weather + "@" + lowTemperature + "!" + highTemperature; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/WeatherNowResp.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/WeatherNowResp.java new file mode 100644 index 0000000..3aaac5c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/deviceResp/WeatherNowResp.java @@ -0,0 +1,36 @@ +package com.smartlive.bswatch.netty.watchvo.resp.deviceResp; + +import com.smartlive.common.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.util.CollectionUtils; + +/** + * @author:lilj + * @date:2025/6/10 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WeatherNowResp { + private String day; + private String area; + private String weather; + private String temperature; + private String lowTemperature; + private String highTemperature; + + @Override + public String toString() { + // 如果都不为null那么就可以返回正常结果了 + if(StringUtils.isNotBlank(weather) && StringUtils.isNotBlank(area) && StringUtils.isNotBlank(temperature) && StringUtils.isNotBlank(lowTemperature) && StringUtils.isNotBlank(highTemperature)){ + return day+"@"+weather+"@"+area+"@"+temperature+"@"+lowTemperature+"!"+highTemperature; + }else { + return "0"; + } + } + + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/AddPhoneNode.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/AddPhoneNode.java new file mode 100644 index 0000000..51e09a1 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/AddPhoneNode.java @@ -0,0 +1,36 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +import lombok.Data; + +import java.util.List; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +public class AddPhoneNode { + private String phone; + private List times; + private String nickName; + + public AddPhoneNode(String phone, List times, String nickName) { + this.phone = phone; + if(times == null){ + throw new RuntimeException("添加号码必须指定时段"); + } + if(times != null && times.size() > 2){ + throw new RuntimeException("时段至多添加2个"); + } + this.times = times; + this.nickName = nickName; + } + + public AddPhoneNode() { + } + + @Override + public String toString() { + return phone + "="+ String.join("+",times); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/Button.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/Button.java new file mode 100644 index 0000000..f273fbc --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/Button.java @@ -0,0 +1,29 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +import lombok.Data; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +public class Button { + // 按键索引:从0开始,0为sos按键, + private String index; + private String phone; + // 联系人备注 + private String nickName; + + public Button(String index,String phone,String nickName){ + this.index = index; + this.phone = phone; + this.nickName = nickName; + } + public Button(){ + + } + @Override + public String toString() { + return index + "=" + phone; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/GPSLocation.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/GPSLocation.java new file mode 100644 index 0000000..2c95bf4 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/GPSLocation.java @@ -0,0 +1,29 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GPSLocation { + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + @Override + public String toString() { + return longitude + "," + latitude; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/LbsLocation.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/LbsLocation.java new file mode 100644 index 0000000..8f898aa --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/LbsLocation.java @@ -0,0 +1,33 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class LbsLocation { + //460!1!11433!68256005!-56 + // 国家编码 + private String mcc; + // 移动0,联通1 + private String mnc; + // 位置区域编码 + private String lac; + + private String cellid; + // 信号强度 + private String signal; + + //http://apilocate.amap.com/position?accesstype=0&key=97509bb13f02a18faf682d0f3853635e&bts=460,01,11433,68256005,-56&macs=F4:83:CD:CA:67:3E&macs=F6:96:DE:96:FE:EB&macs=54:35:30:2F:26:BA' + public String toQueryString(){ + StringBuilder sb = new StringBuilder(); + sb.append(mcc).append(",").append(mnc).append(",").append(lac).append(",").append(cellid).append(",").append(signal); + return sb.toString(); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/TimePeriod.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/TimePeriod.java new file mode 100644 index 0000000..f7d2c72 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/TimePeriod.java @@ -0,0 +1,38 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +/** + * 时间段设置 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +public class TimePeriod { + /** + * 时间段 + */ + private String times; + /** + * 周期: 0:周日;1-6:周一至周六 + */ + private String period; + /** + * 是否生效:1 生效 0 不生效 + */ + private String effective; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(times).append("!").append(period).append("!").append(effective); + return sb.toString(); + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/WifiInfo.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/WifiInfo.java new file mode 100644 index 0000000..1e4053f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/WifiInfo.java @@ -0,0 +1,21 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WifiInfo { + private String wifiName; + + private String wifiMac; + // 信号强度 + private String wifiSignal; +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/WifiLocation.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/WifiLocation.java new file mode 100644 index 0000000..14cf81c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/netty/watchvo/resp/entity/WifiLocation.java @@ -0,0 +1,38 @@ +package com.smartlive.bswatch.netty.watchvo.resp.entity; + +/** + * @author:lilj + * @date:2025/1/21 + */ + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * wifi定位信息 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WifiLocation { + private String mac; + private String signal; + + public static boolean validateMac(String mac){ + String macRegex = "([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})|([0-9A-Fa-f]{12})"; + return mac.matches(macRegex); + } + + public static void main(String[] args) { + String mac1 = "00:1A:2B:3C:4D:5E"; + String mac2 = "00-1A-2B-3C-4D-5E"; + String mac3 = "001A2B3C4D5E"; + String mac4 = "00:1A:2B:3C:4D:5Z"; // 无效 MAC 地址 + + System.out.println(validateMac(mac1)); // true + System.out.println(validateMac(mac2)); // true + System.out.println(validateMac(mac3)); // true + System.out.println(validateMac(mac4)); // false + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/AddressService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/AddressService.java new file mode 100644 index 0000000..7ae93bb --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/AddressService.java @@ -0,0 +1,44 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.Address; +import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.stereotype.Service; + +import java.util.List; + +public interface AddressService extends IService
{ + + /** + * 添加地址 + */ + boolean addAddress(Address address); + + /** + * 修改地址 + */ + boolean updateAddress(Address address); + + /** + * 删除地址 + */ + boolean deleteAddress(Long addressId); + + /** + * 获取用户地址列表 + */ + List
getAddressList(Long userId); + + /** + * 设置默认地址 + */ + boolean setDefaultAddress(Long addressId, Long userId); + + /** + * 获取用户默认地址 + */ + Address getDefaultAddress(Long userId); + /** + * 获取订单地址信息的json字符串 + */ + String getOrderAddressJson(Long addressId); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/AlipayService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/AlipayService.java new file mode 100644 index 0000000..9d102bc --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/AlipayService.java @@ -0,0 +1,287 @@ +package com.smartlive.bswatch.service; + +import com.alipay.api.AlipayApiException; +import com.smartlive.bswatch.component.AlipayUtil; +import com.smartlive.bswatch.entity.OrderWatch; +import com.smartlive.bswatch.entity.WatchGoods; +import com.smartlive.common.utils.uuid.IdUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Service +public class AlipayService { + @Resource + private AlipayUtil alipayUtil; + + @Resource + private OrderWatchService orderWatchService; + + @Resource + private WatchGoodsService watchGoodsService; + @Resource + private AddressService addressService; + + /** + * 创建支付宝APP支付订单 + */ + @Transactional + public Map createAlipayAppOrder(Long userId, Integer watchId,BigDecimal money, + Integer quantity, Long addressId) { + Map result = new HashMap<>(); + + try { + // 1. 验证商品信息 + WatchGoods goods = watchGoodsService.getWatchGoodsById(watchId); + if (goods == null || goods.getStatus() != 0) { + result.put("success", false); + result.put("message", "商品不存在或已下架"); + return result; + } + //获取地址信息 + String json = addressService.getOrderAddressJson(addressId); + // 2. 计算订单金额 + BigDecimal totalAmount = goods.getPrice().multiply(new BigDecimal(quantity)); + //验证金额是否一致 money + if (totalAmount.compareTo(money) != 0) { + result.put("success", false); + result.put("message", "金额不一致"); + } + // 3. 生成订单号 + String tradeNo = IdUtils.fastSimpleUUID(); + + // 4. 创建业务订单 + OrderWatch order = new OrderWatch(); + order.setUserId(userId); + order.setTradeNo(tradeNo); + order.setPayType(1); + order.setCredit(totalAmount); + order.setIsPass(0); // 未支付 + order.setStatus(0); // 未发放 + order.setWatchName(goods.getWatchName()); + order.setWatchPrice(goods.getPrice()); + order.setWatchNum(quantity); + order.setWatchImage(goods.getImage()); + order.setAdress(json); + order.setCreatedTime(new Date()); + order.setUpdatedTime(new Date()); + + orderWatchService.save(order); + + // 5. 创建支付宝支付订单 + String subject = "腕表购买 - " + goods.getWatchName(); + String body = "购买腕表:" + goods.getWatchName() + ",数量:" + quantity; + + String orderInfo = alipayUtil.createOrder(tradeNo, subject, totalAmount, body); + + // 6. 返回支付参数 + result.put("success", true); + result.put("alipayOrderInfo", orderInfo); + result.put("message", "支付宝APP支付订单创建成功"); + + log.info("支付宝APP支付订单创建成功,订单号:{},金额:{}", tradeNo, totalAmount); + + } catch (Exception e) { + log.error("创建支付宝APP支付订单失败", e); + result.put("success", false); + result.put("message", "创建支付订单失败:" + e.getMessage()); + } + + return result; + } + + /** + * 处理支付宝回调通知 + */ + public String handleAlipayNotify(HttpServletRequest request) { + log.info("收到支付宝APP支付回调通知"); + + try { + // 1. 验证签名 + if (!alipayUtil.verifyCallback(request)) { + log.error("支付宝回调签名验证失败"); + return "failure"; + } + + // 2. 获取回调参数 + Map params = alipayUtil.processCallbackParams(request); + String tradeStatus = params.get("trade_status"); + String outTradeNo = params.get("out_trade_no"); + String tradeNo = params.get("trade_no"); + String totalAmount = params.get("total_amount"); + + log.info("支付宝回调参数 - 订单号: {}, 交易状态: {}, 支付宝交易号: {}, 金额: {}", + outTradeNo, tradeStatus, tradeNo, totalAmount); + + // 3. 处理支付成功 + if ("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)) { + return processPaySuccess(outTradeNo, tradeNo, totalAmount); + } + // 4. 处理交易关闭 + else if ("TRADE_CLOSED".equals(tradeStatus)) { + log.info("支付宝交易关闭,订单号:{}", outTradeNo); + return "success"; + } + // 5. 其他状态 + else { + log.warn("未处理的交易状态: {}", tradeStatus); + return "success"; // 其他状态也返回success,防止支付宝重复通知 + } + + } catch (Exception e) { + log.error("处理支付宝回调通知异常", e); + return "failure"; + } + } + + /** + * 处理支付成功 + */ + private String processPaySuccess(String outTradeNo, String tradeNo, String totalAmount) { + try { + // 1. 查询订单 + OrderWatch order = orderWatchService.getOrderByTradeNo(outTradeNo); + if (order == null) { + log.error("订单不存在,订单号:{}", outTradeNo); + return "failure"; + } + + // 2. 检查订单状态(防止重复处理) + if (order.getIsPass() == 1) { + log.info("订单已支付,订单号:{}", outTradeNo); + return "success"; + } + + // 3. 验证金额 + BigDecimal notifyAmount = new BigDecimal(totalAmount); + if (order.getCredit().compareTo(notifyAmount) != 0) { + log.error("订单金额不匹配,订单号:{},订单金额:{},通知金额:{}", + outTradeNo, order.getCredit(), notifyAmount); + return "failure"; + } + + // 4. 更新订单状态 + order.setPayNo(tradeNo); + order.setIsPass(1); // 已支付 + order.setOrderTime(new Date()); + + boolean result = orderWatchService.updateById(order); + if (!result) { + log.error("更新订单状态失败,订单号:{}", outTradeNo); + return "failure"; + } + + log.info("支付宝APP支付成功,订单号:{},支付宝交易号:{}", outTradeNo, tradeNo); + + // 6. 处理后续业务逻辑( 库存等) + processAfterPaySuccess(order); + + return "success"; + + } catch (Exception e) { + log.error("处理支付宝支付成功回调异常", e); + return "failure"; + } + } + + + /** + * 支付成功后的业务处理 + */ + private void processAfterPaySuccess(OrderWatch order) { + try { + // 1. 扣减库存(如果需要) + watchGoodsService.reduceStock(order.getWatchId(), order.getWatchNum()); + + } catch (Exception e) { + log.error("处理支付后续业务异常", e); + } + } + + /** + * 查询支付宝订单状态 + */ + public Map queryOrderStatus(String tradeNo) { + Map result = new HashMap<>(); + + try { + Map queryResult = alipayUtil.queryOrder(tradeNo); + + result.put("success", true); + result.put("data", queryResult); + + } catch (Exception e) { + log.error("查询支付宝订单状态失败", e); + result.put("success", false); + result.put("message", e.getMessage()); + } + + return result; + } + + /** + * 支付宝退款 + */ + @Transactional + public Map refund(String tradeNo, BigDecimal refundAmount, + String refundReason) { + Map result = new HashMap<>(); + + try { + // 1. 查询订单 + OrderWatch order = orderWatchService.getOrderByTradeNo(tradeNo); + if (order == null || order.getIsPass() != 1) { + result.put("success", false); + result.put("message", "订单不存在或未支付"); + return result; + } + + // 2. 验证退款金额 + if (refundAmount.compareTo(order.getCredit()) > 0) { + result.put("success", false); + result.put("message", "退款金额不能超过订单金额"); + return result; + } + + // 3. 调用支付宝退款接口 + boolean refundSuccess = alipayUtil.refund( + tradeNo, + refundAmount.toString(), + refundReason + ); + + if (!refundSuccess) { + result.put("success", false); + result.put("message", "支付宝退款失败"); + return result; + } + + // 4. 更新订单状态 + + orderWatchService.updateOrderStatus(order.getId(),2); + + // 5. 记录退款日志 + log.info("支付宝退款成功,订单号:{},退款金额:{}", tradeNo, refundAmount); + + result.put("success", true); + result.put("message", "退款成功"); + + } catch (Exception e) { + log.error("支付宝退款失败", e); + result.put("success", false); + result.put("message", "退款失败:" + e.getMessage()); + } + + return result; + } + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/CommonService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/CommonService.java new file mode 100644 index 0000000..f92c2f8 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/CommonService.java @@ -0,0 +1,68 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.*; +import com.smartlive.bswatch.vo.commandVO.CurrentPositionRespVO; +import com.smartlive.bswatch.vo.controllerVO.CommonVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +/** + * @author:lilj + * @date:2025/2/10 + */ +public interface CommonService { + WatchDevice getWatchDeviceByEmpNo(String empNo,String watchSign); + + ListgetUsedWatchDeviceList(); + + + void cacheEvictDeviceByEmpNo(String empNo,String watchSign); + + WatchDevice getWatchDeviceByWatchSign(String watchSign); + + void cacheEvictDeviceByWatchSign(String watchSign); + + AjaxResult pageResulet(CommonVO commonVO, Function function); + + void setButton(String empNO); + + void setButtonBatch(List watchSignSet); + + void setWhitePhone(String watchSign); + + void setWhitePhoneBatch(List watchSignSet); + + void setWhitePhonePeriod(String watchSign,String empNo, boolean isDelete); + + void setWhitePhoneDeleteBatch( List watchWhitePeriodList); + + void setClassModel( String watchSign); + + + /** + * 电子围栏缓存 + * @param empNo + * @return + */ + List getCacheWatchFenceList(String empNo,String watchSign); + + /** + * 电子围栏缓存移除 + */ + void cacheEvictWatchFenceList(String empNo,String watchSign); + + /** + * 多个电子围栏缓存移除 + */ + void cacheEvictWatchFenceListBatch(Map> empNoToWatchSignMap); + + void sendGetCurrentLocation(CurrentPositionRespVO currentPositionRespVO); + + + // WatchDevice getWatchDeviceByEmpNo(String empNo); + // + // void cacheEvictDeviceByEmpNo(String empNo); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IDevicePullDataService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IDevicePullDataService.java new file mode 100644 index 0000000..fb3ae25 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IDevicePullDataService.java @@ -0,0 +1,25 @@ +package com.smartlive.bswatch.service; + +/** + * @author:lilj + * @date:2025/2/6 + */ + +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.bswatch.netty.watchvo.resp.deviceResp.*; + +/** + * 设备拉取平台数据Service + */ +public interface IDevicePullDataService { + NormalButtonResp getButton(MessageVO messageVO); + + IncomeCallResp getIncomeCall(MessageVO messageVO); + + ClassModelResp getClassModelResp(MessageVO messageVO); + + StudentInfoResp getStudentInfoResp(MessageVO messageVO); + + String getSkipMac(MessageVO messageVO); + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IDeviceUploadService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IDeviceUploadService.java new file mode 100644 index 0000000..5926469 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IDeviceUploadService.java @@ -0,0 +1,32 @@ +package com.smartlive.bswatch.service; + +/** + * @author:lilj + * @date:2025/2/5 + */ + +import com.smartlive.bswatch.netty.watchvo.MessageVO; + +/** + * 腕表数据上报处理service + * 设备拉取数据 + */ +public interface IDeviceUploadService { + public boolean login(MessageVO messageVO); + + void recordStep(MessageVO messageVO); + + void recordHealth(MessageVO messageVO); + + void recordLocation(MessageVO messageVO); + + void recordCallLog(MessageVO messageVO); + + void recordWatchModeLog(MessageVO messageVO); + + void recordPower(MessageVO messageVO); + + void recordSleep(MessageVO messageVO); + + void recordSos(MessageVO messageVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchCallRecordService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchCallRecordService.java new file mode 100644 index 0000000..7b5d558 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchCallRecordService.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchCallRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchCallRecordService extends IService { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchClassModelService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchClassModelService.java new file mode 100644 index 0000000..0b9abf1 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchClassModelService.java @@ -0,0 +1,25 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchClassModel; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.WatchClassModelVO; +import com.smartlive.common.core.domain.AjaxResult; + +/** + *

+ * 腕表课堂模式表 服务类 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +public interface IWatchClassModelService extends IService { + + AjaxResult queryVO(WatchClassModelVO classModelVO); + + AjaxResult saveVO(WatchClassModelVO classModelVO); + + AjaxResult updateVO(WatchClassModelVO classModelVO); + + AjaxResult delete(Integer id); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchDeviceService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchDeviceService.java new file mode 100644 index 0000000..8704a1a --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchDeviceService.java @@ -0,0 +1,46 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchDevice; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.WatchDeviceVO; +import com.smartlive.bswatch.vo.controllerVO.WatchOperationAddVO; +import com.smartlive.bswatch.vo.controllerVO.WatchOperationVO; +import com.smartlive.common.core.domain.AjaxResult; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchDeviceService extends IService { + + List selectWatchDeviceBySign(String watchSign); + + AjaxResult queryWatchInfo(@NotBlank String watchSign); + + AjaxResult bindDevice(WatchDeviceVO watchDeviceVO); + + AjaxResult unbindDevice(String empNo,String watchSign); + + AjaxResult modeChange(WatchDeviceVO watchDeviceVO); + + AjaxResult setLocationFreq(WatchDeviceVO watchDeviceVO); + + AjaxResult queryWatches(WatchOperationVO watchOperationVO); + + AjaxResult addWatch(WatchOperationAddVO watchOperationAddVO); + + AjaxResult deleteWatch( Long deviceId); + + AjaxResult getWatchSignList(String empNo); + + List queryWatchesByPage(WatchOperationVO watchOperationVO); + + List getUsedWatchDeviceList(); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchEmpPhoneService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchEmpPhoneService.java new file mode 100644 index 0000000..969b083 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchEmpPhoneService.java @@ -0,0 +1,26 @@ +package com.smartlive.bswatch.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.entity.WatchEmpPhone; +import com.smartlive.bswatch.vo.controllerVO.UpdateEmpPhoneVO; +import com.smartlive.bswatch.vo.controllerVO.WatchEmpPhoneVO; +import com.smartlive.common.core.domain.AjaxResult; + +/** + *

+ * 员工亲情电话 服务类 + *

+ * + * @author lilj + * @since 2025-02-06 + */ +public interface IWatchEmpPhoneService extends IService { + + AjaxResult selectEmpPhone(WatchEmpPhoneVO empPhoneVO); + + AjaxResult updateEmphone(WatchEmpPhoneVO empPhoneVO); + + AjaxResult deleteById(Integer id); + + AjaxResult addEmpPhone(WatchEmpPhoneVO empPhoneVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchEmployeeService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchEmployeeService.java new file mode 100644 index 0000000..0aaf22c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchEmployeeService.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.Employee; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 员工表 服务类 + *

+ * + * @author lilj + * @since 2025-02-06 + */ +public interface IWatchEmployeeService extends IService { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchFenceService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchFenceService.java new file mode 100644 index 0000000..8f20481 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchFenceService.java @@ -0,0 +1,29 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchFence; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.WatchFenceVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 腕表安全围栏表 服务类 + *

+ * + * @author lilj + * @since 2025-02-08 + */ +public interface IWatchFenceService extends IService { + + AjaxResult listVO(WatchFenceVO fenceVO); + + AjaxResult saveVO(WatchFenceVO fenceVO); + + AjaxResult updateVO(WatchFenceVO fenceVO); + + AjaxResult delete(Long id); + + AjaxResult deleteBatch(List idList); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchFloodPressureService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchFloodPressureService.java new file mode 100644 index 0000000..bd61669 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchFloodPressureService.java @@ -0,0 +1,36 @@ +package com.smartlive.bswatch.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.entity.WatchFloodPressure; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.PressureVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 腕表血压数据表 服务类 + *

+ * + * @author lilj + * @since 2025-03-17 + */ +public interface IWatchFloodPressureService extends IService { + + AjaxResult queryPressure(HealthQueryVO healthQueryVO); + + List queryPressureList(HealthQueryVO healthQueryVO); + + List selectByEmpAndTime(String empNo, String startDate, String endDate); + + /** + * 获取指定日期范围内的血压数据,每天只取最新的一条记录 + * @param startDate 开始日期 + * @param endDate 结束日期 + * @param empNo 员工编号 + * @return 血压记录列表 + */ + List getLatestPressureByDateRange(String empNo, String startDate, String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthReportService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthReportService.java new file mode 100644 index 0000000..478eb00 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthReportService.java @@ -0,0 +1,44 @@ +package com.smartlive.bswatch.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.TO.HeathReportTO; +import com.smartlive.bswatch.entity.WatchHealthReport; + +import java.util.List; + +/** + *

+ * 健康周报告表 服务类 + *

+ * + * @author system + * @since 2025-11-17 + */ +public interface IWatchHealthReportService extends IService { + + /** + * 生成周健康报告 + */ + Boolean generateWeeklyReport(String empNo,String watchName,String watchSign, String startDate, String endDate); + + /** + * 获取周健康报告 + */ + WatchHealthReport getWeeklyReport(Long reportId); + + /** + * 获取报告列表 + */ + List getReportHistory(String empNo, String time); + + /** + * 批量生成周报告(定时任务用) + */ + void batchGenerateWeeklyReports(String reportDate); + + /** + * 重新生成指定周的报告 + */ + boolean regenerateReport(Long reportId); +} \ No newline at end of file diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthRulesService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthRulesService.java new file mode 100644 index 0000000..d89aec6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthRulesService.java @@ -0,0 +1,54 @@ +package com.smartlive.bswatch.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.TO.RuleMatchContext; +import com.smartlive.bswatch.entity.WatchHealthRules; + +import java.util.List; + +/** + *

+ * 腕表健康规则表 服务类 + *

+ * + * @author system + * @since 2025-11-17 + */ +public interface IWatchHealthRulesService extends IService { + + /** + * 根据指标数据匹配规则 + */ + WatchHealthRules matchRule(RuleMatchContext context); + + /** + * 获取所有启用的规则 + */ + List getAllActiveRules(); + + /** + * 根据指标类型获取规则 + */ + List getRulesByIndicator(String indicatorType); + + /** + * 更新规则 + */ + boolean updateRule(WatchHealthRules rule); + + /** + * 添加规则 + */ + boolean addRule(WatchHealthRules rule); + + /** + * 删除规则 + */ + boolean deleteRule(Long ruleId); + + /** + * 重新加载规则缓存 + */ + void reloadRules(); +} \ No newline at end of file diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthService.java new file mode 100644 index 0000000..e5d534f --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHealthService.java @@ -0,0 +1,36 @@ +package com.smartlive.bswatch.service; + +/** + * @author:lilj + * @date:2025/2/14 + */ + +import com.smartlive.bswatch.vo.controllerVO.*; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + * 腕表健康数据接口 + */ +public interface IWatchHealthService { + AjaxResult queryHeartBeat(HealthQueryVO healthQueryVO); + + AjaxResult queryTemperature(HealthQueryVO healthQueryVO); + + AjaxResult queryBloodOxy(HealthQueryVO healthQueryVO); + + AjaxResult queryStep(HealthQueryVO healthQueryVO); + + AjaxResult queryPressure(HealthQueryVO healthQueryVO); + + AjaxResult querySleep(HealthQueryVO healthQueryVO); + + List queryHeartBeatByPage(HealthQueryVO healthQueryVO); + + List queryTemperatureByPage(HealthQueryVO healthQueryVO); + + List queryBloodOxyByPage(HealthQueryVO healthQueryVO); + + List queryPressureByPage(HealthQueryVO healthQueryVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHeartService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHeartService.java new file mode 100644 index 0000000..6d1ecab --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchHeartService.java @@ -0,0 +1,29 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchHeart; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.HeartBeatVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchHeartService extends IService { + + AjaxResult queryVO(HealthQueryVO healthQueryVO); + + List queryVOList(HealthQueryVO healthQueryVO); + + List getLatestHeartByDateRange(String empNo, String startDate, String endDate); + + List selectByEmpAndTime(String empNo, String startDate, String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchLocationService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchLocationService.java new file mode 100644 index 0000000..5ecf0f1 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchLocationService.java @@ -0,0 +1,23 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchLocation; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.LocationQueryVO; +import com.smartlive.common.core.domain.AjaxResult; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchLocationService extends IService { + + AjaxResult sendLocationCommond(LocationQueryVO locationQueryVO); + + AjaxResult getCurrentLocationInfo(LocationQueryVO locationQueryVO); + + AjaxResult lcoationTrack(LocationQueryVO locationQueryVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchModeLogService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchModeLogService.java new file mode 100644 index 0000000..30e7490 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchModeLogService.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchModeLog; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-28 + */ +public interface IWatchModeLogService extends IService { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchOxyService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchOxyService.java new file mode 100644 index 0000000..9b8f1d0 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchOxyService.java @@ -0,0 +1,36 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchOxy; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.BloodOxyVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchOxyService extends IService { + + AjaxResult queryVO(HealthQueryVO healthQueryVO); + + List queryVOList(HealthQueryVO healthQueryVO); + + /** + * 获取指定日期范围内的血氧数据,每天只取最新的一条记录 + * @param startDate 开始日期 + * @param endDate 结束日期 + * @param empNo 员工编号 + * @return 血氧记录列表 + */ + List getLatestOxyByDateRange(String empNo, String startDate, String endDate); + + List selectByEmpAndTime(String empNo, String startDate, String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchPowerService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchPowerService.java new file mode 100644 index 0000000..f2f40c6 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchPowerService.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchPower; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-28 + */ +public interface IWatchPowerService extends IService { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSkipService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSkipService.java new file mode 100644 index 0000000..caef56e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSkipService.java @@ -0,0 +1,27 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchSkip; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.WatchSkipVO; +import com.smartlive.common.core.domain.AjaxResult; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * + * 服务类 + *

+ * + * @author lilj + * @since 2025-04-02 + */ +public interface IWatchSkipService extends IService { + + AjaxResult querySkip(@NotBlank(message = "人员编号不能为空") String empNo,@NotBlank(message = "设备唯一标识不能为空") String watchSign); + + AjaxResult bindSkip(WatchSkipVO watchSkipVO); + + AjaxResult unbindSkip(@NotBlank(message = "人员编号不能为空") String empNo,String watchSign); +} + diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSleepService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSleepService.java new file mode 100644 index 0000000..e4a43ce --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSleepService.java @@ -0,0 +1,33 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchSleep; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 腕表睡眠数据表 服务类 + *

+ * + * @author lilj + * @since 2025-03-18 + */ +public interface IWatchSleepService extends IService { + + AjaxResult querySleep(HealthQueryVO healthQueryVO); + + /** + * 获取指定日期范围内的睡眠数据,每天只取最新的一条记录 + * @param startDate 开始日期 + * @param endDate 结束日期 + * @param empNo 员工编号 + * @return 睡眠记录列表 + */ + List getLatestSleepByDateRange(String empNo, String startDate, String endDate); + + List selectByEmpAndTime(String empNo, String startDate, String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSosLogService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSosLogService.java new file mode 100644 index 0000000..9686894 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSosLogService.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchSosLog; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 腕表sos报警日志表 服务类 + *

+ * + * @author lilj + * @since 2025-03-18 + */ +public interface IWatchSosLogService extends IService { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSosService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSosService.java new file mode 100644 index 0000000..d05c64e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSosService.java @@ -0,0 +1,27 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchSos; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.SosPhoneVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchSosService extends IService { + + boolean saveSosPhone(SosPhoneVO watchSos); + + boolean updateSosPhone(SosPhoneVO watchSos); + + AjaxResult qeuryByVO(SosPhoneVO sosPhoneVo); + + boolean deleteByIds(List idList); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchStepService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchStepService.java new file mode 100644 index 0000000..13207c9 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchStepService.java @@ -0,0 +1,19 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchStep; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.common.core.domain.AjaxResult; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchStepService extends IService { + + AjaxResult queryVO(HealthQueryVO healthQueryVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSysDeptService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSysDeptService.java new file mode 100644 index 0000000..37b53a1 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSysDeptService.java @@ -0,0 +1,18 @@ +package com.smartlive.bswatch.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.entity.WatchSysDept; +import com.smartlive.bswatch.vo.commandVO.SysDeptVO; + +/** + *

+ * 部门表 服务类 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +public interface IWatchSysDeptService extends IService { + + SysDeptVO getSysDeptVO(Integer deptId); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSysOrganiService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSysOrganiService.java new file mode 100644 index 0000000..e112f5c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchSysOrganiService.java @@ -0,0 +1,16 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.SysOrgani; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 组织表 服务类 + *

+ * + * @author lilj + * @since 2025-02-07 + */ +public interface IWatchSysOrganiService extends IService { + +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchTemperatureService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchTemperatureService.java new file mode 100644 index 0000000..c92a41d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchTemperatureService.java @@ -0,0 +1,29 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchTemperature; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.commandVO.HeathReportVO; +import com.smartlive.bswatch.vo.controllerVO.HealthQueryVO; +import com.smartlive.bswatch.vo.controllerVO.TemperatureVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchTemperatureService extends IService { + + AjaxResult queryVO(HealthQueryVO healthQueryVO); + + List queryVOList(HealthQueryVO healthQueryVO); + + List getLatestTemperatureByDateRange(String empNo, String startDate, String endDate); + + List selectByEmpAndTime(String empNo, String startDate, String endDate); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWarnService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWarnService.java new file mode 100644 index 0000000..ec89343 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWarnService.java @@ -0,0 +1,19 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchWarn; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.WatchWarnVO; +import com.smartlive.common.core.domain.AjaxResult; + +/** + *

+ * 腕表定位警报表 服务类 + *

+ * + * @author lilj + * @since 2025-02-08 + */ +public interface IWatchWarnService extends IService { + + AjaxResult queryVO(WatchWarnVO watchWarnVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWhitePeriodService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWhitePeriodService.java new file mode 100644 index 0000000..e092673 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWhitePeriodService.java @@ -0,0 +1,27 @@ +package com.smartlive.bswatch.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.entity.WatchWhitePeriod; +import com.smartlive.bswatch.vo.controllerVO.WatchWhitePeriodVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchWhitePeriodService extends IService { + + AjaxResult queryByVO(WatchWhitePeriodVO watchWhitePeriodVO); + + AjaxResult saveWithVO(WatchWhitePeriodVO watchWhitePeriodVO); + + AjaxResult updateWithVO(WatchWhitePeriodVO watchWhitePeriodVO); + + AjaxResult removeWithIds(List list); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWhiteService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWhiteService.java new file mode 100644 index 0000000..d3f180e --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/IWatchWhiteService.java @@ -0,0 +1,30 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchWhite; +import com.baomidou.mybatisplus.extension.service.IService; +import com.smartlive.bswatch.vo.controllerVO.WatchWhitePhoneAddVO; +import com.smartlive.bswatch.vo.controllerVO.WatchWhiteVO; +import com.smartlive.common.core.domain.AjaxResult; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lilj + * @since 2025-02-05 + */ +public interface IWatchWhiteService extends IService { + + AjaxResult queryByVO(WatchWhiteVO watchWhiteVO); + + AjaxResult add(WatchWhitePhoneAddVO watchWhitePhoneAddVO); + + AjaxResult updateWithVO(WatchWhiteVO watchWhiteVO); + + AjaxResult removeWithIds(List idList); + + AjaxResult addWhitePhone(WatchWhiteVO watchWhiteVO); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/OrderWatchService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/OrderWatchService.java new file mode 100644 index 0000000..d1d645a --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/OrderWatchService.java @@ -0,0 +1,60 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.OrderWatch; +import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + +public interface OrderWatchService extends IService { + + /** + * 添加订单 + */ + boolean addOrderWatch(OrderWatch orderWatch); + + /** + * 更新订单 + */ + boolean updateOrderWatch(OrderWatch orderWatch); + + /** + * 删除订单 + */ + boolean deleteOrderWatch(Integer id); + + /** + * 获取订单列表 + */ + List getOrderWatchList(); + + /** + * 根据用户ID获取订单列表 + */ + List getOrderWatchListByUserId(Long userId); + + /** + * 根据订单ID获取订单详情 + */ + OrderWatch getOrderWatchById(Integer id); + + /** + * 更新订单状态 + */ + boolean updateOrderStatus(Integer id, Integer status); + + /** + * 更新支付状态 + */ + boolean updatePayStatus(Integer id, Boolean isPass); + + /** + * 更新快递单号 + */ + boolean updateTrackNum(Integer id, String trackNum); + /** + * 根据订单号获取订单详情 + */ + OrderWatch getOrderByTradeNo(String outTradeNo); + + boolean updateOrderPaySuccess(String outTradeNo, String tradeNo, int isPass); +} + diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/WatchGoodsService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/WatchGoodsService.java new file mode 100644 index 0000000..ab16bfc --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/WatchGoodsService.java @@ -0,0 +1,53 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.entity.WatchGoods; +import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + +public interface WatchGoodsService extends IService { + + /** + * 添加腕表商品 + */ + boolean addWatchGoods(WatchGoods watchGoods); + + /** + * 更新腕表商品 + */ + boolean updateWatchGoods(WatchGoods watchGoods); + + /** + * 删除腕表商品 + */ + boolean deleteWatchGoods(Integer id); + + /** + * 获取腕表商品列表 + */ + List getWatchGoodsList(); + + /** + * 根据ID获取腕表商品 + */ + WatchGoods getWatchGoodsById(Integer id); + + /** + * 根据状态获取腕表商品列表 + */ + List getWatchGoodsByStatus(Integer status); + + /** + * 上架腕表商品 + */ + boolean onShelf(Integer id); + + /** + * 下架腕表商品 + */ + boolean offShelf(Integer id); + + /** + * 减库存 + */ + boolean reduceStock(Integer watchId, Integer quantity); +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/WechatService.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/WechatService.java new file mode 100644 index 0000000..4e75763 --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/WechatService.java @@ -0,0 +1,273 @@ +package com.smartlive.bswatch.service; + +import com.smartlive.bswatch.component.WechatPayUtil; +import com.smartlive.bswatch.entity.OrderWatch; +import com.smartlive.bswatch.entity.WatchGoods; +import com.smartlive.common.utils.uuid.IdUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import com.wechat.pay.java.service.payments.model.Transaction; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Service +public class WechatService { + + @Resource + private WechatPayUtil wechatAppUtil; + + @Resource + private OrderWatchService orderWatchService; + + @Resource + private WatchGoodsService watchGoodsService; + + @Resource + private AddressService addressService; + + /** + * 创建微信APP支付订单 + */ + @Transactional + public Map createWechatAppOrder(Long userId, Integer watchId, BigDecimal money, + Integer quantity, Long addressId) { + Map result = new HashMap<>(); + + try { + // 1. 验证商品信息 + WatchGoods goods = watchGoodsService.getWatchGoodsById(watchId); + if (goods == null || goods.getStatus() != 0) { + result.put("success", false); + result.put("message", "商品不存在或已下架"); + return result; + } + //获取地址信息 + String json = addressService.getOrderAddressJson(addressId); + // 2. 计算订单金额 + BigDecimal totalAmount = goods.getPrice().multiply(new BigDecimal(quantity)); + //验证金额是否一致 money + if (totalAmount.compareTo(money) != 0) { + result.put("success", false); + result.put("message", "金额不一致"); + } + // 3. 生成订单号 + String tradeNo = IdUtils.fastSimpleUUID(); + // 4. 创建业务订单 + OrderWatch order = new OrderWatch(); + order.setUserId(userId); + order.setTradeNo(tradeNo); + order.setPayType(2); + order.setCredit(totalAmount); + order.setIsPass(0); // 未支付 + order.setStatus(0); // 未发放 + order.setWatchName(goods.getWatchName()); + order.setWatchPrice(goods.getPrice()); + order.setWatchNum(quantity); + order.setWatchImage(goods.getImage()); + order.setAdress(json); + order.setCreatedTime(new Date()); + order.setUpdatedTime(new Date()); + + orderWatchService.save(order); + + // 5. 创建微信支付订单 + String description = "腕表购买 - " + goods.getWatchName() + " x" + quantity; + + Map payParams = wechatAppUtil.createAppOrder( + tradeNo, description, totalAmount + ); + + // 6. 返回支付参数 + result.put("success", true); + result.put("orderNo", tradeNo); + result.put("amount", totalAmount); + result.put("payParams", payParams); + result.put("message", "微信APP支付订单创建成功"); + + log.info("微信APP支付订单创建成功,订单号:{},金额:{}", tradeNo, totalAmount); + + } catch (Exception e) { + log.error("创建微信APP支付订单失败", e); + result.put("success", false); + result.put("message", "创建支付订单失败:" + e.getMessage()); + } + + return result; + } + + /** + * 处理微信支付回调通知 + */ + public String handleWechatNotify(HttpServletRequest request) { + log.info("收到微信APP支付回调通知"); + + try { + // 1. 解析回调通知 + Transaction transaction = wechatAppUtil.handleNotify(request); + + String tradeState = transaction.getTradeState().name(); + String outTradeNo = transaction.getOutTradeNo(); + String transactionId = transaction.getTransactionId(); + int totalAmount = transaction.getAmount().getTotal(); + + log.info("微信支付回调参数 - 订单号: {}, 交易状态: {}, 微信交易号: {}, 金额: {}", + outTradeNo, tradeState, transactionId, totalAmount); + + // 2. 处理支付成功 + if ("SUCCESS".equals(tradeState)) { + return processPaySuccess(outTradeNo, transactionId, + new BigDecimal(totalAmount).divide(new BigDecimal("100"))); + } + /* // 3. 处理退款 + else if ("REFUND".equals(tradeState)) { + return processRefund(outTradeNo); + }*/ + // 4. 处理关闭 + else if ("CLOSED".equals(tradeState)) { + log.info("微信交易关闭,订单号:{}", outTradeNo); + return buildWechatResponse("SUCCESS", "OK"); + } + // 5. 其他状态 + else { + log.warn("未处理的交易状态: {}", tradeState); + return buildWechatResponse("SUCCESS", "OK"); + } + + } catch (Exception e) { + log.error("处理微信支付回调异常", e); + return buildWechatResponse("FAIL", "处理异常"); + } + } + + /** + * 处理支付成功 + */ + private String processPaySuccess(String outTradeNo, String transactionId, + BigDecimal totalAmount) { + try { + // 1. 查询订单 + OrderWatch order = orderWatchService.getOrderByTradeNo(outTradeNo); + if (order == null) { + log.error("订单不存在,订单号:{}", outTradeNo); + return buildWechatResponse("FAIL", "订单不存在"); + } + + // 2. 检查订单状态(防止重复处理) + if (order.getIsPass() == 1) { + log.info("订单已支付,订单号:{}", outTradeNo); + return buildWechatResponse("SUCCESS", "OK"); + } + + // 3. 验证金额 + if (order.getCredit().compareTo(totalAmount) != 0) { + log.error("订单金额不匹配,订单号:{},订单金额:{},通知金额:{}", + outTradeNo, order.getCredit(), totalAmount); + return buildWechatResponse("FAIL", "金额不匹配"); + } + + // 4. 更新订单状态 + order.setPayNo(transactionId); + order.setIsPass(1); // 已支付 + order.setOrderTime(new Date()); + + boolean result = orderWatchService.updateById(order); + if (!result) { + log.error("更新订单状态失败,订单号:{}", outTradeNo); + return buildWechatResponse("FAIL", "更新订单状态失败"); + } + + log.info("微信APP支付成功,订单号:{},微信交易号:{}", outTradeNo, transactionId); + + // 6. 处理后续业务逻辑 + processAfterPaySuccess(order); + + return buildWechatResponse("SUCCESS", "OK"); + + } catch (Exception e) { + log.error("处理微信支付成功回调异常", e); + return buildWechatResponse("FAIL", "处理异常"); + } + } + + /* *//** + * 处理退款 + *//* + private String processRefund(String outTradeNo) { + try { + // 更新订单状态为已退款 + OrderWatch order = new OrderWatch(); + order.setTradeNo(outTradeNo); + order.setIsPass(2); // 已退款 + order.setUpdatedTime(new Date()); + + orderWatchService.updateOrderStatus(); + + log.info("微信支付已退款,订单号:{}", outTradeNo); + return buildWechatResponse("SUCCESS", "OK"); + + } catch (Exception e) { + log.error("处理微信退款异常", e); + return buildWechatResponse("FAIL", "处理异常"); + } + }*/ + + /** + * 构建微信响应 + */ + private String buildWechatResponse(String code, String message) { + return String.format("{\"code\": \"%s\", \"message\": \"%s\"}", code, message); + } + + /** + * 支付成功后的业务处理 + */ + private void processAfterPaySuccess(OrderWatch order) { + try { + log.info("开始处理库存,订单号:{}", order.getTradeNo()); + watchGoodsService.reduceStock(order.getWatchId(), order.getWatchNum()); + } catch (Exception e) { + log.error("处理支付后续业务异常", e); + } + } + + /** + * 查询订单状态 + */ + public Map queryOrderStatus(String tradeNo) { + Map result = new HashMap<>(); + + try { + // 查询数据库订单状态 + OrderWatch order = orderWatchService.getOrderByTradeNo(tradeNo); + if (order == null) { + result.put("success", false); + result.put("message", "订单不存在"); + return result; + } + + Map data = new HashMap<>(); + data.put("orderNo", order.getTradeNo()); + data.put("payStatus", order.getIsPass()); + data.put("amount", order.getCredit()); + data.put("payTime", order.getOrderTime()); + + result.put("success", true); + result.put("data", data); + + } catch (Exception e) { + log.error("查询订单状态失败", e); + result.put("success", false); + result.put("message", e.getMessage()); + } + + return result; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/impl/AddressServiceImpl.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/impl/AddressServiceImpl.java new file mode 100644 index 0000000..3e2302d --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/impl/AddressServiceImpl.java @@ -0,0 +1,86 @@ +package com.smartlive.bswatch.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.smartlive.bswatch.entity.Address; +import com.smartlive.bswatch.mapper.AddressMapper; +import com.smartlive.bswatch.service.AddressService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +public class AddressServiceImpl extends ServiceImpl implements AddressService{ + + @Override + @Transactional + public boolean addAddress(Address address) { + address.setDelFlag(0); + // 如果是第一个地址,设置为默认地址 + if (getAddressList(address.getUserId()).isEmpty()) { + address.setStatus(1); + } else { + address.setStatus(0); + } + return this.save(address); + } + + @Override + public boolean updateAddress(Address address) { + return this.updateById(address); + } + + @Override + public boolean deleteAddress(Long addressId) { + /*Address address = new Address(); + address.setAddressId(addressId); + address.setDelFlag(1); // 逻辑删除*/ + return this.removeById(addressId); + } + + @Override + public List
getAddressList(Long userId) { + QueryWrapper
wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", userId) + /*.eq("del_flag", 0)*/ // 只查询未删除的地址 + .orderByDesc("status") // 默认地址排在前面 + .orderByDesc("create_time"); // 按创建时间倒序 + return this.list(wrapper); + } + + @Override + @Transactional + public boolean setDefaultAddress(Long addressId, Long userId) { + // 先将用户的所有地址设置为非默认 + UpdateWrapper
updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("user_id", userId) + .set("status", 0); + this.update(updateWrapper); + + // 再将指定地址设置为默认 + Address address = new Address(); + address.setAddressId(addressId); + address.setStatus(1); + return this.updateById(address); + } + + @Override + public Address getDefaultAddress(Long userId) { + QueryWrapper
wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", userId) + .eq("status", 1) + .eq("del_flag", 0); + return this.getOne(wrapper); + } + + @Override + public String getOrderAddressJson(Long addressId) { + Address address = this.getById(addressId); + if (address != null) { + return "{\"consignee\":\"" + address.getConsignee() + "\",\"phone\":\"" + address.getPhone() + "\",\"region\":\"" + address.getRegion() + "\",\"detailedAddress\":\"" + address.getDetailedAddress() + "\"}"; + } + return ""; + } +} diff --git a/smart-position-watch/src/main/java/com/smartlive/bswatch/service/impl/CommonServiceImpl.java b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/impl/CommonServiceImpl.java new file mode 100644 index 0000000..4afd20c --- /dev/null +++ b/smart-position-watch/src/main/java/com/smartlive/bswatch/service/impl/CommonServiceImpl.java @@ -0,0 +1,764 @@ +package com.smartlive.bswatch.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.smartlive.bswatch.costant.WatchConstant; +import com.smartlive.bswatch.enmus.WatchApiEnum; +import com.smartlive.bswatch.entity.*; +import com.smartlive.bswatch.mapper.*; +import com.smartlive.bswatch.vo.commandVO.*; +import com.smartlive.bswatch.netty.publisher.WatchBatchCommandPublisher; +import com.smartlive.bswatch.netty.watchvo.MessageVO; +import com.smartlive.bswatch.netty.watchvo.resp.entity.Button; +import com.smartlive.bswatch.netty.watchvo.resp.entity.TimePeriod; +import com.smartlive.bswatch.service.CommonService; +import com.smartlive.bswatch.utils.WatchMsgSendUtil; +import com.smartlive.bswatch.vo.controllerVO.CommonVO; +import com.smartlive.bswatch.vo.controllerVO.WatchWhiteVO; +import com.smartlive.common.core.domain.AjaxResult; +import com.smartlive.common.core.domain.entity.SysUser; +import com.smartlive.common.core.page.TableDataInfo; +import com.smartlive.common.enums.WatchReturnMessage; +import com.smartlive.common.exception.ServiceException; +import com.smartlive.common.utils.AESUtils; +import com.smartlive.common.utils.PageResult; +import com.smartlive.system.service.ISysUserService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.cache.annotation.Caching; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @author:lilj + * @date:2025/2/10 + */ +@Slf4j +@Service +public class CommonServiceImpl implements CommonService { + + @Autowired + private WatchBatchCommandPublisher publisher; + + @Autowired + private WatchDeviceMapper watchDeviceMapper; + + @Autowired + private WatchEmployeeMapper watchEmployeeMapper; + + @Autowired + private WatchSosMapper watchSosMapper; + + @Autowired + private WatchEmpPhoneMapper watchEmpPhoneMapper; + + @Autowired + private WatchWhiteMapper watchWhiteMapper; + + @Autowired + private WatchWhitePeriodMapper watchWhitePeriodMapper; + + @Autowired + private WatchSysOrganiMapper sysOrganiMapper; + + @Autowired + private WatchClassModelMapper watchClassModelMapper; + ; + + @Autowired + private WatchFenceMapper watchFenceMapper; + + @Autowired + private ISysUserService sysUserService; + + @Cacheable(cacheNames = "watchDevice", key = "#empNo+'_'+#watchSign") + @Override + public WatchDevice getWatchDeviceByEmpNo(String empNo, String watchSign) { + log.info("CommonServiceImpl.getWatchDeviceByEmpNo()====>缓存未命中根据empNo查询设备信息:" + empNo); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WatchDevice::getEmpNo, empNo); + queryWrapper.eq(WatchDevice::getWatchSign, watchSign); + List empDeviceList = watchDeviceMapper.selectList(queryWrapper); + if (!CollectionUtils.isEmpty(empDeviceList)) { + return empDeviceList.get(0); + } + return null; + } + + @CacheEvict(cacheNames = "watchDevice", key = "#empNo+'_'+#watchSign") + @Override + public void cacheEvictDeviceByEmpNo(String empNo, String watchSign) { + log.info("CommonServiceImpl.cacheEvictDeviceByEmpNo()====> 移除人员信息"); + } + + /** + * 根据watchSign查询设备信息 + * + * @param watchSign + * @return + */ + @Cacheable(cacheNames = "watchDevice", key = "#watchSign") + @Override + public WatchDevice getWatchDeviceByWatchSign(String watchSign) { + log.info("CommonServiceImpl.getWatchDeviceByWatchSign()====>缓存未命中根据watchSign查询设备信息:" + watchSign); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WatchDevice::getWatchSign, watchSign); + List watchDeviceList = watchDeviceMapper.selectList(queryWrapper); + if (!CollectionUtils.isEmpty(watchDeviceList)) { + WatchDevice watchDevice = watchDeviceList.get(0); + if (watchDevice != null && StringUtils.isNotBlank(watchDevice.getEmpNo())) { + // 查询人员信息 + // 2.查询用户信息 + SysUser user = sysUserService.selectUserById(Long.parseLong(watchDevice.getEmpNo())); + if (user != null && StringUtils.isNotBlank(user.getNickName())) { + watchDevice.setEmpName(AESUtils.decrypt(user.getNickName())); + } + } + return watchDevice; + } + return null; + } + + @CacheEvict(cacheNames = "watchDevice", key = "#watchSign") + @Override + public void cacheEvictDeviceByWatchSign(String watchSign) { + log.info("CommonServiceImpl.cacheEvictDeviceByWatchSign()====> 移除设备信息"); + } + + @Override + public AjaxResult pageResulet(CommonVO commonVO, Function function) { + if (false == commonVO.getIsPage() || (commonVO.getPage() == null && commonVO.getPageSize() == null)) { + List applyList = function.apply(commonVO); + // 用户姓名解密处理 + if (!CollectionUtils.isEmpty(applyList)) { + applyList.forEach(commonVO1 -> { + if (StringUtils.isNotBlank(commonVO1.getEmpName())) { + commonVO1.setEmpName(AESUtils.decrypt(commonVO1.getEmpName())); + } + }); + } + return AjaxResult.success(applyList); + } + Integer page = commonVO.getPage(); + Integer pageSize = commonVO.getPageSize(); + if (page == null || pageSize == null) { + throw new ServiceException(WatchReturnMessage.PAGE_ERROR); + } + PageHelper.startPage(page, pageSize); + List applyList = function.apply(commonVO); + // 用户姓名解密处理 + if (!CollectionUtils.isEmpty(applyList)) { + applyList.forEach(commonVO1 -> { + if (StringUtils.isNotBlank(commonVO1.getEmpName())) { + commonVO1.setEmpName(AESUtils.decrypt(commonVO1.getEmpName())); + } + }); + } + PageInfo pageInfo = new PageInfo<>(applyList); + PageResult result = new PageResult(); + result.setPageIndex(page); + result.setPages(pageInfo.getPages()); + result.setTotles(pageInfo.getTotal()); + result.setResult(applyList); + return AjaxResult.success(result); + } + + @Override + public void setButton(String watchSign) { + WatchDevice watchDevice = this.getWatchDeviceByWatchSign(watchSign); + if (watchDevice == null || StringUtils.isBlank(watchDevice.getWatchSign())) { + // throw new ServiceException(WatchReturnMessage.EMPLOYEE_UNBIND_DEVICE); + throw new ServiceException(WatchReturnMessage.UNBIDND_UNSEND_COMMAND); + // todo: 暂时运行未绑定设备的人员操作数据库 + // return; + } + // 构建参数:发送指令 + List