diff --git a/inventory-dao/src/main/java/com/rzyc/model/ent/EntUser.java b/inventory-dao/src/main/java/com/rzyc/model/ent/EntUser.java
index 15b1dcb..9b6f523 100644
--- a/inventory-dao/src/main/java/com/rzyc/model/ent/EntUser.java
+++ b/inventory-dao/src/main/java/com/rzyc/model/ent/EntUser.java
@@ -1,6 +1,8 @@
package com.rzyc.model.ent;
import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.time.LocalTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -110,6 +112,17 @@ public class EntUser implements Serializable {
@ApiModelProperty(value = "工号")
private String jobNumber;
+ @TableField(exist = false)
+ private LocalTime localTime;
+
+ public LocalTime getLocalTime() {
+ return localTime;
+ }
+
+ public void setLocalTime(LocalTime localTime) {
+ this.localTime = localTime;
+ }
+
public String getJobNumber() {
return jobNumber;
}
diff --git a/inventory-ent/pom.xml b/inventory-ent/pom.xml
index 3891f5e..8846fc7 100644
--- a/inventory-ent/pom.xml
+++ b/inventory-ent/pom.xml
@@ -210,6 +210,17 @@
RELEASE
compile
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.apache.commons
+ commons-pool2
+
+
diff --git a/inventory-ent/src/main/java/com/rzyc/config/RedisPoolConfig.java b/inventory-ent/src/main/java/com/rzyc/config/RedisPoolConfig.java
new file mode 100644
index 0000000..209cb0b
--- /dev/null
+++ b/inventory-ent/src/main/java/com/rzyc/config/RedisPoolConfig.java
@@ -0,0 +1,52 @@
+package com.rzyc.config;
+
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+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.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * Redis 连接及序列化
+ * @author Xuwanxin
+ * @date 2022/10/13
+ * */
+
+@Configuration
+public class RedisPoolConfig {
+
+
+ /**
+ * 在使用localTime对象时,GenericJackson2JsonRedisSerializer反序列化会报转换错误,遇到之后还需要再单独处理
+ * */
+ @Bean
+ public RedisTemplate strRedisTemplate(RedisConnectionFactory redisConnectionFactory){
+ RedisTemplate redisTemplate = new RedisTemplate<>();
+ // key 序列化方式
+ redisTemplate.setKeySerializer(new StringRedisSerializer());
+ // value 序列化
+ redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
+ // hash 类型 key序列化
+ redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+ // hash 类型 value序列化方式
+ redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
+ // 注入连接工厂
+ redisTemplate.setConnectionFactory(redisConnectionFactory);
+ // 让设置生效
+ redisTemplate.afterPropertiesSet();
+ return redisTemplate;
+ }
+
+
+
+
+}
diff --git a/inventory-ent/src/main/java/com/rzyc/config/RedisUtil.java b/inventory-ent/src/main/java/com/rzyc/config/RedisUtil.java
new file mode 100644
index 0000000..ef55f08
--- /dev/null
+++ b/inventory-ent/src/main/java/com/rzyc/config/RedisUtil.java
@@ -0,0 +1,595 @@
+package com.rzyc.config;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class RedisUtil {
+
+ @Autowired
+ RedisTemplate redisTemplate;
+
+ /**
+ * get 多参数分隔 :
+ * @param key 键
+ */
+ public String appendSymbol(String ... key) {
+ StringBuilder stringBuilder = new StringBuilder();
+ try {
+ for (String k:key) {
+ stringBuilder.append(k);
+ stringBuilder.append(":");
+ }
+ return stringBuilder.deleteCharAt(stringBuilder.lastIndexOf(":")).toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "error";
+ }
+ }
+
+
+ /**
+ * 指定缓存失效时间
+ * @param key 键
+ * @param time 时间(秒)
+ */
+ public boolean expire(String key, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.expire(key, time, TimeUnit.SECONDS);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 根据key 获取过期时间
+ * @param key 键 不能为null
+ * @return 时间(秒) 返回0代表为永久有效
+ */
+ public long getExpire(String key) {
+ return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+ }
+
+
+ /**
+ * 判断key是否存在
+ * @param key 键
+ * @return true 存在 false不存在
+ */
+ public boolean hasKey(String key) {
+ try {
+ return redisTemplate.hasKey(key);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+ /**
+ * 删除缓存
+ * @param key 可以传一个值 或多个
+ */
+ @SuppressWarnings("unchecked")
+ public void del(String... key) {
+ if (key != null && key.length > 0) {
+ if (key.length == 1) {
+ redisTemplate.delete(key[0]);
+ } else {
+ redisTemplate.delete(String.valueOf(CollectionUtils.arrayToList(key)));
+ }
+ }
+ }
+
+
+ // ============================String=============================
+
+ /**
+ * 普通缓存获取
+ * @param key 键
+ * @return 值
+ */
+ public Object get(String key) {
+ return key == null ? null : redisTemplate.opsForValue().get(key);
+ }
+
+ /**
+ * 普通缓存放入
+ * @param key 键
+ * @param value 值
+ * @return true成功 false失败
+ */
+
+ public boolean set(String key, Object value) {
+ try {
+ redisTemplate.opsForValue().set(key, value);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+ /**
+ * 普通缓存放入并设置时间
+ * @param key 键
+ * @param value 值
+ * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
+ * @return true成功 false 失败
+ */
+
+ public boolean set(String key, Object value, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+ } else {
+ set(key, value);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+ /**
+ * 递增
+ * @param key 键
+ * @param delta 要增加几(大于0)
+ */
+ public long incr(String key, long delta) {
+ if (delta < 0) {
+ throw new RuntimeException("递增因子必须大于0");
+ }
+ return redisTemplate.opsForValue().increment(key, delta);
+ }
+
+
+ /**
+ * 递减
+ * @param key 键
+ * @param delta 要减少几(小于0)
+ */
+ public long decr(String key, long delta) {
+ if (delta < 0) {
+ throw new RuntimeException("递减因子必须大于0");
+ }
+ return redisTemplate.opsForValue().increment(key, -delta);
+ }
+
+
+ // ================================Map=================================
+
+ /**
+ * HashGet
+ * @param key 键 不能为null
+ * @param item 项 不能为null
+ */
+ public Object hget(String key, String item) {
+ return redisTemplate.opsForHash().get(key, item);
+ }
+
+ /**
+ * 获取hashKey对应的所有键值
+ * @param key 键
+ * @return 对应的多个键值
+ */
+ public Map