diff --git a/src/main/java/club/joylink/rtss/constants/TencentSMSTemplate.java b/src/main/java/club/joylink/rtss/constants/TencentSMSTemplate.java index fe4ad2667..a590c668a 100644 --- a/src/main/java/club/joylink/rtss/constants/TencentSMSTemplate.java +++ b/src/main/java/club/joylink/rtss/constants/TencentSMSTemplate.java @@ -12,6 +12,8 @@ public enum TencentSMSTemplate { VerificationCode_International("JiuLian", 453984, 2), OrderNotice("玖琏科技", 260120, 4), SystemNotice("玖琏科技", 0000, 3), + + ZzjAlertNotice("玖琏科技", 1206126, 2), ; private String sign; diff --git a/src/main/java/club/joylink/rtss/controller/SmsController.java b/src/main/java/club/joylink/rtss/controller/SmsController.java new file mode 100644 index 000000000..31d740f8b --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/SmsController.java @@ -0,0 +1,42 @@ +package club.joylink.rtss.controller; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.ISmsService; +import club.joylink.rtss.vo.SmsResponse; +import club.joylink.rtss.vo.sms.ZzjAlertSmsParamVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +/** + * 短信接口 + */ +@Slf4j +@RestController +@RequestMapping("/api/sms") +public class SmsController { + @Autowired + private ISmsService iSmsService; + + @PostMapping("/zzjAlert") + public void sendZzjAlert(@RequestBody ZzjAlertSmsParamVo paramVo) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL + .assertTrue(paramVo.isValidRequest()); + long ts = System.currentTimeMillis(); + List params = new ArrayList<>(); + params.add(paramVo.getDeviceName()); + params.add(paramVo.getDescription()); + SmsResponse resp = this.iSmsService.sendZzjAlertNotice(paramVo.getMobile(), + paramVo.getNationCode(), params, ts); + BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.assertTrue(resp.getResult() == 0, + String.format("短信发送服务调用异常:[result: %s, errmsg: %s]", resp.getResult(), resp.getErrmsg())); + } + + +} diff --git a/src/main/java/club/joylink/rtss/controller/user/LoginUserController.java b/src/main/java/club/joylink/rtss/controller/user/LoginUserController.java index 5d15bc078..443b7ebf3 100644 --- a/src/main/java/club/joylink/rtss/controller/user/LoginUserController.java +++ b/src/main/java/club/joylink/rtss/controller/user/LoginUserController.java @@ -54,11 +54,15 @@ public class LoginUserController { } return filter; }).collect(Collectors.toList()); + int total = filterList.size(); + if (queryVO.getOffset() > total) { + queryVO.setPageNum(1); + } List resultList = filterList.stream() .skip(queryVO.getOffset()) .limit(queryVO.getPageSize()) .collect(Collectors.toList()); - return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), filterList.size(), resultList); + return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), total, resultList); } } diff --git a/src/main/java/club/joylink/rtss/services/ISmsService.java b/src/main/java/club/joylink/rtss/services/ISmsService.java index c7d1ea4c0..e6c9b40e3 100644 --- a/src/main/java/club/joylink/rtss/services/ISmsService.java +++ b/src/main/java/club/joylink/rtss/services/ISmsService.java @@ -22,6 +22,8 @@ public interface ISmsService { */ SmsResponse sendValidateCode(String mobile, String nationCode, List params, long ts); + SmsResponse sendZzjAlertNotice(String mobile, String nationCode, List parmas, long ts); + /** * 发送订单通知 */ diff --git a/src/main/java/club/joylink/rtss/services/LoginSessionManager.java b/src/main/java/club/joylink/rtss/services/LoginSessionManager.java index 8f5f93ea5..44846c71c 100644 --- a/src/main/java/club/joylink/rtss/services/LoginSessionManager.java +++ b/src/main/java/club/joylink/rtss/services/LoginSessionManager.java @@ -107,6 +107,7 @@ public class LoginSessionManager { LoginUserInfoVO loginUserInfoVO = this.queryLoginInfoByToken(token); BusinessExceptionAssertEnum.LOGIN_EXPIRED.assertNotNull(loginUserInfoVO); loginUserInfoVO.cancelPreLogout(); + loginUserInfoVO.updateLastQueryTime(); return loginUserInfoVO; } diff --git a/src/main/java/club/joylink/rtss/services/TcSmsService.java b/src/main/java/club/joylink/rtss/services/TcSmsService.java index c4656944f..dba3dd179 100644 --- a/src/main/java/club/joylink/rtss/services/TcSmsService.java +++ b/src/main/java/club/joylink/rtss/services/TcSmsService.java @@ -114,6 +114,11 @@ public class TcSmsService implements ISmsService { return sendToOneOnTpl(template, mobile, nationCode, params, ts); } + @Override + public SmsResponse sendZzjAlertNotice(String mobile, String nationCode, List parmas, long ts) { + return sendToOneOnTpl(TencentSMSTemplate.ZzjAlertNotice, mobile, nationCode, parmas, ts); + } + @Override public SmsResponse sendOrderNotice(List internationalMobileList, List params) { return sendToMultiOnTpl(TencentSMSTemplate.OrderNotice, internationalMobileList, params); diff --git a/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java b/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java index 4b125e69f..28a8a5972 100644 --- a/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java +++ b/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java @@ -80,6 +80,43 @@ public class AuthenticateService implements IAuthenticateService { @Autowired private StompMessageService stompMessageService; + @Scheduled(fixedRate = 1000) + public void clearExpireCache() { + LocalDateTime now = LocalDateTime.now(); + // 清理扫码登录状态 + List loginStatus = this.loginSessionManager.queryAllLoginStatus(); + for (LoginStatusVO status : loginStatus) { + if ((status.getFinishTime() != null && now.isAfter(status.getFinishTime().plusSeconds(30))) || + now.isAfter(status.getLastQueryTime().plusMinutes(1))) { + this.loginSessionManager.removeLoginStatus(status); + } + } + // 清理用户会话信息 + List loginUserInfos = this.loginSessionManager.getAllLoginUserInfos(); + for (LoginUserInfoVO loginUserInfo : loginUserInfos) { + if (loginUserInfo.isWechatLogin()) { + if (now.isAfter(loginUserInfo.getLastQueryTime().plusMinutes(10))) { + log.info("登出小程序用户:{}", loginUserInfo.getAccountVO().getId()); + this.logout(loginUserInfo); + } + continue; + } + if (loginUserInfo.getPreLogoutTime() != null) { // 预登出 + LocalDateTime preLogoutTime = loginUserInfo.getPreLogoutTime(); + if (Objects.nonNull(preLogoutTime) && + now.isAfter(preLogoutTime.plusSeconds(30))) { + // 预退出30秒如果还没有取消,视为退出系统 + log.info(String.format("登出预登出用户[%s-%s-%s-%s]", + loginUserInfo.getAccountVO().getId(), + loginUserInfo.getClient(), + loginUserInfo.getProject(), + loginUserInfo.getDeviceVO())); + this.logout(loginUserInfo); + } + } + } + } + @Override public LoginStatusVO getWmLoginUrl(String clientId, String secret, Project project, String deviceCode) { String envId = SystemEnv.getSystemEnvIdByName(this.otherConfig.getEnv()); @@ -95,13 +132,15 @@ public class AuthenticateService implements IAuthenticateService { LoginScanParam param = new LoginScanParam(envId, sessionId, clientId); String state = param.toParam(); String url = weChatConfig.getWmLoginUrl(state); + LocalDateTime now = LocalDateTime.now(); LoginStatusVO loginStatusVO = LoginStatusVO.builder() .url(url) .sessionId(sessionId) .client(client) .project(project) .deviceVO(deviceVO) - .time(LocalDateTime.now()) + .time(now) + .lastQueryTime(now) .status(LoginStatusVO.ScanLoginStatus.WAIT) .build(); this.loginSessionManager.saveLoginStatus(loginStatusVO); @@ -195,30 +234,6 @@ public class AuthenticateService implements IAuthenticateService { } } - /** - * 检查预登出用户,超时登出 - */ - @Scheduled(fixedRate = 1000) - public void logoutProgress() { - List infoVOList = this.loginSessionManager.queryPreLogoutInfos(); - if (!CollectionUtils.isEmpty(infoVOList)) { - LocalDateTime now = LocalDateTime.now(); - for (LoginUserInfoVO userInfoVO : infoVOList) { - LocalDateTime preLogoutTime = userInfoVO.getPreLogoutTime(); - if (Objects.nonNull(preLogoutTime) && - now.isAfter(preLogoutTime.plusSeconds(10))) { - // 预退出10秒如果还没有取消,视为退出系统 - log.info(String.format("登出预登出用户[%s-%s-%s-%s]", - userInfoVO.getAccountVO().getId(), - userInfoVO.getClient(), - userInfoVO.getProject(), - userInfoVO.getDeviceVO())); - this.logout(userInfoVO); - } - } - } - } - @Override public void wmConfirmClientLogin(String code, String state) { LoginScanParam param = LoginScanParam.parse(state); @@ -390,7 +405,7 @@ public class AuthenticateService implements IAuthenticateService { if (Objects.nonNull(loginUserInfoVO)) { log.debug(String.format("用户[%s(%s)]登出[%s]", loginUserInfoVO.getAccountVO().getNickname(), loginUserInfoVO.getAccountVO().getId(), - loginUserInfoVO.getClientInfoStr())); + loginUserInfoVO.buildClientInfoStr())); // 清除用户登录信息 this.loginSessionManager.clearOf(loginUserInfoVO); UserLogoutEvent userLogoutEvent = new UserLogoutEvent(this, loginUserInfoVO); @@ -439,34 +454,11 @@ public class AuthenticateService implements IAuthenticateService { if (loginStatusVO.isProjectDeviceLogin()) { this.checkAndHandleSpecialDeviceLogin(loginStatusVO); } - loginStatusVO.checkExpireAndUpdate(); - if (loginStatusVO.isComplete()) { - // 完成,删除 - this.loginSessionManager.removeLoginStatus(loginStatusVO); - return LoginStatusVO.builder() + loginStatusVO.updateQueryTime(); + return LoginStatusVO.builder() .status(loginStatusVO.getStatus()) .token(loginStatusVO.getToken()) .build(); - } else { - return LoginStatusVO.builder() - .status(loginStatusVO.getStatus()) - .build(); - } - } - - @Scheduled(fixedRate = 5000) - public void loginStatusClean() { - List loginStatusList = this.loginSessionManager.queryAllLoginStatus(); - List removeList = new ArrayList<>(); - for (LoginStatusVO loginStatusVO : loginStatusList) { - int deleteRemain = loginStatusVO.updateDeleteRemain(5000); - if (deleteRemain > 10000) { - removeList.add(loginStatusVO); - } - } - for (LoginStatusVO loginStatusVO : removeList) { - this.loginSessionManager.removeLoginStatus(loginStatusVO); - } } private void checkAndHandleSpecialDeviceLogin(LoginStatusVO loginStatusVO) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index c582454f9..bbf817877 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -404,8 +404,9 @@ public class Operation { Driver_ATO_Open, /** 改变ATP状态 */ Driver_ATP_Change, -// /** 改变列车运行模式 */ -// Driver_Drive_Mode_Change, + /** 改变列车运行模式 */ + @Deprecated // 场景旧数据反序列化需要 + Driver_Drive_Mode_Change, /** 换端 */ Driver_Change_Head, /** 列车车门开关 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java index 178862d8f..073c613cb 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java @@ -4,6 +4,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -80,8 +81,10 @@ public class DriverOperateHandler { ATPService.changeGear(train, gear); } -// @OperateHandlerMapping(type = Operation.Type.Driver_Drive_Mode_Change) -// public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) { + // 场景旧数据反序列化需要 + @Deprecated + @OperateHandlerMapping(type = Operation.Type.Driver_Drive_Mode_Change) + public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) { // VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); // switch (driveMode) { // case AM: @@ -92,7 +95,7 @@ public class DriverOperateHandler { // break; // } // } -// } + } @OperateHandlerMapping(type = Operation.Type.Driver_ATO_Open) public void openAto(Simulation simulation, String groupNumber) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 77c4dbfb6..0ab5d176b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -425,11 +425,10 @@ public class Section extends DelayUnlockDevice { */ public void clearOccupy() { setCtOccupied(false); - this.setNctOccupied(false); + setNctOccupied(false); if (!CollectionUtils.isEmpty(this.logicList)) { for (Section section : this.logicList) { - section.setCtOccupied(false); - section.setNctOccupied(false); + section.clearOccupy(); } } // if (this.isAxleCounter()) { @@ -850,14 +849,14 @@ public class Section extends DelayUnlockDevice { } Section cross = queryCross(); if (cross != null) { - cross.crossJudgeInvalid(); + cross.crossJudgeOccupied(); } } /** - * 岔心判断失效 + * 岔心判断占用 */ - private void crossJudgeInvalid() { + private void crossJudgeOccupied() { if (!this.cross) return; this.logicList.forEach(logic -> { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/SrTrainControlParam.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/SrTrainControlParam.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/SrTrainControlParam.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/SrTrainControlParam.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/SrTrainController.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/SrTrainController.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/SrTrainController.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/SrTrainController.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrSectionConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrSectionConfig.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrSectionConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrSectionConfig.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrSignalConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrSignalConfig.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrSignalConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrSignalConfig.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrSwitchConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrSwitchConfig.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrSwitchConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrSwitchConfig.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrTrainConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrTrainConfig.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/config/SrTrainConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/config/SrTrainConfig.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrSectionServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrSectionServiceImpl.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrSectionServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrSectionServiceImpl.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrSignalServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrSignalServiceImpl.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrSignalServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrSignalServiceImpl.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrSwitchServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrSwitchServiceImpl.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrSwitchServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrSwitchServiceImpl.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrTrainServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrTrainServiceImpl.java similarity index 100% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/Sr/service/SrTrainServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/udp/sr/service/SrTrainServiceImpl.java diff --git a/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java b/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java index 60eedf988..4d9c0fd34 100644 --- a/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java +++ b/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java @@ -43,16 +43,23 @@ public class LoginUserInfoVO { private String group; private LocalDateTime preLogoutTime; + private LocalDateTime lastQueryTime; // 最后使用时间 public LoginUserInfoVO(AccountVO accountVO, Client client, Project project, ProjectDeviceVO deviceVO) { this.accountVO = accountVO; this.client = client; this.project = project; this.deviceVO = deviceVO; - this.loginTime = LocalDateTime.now(); + LocalDateTime now = LocalDateTime.now(); + this.loginTime = now; + this.lastQueryTime = now; this.token = buildToken(); } + public void updateLastQueryTime() { + this.lastQueryTime = LocalDateTime.now(); + } + public static LoginUserInfoVO buildStressTestInfo() { AccountVO accountVO = new AccountVO(); accountVO.setId(1l); @@ -83,7 +90,7 @@ public class LoginUserInfoVO { return accountLogin; } - public String getClientInfoStr() { + public String buildClientInfoStr() { String device = null; if (Objects.nonNull(this.deviceVO)) { device = this.deviceVO.toString(); @@ -92,7 +99,7 @@ public class LoginUserInfoVO { } public String buildDebugStr() { - return String.format("%s, user{id: %s, nickname: %s, name: %s}", this.getClientInfoStr(), accountVO.getId(), accountVO.getNickname(), accountVO.getName()); + return String.format("%s, user{id: %s, nickname: %s, name: %s}", this.buildClientInfoStr(), accountVO.getId(), accountVO.getNickname(), accountVO.getName()); } public boolean isProjectDeviceLogin() { @@ -112,4 +119,8 @@ public class LoginUserInfoVO { public boolean isDispatcherRaceTrainingLogin() { return Project.DRTS.equals(this.project); } + + public boolean isWechatLogin() { + return Client.Assistant.equals(this.getClient()); + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java b/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java index 623163d34..33187e349 100644 --- a/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/LoginStatusVO.java @@ -30,7 +30,10 @@ public class LoginStatusVO { private LocalDateTime time; - private int deleteRemain; + @JsonIgnore + private LocalDateTime finishTime; + @JsonIgnore + private LocalDateTime lastQueryTime; private ScanLoginStatus status; @@ -54,25 +57,16 @@ public class LoginStatusVO { } public void checkExpireAndUpdate() { - this.resetDeleteRemain(); if (Objects.nonNull(this.deviceVO)) { // 项目设备,永不过期 return; } if (LocalDateTime.now().isAfter(time.plusMinutes(5))) { this.status = ScanLoginStatus.EXPIRE; + this.finishTime = LocalDateTime.now(); } } - private void resetDeleteRemain() { - this.deleteRemain = 0; - } - - public int updateDeleteRemain(int add) { - this.deleteRemain += add; - return this.deleteRemain; - } - @JsonIgnore public boolean isProjectDeviceLogin() { return Objects.nonNull(this.deviceVO); @@ -81,6 +75,11 @@ public class LoginStatusVO { public void success(String token) { this.token = token; this.status = LoginStatusVO.ScanLoginStatus.SUCCESS; + this.finishTime = LocalDateTime.now(); + } + + public void updateQueryTime() { + this.lastQueryTime = LocalDateTime.now(); } public enum ScanLoginStatus { diff --git a/src/main/java/club/joylink/rtss/vo/sms/SmsParamVo.java b/src/main/java/club/joylink/rtss/vo/sms/SmsParamVo.java new file mode 100644 index 000000000..006ed3255 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/sms/SmsParamVo.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.vo.sms; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public abstract class SmsParamVo { + /** + * 手机号 + */ + private String mobile; + /** + * 国际码 + */ + private String nationCode = "86"; + /** + * 请求校验 + */ + String checksum; + + public abstract String calCheckSum(); + + public boolean isValidRequest() { + return this.calCheckSum().equals(checksum); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/sms/ZzjAlertSmsParamVo.java b/src/main/java/club/joylink/rtss/vo/sms/ZzjAlertSmsParamVo.java new file mode 100644 index 000000000..a05403356 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/sms/ZzjAlertSmsParamVo.java @@ -0,0 +1,28 @@ +package club.joylink.rtss.vo.sms; + +import club.joylink.rtss.util.EncryptUtil; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * 转辙机告警短信消息参数 + */ +@Getter +@Setter +@NoArgsConstructor +public class ZzjAlertSmsParamVo extends SmsParamVo { + /** + * 设备名称 + */ + private String deviceName; + /** + * 故障描述 + */ + private String description; + + @Override + public String calCheckSum() { + return EncryptUtil.md5(String.format("[%s]-%s::%s::%s", "joylink", this.getMobile(), this.deviceName, this.description)); + } +}