zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/config/RedisConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Loc.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/RedisUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-wcs/src/main/resources/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/config/RedisConfig.java
New file @@ -0,0 +1,98 @@ package com.zy.asrs.wcs.common.config; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.*; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; /** * Redis配置类 * Created by vincent on 2019-12-23 */ @Configuration //@EnableCaching // 开启数据缓存机制 public class RedisConfig extends CachingConfigurerSupport { /** * RedisTemplate相关配置 */ @Bean public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { RedisTemplate<String, Object> template = new RedisTemplate<>(); // 配置连接工厂 template.setConnectionFactory(factory); //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式) Jackson2JsonRedisSerializer<Object> jacksonSerializer = new Jackson2JsonRedisSerializer<>(Object.class); ObjectMapper om = new ObjectMapper(); // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常 om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jacksonSerializer.setObjectMapper(om); // 值采用json序列化 template.setValueSerializer(jacksonSerializer); //使用StringRedisSerializer来序列化和反序列化redis的key值 template.setKeySerializer(new StringRedisSerializer()); // 设置hash key 和value序列化模式 template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(jacksonSerializer); template.afterPropertiesSet(); return template; } /** * 对redis字符串类型数据操作 */ @Bean public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForValue(); } /** * 对hash类型的数据操作 */ @Bean public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForHash(); } /** * 对链表类型的数据操作 */ @Bean public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForList(); } /** * 对无序集合类型的数据操作 */ @Bean public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForSet(); } /** * 对有序集合类型的数据操作 */ @Bean public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForZSet(); } } zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/Loc.java
@@ -1,6 +1,7 @@ package com.zy.asrs.wcs.core.entity; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.*; import java.text.SimpleDateFormat; import java.util.Date; @@ -13,10 +14,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
@@ -43,7 +43,7 @@ @Autowired private ShuttleCommandService shuttleCommandService; @Scheduled(cron = "0/1 * * * * ? ") // @Scheduled(cron = "0/1 * * * * ? ") public synchronized void executeWrkMast() { Date now = new Date(); // ANALYZE_INBOUND zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/RedisUtil.java
@@ -24,14 +24,6 @@ @Autowired private RedisTemplate redisTemplate; public RedisTemplate getRedisTemplate() { return redisTemplate; } public RedisUtil(RedisTemplate redisTemplate) { this.redisTemplate = redisTemplate; } /** * 指定缓存失效时间 * zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
@@ -16,6 +16,8 @@ import lombok.Data; import lombok.extern.slf4j.Slf4j; import java.util.HashMap; /** * 四向穿梭车 */ @@ -220,7 +222,7 @@ public Integer getTaskNo() { RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); if (null != redisUtil) { Object o = redisUtil.get(DeviceRedisConstant.SHUTTLE_FLAG + this.taskNo); Object o = redisUtil.get(DeviceRedisConstant.SHUTTLE_FLAG + this.shuttleNo); if (!Cools.isEmpty(o)) { this.taskNo = Integer.parseInt(String.valueOf(o)); } @@ -239,9 +241,10 @@ } //源库位(小车当前位置) Loc currentLoc = locService.getOne(new LambdaQueryWrapper<Loc>() LambdaQueryWrapper<Loc> wrapper = new LambdaQueryWrapper<Loc>() .eq(Loc::getCode, this.currentCode) .eq(Loc::getHostId, this.device.getHostId())); .eq(Loc::getHostId, this.device.getHostId()); Loc currentLoc = locService.getOne(wrapper); if (currentLoc == null) { return null; } zy-asrs-wcs/src/main/resources/application.yml
@@ -31,6 +31,11 @@ multipart: maxFileSize: 100MB maxRequestSize: 100MB redis: host: 127.0.0.1 port: 6379 database: 1 password: mybatis-plus: mapper-locations: classpath:mapper/*/*.xml @@ -46,6 +51,7 @@ id-type: auto logic-delete-value: 1 logic-not-delete-value: 0 column-format: "`%s`" logging: file: