已修改40个文件
已添加12个文件
已删除3个文件
| | |
| | | <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> |
| | |
| | | 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; |
| | |
| | | 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 |
对比新文件 |
| | |
| | | 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 "您点击太快了,请稍后尝试"; |
| | | } |
对比新文件 |
| | |
| | | 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(),"数据参数异常"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | 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,"文件路径不存在"), |
对比新文件 |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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), |
| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @PostMapping("/list/gasCategory") |
| | | @RepeatedClick |
| | | public ForeignResult listGasCategory(){ |
| | | ForeignResult result = dataReceiveService.listGasCategory(); |
| | | return result; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | bucket.delete(); |
| | | } |
| | | this.gasCategoryList(); |
| | | logger.info("【气体对照表】已加入缓存"); |
| | | logger.info("[GasCategoryList] cache complete"); |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @RepeatedClick |
| | | public Result updateGasThreshold(@RequestBody UpdateGasThresholdReqDTO reqDto){ |
| | | Result result = gasThresholdService.updateGasThreshold(reqDto); |
| | | return result; |
| | |
| | | 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.*; |
| | |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | |
| | | @PostMapping("/add") |
| | | @RepeatedClick |
| | | public Result createGasWarnUser(@RequestBody CreateGasWarnUserReqDTO reqDto){ |
| | | Result result = gasWarnUserService.createGasWarnUser(reqDto); |
| | | return result; |
| | |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @RepeatedClick |
| | | public Result updateGasWarnUser(@RequestBody UpdateGasWarnUserReqDTO reqDto){ |
| | | Result result = gasWarnUserService.updateGasWarnUser(reqDto); |
| | | return result; |
| | |
| | | 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; |
| | |
| | | private RegionService regionService; |
| | | |
| | | @PostMapping("/add") |
| | | @RepeatedClick |
| | | public Result createRegion(@RequestBody CreateRegionReqDTO reqDto){ |
| | | Result result = regionService.createRegion(reqDto); |
| | | return result; |
| | |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @RepeatedClick |
| | | public Result updateRegion(@RequestBody UpdateRegionReqDTO reqDto){ |
| | | Result result = regionService.updateRegion(reqDto); |
| | | return result; |
| | |
| | | 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(); |
| | |
| | | @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) |
| | |
| | | |
| | | private String handlerName; |
| | | |
| | | private String handlerDesc; |
| | | |
| | | private String handlerRealName; |
| | | |
| | | private LocalDateTime handlerTime; |
对比新文件 |
| | |
| | | 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; |
| | | } |
| | |
| | | |
| | | 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; |
| | | |
| | |
| | | import com.gkhy.fourierSpecialGasMonitor.entity.RegionLngLat; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @date 2023/8/9 10:48 |
| | | */ |
| | | @Data |
| | | public class CreateRegionReqDTO { |
| | | public class CreateRegionReqDTO implements Serializable { |
| | | |
| | | private String name; |
| | | |
对比新文件 |
| | |
| | | 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; |
| | | } |
对比新文件 |
| | |
| | | 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; |
| | | } |
对比新文件 |
| | |
| | | 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; |
| | | } |
| | |
| | | |
| | | private Double gasConcentration; |
| | | |
| | | private Long gasThresholdId; |
| | | private Integer gasThresholdId; |
| | | |
| | | private Long gasThresholdName; |
| | | private String gasThresholdName; |
| | | |
| | | private Byte status; |
| | | |
| | |
| | | |
| | | private String handlerRealName; |
| | | |
| | | private String handlerDesc; |
| | | |
| | | private LocalDateTime handlerTime; |
| | | |
| | | private List<FindGasWarnLogSmsUserPageRespDTO> gasWarnLogSmsUsers; |
对比新文件 |
| | |
| | | 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; |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | |
| | | @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; |
| | | } |
| | |
| | | @Data |
| | | public class FindRegionPageRespDTO implements Serializable { |
| | | |
| | | private Long id; |
| | | private Integer id; |
| | | |
| | | private String name; |
| | | |
| | |
| | | @Data |
| | | public class GasThresholdListRespDTO implements Serializable { |
| | | |
| | | private Long id; |
| | | private Integer id; |
| | | |
| | | private String name; |
| | | |
对比新文件 |
| | |
| | | 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; |
| | | |
| | | } |
对比新文件 |
| | |
| | | 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; |
| | | } |
对比新文件 |
| | |
| | | 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(); |
| | | |
| | | } |
| | |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | | * @decription |
| | |
| | | public interface GasWarnLogRepository extends JpaRepository<GasWarnLog,Long>, JpaSpecificationExecutor<GasWarnLog> { |
| | | |
| | | GasWarnLog findByIdAndStatus(Long id,Byte status); |
| | | |
| | | List<GasWarnLog> findAllByWarnTimeBetweenOrderByWarnTimeDesc(LocalDateTime startTime,LocalDateTime endTime); |
| | | } |
| | |
| | | |
| | | List<GasWarnUser> findAllByStatus(Byte status); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | } 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() + "浓度观测结果"; |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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); |
| | |
| | | |
| | | 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); |
| | |
| | | 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(),"设备异常消息推送失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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(),"设备异常消息推送失败"); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | 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); |
| | | |
| | | } |
| | |
| | | return gasCategory; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | logger.info("【气体异常map】init完成"); |
| | | logger.info("[GasExcMap] init complete"); |
| | | } |
| | | |
| | | @PostConstruct |
| | |
| | | } |
| | | } |
| | | } |
| | | logger.info("【预警阈值】init完成"); |
| | | logger.info("[WarningThreshold] init complete"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | GasFlux save = gasFluxService.save(gasFlux); |
| | | if (save == null) |
| | | throw new DataReceiveException(this.getClass(), ForeignResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"气体通量数据保存失败"); |
| | | gasFluxDataCacheAndPush(); |
| | | return ForeignResult.success(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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); |
| | |
| | | @Override |
| | | @Transactional |
| | | public ForeignResult uploadGasConcentration(UploadGasConcentrationReqDTO reqDto) { |
| | | //gasConcentrationParameterVerification(reqDto); |
| | | gasConcentrationParameterVerification(reqDto); |
| | | GasConcentration gasConcentration = new GasConcentration(); |
| | | BeanUtils.copyProperties(reqDto,gasConcentration); |
| | | gasConcentration.setDataReceivingTime(LocalDateTime.now()); |
| | |
| | | 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)) { |
| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | |
| | | 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; |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | 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())); |
| | |
| | | } |
| | | |
| | | @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) |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result updateGasWarnUser(UpdateGasWarnUserReqDTO reqDto) { |
| | | if (reqDto == null || reqDto.getId() == null) |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); |
| | |
| | | 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 { |
| | |
| | | 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; |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | |
| | | 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()])); |
| | | } |
| | | }; |
| | |
| | | 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); |
| | |
| | | @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())) |
| | |
| | | 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 -> { |
| | |
| | | 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 { |
| | | |
| | |
| | | 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("【气体浓度异常】连接成功")); |
| | |
| | | if (webSocketMap.get(this.userId) != null) { |
| | | webSocketMap.remove(this.userId); |
| | | subOnlineCount(); // 人数 -1 |
| | | log.info("【气体浓度异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | //log.info("【气体浓度异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) { |
| | | log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | //log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | |
| | | if (StringUtils.isNotBlank(message)) { |
| | | try { |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Slf4j |
| | | @ServerEndpoint("/gas/{userId}") |
| | | @ServerEndpoint("/ws/gas/{userId}") |
| | | @Component |
| | | public class GasConcentrationWebsocketServer { |
| | | |
| | |
| | | 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("【气体浓度实时推送】连接成功")); |
| | |
| | | if (webSocketMap.get(this.userId) != null) { |
| | | webSocketMap.remove(this.userId); |
| | | subOnlineCount(); // 人数 -1 |
| | | log.info("【气体浓度实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | //log.info("【气体浓度实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) { |
| | | log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | //log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | |
| | | if (StringUtils.isNotBlank(message)) { |
| | | try { |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Slf4j |
| | | @ServerEndpoint("/gas/device/exc/{userId}") |
| | | @ServerEndpoint("/ws/gas/device/exc/{userId}") |
| | | @Component |
| | | public class GasDeviceExcWebsocketServer { |
| | | |
| | |
| | | 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("【气体设备状态异常】连接成功")); |
| | |
| | | if (webSocketMap.get(this.userId) != null) { |
| | | webSocketMap.remove(this.userId); |
| | | subOnlineCount(); // 人数 -1 |
| | | log.info("【气体设备状态异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | //log.info("【气体设备状态异常】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) { |
| | | log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | //log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | |
| | | if (StringUtils.isNotBlank(message)) { |
| | | try { |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Slf4j |
| | | @ServerEndpoint("/gas/flux/{userId}") |
| | | @ServerEndpoint("/ws/gas/flux/{userId}") |
| | | @Component |
| | | public class GasFluxWebsocketServer { |
| | | |
| | |
| | | log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); |
| | | |
| | | addOnlineCount(); // 在线数 +1 |
| | | log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); |
| | | //log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); |
| | | |
| | | try { |
| | | sendMessage(JSON.toJSONString("【气体通量实时推送】连接成功")); |
| | |
| | | if (webSocketMap.get(this.userId) != null) { |
| | | webSocketMap.remove(this.userId); |
| | | subOnlineCount(); // 人数 -1 |
| | | log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | //log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Slf4j |
| | | @ServerEndpoint("/gas/heartbeat/{userId}") |
| | | @ServerEndpoint("/ws/gas/heartbeat/{userId}") |
| | | @Component |
| | | public class HeartbeatExcWebsocketServer { |
| | | |
| | |
| | | log.info("webSocketMap -> " + JSON.toJSONString(webSocketMap)); |
| | | |
| | | addOnlineCount(); // 在线数 +1 |
| | | log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); |
| | | //log.info("【气体通量实时推送】有新窗口开始监听:" + userId + ",当前在线人数为" + getOnlineCount()); |
| | | |
| | | try { |
| | | sendMessage(JSON.toJSONString("【气体通量实时推送】连接成功")); |
| | |
| | | if (webSocketMap.get(this.userId) != null) { |
| | | webSocketMap.remove(this.userId); |
| | | subOnlineCount(); // 人数 -1 |
| | | log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | //log.info("【气体通量实时推送】有一连接关闭,当前在线人数为:" + getOnlineCount()); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) { |
| | | log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | //log.info("收到来自窗口" + userId + "的信息:" + message); |
| | | |
| | | if (StringUtils.isNotBlank(message)) { |
| | | try { |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | server: |
| | | port: 9091 |
| | | port: 17080 |
| | | |
| | | spring: |
| | | # enable-logging: false |
| | |
| | | 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 |
| | |
| | | hibernate: |
| | | ddl-auto: none |
| | | # ddl-auto: update #自动更新 |
| | | show-sql: true #日志中显示sql语句 |
| | | show-sql: false #日志中显示sql语句 |
| | | |
| | | redis: |
| | | # host: 192.168.0.52 |
| | |
| | | file: |
| | | path: |
| | | #基础路径 |
| | | dcPath: /home/upload/laboratoryRiskManage/ |
| | | dcPath: /home/upload/fourierSpecialgasMonitor/ |
| | | urlRootPath: /upload/ |
| | | module: |
| | | #用户模块 |
| | | accountPath: /account/user/ |
| | | accountPath: /fourierSpecialgasMonitor |
| | | |
| | | #线程池配置 |
| | | threadPool: |
| | |
| | | #测试环境 短信功能关闭,只在控制台上打印日志 |
| | | sms: |
| | | send: |
| | | enabled: true |
| | | enabled: false |
| | | |
| | | |
| | |
| | | # 命令重试发送时间间隔,单位:毫秒 |
| | | retryInterval: 1500 |
| | | # 密码 |
| | | password: akj78avauba789a |
| | | password: gkhy@202306 |
| | | # 单个连接最大订阅数量 |
| | | subscriptionsPerConnection: 5 |
| | | # 客户端名称 |