后台优化
parent
a7186fb170
commit
5fc47425b6
Binary file not shown.
@ -1,65 +0,0 @@
|
||||
package com.manage.interfaces.cache;
|
||||
|
||||
/**
|
||||
* @Description 缓存DTO
|
||||
* @Date 2019/7/2 11:41
|
||||
* @Created by ljx
|
||||
*/
|
||||
public class Cache {
|
||||
private String key;//缓存ID
|
||||
private Object value;//缓存数据
|
||||
private long timeOut;//更新时间
|
||||
private boolean expired; //是否终止
|
||||
public Cache() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Cache(String key, Object value, long timeOut, boolean expired) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.timeOut = timeOut;
|
||||
this.expired = expired;
|
||||
}
|
||||
|
||||
public Cache(String key, Object value, long timeOut) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.timeOut = timeOut;
|
||||
}
|
||||
public Cache(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public long getTimeOut() {
|
||||
return timeOut;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setKey(String string) {
|
||||
key = string;
|
||||
}
|
||||
|
||||
public void setTimeOut(long l) {
|
||||
timeOut = l;
|
||||
}
|
||||
|
||||
public void setValue(Object object) {
|
||||
value = object;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return expired;
|
||||
}
|
||||
|
||||
public void setExpired(boolean b) {
|
||||
expired = b;
|
||||
}
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
package com.manage.interfaces.cache;
|
||||
|
||||
import com.manage.vo.Power_UserVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class CacheManager {
|
||||
private static HashMap cacheMap = new HashMap();
|
||||
|
||||
private CacheManager() {
|
||||
super();
|
||||
}
|
||||
public static boolean getSimpleFlag(String key){
|
||||
try{
|
||||
return (Boolean) cacheMap.get(key);
|
||||
}catch(NullPointerException e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static long getServerStartdt(String key){
|
||||
try {
|
||||
return (Long)cacheMap.get(key);
|
||||
} catch (Exception ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public synchronized static boolean setSimpleFlag(String key,boolean flag){
|
||||
if (flag && getSimpleFlag(key)) {
|
||||
return false;
|
||||
}else{
|
||||
cacheMap.put(key, flag);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public synchronized static boolean setSimpleFlag(String key,long serverbegrundt){
|
||||
if (cacheMap.get(key) == null) {
|
||||
cacheMap.put(key,serverbegrundt);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized static Cache getCache(String key) {
|
||||
return (Cache) cacheMap.get(key);
|
||||
}
|
||||
|
||||
private synchronized static boolean hasCache(String key) {
|
||||
return cacheMap.containsKey(key);
|
||||
}
|
||||
|
||||
public synchronized static void clearAll() {
|
||||
cacheMap.clear();
|
||||
}
|
||||
|
||||
public synchronized static void clearAll(String type) {
|
||||
Iterator i = cacheMap.entrySet().iterator();
|
||||
String key;
|
||||
ArrayList<String> arr = new ArrayList<String>();
|
||||
try {
|
||||
while (i.hasNext()) {
|
||||
java.util.Map.Entry entry = (java.util.Map.Entry) i.next();
|
||||
key = (String) entry.getKey();
|
||||
if (key.startsWith(type)) {
|
||||
arr.add(key);
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < arr.size(); k++) {
|
||||
clearOnly(arr.get(k));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void clearOnly(String key) {
|
||||
cacheMap.remove(key);
|
||||
}
|
||||
|
||||
public synchronized static void putCache(String key, Cache obj) {
|
||||
cacheMap.put(key, obj);
|
||||
}
|
||||
|
||||
public static Cache getCacheInfo(String key) {
|
||||
|
||||
if (hasCache(key)) {
|
||||
Cache cache = getCache(key);
|
||||
if (cacheExpired(cache)) {
|
||||
cache.setExpired(true);
|
||||
}
|
||||
return cache;
|
||||
}else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void putCacheInfo(String key, Cache obj, long dt,boolean expired) {
|
||||
Cache cache = new Cache();
|
||||
cache.setKey(key);
|
||||
cache.setTimeOut(dt + System.currentTimeMillis());
|
||||
cache.setValue(obj);
|
||||
cache.setExpired(expired);
|
||||
cacheMap.put(key, cache);
|
||||
}
|
||||
public static void putCacheInfo(String key,Cache obj,long dt){
|
||||
Cache cache = new Cache();
|
||||
cache.setKey(key);
|
||||
cache.setTimeOut(dt+System.currentTimeMillis());
|
||||
cache.setValue(obj);
|
||||
cache.setExpired(false);
|
||||
cacheMap.put(key,cache);
|
||||
}
|
||||
|
||||
public static boolean cacheExpired(Cache cache) {
|
||||
if (null == cache) {
|
||||
return false;
|
||||
}
|
||||
long nowDt = System.currentTimeMillis();
|
||||
long cacheDt = cache.getTimeOut();
|
||||
if (cacheDt <= 0||cacheDt>nowDt) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCacheSize() {
|
||||
return cacheMap.size();
|
||||
}
|
||||
|
||||
public static int getCacheSize(String type) {
|
||||
int k = 0;
|
||||
Iterator i = cacheMap.entrySet().iterator();
|
||||
String key;
|
||||
try {
|
||||
while (i.hasNext()) {
|
||||
java.util.Map.Entry entry = (java.util.Map.Entry) i.next();
|
||||
key = (String) entry.getKey();
|
||||
if (key.indexOf(type) != -1) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getCacheAllkey() {
|
||||
ArrayList a = new ArrayList();
|
||||
try {
|
||||
Iterator i = cacheMap.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
java.util.Map.Entry entry = (java.util.Map.Entry) i.next();
|
||||
a.add((String) entry.getKey());
|
||||
}
|
||||
} catch (Exception ex) {} finally {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<String> getCacheListkey(String type) {
|
||||
ArrayList a = new ArrayList();
|
||||
String key;
|
||||
try {
|
||||
Iterator i = cacheMap.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
java.util.Map.Entry entry = (java.util.Map.Entry) i.next();
|
||||
key = (String) entry.getKey();
|
||||
if (key.indexOf(type) != -1) {
|
||||
a.add(key);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {} finally {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void removeCacheByObject(Power_UserVo obj) {
|
||||
ArrayList a = new ArrayList();
|
||||
Object key;
|
||||
ArrayList<String> arr = new ArrayList<String>();
|
||||
try {
|
||||
Iterator i = cacheMap.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
Cache cache = CacheManager.getCacheInfo((String)entry.getKey());
|
||||
Power_UserVo o = (Power_UserVo)cache.getValue();
|
||||
if (obj.getUserName().equals(o.getUserName())) {
|
||||
arr.add((String)entry.getKey());
|
||||
}
|
||||
}
|
||||
if(null != arr && !arr.isEmpty()){
|
||||
for (int k = 0; k < arr.size(); k++) {
|
||||
clearOnly(arr.get(k));
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
CREATE VIEW power_user_dict AS
|
||||
SELECT
|
||||
`power_user`.`user_id` AS `user_id`,
|
||||
`power_dept`.`dict_id` AS `dict_id`
|
||||
FROM
|
||||
((
|
||||
`power_user`
|
||||
JOIN `mysql`.`help_topic` `b` ON ((
|
||||
`b`.`help_topic_id` < (( length( `power_user`.`dept_id` ) - length( REPLACE ( `power_user`.`dept_id`, _latin1 ',', _latin1 '' ))) + 1 ))))
|
||||
LEFT JOIN `power_dept` ON ((
|
||||
`power_dept`.`dept_id` = `power_user`.`dept_id`
|
||||
)))
|
||||
GROUP BY
|
||||
`power_user`.`user_id`
|
@ -1,33 +0,0 @@
|
||||
package com.manage.util;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @ProjectName:
|
||||
* @Description:
|
||||
* @Param 传输参数
|
||||
* @Return
|
||||
* @Author: 曾文和
|
||||
* @CreateDate: 2019/11/6 10:03
|
||||
* @UpdateUser: 曾文和
|
||||
* @UpdateDate: 2019/11/6 10:03
|
||||
* @UpdateRemark: 更新说明
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class BeanMapperUtils {
|
||||
/**
|
||||
* 使用序列化技术实现深拷贝
|
||||
* @return
|
||||
*/
|
||||
public static Object deepClone(Object object) throws IOException,ClassNotFoundException{
|
||||
//将对象写入流中
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
|
||||
objectOutputStream.writeObject(object);
|
||||
//从流中取出
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
|
||||
return objectInputStream.readObject();
|
||||
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.manage.util;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* <p>Title:JsonModel </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Company: </p>
|
||||
* @author hu
|
||||
* @date
|
||||
*/
|
||||
public class JsonModel {
|
||||
private String id;
|
||||
private String text;
|
||||
private String icon;
|
||||
private StateForJsonModel state;
|
||||
private List<JsonModel> children;
|
||||
private Object li_attr;
|
||||
private Object a_attr;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
public StateForJsonModel getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(StateForJsonModel state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
public List<JsonModel> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
public void setChildren(List<JsonModel> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
|
||||
public Object getLi_attr() {
|
||||
return li_attr;
|
||||
}
|
||||
|
||||
|
||||
public void setLi_attr(Object li_attr) {
|
||||
this.li_attr = li_attr;
|
||||
}
|
||||
|
||||
|
||||
public Object getA_attr() {
|
||||
return a_attr;
|
||||
}
|
||||
|
||||
|
||||
public void setA_attr(Object a_attr) {
|
||||
this.a_attr = a_attr;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.manage.util;
|
||||
|
||||
/**
|
||||
* <p>Title:StateForJsonModel </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Company: </p>
|
||||
* @author hu
|
||||
* @date
|
||||
*/
|
||||
public class StateForJsonModel {
|
||||
private boolean opened;
|
||||
private boolean disabled;
|
||||
private boolean selected;
|
||||
|
||||
|
||||
public boolean isOpened() {
|
||||
return opened;
|
||||
}
|
||||
|
||||
|
||||
public void setOpened(boolean opened) {
|
||||
this.opened = opened;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue