huangzhen
2023-12-28 d6ae4bd543971312b51ba0e40b2565f63ed682e0
气体浓度加入方位
已修改15个文件
89 ■■■■ 文件已修改
src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasConcentration.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/query/GasPageQuery.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasLineChartReqDTO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/UploadGasConcentrationReqDTO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/WindRoseByTimeReqDTO.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasLineChartRespDTO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasPageRespDTO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/enums/WindRoseEnum.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasConcentrationService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasConcentrationServiceImpl.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/MonitorDataServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/gkhy/fourierSpecialGasMonitor/controller/GasCategoryController.java
@@ -31,6 +31,10 @@
    @Autowired
    private RedissonClient redissonClient;
    /**
     * @decription 新增气体
     * @author Mr.huang
     */
    @PostMapping("/add")
    @RepeatedClick
    public Result createGasCategory(@RequestBody CreateGasCategoryReqDTO reqDto){
@@ -38,6 +42,10 @@
        return result;
    }
    /**
     * @decription 更新气体
     * @author Mr.huang
     */
    @PostMapping("/update")
    @RepeatedClick
    public Result updateGasCategory(@RequestBody UpdateGasCategoryReqDTO reqDto){
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/GasConcentration.java
@@ -21,6 +21,8 @@
    private LocalDateTime dataReceivingTime;
    private Integer position;
    private int type;
    private String lng;
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/query/GasPageQuery.java
@@ -17,4 +17,6 @@
    private LocalDateTime endTime;
    private Integer gasName;
    private Integer position;
}
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/GasLineChartReqDTO.java
@@ -18,4 +18,6 @@
    private LocalDateTime endTime;
    private Integer gasName;
    private Integer position;
}
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/UploadGasConcentrationReqDTO.java
@@ -18,6 +18,8 @@
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime time;
    private Integer position;
    private int type;
    private String lng;
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/req/WindRoseByTimeReqDTO.java
@@ -2,6 +2,8 @@
import lombok.Data;
import java.time.LocalDateTime;
/**
 * @author Mr.huang
 * @decription
@@ -11,4 +13,8 @@
public class WindRoseByTimeReqDTO {
    private Integer countTime;
    private LocalDateTime startTime;
    private LocalDateTime endTime;
}
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasLineChartRespDTO.java
@@ -19,6 +19,8 @@
    private LocalDateTime time;
    private Integer position;
    private int type;
    private String lng;
src/main/java/com/gkhy/fourierSpecialGasMonitor/entity/resp/GasPageRespDTO.java
@@ -19,6 +19,8 @@
    private LocalDateTime time;
    private Integer position;
    private int type;
    private String lng;
src/main/java/com/gkhy/fourierSpecialGasMonitor/enums/WindRoseEnum.java
@@ -47,6 +47,12 @@
            LocalDateTime startTime = now.minusHours(24);
            return new WindRoseTimeSlotQuery(startTime,now);
        }
    },
    CUSTOM_TIME(5,"自定义") {
        @Override
        public WindRoseTimeSlotQuery getTimeSlotByStrategy() {
            return null;
        }
    };
    private Integer state;
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/DailyReportSchedule.java
@@ -92,8 +92,7 @@
    @Autowired
    private MonitorDailyReportService monitorDailyReportService;
    //@Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次
    @Scheduled(cron = "0/30 * * * * ?")
    @Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次
    @Async(value = "SocketTaskExecutor")
    public void generateDailyReport() {
        LocalDateTime now = LocalDateTime.now();
@@ -235,6 +234,10 @@
        logger.info("【##】日报生成成功!!! ,时间:"+endTime+",所耗时间: "+execTime+"s");
    }
    /**
     * @decription 画柱形图
     * @author Mr.huang
     */
    public void drawBarChart(List<GasFlux> gasFluxes,String fileurl,String series,String molecularFormula,Integer i,Integer j) {
        List<String> collect = gasFluxes.stream()
                .map(gasFlux -> gasFlux.getTime().format(lineChartXDataDisplay))
src/main/java/com/gkhy/fourierSpecialGasMonitor/schedule/HeartbeatSchedule.java
@@ -25,7 +25,7 @@
 * @decription
 * @date 2023/8/8 10:49
 */
//@Component
@Component
public class HeartbeatSchedule {
    @Autowired
@@ -43,12 +43,13 @@
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Scheduled(cron = "0/1 * * * * ?") // 每秒执行一次
    @Scheduled(cron = "0/30 * * * * ?")
    @Async(value = "SocketTaskExecutor")
    public void gasConcentrationStatus() {
        GasConcentration gasConcentration = gasConcentrationService.getLastData();
        if (gasConcentration != null){
            LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(1);
            LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(2);
            if (LocalDateTime.now().compareTo(lastReceiveTime) > 0){
                try {
                    heartbeatExcWebsocketServer.sendInfo(HeartbeatExecEnum.GAS_CONCENTRATION.getStatus()+"",null);
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/GasConcentrationService.java
@@ -18,7 +18,9 @@
    List<GasConcentration> listDatabyTimeSlot(LocalDateTime startTime, LocalDateTime endTime);
    Page<GasConcentration> listDatabyTimeSlotAndPage(PageQuery<GasPageQuery> pageQuery);
    Page<GasConcentration> listDatabyTimeSlotAndPositionAndPage(PageQuery<GasPageQuery> pageQuery);
    Page<GasConcentration> gasAtmospherePage(PageQuery<GasAtmospherePageQuery> pageQuery);
    List<GasConcentration> listDatabyTimeSlotAndPosition(LocalDateTime startTime, LocalDateTime endTime, Integer position);
}
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasConcentrationServiceImpl.java
@@ -64,13 +64,16 @@
    }
    @Override
    public Page<GasConcentration> listDatabyTimeSlotAndPage(PageQuery<GasPageQuery> pageQuery) {
    public Page<GasConcentration> listDatabyTimeSlotAndPositionAndPage(PageQuery<GasPageQuery> pageQuery) {
        Pageable pageable = PageRequest.of(pageQuery.getPageIndex()-1, pageQuery.getPageSize(), Sort.Direction.DESC, "time");
        Specification<GasConcentration> specification = new Specification<GasConcentration>() {
            @Override
            public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) {
                Set<Predicate> predicateList = new HashSet<>();
                GasPageQuery searchParams = pageQuery.getSearchParams();
                if (searchParams != null && searchParams.getPosition() != null){
                    predicateList.add(criteriaBuilder.equal(root.get("position").as(Integer.class),searchParams.getPosition()));
                }
                if (searchParams != null && searchParams.getStartTime() != null && searchParams.getEndTime() != null){
                    predicateList.add(criteriaBuilder.between(root.get("time").as(LocalDateTime.class),searchParams.getStartTime(),searchParams.getEndTime()));
                }
@@ -98,4 +101,23 @@
        Page<GasConcentration> pageResult = gasConcentrationRepository.findAll(specification,pageable);
        return pageResult;
    }
    @Override
    public List<GasConcentration> listDatabyTimeSlotAndPosition(LocalDateTime startTime, LocalDateTime endTime, Integer position) {
        if (startTime == null || endTime == null)
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"时间区段值不能为空");
        Specification<GasConcentration> specification = new Specification<GasConcentration>() {
            @Override
            public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) {
                Set<Predicate> predicateList = new HashSet<>();
                if (position != null){
                    predicateList.add(criteriaBuilder.equal(root.get("position").as(Integer.class),position));
                }
                predicateList.add(criteriaBuilder.between(root.get("time").as(LocalDateTime.class),startTime,endTime));
                return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
            }
        };
        List<GasConcentration> gasConcentrations = gasConcentrationRepository.findAll(specification);
        return gasConcentrations;
    }
}
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java
@@ -201,9 +201,16 @@
        if (reqDTO == null && reqDTO .getCountTime() == null)
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空");
        Integer countTime = reqDTO.getCountTime();
        WindRoseTimeSlotQuery query = WindRoseEnum.getQueryObject(countTime).getTimeSlotByStrategy();
        List<GasConcentration> gasConcentrations;
        if (reqDTO.getCountTime().equals(WindRoseEnum.CUSTOM_TIME.getState())){
            if (reqDTO.getStartTime() == null && reqDTO.getEndTime() == null)
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空");
            gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(reqDTO.getStartTime(), reqDTO.getEndTime());
        }else {
            WindRoseTimeSlotQuery query = WindRoseEnum.getQueryObject(countTime).getTimeSlotByStrategy();
             gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(query.getStartTime(), query.getEndTime());
        }
        Result result = Result.success();
        List<GasConcentration> gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(query.getStartTime(), query.getEndTime());
        if (CollectionUtils.isEmpty(gasConcentrations))
            return result;
        List<WindRoseByTimeRespDTO> collect = gasConcentrations.stream().map(gasConcentration -> {
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/MonitorDataServiceImpl.java
@@ -67,7 +67,7 @@
            startTime = zeroTime;
            endTime = nowTime;
        }
        List<GasConcentration> gasConcentrationList =  gasConcentrationService.listDatabyTimeSlot(startTime,endTime);
        List<GasConcentration> gasConcentrationList =  gasConcentrationService.listDatabyTimeSlotAndPosition(startTime,endTime,reqDto.getPosition());
        if (CollectionUtils.isEmpty(gasConcentrationList))
            return success;
        GasCategory gasCategory = gasCategoryService.findById(reqDto.getGasName());
@@ -124,7 +124,7 @@
        searchResult.setPageIndex(pageQuery.getPageIndex());
        searchResult.setPageSize(pageQuery.getPageSize());
        searchResult.setSuccess();
        Page<GasConcentration> pageResult =  gasConcentrationService.listDatabyTimeSlotAndPage(pageQuery);
        Page<GasConcentration> pageResult =  gasConcentrationService.listDatabyTimeSlotAndPositionAndPage(pageQuery);
        if (CollectionUtils.isEmpty(pageResult.getContent()))
            return searchResult;
        searchResult.setTotal(pageResult.getTotalElements());