| | |
| | | package com.qianwen.mdc.collect.runner; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.common.collect.Sets; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.time.LocalDate; |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | /* |
| | | import com.qianwen.core.redis.lock.RedisLock; |
| | | import com.qianwen.posting.cache.TimeSliceCache; |
| | | import com.qianwen.posting.dto.CacheBuildDTO; |
| | | import com.qianwen.posting.entity.tdengine.WorkstationState; |
| | | import com.qianwen.posting.mapper.tdengine.WorkstationStateMapper; |
| | | import com.qianwen.posting.service.IWorkstationStateFixPointService; |
| | | */ |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.google.common.collect.Sets; |
| | | import com.qianwen.mdc.collect.cache.TimeSliceCache; |
| | | import com.qianwen.mdc.collect.dto.CacheBuildDTO; |
| | | import com.qianwen.mdc.collect.mapper.iotdb.DeviceStateMapper; |
| | | import com.qianwen.mdc.collect.service.DeviceStateFixPointService; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateTime; |
| | | |
| | | @Component |
| | | public class InitRunner implements ApplicationRunner { |
| | | private static final Logger log = LoggerFactory.getLogger(InitRunner.class); |
| | | @Resource |
| | | |
| | | @Autowired |
| | | private DeviceStateFixPointService stateFixPointService; |
| | | //@Resource |
| | | //private WorkstationStateMapper workstationStateMapper; |
| | | @Autowired |
| | | private TimeSliceCache timeSliceCache; |
| | | @Autowired |
| | | private DeviceStateMapper deviceStateMapper; |
| | | |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | /* |
| | | //生成时间切片 |
| | | CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(LocalDate.now()).build(); |
| | | TimeSliceCache.build(cacheBuildDTO); |
| | | timeSliceCache.build(cacheBuildDTO); |
| | | |
| | | checkNeedStateFixPoint(); |
| | | */ |
| | | } |
| | | |
| | | //@RedisLock("posting:lock:initStateFixPoint") |
| | |
| | | DateTime dateTime = DateTime.now(); |
| | | log.info("进入程序启动校验是否存在工位打过固定点....... "); |
| | | |
| | | long count = deviceStateMapper.fixPointCountByDate(Integer.valueOf(DatePattern.PURE_DATE_FORMAT.format(dateTime))); |
| | | /* |
| | | Long result = this.workstationStateMapper.selectCount(Wrappers.<WorkstationState>lambdaQuery() |
| | | .eq(WorkstationState::getFactoryDate, Integer.valueOf(DatePattern.PURE_DATE_FORMAT.format(dateTime))) |
| | | .eq(WorkstationState::getIsFixPoint, Boolean.TRUE)); |
| | | */ |
| | | Long result = 1L; |
| | | if (result == null || result.longValue() <= 0) { |
| | | log.info("工位未打过固定点....... "); |
| | | //Long result = 1L; |
| | | if (count <= 0) { |
| | | log.info("设备未打过锚点,启动时打点....... "); |
| | | //this.workStationStateFixPointService.workStationStateFixPoint(dateTime, null); |
| | | stateFixPointService.deviceStateFixPoint(dateTime, null); |
| | | return; |
| | | }else { |
| | | log.info("设备已存在锚点"); |
| | | } |
| | | log.info("工位已存在固定点"); |
| | | } |
| | | } |