package com.zy.asrs.wcs.asrs.execute;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.zy.asrs.wcs.core.utils.RedisUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.List;
|
|
@Component
|
public class BaseExecute {
|
|
@Autowired
|
private RedisUtil redisUtil;
|
|
public boolean redisSet(String redisKey, String key, Object data) {
|
if (redisUtil.hasKey(redisKey)) {
|
Object obj = redisUtil.get(redisKey);
|
JSONObject object = JSON.parseObject(String.valueOf(obj));
|
object.put(key, data);
|
redisUtil.set(redisKey, JSON.toJSONString(object));
|
} else {
|
JSONObject object = new JSONObject();
|
object.put(key, data);
|
redisUtil.set(redisKey, JSON.toJSONString(object));
|
}
|
return true;
|
}
|
|
public Object redisGet(String redisKey, String key) {
|
if (redisUtil.hasKey(redisKey)) {
|
Object obj = redisUtil.get(redisKey);
|
JSONObject object = JSON.parseObject(String.valueOf(obj));
|
if (!object.containsKey(key)) {
|
return null;
|
}
|
return object.get(key);
|
}
|
return null;
|
}
|
|
public JSONObject findFLow(List<JSONObject> list, String id) {
|
for (JSONObject flow : list) {
|
if (flow.getString("id").equals(id)) {
|
return flow;
|
}
|
}
|
return null;
|
}
|
|
}
|