From 4d4e6c810d99235e97beab7a8cbdbe8706a5e505 Mon Sep 17 00:00:00 2001 From: huangzhen <867217663@qq.com> Date: 星期二, 05 九月 2023 13:57:25 +0800 Subject: [PATCH] 新增一些功能 --- src/main/resources/config/redisson-online-uat.yml | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogInfoReqDTO.java | 18 + src/main/resources/template/dailyReportTemplate.docx | 0 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionReqDTO.java | 3 src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasCategoryServiceImpl.java | 8 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/HandleGasWarnLogReqDTO.java | 20 + src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdRespDTO.java | 9 src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnLogRepository.java | 5 src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java | 41 + src/main/resources/config/application-online-uat.yaml | 16 src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/exception/RepeatedClickException.java | 34 ++ src/main/java/com/gkhy/fourierSpecialGasMonitor/Application.java | 5 src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/entity/User.java | 8 src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java | 7 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionPageRespDTO.java | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnUserRepository.java | 3 src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java | 84 ++++ src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/DataReceiveController.java | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogCountByTimeReqDTO.java | 16 src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java | 5 src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasThresholdController.java | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationExcWebsocketServer.java | 15 src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/enums/ResultCode.java | 1 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionLngLatReqDTO.java | 4 src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/converter/UserInfoDomainConverter.java | 14 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasWarnLog.java | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/enums/GasWarnTimesCountEnum.java | 71 ++++ src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnUserServiceImpl.java | 21 src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java | 13 src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/HeartbeatExcWebsocketServer.java | 12 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogInfoByTimeRespDTO.java | 35 ++ pom.xml | 4 src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnLogController.java | 21 + src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasFluxWebsocketServer.java | 10 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindGasWarnLogPageRespDTO.java | 6 src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasThresholdServiceImpl.java | 10 src/main/java/com/gkhy/fourierSpecialGasMonitor/aspect/RepeatedClickAspect.java | 61 +++ src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogCountByTimeRespDTO.java | 19 + src/main/java/com/gkhy/fourierSpecialGasMonitor/config/exception/GlobalExceptionHandler.java | 12 src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java | 40 + src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationWebsocketServer.java | 14 src/main/resources/config/application-dev.yaml | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdLngLatRespDTO.java | 21 + src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasWarnLogService.java | 10 src/main/java/com/gkhy/fourierSpecialGasMonitor/config/authorization/TokenCheckWhiteListEnum.java | 1 src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasThresholdListRespDTO.java | 2 src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/TestSchedule.java | 199 +++++++++++ /dev/null | 30 - src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/query/GasWarnTimesCountTimeSlotQuery.java | 22 + src/main/java/com/gkhy/fourierSpecialGasMonitor/annotation/RepeatedClick.java | 16 src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnUserController.java | 3 src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/RegionController.java | 3 src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasDeviceExcWebsocketServer.java | 14 53 files changed, 833 insertions(+), 165 deletions(-) diff --git a/pom.xml b/pom.xml index 08f110f..2adaf2a 100644 --- a/pom.xml +++ b/pom.xml @@ -132,10 +132,6 @@ <artifactId>hutool-all</artifactId> <version>5.8.10</version> </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </dependency> <dependency> <groupId>org.apache.poi</groupId> diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/Application.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/Application.java index 0756f61..b5ea265 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/Application.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/Application.java @@ -1,5 +1,7 @@ package com.gkhy.fourierSpecialGasMonitor; +import com.gkhy.fourierSpecialGasMonitor.entity.query.GasWarnTimesCountTimeSlotQuery; +import com.gkhy.fourierSpecialGasMonitor.enums.GasWarnTimesCountEnum; import io.micrometer.core.instrument.util.StringUtils; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,6 +9,9 @@ import org.springframework.scheduling.annotation.EnableScheduling; import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.Random; +import java.util.concurrent.TimeUnit; @EnableJpaAuditing @EnableScheduling diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/annotation/RepeatedClick.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/annotation/RepeatedClick.java new file mode 100644 index 0000000..2ec81d8 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/annotation/RepeatedClick.java @@ -0,0 +1,16 @@ +package com.gkhy.fourierSpecialGasMonitor.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface RepeatedClick { + + //2秒内都属于重复提交 + int clickTime() default 2; + + String errorMessage() default "您点击太快了,请稍后尝试"; +} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/api/controller/account/UserIndentityController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/api/controller/account/UserIndentityController.java deleted file mode 100644 index a7eeb30..0000000 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/api/controller/account/UserIndentityController.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.gkhy.fourierSpecialGasMonitor.api.controller.account; - -import com.gkhy.fourierSpecialGasMonitor.api.controller.account.converter.UserIdentityApiConverter; -import com.gkhy.fourierSpecialGasMonitor.api.controller.account.dto.resp.UserIdentityApiDTO; -import com.gkhy.fourierSpecialGasMonitor.application.account.dto.respDto.UserIndentityAppDTO; -import com.gkhy.fourierSpecialGasMonitor.application.account.service.UserIdentityAppService; -import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * @email 1603559716@qq.com - * @author: zf - * @date: 2023/5/4 - * @time: 13:40 - */ -@RestController -@RequestMapping("/account/user/identity") -public class UserIndentityController { - - @Autowired - private UserIdentityApiConverter userIdentityApiConverter; - @Autowired - private UserIdentityAppService userIdentityAppService; - - @PostMapping("/list") - public Result findUser(){ - Result<List<UserIdentityApiDTO>> result = new Result<>(); - result.setSuccess(); - List<UserIndentityAppDTO> list = userIdentityAppService.list(); - result.setData(userIdentityApiConverter.toApiDtoList(list)); - return result; - } -} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/application/account/service/UserIdentityAppService.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/application/account/service/UserIdentityAppService.java deleted file mode 100644 index 9553e74..0000000 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/application/account/service/UserIdentityAppService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gkhy.fourierSpecialGasMonitor.application.account.service; - -import com.gkhy.fourierSpecialGasMonitor.application.account.dto.respDto.UserIndentityAppDTO; - -import java.util.List; - -/** - * @email 1603559716@qq.com - * @author: zf - * @date: 2023/5/4 - * @time: 13:49 - */ -public interface UserIdentityAppService { - List<UserIndentityAppDTO> list(); -} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/application/account/service/impl/UserIdentityAppServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/application/account/service/impl/UserIdentityAppServiceImpl.java deleted file mode 100644 index 4ba0140..0000000 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/application/account/service/impl/UserIdentityAppServiceImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gkhy.fourierSpecialGasMonitor.application.account.service.impl; - -import com.gkhy.fourierSpecialGasMonitor.application.account.converter.UserIndentityAppConverter; -import com.gkhy.fourierSpecialGasMonitor.application.account.dto.respDto.UserIndentityAppDTO; -import com.gkhy.fourierSpecialGasMonitor.application.account.service.UserIdentityAppService; -import com.gkhy.fourierSpecialGasMonitor.domain.account.model.dto.UserIdentityDomainDTO; -import com.gkhy.fourierSpecialGasMonitor.domain.account.service.UserIdentityDomainService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @email 1603559716@qq.com - * @author: zf - * @date: 2023/5/4 - * @time: 13:49 - */ -@Service -public class UserIdentityAppServiceImpl implements UserIdentityAppService { - @Autowired - private UserIdentityDomainService userIdentityDomainService; - @Autowired - private UserIndentityAppConverter userIndentityAppConverter; - @Override - public List<UserIndentityAppDTO> list() { - List<UserIdentityDomainDTO> list = userIdentityDomainService.getList(); - return userIndentityAppConverter.toUserIndentityAppDTO(list); - } -} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/aspect/RepeatedClickAspect.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/aspect/RepeatedClickAspect.java new file mode 100644 index 0000000..d39d062 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/aspect/RepeatedClickAspect.java @@ -0,0 +1,61 @@ +package com.gkhy.fourierSpecialGasMonitor.aspect; + + +import com.gkhy.fourierSpecialGasMonitor.commons.enums.ResultCode; +import com.gkhy.fourierSpecialGasMonitor.commons.exception.BusinessException; +import com.gkhy.fourierSpecialGasMonitor.commons.exception.RepeatedClickException; +import com.gkhy.fourierSpecialGasMonitor.config.authorization.TokenConfig; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.concurrent.TimeUnit; + +@Component +@Aspect +public class RepeatedClickAspect { + + @Resource + protected TokenConfig tokenConfig; + + @Autowired + private RedisTemplate redisTemplate; + + @Before("@annotation(com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick)") + @ResponseBody + public void beforeRepeatedClick(JoinPoint joinPoint){ + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest arg = requestAttributes.getRequest(); + MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); + RepeatedClick annotation = methodSignature.getMethod().getAnnotation(RepeatedClick.class); + if (annotation != null){ + int clickTime = annotation.clickTime(); + String errorMessage = annotation.errorMessage(); + String userId = arg.getHeader(tokenConfig.getLoginUserHeader()); + if (!StringUtils.isEmpty(userId)) { + try { + Long uid = Long.parseLong(userId); + String key = "uid:"+uid+"_"+ arg.getRequestURI() + "_" + arg.getMethod(); + if (redisTemplate.hasKey(key)){ + throw new RepeatedClickException(errorMessage); + }else { + redisTemplate.opsForValue().set(key,"",clickTime, TimeUnit.SECONDS); + } + } catch (NumberFormatException e) { + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(),"数据参数异常"); + } + } + } + } +} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/enums/ResultCode.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/enums/ResultCode.java index edfbc0a..3c826ba 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/enums/ResultCode.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/enums/ResultCode.java @@ -38,6 +38,7 @@ SYSTEM_ERROR_API_OUT_OF_TIME(502,"接口超时"), SYSTEM_ERROR_DATABASE_FAIL(503,"数据库错误"), SYSTEM_ERROR_SERIALIZA_FAIL(504,"序列化错误"), + SYSTEM_ERROR_WEBSOCKET_SEND_INFO_FAIL(505,"websocket发送消息失败"), //文件 FILE_NOT_EXISIST(600,"文件不存在"), PATH_NOT_EXISIST(601,"文件路径不存在"), diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/exception/RepeatedClickException.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/exception/RepeatedClickException.java new file mode 100644 index 0000000..69adfd9 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/commons/exception/RepeatedClickException.java @@ -0,0 +1,34 @@ +package com.gkhy.fourierSpecialGasMonitor.commons.exception; + +public class RepeatedClickException extends RuntimeException{ + + private String code; + private String error; + + public RepeatedClickException(String message) { + super(message); + } + + + public RepeatedClickException(String code, String error) { + super(error); + this.code = code; + this.error = error; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } +} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/authorization/TokenCheckWhiteListEnum.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/authorization/TokenCheckWhiteListEnum.java index de89ad3..f24c99c 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/authorization/TokenCheckWhiteListEnum.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/authorization/TokenCheckWhiteListEnum.java @@ -11,6 +11,7 @@ PATH_FORGET_PASSWORD("/account/auth/pwd/forget/reset","忘记密码重置密码接口",true), PATH_LICENSE("/sys/lic/**","授权证书查看",true), PATH_ACCOUNT_AUTH("/account/auth/**","用户认证",true), + PATH_WEBSOCKET("/ws/**","websocket相关接口",true), /*PATH_TEST_ACCOUNT("/account/user/**","账号测试接口",true), //basic部分测试接口 PATH_TEST_BASIC("/basic/**","账号测试接口",true), diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/exception/GlobalExceptionHandler.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/exception/GlobalExceptionHandler.java index cb55785..f6325f6 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/config/exception/GlobalExceptionHandler.java @@ -9,6 +9,7 @@ import com.gkhy.fourierSpecialGasMonitor.commons.exception.BusinessException; import com.gkhy.fourierSpecialGasMonitor.commons.exception.DataReceiveException; import com.gkhy.fourierSpecialGasMonitor.commons.exception.ExceptionInfo; +import com.gkhy.fourierSpecialGasMonitor.commons.exception.RepeatedClickException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -83,6 +84,17 @@ return result; } + /** + * 重复点击异常 + */ + @ResponseBody + @ExceptionHandler(value = RepeatedClickException.class) + public Result repeatedClickExceptionHandler(RepeatedClickException e) throws JsonProcessingException { + Result result = new Result(); + result.setSuccess(); + result.setMsg(e.getMessage()); + return result; + } /** * @Description: AuthenticationException diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/DataReceiveController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/DataReceiveController.java index ec65961..5bf0ae9 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/DataReceiveController.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/DataReceiveController.java @@ -1,5 +1,6 @@ package com.gkhy.fourierSpecialGasMonitor.controller; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.commons.domain.ForeignResult; import com.gkhy.fourierSpecialGasMonitor.entity.req.DeviceMonitorReqDTO; import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasConcentrationReqDTO; @@ -33,6 +34,7 @@ } @PostMapping("/list/gasCategory") + @RepeatedClick public ForeignResult listGasCategory(){ ForeignResult result = dataReceiveService.listGasCategory(); return result; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java index 7d8d93c..b0e0751 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java @@ -1,5 +1,6 @@ package com.gkhy.fourierSpecialGasMonitor.controller; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.api.controller.common.BaseController; import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; import com.gkhy.fourierSpecialGasMonitor.commons.model.PageQuery; @@ -31,12 +32,14 @@ private RedissonClient redissonClient; @PostMapping("/add") + @RepeatedClick public Result createGasCategory(@RequestBody CreateGasCategoryReqDTO reqDto){ Result result = gasCategoryService.createGasCategory(reqDto); return result; } @PostMapping("/update") + @RepeatedClick public Result updateGasCategory(@RequestBody UpdateGasCategoryReqDTO reqDto){ Result result = gasCategoryService.updateGasCategory(reqDto); return result; @@ -69,7 +72,7 @@ bucket.delete(); } this.gasCategoryList(); - logger.info("【气体对照表】已加入缓存"); + logger.info("[GasCategoryList] cache complete"); } } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasThresholdController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasThresholdController.java index 6182828..1846f4d 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasThresholdController.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasThresholdController.java @@ -1,5 +1,6 @@ package com.gkhy.fourierSpecialGasMonitor.controller; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; import com.gkhy.fourierSpecialGasMonitor.entity.req.UpdateGasThresholdReqDTO; import com.gkhy.fourierSpecialGasMonitor.entity.req.UpdateRegionReqDTO; @@ -29,6 +30,7 @@ } @PostMapping("/update") + @RepeatedClick public Result updateGasThreshold(@RequestBody UpdateGasThresholdReqDTO reqDto){ Result result = gasThresholdService.updateGasThreshold(reqDto); return result; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnLogController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnLogController.java index 97a68b6..c426134 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnLogController.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnLogController.java @@ -1,9 +1,12 @@ package com.gkhy.fourierSpecialGasMonitor.controller; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; import com.gkhy.fourierSpecialGasMonitor.commons.model.PageQuery; -import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasCategoryPageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasWarnLogPageQuery; +import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogCountByTimeReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogInfoReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.HandleGasWarnLogReqDTO; import com.gkhy.fourierSpecialGasMonitor.service.GasWarnLogService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -27,8 +30,20 @@ } @PostMapping("/handleById") - public Result handleGasWarnLog(@RequestParam Long id){ - Result result = gasWarnLogService.handleGasWarnLog(id); + @RepeatedClick + public Result handleGasWarnLog(@RequestBody HandleGasWarnLogReqDTO reqDto){ + Result result = gasWarnLogService.handleGasWarnLog(reqDto); + return result; + } + + @PostMapping("/gasWarnLogCountByTime") + public Result gasWarnLogCountByTime(@RequestBody GasWarnLogCountByTimeReqDTO gasWarnLogCountByTimeReqDTO){ + Result result = gasWarnLogService.gasWarnLogCountByTime(gasWarnLogCountByTimeReqDTO); + return result; + } + @PostMapping("/gasWarnLogInfoByTime") + public Result gasWarnLogInfoByTime(@RequestBody GasWarnLogInfoReqDTO gasWarnLogInfoReqDTO){ + Result result = gasWarnLogService.gasWarnLogInfoByTime(gasWarnLogInfoReqDTO); return result; } } \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnUserController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnUserController.java index f9d4bef..15921bf 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnUserController.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasWarnUserController.java @@ -1,5 +1,6 @@ package com.gkhy.fourierSpecialGasMonitor.controller; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; import com.gkhy.fourierSpecialGasMonitor.commons.model.PageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasCategoryPageQuery; @@ -24,6 +25,7 @@ @PostMapping("/add") + @RepeatedClick public Result createGasWarnUser(@RequestBody CreateGasWarnUserReqDTO reqDto){ Result result = gasWarnUserService.createGasWarnUser(reqDto); return result; @@ -36,6 +38,7 @@ } @PostMapping("/update") + @RepeatedClick public Result updateGasWarnUser(@RequestBody UpdateGasWarnUserReqDTO reqDto){ Result result = gasWarnUserService.updateGasWarnUser(reqDto); return result; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/RegionController.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/RegionController.java index 043f01f..102b09b 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/RegionController.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/RegionController.java @@ -1,5 +1,6 @@ package com.gkhy.fourierSpecialGasMonitor.controller; +import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; import com.gkhy.fourierSpecialGasMonitor.commons.model.PageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindRegionPageQuery; @@ -21,6 +22,7 @@ private RegionService regionService; @PostMapping("/add") + @RepeatedClick public Result createRegion(@RequestBody CreateRegionReqDTO reqDto){ Result result = regionService.createRegion(reqDto); return result; @@ -33,6 +35,7 @@ } @PostMapping("/update") + @RepeatedClick public Result updateRegion(@RequestBody UpdateRegionReqDTO reqDto){ Result result = regionService.updateRegion(reqDto); return result; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/converter/UserInfoDomainConverter.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/converter/UserInfoDomainConverter.java index 2da0278..e2d4d22 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/converter/UserInfoDomainConverter.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/converter/UserInfoDomainConverter.java @@ -43,13 +43,13 @@ userInfoDomainDTO.setRoles(roleBindDomainDTOList); //身份 - List<SysUserIdentityBindDomainDTO> userIdentityBindDomainDTOS = new ArrayList<>(); - if(user.getSysUserIdentityBinds() != null){ - user.getSysUserIdentityBinds().forEach(userIdentity ->{ - userIdentityBindDomainDTOS.add(toUserIndentityDomainDTO(userIdentity)); - }); - } - userInfoDomainDTO.setUserIdentities(userIdentityBindDomainDTOS); + //List<SysUserIdentityBindDomainDTO> userIdentityBindDomainDTOS = new ArrayList<>(); + //if(user.getSysUserIdentityBinds() != null){ + // user.getSysUserIdentityBinds().forEach(userIdentity ->{ + // userIdentityBindDomainDTOS.add(toUserIndentityDomainDTO(userIdentity)); + // }); + //} + //userInfoDomainDTO.setUserIdentities(userIdentityBindDomainDTOS); //资质附件 if(user.getQualificationAttachment() != null){ AttachmentDomainDTO attachmentDomainDTO = new AttachmentDomainDTO(); diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/entity/User.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/entity/User.java index 4d1bcfd..27a6c6e 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/entity/User.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/domain/account/entity/User.java @@ -72,10 +72,10 @@ @JoinColumn(name = "userId",referencedColumnName = "id",insertable =false ,updatable = false) private List<SysUserRoleBind> sysUserRoleBinds; - @OneToMany(fetch = FetchType.EAGER,cascade = {CascadeType.REFRESH}) - @Fetch(FetchMode.SUBSELECT) - @JoinColumn(name = "userId",referencedColumnName = "id",insertable =false ,updatable = false) - private List<SysUserIdentityBind> sysUserIdentityBinds; + //@OneToMany(fetch = FetchType.EAGER,cascade = {CascadeType.REFRESH}) + //@Fetch(FetchMode.SUBSELECT) + //@JoinColumn(name = "userId",referencedColumnName = "id",insertable =false ,updatable = false) + //private List<SysUserIdentityBind> sysUserIdentityBinds; @ManyToOne(fetch = FetchType.EAGER,cascade = {CascadeType.REFRESH}) @JoinColumn(name = "depId",referencedColumnName = "id",insertable =false ,updatable = false) diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasWarnLog.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasWarnLog.java index 31cb94f..2d87446 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasWarnLog.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasWarnLog.java @@ -48,6 +48,8 @@ private String handlerName; + private String handlerDesc; + private String handlerRealName; private LocalDateTime handlerTime; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/query/GasWarnTimesCountTimeSlotQuery.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/query/GasWarnTimesCountTimeSlotQuery.java new file mode 100644 index 0000000..1406613 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/query/GasWarnTimesCountTimeSlotQuery.java @@ -0,0 +1,22 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.query; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author Mr.huang + * @decription + * @date 2023/9/2 23:34 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GasWarnTimesCountTimeSlotQuery { + + private LocalDateTime startTime; + + private LocalDateTime endTime; +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionLngLatReqDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionLngLatReqDTO.java index d9719cb..42ac056 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionLngLatReqDTO.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionLngLatReqDTO.java @@ -2,13 +2,15 @@ import lombok.Data; +import java.io.Serializable; + /** * @author Mr.huang * @decription * @date 2023/8/9 10:50 */ @Data -public class CreateRegionLngLatReqDTO { +public class CreateRegionLngLatReqDTO implements Serializable { private String lng; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionReqDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionReqDTO.java index cd0b90d..16e6805 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionReqDTO.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/CreateRegionReqDTO.java @@ -3,6 +3,7 @@ import com.gkhy.fourierSpecialGasMonitor.entity.RegionLngLat; import lombok.Data; +import java.io.Serializable; import java.util.List; /** @@ -11,7 +12,7 @@ * @date 2023/8/9 10:48 */ @Data -public class CreateRegionReqDTO { +public class CreateRegionReqDTO implements Serializable { private String name; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogCountByTimeReqDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogCountByTimeReqDTO.java new file mode 100644 index 0000000..e5cf557 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogCountByTimeReqDTO.java @@ -0,0 +1,16 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.req; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author Mr.huang + * @decription + * @date 2023/9/1 9:36 + */ +@Data +public class GasWarnLogCountByTimeReqDTO { + + private Integer countTime; +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogInfoReqDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogInfoReqDTO.java new file mode 100644 index 0000000..73f5124 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasWarnLogInfoReqDTO.java @@ -0,0 +1,18 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.req; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author Mr.huang + * @decription + * @date 2023/9/1 9:36 + */ +@Data +public class GasWarnLogInfoReqDTO { + + private LocalDateTime startTime; + + private LocalDateTime endTime; +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/HandleGasWarnLogReqDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/HandleGasWarnLogReqDTO.java new file mode 100644 index 0000000..8cac3ce --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/HandleGasWarnLogReqDTO.java @@ -0,0 +1,20 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.req; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Mr.huang + * @decription + * @date 2023/8/31 13:58 + */ +@Data +public class HandleGasWarnLogReqDTO implements Serializable { + + private Long id; + + private Long userId; + + private String handlerDesc; +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindGasWarnLogPageRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindGasWarnLogPageRespDTO.java index 98a0084..1bfc819 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindGasWarnLogPageRespDTO.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindGasWarnLogPageRespDTO.java @@ -39,9 +39,9 @@ private Double gasConcentration; - private Long gasThresholdId; + private Integer gasThresholdId; - private Long gasThresholdName; + private String gasThresholdName; private Byte status; @@ -51,6 +51,8 @@ private String handlerRealName; + private String handlerDesc; + private LocalDateTime handlerTime; private List<FindGasWarnLogSmsUserPageRespDTO> gasWarnLogSmsUsers; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdLngLatRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdLngLatRespDTO.java new file mode 100644 index 0000000..2b8ebf9 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdLngLatRespDTO.java @@ -0,0 +1,21 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.resp; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Mr.huang + * @decription + * @date 2023/8/9 13:53 + */ +@Data +public class FindRegionByIdLngLatRespDTO implements Serializable { + private Long id; + + private Integer regionId; + + private String lng; + + private String lat; +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdRespDTO.java index 87f6b63..d563406 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdRespDTO.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionByIdRespDTO.java @@ -3,6 +3,7 @@ import lombok.Data; import java.io.Serializable; +import java.util.List; /** * @author Mr.huang @@ -12,11 +13,11 @@ @Data public class FindRegionByIdRespDTO implements Serializable { - private Long id; + private Integer id; - private Long regionId; + private String name; - private String lng; + private String color; - private String lat; + private List<FindRegionByIdLngLatRespDTO> lngLatRespDTOS; } \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionPageRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionPageRespDTO.java index 6ba79be..b7048f0 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionPageRespDTO.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/FindRegionPageRespDTO.java @@ -14,7 +14,7 @@ @Data public class FindRegionPageRespDTO implements Serializable { - private Long id; + private Integer id; private String name; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasThresholdListRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasThresholdListRespDTO.java index 3f17955..47629e6 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasThresholdListRespDTO.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasThresholdListRespDTO.java @@ -12,7 +12,7 @@ @Data public class GasThresholdListRespDTO implements Serializable { - private Long id; + private Integer id; private String name; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogCountByTimeRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogCountByTimeRespDTO.java new file mode 100644 index 0000000..a4b792a --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogCountByTimeRespDTO.java @@ -0,0 +1,19 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.resp; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Mr.huang + * @decription + * @date 2023/9/1 10:01 + */ +@Data +public class GasWarnLogCountByTimeRespDTO implements Serializable { + + private Long yellowWarnNum; + + private Long redWarnNum; + +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogInfoByTimeRespDTO.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogInfoByTimeRespDTO.java new file mode 100644 index 0000000..164b018 --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasWarnLogInfoByTimeRespDTO.java @@ -0,0 +1,35 @@ +package com.gkhy.fourierSpecialGasMonitor.entity.resp; + +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * @author Mr.huang + * @decription + * @date 2023/9/1 10:14 + */ +@Data +public class GasWarnLogInfoByTimeRespDTO implements Serializable { + + private Long id; + + private LocalDateTime warnTime; + + private Integer gasCategoryId; + + private String gasMolecularFormula; + + private String gasName; + + private String gasUnit; + + private Double gasConcentrationThreshold; + + private Double gasConcentration; + + private Integer gasThresholdId; + + private String gasThresholdName; +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/enums/GasWarnTimesCountEnum.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/enums/GasWarnTimesCountEnum.java new file mode 100644 index 0000000..b719caa --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/enums/GasWarnTimesCountEnum.java @@ -0,0 +1,71 @@ +package com.gkhy.fourierSpecialGasMonitor.enums; + +import com.gkhy.fourierSpecialGasMonitor.entity.query.GasWarnTimesCountTimeSlotQuery; +import lombok.Getter; + +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.temporal.TemporalAdjusters; + +/** + * @author Mr.huang + * @decription + * @date 2023/9/2 23:31 + */ +@Getter +public enum GasWarnTimesCountEnum { + + TODAY(1,"今天"){ + @Override + public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.with(LocalTime.MIN); + return new GasWarnTimesCountTimeSlotQuery(startTime,now); + } + }, + IN_7_DAYS(2,"7天内"){ + @Override + public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.minusDays(6).with(LocalTime.MIN); + return new GasWarnTimesCountTimeSlotQuery(startTime,now); + } + }, + IN_30_DAYS(3,"30天内"){ + @Override + public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.minusDays(29).with(LocalTime.MIN); + return new GasWarnTimesCountTimeSlotQuery(startTime,now); + } + }, + THISYEAR(4,"今年"){ + @Override + public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.with(TemporalAdjusters.firstDayOfYear()).with(LocalTime.MIN); + return new GasWarnTimesCountTimeSlotQuery(startTime,now); + } + }; + + private Integer state; + private String description; + + GasWarnTimesCountEnum(int state, String description) { + this.state = state; + this.description = description; + } + + + public static GasWarnTimesCountEnum getQueryObject(Integer key){ + for (GasWarnTimesCountEnum value : GasWarnTimesCountEnum.values()) { + if (value.state.equals(key)){ + return value; + } + } + return TODAY; + } + + public abstract GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy(); + +} diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnLogRepository.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnLogRepository.java index a8e73f9..3c1cd61 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnLogRepository.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnLogRepository.java @@ -6,6 +6,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; +import java.util.List; + /** * @author Mr.huang * @decription @@ -15,4 +18,6 @@ public interface GasWarnLogRepository extends JpaRepository<GasWarnLog,Long>, JpaSpecificationExecutor<GasWarnLog> { GasWarnLog findByIdAndStatus(Long id,Byte status); + + List<GasWarnLog> findAllByWarnTimeBetweenOrderByWarnTimeDesc(LocalDateTime startTime,LocalDateTime endTime); } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnUserRepository.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnUserRepository.java index 11516d1..15b8858 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnUserRepository.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/repository/GasWarnUserRepository.java @@ -22,4 +22,7 @@ List<GasWarnUser> findAllByStatus(Byte status); + + + } \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java index 722471f..28b8834 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java @@ -93,7 +93,7 @@ String startTime = now.format(execformatter); RBucket<List<GasCategory>> bucket = redissonClient.getBucket("gas_category_cache_info"); List<GasCategory> gasCategories = bucket.get(); - //logger.info("【##】开始生成日报 ,时间:"+startTime); + logger.info("【##】开始生成日报 ,时间:"+startTime); OPCPackage opcPackage = null; //加载文档 XWPFDocument doc = null; @@ -164,7 +164,8 @@ } catch (IOException e) { e.printStackTrace(); } - List<GasConcentration> gasConcentrations = gasConcentrationService.listDatabyTimeSlot(LocalDateTime.now().minusDays(2).with(LocalDate.MIN), LocalDateTime.now()); + List<GasConcentration> gasConcentrations = gasConcentrationService.listDatabyTimeSlot(LocalDateTime.of(now.minusDays(1).toLocalDate(), LocalTime.MIN) + , LocalDateTime.of(now.minusDays(1).toLocalDate(), LocalTime.MAX)); if (!CollectionUtils.isEmpty(gasConcentrations)) { for (int i = 0; i < 30; i++) { String series = gasCategories.get(i).getMolecularFormula() + "浓度观测结果"; @@ -182,8 +183,8 @@ Map<Integer, String> regionMap = allRegion.stream() .collect(Collectors.toMap(Region::getId, Region::getName)); if (!CollectionUtils.isEmpty(gasFluxes)) { - for (int i = 1; i <= 1; i++) { - for (int j = 0; j < 1; j++) { + for (int i = 1; i <= areaNum.size(); i++) { + for (int j = 0; j < 20; j++) { drawBarChart(gasFluxes, fileurl, regionMap.get(i), "柱形图" + gasCategories.get(j).getMolecularFormula(), i, j + 1); } } @@ -198,7 +199,7 @@ MonitorDailyReport save = monitorDailyReportService.save(report); if (save == null) throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL,"日常报表保存失败"); - //logger.info("【##】日报生成成功!!! ,时间:"+endTime+",所耗时间: "+execTime+"s"); + logger.info("【##】日报生成成功!!! ,时间:"+endTime+",所耗时间: "+execTime+"s"); } public void drawBarChart(List<GasFlux> gasFluxes,String fileurl,String series,String molecularFormula,Integer i,Integer j) { @@ -432,7 +433,7 @@ private Map<String, Object> dataMap(List<GasCategory> gasCategories){ LocalDateTime now = LocalDateTime.now(); String today = now.format(formatter); - String yesterday = LocalDateTime.now().plusDays(1).format(formatter); + String yesterday = LocalDateTime.now().minusDays(1).format(formatter); //要替换的map,key为占位符,value为要被替换的值 Map<String, Object> map = new HashMap<>(); map.put("${today}", today); diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java index 6bb7087..57078f3 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java @@ -42,11 +42,10 @@ private final Logger logger = LoggerFactory.getLogger(this.getClass()); - //@Scheduled(cron = "1 * * * * *") // 每分钟执行一次 + @Scheduled(cron = "1 * * * * ?") // 每天凌晨执行 @Async(value = "SocketTaskExecutor") public void gasConcentrationStatus() { - GasConcentration gasConcentration = gasConcentrationService.getLastData(); if (gasConcentration != null){ LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(1); @@ -61,7 +60,7 @@ if (save == null) throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"设备异常日志保存失败"); } catch (IOException e) { - e.printStackTrace(); + throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_WEBSOCKET_SEND_INFO_FAIL.getCode(),"设备异常消息推送失败"); } } } @@ -84,7 +83,7 @@ if (save == null) throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"设备异常日志保存失败"); } catch (IOException e) { - e.printStackTrace(); + throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_WEBSOCKET_SEND_INFO_FAIL.getCode(),"设备异常消息推送失败"); } } } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/TestSchedule.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/TestSchedule.java new file mode 100644 index 0000000..2806d4e --- /dev/null +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/TestSchedule.java @@ -0,0 +1,199 @@ +package com.gkhy.fourierSpecialGasMonitor.schedule; + +import com.gkhy.fourierSpecialGasMonitor.entity.req.DeviceMonitorReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasConcentrationReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasFluxReqDTO; +import com.gkhy.fourierSpecialGasMonitor.service.DataReceiveService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.text.DecimalFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * @author Mr.huang + * @decription + * @date 2023/8/22 13:49 + */ +@Component +public class TestSchedule { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private DataReceiveService dataReceiveService; + + private static final DateTimeFormatter execformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + + @Scheduled(cron = "1 * * * * ?") + @Async(value = "SocketTaskExecutor") + public void testDeviceMonitor() { + logger.info("【硬件设备一分钟一次推送测试】:" + LocalDateTime.now().format(execformatter)); + DeviceMonitorReqDTO deviceMonitorReqDTO = new DeviceMonitorReqDTO(); + deviceMonitorReqDTO.setTime(LocalDateTime.now()); + deviceMonitorReqDTO.setConState(0); + deviceMonitorReqDTO.setFluxState(0); + List<Integer> list = new ArrayList<>(); + list.add(0); + deviceMonitorReqDTO.setHardwareState(list); + dataReceiveService.deviceMonitor(deviceMonitorReqDTO); + } + + + @Scheduled(cron = "0/30 * * * * ?") + @Async(value = "SocketTaskExecutor") + public void testGasConcentration() { + logger.info("【气体实时浓度推送测试】:"+LocalDateTime.now().format(execformatter)); + Random random = new Random(); + double randomDouble = random.nextDouble() * 99.9 + 1; // 生成1到100之间的随机双精度数 + DecimalFormat decimalFormat = new DecimalFormat("0.0"); + String formattedDouble = decimalFormat.format(randomDouble); + double result = Double.parseDouble(formattedDouble); + UploadGasConcentrationReqDTO dto = new UploadGasConcentrationReqDTO(); + dto.setEquipmentId("No-123456"); + dto.setTime(LocalDateTime.now()); + dto.setType(1); + dto.setLng("东经43"); + dto.setLat("北纬53"); + dto.setAngle("60"); + dto.setTemp(26.9); + dto.setHumidity(63.3); + dto.setWindSpeed(12.3); + dto.setWindDirection(56); + dto.setPressure(200.0); + dto.setGasName01(1); + dto.setGasValue01(result); + dto.setGasName02(2); + dto.setGasValue02(result); + dto.setGasName03(3); + dto.setGasValue03(result); + dto.setGasName04(4); + dto.setGasValue04(result); + dto.setGasName05(5); + dto.setGasValue05(result); + dto.setGasName06(6); + dto.setGasValue06(result); + dto.setGasName07(7); + dto.setGasValue07(result); + dto.setGasName08(8); + dto.setGasValue08(result); + dto.setGasName09(9); + dto.setGasValue09(result); + dto.setGasName10(10); + dto.setGasValue10(result); + dto.setGasName11(11); + dto.setGasValue11(result); + dto.setGasName12(12); + dto.setGasValue12(result); + dto.setGasName13(13); + dto.setGasValue13(result); + dto.setGasName14(14); + dto.setGasValue14(result); + dto.setGasName15(15); + dto.setGasValue15(result); + dto.setGasName16(16); + dto.setGasValue16(result); + dto.setGasName17(17); + dto.setGasValue17(result); + dto.setGasName18(18); + dto.setGasValue18(result); + dto.setGasName19(19); + dto.setGasValue19(result); + dto.setGasName20(20); + dto.setGasValue20(result); + dto.setGasName21(21); + dto.setGasValue21(result); + dto.setGasName22(22); + dto.setGasValue22(result); + dto.setGasName23(23); + dto.setGasValue23(result); + dto.setGasName24(24); + dto.setGasValue24(result); + dto.setGasName25(25); + dto.setGasValue25(result); + dto.setGasName26(26); + dto.setGasValue26(result); + dto.setGasName27(27); + dto.setGasValue27(result); + dto.setGasName28(28); + dto.setGasValue28(result); + dto.setGasName29(29); + dto.setGasValue29(result); + dto.setGasName30(30); + dto.setGasValue30(result); + dataReceiveService.uploadGasConcentration(dto); + } + + //@Scheduled(cron = "0 0/15 * * * ?") + @Scheduled(cron = "0/30 * * * * ?") + @Async(value = "SocketTaskExecutor") + public void testGasFlux() { + logger.info("【气体通量推送测试】:"+LocalDateTime.now().format(execformatter)); + for (int i = 1; i <= 8 ; i++) { + Random random = new Random(); + double randomDouble = random.nextDouble() * 99.9 + 1; // 生成1到100之间的随机双精度数 + DecimalFormat decimalFormat = new DecimalFormat("0.0"); + String formattedDouble = decimalFormat.format(randomDouble); + double result = Double.parseDouble(formattedDouble); + UploadGasFluxReqDTO dto = new UploadGasFluxReqDTO(); + dto.setEquipmentId("No-123456"); + dto.setTime(LocalDateTime.now()); + dto.setAreaId(i); + dto.setType(1); + dto.setWindSpeed(12.3); + dto.setWindDirection(56); + dto.setGasName01(1); + dto.setGasValue01(result); + dto.setGasName02(2); + dto.setGasValue02(result); + dto.setGasName03(3); + dto.setGasValue03(result); + dto.setGasName04(4); + dto.setGasValue04(result); + dto.setGasName05(5); + dto.setGasValue05(result); + dto.setGasName06(6); + dto.setGasValue06(result); + dto.setGasName07(7); + dto.setGasValue07(result); + dto.setGasName08(8); + dto.setGasValue08(result); + dto.setGasName09(9); + dto.setGasValue09(result); + dto.setGasName10(10); + dto.setGasValue10(result); + dto.setGasName11(11); + dto.setGasValue11(result); + dto.setGasName12(12); + dto.setGasValue12(result); + dto.setGasName13(13); + dto.setGasValue13(result); + dto.setGasName14(14); + dto.setGasValue14(result); + dto.setGasName15(15); + dto.setGasValue15(result); + dto.setGasName16(16); + dto.setGasValue16(result); + dto.setGasName17(17); + dto.setGasValue17(result); + dto.setGasName18(18); + dto.setGasValue18(result); + dto.setGasName19(19); + dto.setGasValue19(result); + dto.setGasName20(20); + dto.setGasValue20(result); + dataReceiveService.uploadGasFlux(dto); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasWarnLogService.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasWarnLogService.java index 7595768..b2361c1 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasWarnLogService.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasWarnLogService.java @@ -4,6 +4,9 @@ import com.gkhy.fourierSpecialGasMonitor.commons.model.PageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.GasWarnLog; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasWarnLogPageQuery; +import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogCountByTimeReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogInfoReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.HandleGasWarnLogReqDTO; import java.util.List; @@ -15,9 +18,14 @@ public interface GasWarnLogService { Result findGasWarnLogPage(PageQuery<FindGasWarnLogPageQuery> pageQuery); - Result handleGasWarnLog(Long id); + Result handleGasWarnLog(HandleGasWarnLogReqDTO reqDto); GasWarnLog save(GasWarnLog gasWarnLog); List<GasWarnLog> listYesterday(); + + Result gasWarnLogCountByTime(GasWarnLogCountByTimeReqDTO gasWarnLogCountByTimeReqDTO); + + Result gasWarnLogInfoByTime(GasWarnLogInfoReqDTO gasWarnLogInfoReqDTO); + } \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java index e7b2837..2cc0b35 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java @@ -127,7 +127,7 @@ return gasCategory; }).collect(Collectors.toList()); } - logger.info("【气体异常map】init完成"); + logger.info("[GasExcMap] init complete"); } @PostConstruct @@ -143,7 +143,7 @@ } } } - logger.info("【预警阈值】init完成"); + logger.info("[WarningThreshold] init complete"); } @Override @@ -164,6 +164,7 @@ GasFlux save = gasFluxService.save(gasFlux); if (save == null) throw new DataReceiveException(this.getClass(), ForeignResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"气体通量数据保存失败"); + gasFluxDataCacheAndPush(); return ForeignResult.success(); } @@ -193,13 +194,21 @@ push = true; descs.add(GasFluxStateEnum.INVERSION_FAILED_10_MINUTES_NO_DATA.getDesc()); } - if (push == true){ - String message = JSON.toJSONString(reqDTO); - try { - GasDeviceExcWebsocketServer.sendInfo(message,null); - } catch (IOException e) { - logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败"); - } + String message = JSON.toJSONString(reqDTO); + //todo 暂时改为实时推送给前端 + try { + GasDeviceExcWebsocketServer.sendInfo(message,null); + } catch (IOException e) { + logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败"); + } + if (push){ + //todo 线上环境还是异常才向前端推送 + //String message = JSON.toJSONString(reqDTO); + //try { + // GasDeviceExcWebsocketServer.sendInfo(message,null); + //} catch (IOException e) { + // logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败"); + //} String execInfo = JSON.toJSONString(descs); logger.info("【警告】设备异常,异常原因: "+ execInfo); DeviceExceptionLog log = new DeviceExceptionLog(); @@ -212,7 +221,7 @@ return ForeignResult.success(); } - private void gasFluxDataCacheAndPush(GasFlux save){ + private void gasFluxDataCacheAndPush(){ LocalDateTime time = LocalDateTime.now(); LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0); List<GasFlux> gasFluxes = gasFluxService.listTodayGasFluxData(startTime,time); @@ -231,7 +240,7 @@ @Override @Transactional public ForeignResult uploadGasConcentration(UploadGasConcentrationReqDTO reqDto) { - //gasConcentrationParameterVerification(reqDto); + gasConcentrationParameterVerification(reqDto); GasConcentration gasConcentration = new GasConcentration(); BeanUtils.copyProperties(reqDto,gasConcentration); gasConcentration.setDataReceivingTime(LocalDateTime.now()); @@ -279,7 +288,6 @@ Integer count= integer + 1; gasExcCountMap.put(i,count); if (yellowWarningThreshold.equals(count)) { - System.out.println("超过次数: "+count); warnLogGenerateAndExecPush(WarningThresholdEnum.YELLOW.getCode(), gasCategory.get(i),value); } if (redWarningThreshold.equals(count)) { @@ -356,13 +364,19 @@ } private void dataCacheAndPush(GasConcentration save){ + LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime time = LocalDateTime.now(); String cacheName = time.format(formatter); RBucket<String> bucket = redissonClient.getBucket(gasConcentrationCachePrefix+cacheName); String cache = bucket.get(); List<GasConcentration> gasConcentrations = JSON.parseArray(cache,GasConcentration.class); if (CollectionUtils.isEmpty(gasConcentrations)){ - gasConcentrations = new ArrayList<>(); + List<GasConcentration> concentrations = gasConcentrationService.listDatabyTimeSlot(startTime, time); + if (CollectionUtils.isEmpty(concentrations)){ + gasConcentrations = new ArrayList<>(); + }else { + gasConcentrations = concentrations; + } gasConcentrations.add(save); }else { gasConcentrations.add(save); diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasCategoryServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasCategoryServiceImpl.java index 0898d67..f9aedeb 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasCategoryServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasCategoryServiceImpl.java @@ -24,6 +24,7 @@ import org.redisson.api.RedissonClient; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -213,8 +214,11 @@ searchResult.setTotal(pageResult.getTotalElements()); searchResult.setPages(pageResult.getTotalPages()); if (!CollectionUtils.isEmpty(pageResult.getContent())){ - List<FindGasCategoryPageRespDTO> respDTOS = new ArrayList<>(); - BeanUtils.copyProperties(pageResult.getContent(),respDTOS); + List<FindGasCategoryPageRespDTO> respDTOS = pageResult.getContent().stream().map(gasCategory -> { + FindGasCategoryPageRespDTO dto = new FindGasCategoryPageRespDTO(); + BeanUtils.copyProperties(gasCategory,dto); + return dto; + }).collect(Collectors.toList()); searchResult.setData(respDTOS); } return searchResult; diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasThresholdServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasThresholdServiceImpl.java index 1df8a20..0fddf58 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasThresholdServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasThresholdServiceImpl.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; /** * @author Mr.huang @@ -58,9 +59,12 @@ Result success = Result.success(); List<GasThreshold> gasThresholds = gasThresholdRepository.findAll(); if (!CollectionUtils.isEmpty(gasThresholds)){ - List<GasThresholdListRespDTO> respDTOS = new ArrayList<>(); - BeanUtils.copyProperties(gasThresholds,respDTOS); - success.setData(respDTOS); + List<GasThresholdListRespDTO> collect = gasThresholds.stream().map(gasThreshold -> { + GasThresholdListRespDTO dto = new GasThresholdListRespDTO(); + BeanUtils.copyProperties(gasThreshold, dto); + return dto; + }).collect(Collectors.toList()); + success.setData(collect); } return success; } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java index 1846dd5..0f93767 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java @@ -9,16 +9,21 @@ import com.gkhy.fourierSpecialGasMonitor.domain.account.enums.UserStatusEnum; import com.gkhy.fourierSpecialGasMonitor.domain.account.repository.jpa.UserRepository; import com.gkhy.fourierSpecialGasMonitor.entity.GasWarnLog; -import com.gkhy.fourierSpecialGasMonitor.entity.MonitorDailyReport; -import com.gkhy.fourierSpecialGasMonitor.entity.query.FindDailyReportPageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasWarnLogPageQuery; -import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindDailyReportPageRespDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.query.GasWarnTimesCountTimeSlotQuery; +import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogCountByTimeReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogInfoReqDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.req.HandleGasWarnLogReqDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindGasWarnLogPageRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindGasWarnLogSmsUserPageRespDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.resp.GasWarnLogCountByTimeRespDTO; +import com.gkhy.fourierSpecialGasMonitor.entity.resp.GasWarnLogInfoByTimeRespDTO; +import com.gkhy.fourierSpecialGasMonitor.enums.GasWarnTimesCountEnum; import com.gkhy.fourierSpecialGasMonitor.enums.WarnHandleStatusEnum; import com.gkhy.fourierSpecialGasMonitor.repository.GasWarnLogRepository; import com.gkhy.fourierSpecialGasMonitor.service.GasWarnLogService; import com.gkhy.fourierSpecialGasMonitor.utils.ThreadLocalUtil; +import io.micrometer.core.instrument.util.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -33,14 +38,9 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.temporal.TemporalAdjusters; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -77,7 +77,7 @@ Set<Predicate> predicateList = new HashSet<>(); FindGasWarnLogPageQuery searchParams = pageQuery.getSearchParams(); if (searchParams != null && searchParams.getStartTime() != null && searchParams.getEndTime() != null){ - predicateList.add(criteriaBuilder.between(root.get("gmtCreate").as(LocalDateTime.class),searchParams.getStartTime(),searchParams.getEndTime())); + predicateList.add(criteriaBuilder.between(root.get("warnTime").as(LocalDateTime.class),searchParams.getStartTime(),searchParams.getEndTime())); } if (searchParams != null && searchParams.getStatus() != null){ predicateList.add(criteriaBuilder.equal(root.get("status").as(Byte.class), searchParams.getStatus())); @@ -115,18 +115,28 @@ } @Override - public Result handleGasWarnLog(Long id) { + public Result handleGasWarnLog(HandleGasWarnLogReqDTO reqDto) { User currentUser = getCurrentUser(); - if (id == null){ + if (reqDto == null){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空"); } - GasWarnLog gasWarnLog = gasWarnLogRepository.findByIdAndStatus(id, WarnHandleStatusEnum.HANDLE_NO.getStatus()); + if (reqDto.getId() == null) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空"); + if (reqDto.getUserId() == null) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空"); + if (StringUtils.isBlank(reqDto.getHandlerDesc())) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空"); + GasWarnLog gasWarnLog = gasWarnLogRepository.findByIdAndStatus(reqDto.getId(), WarnHandleStatusEnum.HANDLE_NO.getStatus()); if (gasWarnLog == null) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"预警信息不存在"); - gasWarnLog.setHandlerId(currentUser.getId()); - gasWarnLog.setHandlerName(currentUser.getName()); - gasWarnLog.setHandlerRealName(currentUser.getRealName()); + User user = userRepository.findUserByIdAndStatus(reqDto.getUserId(), UserStatusEnum.STATUS_ACTIVE.getStatus()); + if (user == null) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"处理人不存在"); + gasWarnLog.setHandlerId(user.getId()); + gasWarnLog.setHandlerName(user.getName()); + gasWarnLog.setHandlerRealName(user.getRealName()); gasWarnLog.setHandlerTime(LocalDateTime.now()); + gasWarnLog.setHandlerDesc(reqDto.getHandlerDesc()); gasWarnLog.setStatus(WarnHandleStatusEnum.HANDLE_YES.getStatus()); GasWarnLog save = gasWarnLogRepository.save(gasWarnLog); if (save == null) @@ -160,4 +170,46 @@ List<GasWarnLog> warnLogs = gasWarnLogRepository.findAll(specification); return warnLogs; } + + @Override + public Result gasWarnLogCountByTime(GasWarnLogCountByTimeReqDTO gasWarnLogCountByTimeReqDTO) { + if (gasWarnLogCountByTimeReqDTO == null && gasWarnLogCountByTimeReqDTO .getCountTime() == null) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空"); + Integer countTime = gasWarnLogCountByTimeReqDTO.getCountTime(); + GasWarnTimesCountTimeSlotQuery query = GasWarnTimesCountEnum.getQueryObject(countTime).getTimeSlotByStrategy(); + Result result = Result.success(); + List<GasWarnLog> gasWarnLog = gasWarnLogRepository.findAllByWarnTimeBetweenOrderByWarnTimeDesc(query.getStartTime(), query.getEndTime()); + if (CollectionUtils.isEmpty(gasWarnLog)) + return result; + GasWarnLogCountByTimeRespDTO gasWarnLogCountByTimeRespDTO = new GasWarnLogCountByTimeRespDTO(); + Map<Integer, Long> nameCountMap = gasWarnLog.stream() + .collect(Collectors.groupingBy(GasWarnLog::getGasThresholdId, Collectors.counting())); + gasWarnLogCountByTimeRespDTO.setYellowWarnNum(nameCountMap.get(1)); + gasWarnLogCountByTimeRespDTO.setRedWarnNum(nameCountMap.get(2)); + result.setData(gasWarnLogCountByTimeRespDTO); + return result; + } + + @Override + public Result gasWarnLogInfoByTime(GasWarnLogInfoReqDTO gasWarnLogInfoReqDTO) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.with(LocalTime.MIN); + if (gasWarnLogInfoReqDTO != null && gasWarnLogInfoReqDTO.getStartTime() != null) { + startTime = gasWarnLogInfoReqDTO.getStartTime(); + } + if (gasWarnLogInfoReqDTO != null && gasWarnLogInfoReqDTO.getEndTime() != null) { + now = gasWarnLogInfoReqDTO.getEndTime(); + } + Result result = Result.success(); + List<GasWarnLog> gasWarnLogs = gasWarnLogRepository.findAllByWarnTimeBetweenOrderByWarnTimeDesc(startTime, now); + if (CollectionUtils.isEmpty(gasWarnLogs)) + return result; + List<GasWarnLogInfoByTimeRespDTO> dtos = gasWarnLogs.stream().map(gasWarnLog -> { + GasWarnLogInfoByTimeRespDTO dto = new GasWarnLogInfoByTimeRespDTO(); + BeanUtils.copyProperties(gasWarnLog, dto); + return dto; + }).collect(Collectors.toList()); + result.setData(dtos); + return result; + } } \ No newline at end of file diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnUserServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnUserServiceImpl.java index bc219a2..2f7e254 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnUserServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnUserServiceImpl.java @@ -30,6 +30,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.persistence.criteria.CriteriaBuilder; @@ -42,6 +43,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; /** * @author Mr.huang @@ -116,6 +118,7 @@ } @Override + @Transactional public Result updateGasWarnUser(UpdateGasWarnUserReqDTO reqDto) { if (reqDto == null || reqDto.getId() == null) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); @@ -131,10 +134,11 @@ GasWarnUser gasWarnUser = gasWarnUserRepository.findByUserIdAndStatus(reqDto.getUserId(), DeleteStatusEnum.DELECT_NO.getStatus()); if (gasWarnUser != null && !reqDto.getUserId().equals(gasWarnUser.getUserId())) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "预警通知人员已存在"); - BeanUtils.copyProperties(reqDto, gasWarnUser); - gasWarnUser.setGmtModified(LocalDateTime.now()); - gasWarnUser.setLastmodifiedby(getCurrentUser().getRealName()); - GasWarnUser save = gasWarnUserRepository.save(gasWarnUser); + GasWarnUser gasWarnUserById = gasWarnUserRepository.findByIdAndStatus(reqDto.getId(), DeleteStatusEnum.DELECT_NO.getStatus()); + BeanUtils.copyProperties(reqDto, gasWarnUserById); + gasWarnUserById.setGmtModified(LocalDateTime.now()); + gasWarnUserById.setLastmodifiedby(getCurrentUser().getRealName()); + GasWarnUser save = gasWarnUserRepository.save(gasWarnUserById); if (save == null) throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(), "预警通知人员更新失败"); }finally { @@ -169,9 +173,12 @@ searchResult.setTotal(pageResult.getTotalElements()); searchResult.setPages(pageResult.getTotalPages()); if (!CollectionUtils.isEmpty(pageResult.getContent())){ - List<FindGasWarnUserPageRespDTO> respDTOS = new ArrayList<>(); - BeanUtils.copyProperties(pageResult.getContent(),respDTOS); - searchResult.setData(respDTOS); + List<FindGasWarnUserPageRespDTO> collect = pageResult.getContent().stream().map(gasWarnUser -> { + FindGasWarnUserPageRespDTO dto = new FindGasWarnUserPageRespDTO(); + BeanUtils.copyProperties(gasWarnUser, dto); + return dto; + }).collect(Collectors.toList()); + searchResult.setData(collect); } return searchResult; } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java index 8678626..6eadae7 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java @@ -12,6 +12,7 @@ import com.gkhy.fourierSpecialGasMonitor.entity.RegionLngLat; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindRegionPageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.req.*; +import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionByIdLngLatRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionByIdRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionLngLatPageRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionPageRespDTO; @@ -135,12 +136,18 @@ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); Region region = regionRepository.findByIdAndStatus(id, DeleteStatusEnum.DELECT_NO.getStatus()); if (region != null){ + FindRegionByIdRespDTO findRegionByIdRespDTO = new FindRegionByIdRespDTO(); + BeanUtils.copyProperties(region,findRegionByIdRespDTO); List<RegionLngLat> regionLngLats = region.getRegionLngLats(); if (!CollectionUtils.isEmpty(regionLngLats)){ - List<FindRegionByIdRespDTO> respDTOS = new ArrayList<>(); - BeanUtils.copyProperties(regionLngLats,respDTOS); - success.setData(respDTOS); + List<FindRegionByIdLngLatRespDTO> collect = regionLngLats.stream().map(regionLngLat -> { + FindRegionByIdLngLatRespDTO findRegionByIdLngLatRespDTO = new FindRegionByIdLngLatRespDTO(); + BeanUtils.copyProperties(regionLngLat, findRegionByIdLngLatRespDTO); + return findRegionByIdLngLatRespDTO; + }).collect(Collectors.toList()); + findRegionByIdRespDTO.setLngLatRespDTOS(collect); } + success.setData(findRegionByIdRespDTO); } return success; } @@ -159,7 +166,7 @@ if (searchParams != null && !StringUtils.isBlank(searchParams.getName())){ predicateList.add(criteriaBuilder.like(root.get("name").as(String.class),"%"+searchParams.getName()+"%")); } - predicateList.add(criteriaBuilder.equal(root.get("deleteStatus").as(Byte.class), DeleteStatusEnum.DELECT_NO.getStatus())); + predicateList.add(criteriaBuilder.equal(root.get("status").as(Byte.class), DeleteStatusEnum.DELECT_NO.getStatus())); return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); } }; @@ -174,9 +181,14 @@ List<FindRegionPageRespDTO> dtos = pageResult.getContent().stream().map(region -> { FindRegionPageRespDTO dto = new FindRegionPageRespDTO(); BeanUtils.copyProperties(region, dto); - List<FindRegionLngLatPageRespDTO> regionLngLatPageRespDTOS = new ArrayList<>(); - BeanUtils.copyProperties(region.getRegionLngLats(), regionLngLatPageRespDTOS); - dto.setRegionLngLats(regionLngLatPageRespDTOS); + if (!CollectionUtils.isEmpty(region.getRegionLngLats())) { + List<FindRegionLngLatPageRespDTO> collect = region.getRegionLngLats().stream().map(regionLngLat -> { + FindRegionLngLatPageRespDTO findRegionLngLatPageRespDTO = new FindRegionLngLatPageRespDTO(); + BeanUtils.copyProperties(regionLngLat, findRegionLngLatPageRespDTO); + return findRegionLngLatPageRespDTO; + }).collect(Collectors.toList()); + dto.setRegionLngLats(collect); + } return dto; }).collect(Collectors.toList()); searchResult.setData(dtos); @@ -188,8 +200,11 @@ @Transactional public Result updateRegion(UpdateRegionReqDTO reqDto) { User currentUser = getCurrentUser(); - if (reqDto == null) + if (reqDto == null || reqDto.getId() == null) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); + Region region = regionRepository.findByIdAndStatus(reqDto.getId(), DeleteStatusEnum.DELECT_NO.getStatus()); + if (region == null) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"区域不存在"); if (StringUtils.isBlank(reqDto.getName())) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"区域名称为空"); if (StringUtils.isBlank(reqDto.getColor())) @@ -201,10 +216,12 @@ Region regionold = findByNameAndStatus(reqDto.getName()); if (regionold != null && !regionold.getId().equals(reqDto.getId())) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "区域名称已存在"); - regionold.setName(reqDto.getName()); - regionold.setColor(reqDto.getColor()); - regionold.setLastmodifiedby(currentUser.getRealName()); - regionold.setGmtModified(LocalDateTime.now()); + region.setName(reqDto.getName()); + region.setColor(reqDto.getColor()); + region.setLastmodifiedby(currentUser.getRealName()); + region.setGmtModified(LocalDateTime.now()); + if (regionRepository.save(region) == null) + throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"区域保存失败"); regionLngLatRepository.deleteAllByRegionId(reqDto.getId()); List<UpdateRegionLngLatReqDTO> regionLngLats = reqDto.getRegionLngLats(); List<RegionLngLat> collect = regionLngLats.stream().map(regionLngLat -> { diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationExcWebsocketServer.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationExcWebsocketServer.java index 6a52921..1ab64e0 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationExcWebsocketServer.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationExcWebsocketServer.java @@ -14,9 +14,10 @@ import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; @Slf4j -@ServerEndpoint("/gas/exc/{userId}") +@ServerEndpoint("/ws/gas/exc/{userId}") @Component public class GasConcentrationExcWebsocketServer { @@ -54,10 +55,10 @@ this.userId = userId; webSocketMap.put(userId, this); - log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); + //log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); addOnlineCount(); // 在线数 +1 - log.info("【气体浓度异常】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); + //log.info("【气体浓度异常】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); try { sendMessage(JSON.toJSONString("【气体浓度异常】连接成功")); @@ -77,7 +78,7 @@ if (webSocketMap.get(this.userId) != null) { webSocketMap.remove(this.userId); subOnlineCount(); // 人数 -1 - log.info("【气体浓度异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); + //log.info("【气体浓度异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); } } @@ -89,7 +90,7 @@ */ @OnMessage public void onMessage(String message, Session session) { - log.info("收到来自窗口" + userId + "的信息:" + message); + //log.info("收到来自窗口" + userId + "的信息:" + message); if (StringUtils.isNotBlank(message)) { try { @@ -147,10 +148,10 @@ if (userId == null) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体浓度异常】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体浓度异常】发送消息到:" + entry.getKey() + ",消息:" + message); } else if (entry.getKey().equals(userId)) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体浓度异常】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体浓度异常】发送消息到:" + entry.getKey() + ",消息:" + message); } } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationWebsocketServer.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationWebsocketServer.java index cb7acd8..b6a6452 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationWebsocketServer.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasConcentrationWebsocketServer.java @@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j -@ServerEndpoint("/gas/{userId}") +@ServerEndpoint("/ws/gas/{userId}") @Component public class GasConcentrationWebsocketServer { @@ -53,10 +53,10 @@ this.userId = userId; webSocketMap.put(userId, this); - log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); + //log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); addOnlineCount(); // 在线数 +1 - log.info("【气体浓度实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); + //log.info("【气体浓度实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); try { sendMessage(JSON.toJSONString("【气体浓度实时推送】连接成功")); @@ -76,7 +76,7 @@ if (webSocketMap.get(this.userId) != null) { webSocketMap.remove(this.userId); subOnlineCount(); // 人数 -1 - log.info("【气体浓度实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); + //log.info("【气体浓度实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); } } @@ -88,7 +88,7 @@ */ @OnMessage public void onMessage(String message, Session session) { - log.info("收到来自窗口" + userId + "的信息:" + message); + //log.info("收到来自窗口" + userId + "的信息:" + message); if (StringUtils.isNotBlank(message)) { try { @@ -146,10 +146,10 @@ if (userId == null) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体浓度实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体浓度实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); } else if (entry.getKey().equals(userId)) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体浓度实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体浓度实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); } } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasDeviceExcWebsocketServer.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasDeviceExcWebsocketServer.java index 9f0050c..cfa9820 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasDeviceExcWebsocketServer.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasDeviceExcWebsocketServer.java @@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j -@ServerEndpoint("/gas/device/exc/{userId}") +@ServerEndpoint("/ws/gas/device/exc/{userId}") @Component public class GasDeviceExcWebsocketServer { @@ -53,10 +53,10 @@ this.userId = userId; webSocketMap.put(userId, this); - log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); + //log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); addOnlineCount(); // 在线数 +1 - log.info("【气体设备状态异常】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); + //log.info("【气体设备状态异常】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); try { sendMessage(JSON.toJSONString("【气体设备状态异常】连接成功")); @@ -76,7 +76,7 @@ if (webSocketMap.get(this.userId) != null) { webSocketMap.remove(this.userId); subOnlineCount(); // 人数 -1 - log.info("【气体设备状态异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); + //log.info("【气体设备状态异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); } } @@ -88,7 +88,7 @@ */ @OnMessage public void onMessage(String message, Session session) { - log.info("收到来自窗口" + userId + "的信息:" + message); + //log.info("收到来自窗口" + userId + "的信息:" + message); if (StringUtils.isNotBlank(message)) { try { @@ -146,10 +146,10 @@ if (userId == null) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体设备状态异常】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体设备状态异常】发送消息到:" + entry.getKey() + ",消息:" + message); } else if (entry.getKey().equals(userId)) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体设备状态异常】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体设备状态异常】发送消息到:" + entry.getKey() + ",消息:" + message); } } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasFluxWebsocketServer.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasFluxWebsocketServer.java index 0671a9f..c267667 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasFluxWebsocketServer.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/GasFluxWebsocketServer.java @@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j -@ServerEndpoint("/gas/flux/{userId}") +@ServerEndpoint("/ws/gas/flux/{userId}") @Component public class GasFluxWebsocketServer { @@ -56,7 +56,7 @@ log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); addOnlineCount(); // 在线数 +1 - log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); + //log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); try { sendMessage(JSON.toJSONString("【气体通量实时推送】连接成功")); @@ -76,7 +76,7 @@ if (webSocketMap.get(this.userId) != null) { webSocketMap.remove(this.userId); subOnlineCount(); // 人数 -1 - log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); + //log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); } } @@ -146,10 +146,10 @@ if (userId == null) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); } else if (entry.getKey().equals(userId)) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); } } diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/HeartbeatExcWebsocketServer.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/HeartbeatExcWebsocketServer.java index abda9b4..5598fda 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/HeartbeatExcWebsocketServer.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/websocket/HeartbeatExcWebsocketServer.java @@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j -@ServerEndpoint("/gas/heartbeat/{userId}") +@ServerEndpoint("/ws/gas/heartbeat/{userId}") @Component public class HeartbeatExcWebsocketServer { @@ -56,7 +56,7 @@ log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); addOnlineCount(); // 在线数 +1 - log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); + //log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); try { sendMessage(JSON.toJSONString("【气体通量实时推送】连接成功")); @@ -76,7 +76,7 @@ if (webSocketMap.get(this.userId) != null) { webSocketMap.remove(this.userId); subOnlineCount(); // 人数 -1 - log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); + //log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); } } @@ -88,7 +88,7 @@ */ @OnMessage public void onMessage(String message, Session session) { - log.info("收到来自窗口" + userId + "的信息:" + message); + //log.info("收到来自窗口" + userId + "的信息:" + message); if (StringUtils.isNotBlank(message)) { try { @@ -146,10 +146,10 @@ if (userId == null) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); } else if (entry.getKey().equals(userId)) { webSocketMap.get(entry.getKey()).sendMessage(message); - log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); + //log.info("【气体通量实时推送】发送消息到:" + entry.getKey() + ",消息:" + message); } } diff --git a/src/main/resources/config/application-dev.yaml b/src/main/resources/config/application-dev.yaml index 1ae602b..338d7e9 100644 --- a/src/main/resources/config/application-dev.yaml +++ b/src/main/resources/config/application-dev.yaml @@ -1,5 +1,5 @@ server: - port: 9091 + port: 17080 spring: # enable-logging: false diff --git a/src/main/resources/config/application-online-uat.yaml b/src/main/resources/config/application-online-uat.yaml index 865402b..c465132 100644 --- a/src/main/resources/config/application-online-uat.yaml +++ b/src/main/resources/config/application-online-uat.yaml @@ -1,17 +1,17 @@ -erver: - port: 16070 +server: + port: 17080 spring: # enable-logging: false datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://121.239.169.30:33306/laboratory_risk_manage.uat?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true + url: jdbc:mysql://121.239.169.30:33306/fourier_specialgas_monitor.uat?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true username: root password: e7be93ef5413e5ed master: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://121.239.169.30:33306/laboratory_risk_manage.uat?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true + url: jdbc:mysql://121.239.169.30:33306/fourier_specialgas_monitor.uat?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true username: root password: e7be93ef5413e5ed type: com.alibaba.druid.pool.DruidDataSource @@ -19,7 +19,7 @@ hibernate: ddl-auto: none # ddl-auto: update #自动更新 - show-sql: true #日志中显示sql语句 + show-sql: false #日志中显示sql语句 redis: # host: 192.168.0.52 @@ -66,11 +66,11 @@ file: path: #基础路径 - dcPath: /home/upload/laboratoryRiskManage/ + dcPath: /home/upload/fourierSpecialgasMonitor/ urlRootPath: /upload/ module: #用户模块 - accountPath: /account/user/ + accountPath: /fourierSpecialgasMonitor #线程池配置 threadPool: @@ -91,6 +91,6 @@ #测试环境 短信功能关闭,只在控制台上打印日志 sms: send: - enabled: true + enabled: false diff --git a/src/main/resources/config/redisson-online-uat.yml b/src/main/resources/config/redisson-online-uat.yml index c071833..3acfc59 100644 --- a/src/main/resources/config/redisson-online-uat.yml +++ b/src/main/resources/config/redisson-online-uat.yml @@ -10,7 +10,7 @@ # 命令重试发送时间间隔,单位:毫秒 retryInterval: 1500 # 密码 - password: akj78avauba789a + password: gkhy@202306 # 单个连接最大订阅数量 subscriptionsPerConnection: 5 # 客户端名称 diff --git a/src/main/resources/template/dailyReportTemplate.docx b/src/main/resources/template/dailyReportTemplate.docx index bffd0c4..5645ae0 100644 --- a/src/main/resources/template/dailyReportTemplate.docx +++ b/src/main/resources/template/dailyReportTemplate.docx Binary files differ -- Gitblit v1.9.2