后台优化

master
zengwh 5 years ago
parent a7186fb170
commit 5fc47425b6

@ -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`

@ -524,7 +524,7 @@ function exportExcel(){
var checks = $("#checks").val();
if(checks != '') {
checks = checks.substring(0, checks.length - 1);
var url = path+"/user/export?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks;
var url = path+"/user/export?checks="+checks;
window.location.href = url;
}else{
Common.confirm({
@ -532,7 +532,7 @@ function exportExcel(){
message: "没有选中,您确定要按搜索栏条件导出?",
operate: function (reselt) {
if (reselt) {
var url = path+"/user/export?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks;
var url = path+"/user/export?userName="+$("#user_name").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val();
window.location.href = url;
}
}

@ -523,7 +523,7 @@ function exportExcel(){
var checks = $("#checks").val();
if(checks != '') {
checks = checks.substring(0, checks.length - 1);
var url = path+"/user/export1?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks;
var url = path+"/user/export1?checks="+checks;
window.location.href = url;
}else{
Common.confirm({
@ -531,7 +531,7 @@ function exportExcel(){
message: "没有选中,您确定要按搜索栏条件导出?",
operate: function (reselt) {
if (reselt) {
var url = path+"/user/export?userName="+$("#user_name").val()+"&userEmail="+$("#user_email").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val()+"&checks="+checks;
var url = path+"/user/export?userName="+$("#user_name").val()+"&searchRoleId="+$("#roleId").val()+"&deptId="+$("#dept_id").val()+"&effective="+$("#effective").val();
window.location.href = url;
}
}

@ -31,13 +31,4 @@ public class ActionScopeUtils {
public static Object getSessionAttribute(String key){
return getSession(getRequest()).getAttribute(key);
}
public static void setRequestAttribute(String key,Object value){
getRequest().setAttribute(key,value);
}
public static Object getRequestAttribute(String key){
return getRequest().getAttribute(key);
}
}

@ -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();
}
}

@ -11,8 +11,6 @@ public class Constant {
public static final Integer EFFECTIVE_NO = 0;
// 未登录拦截
public static final String RELEASE_REQUEST = "releaseRequest";
// ajax拦截
public static final String AJAX_REQUEST = "ajaxRequest";
public static final String CURRENT_USER = "CURRENT_USER";
}

@ -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;
}
}

@ -51,6 +51,6 @@ public class SigarUtils{
String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("win") >= 0) {
return true;
} else return false;
} else {return false;}
}
}

@ -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;
}
}

@ -50,7 +50,7 @@ public class ImportExcelJudgeMethod {
@Autowired
private Power_Sys_DictMapper sysDictMapper;
//公共批量插入方法
private static final String SIMPLEINSERT = "SimpleInsert";
private final String SIMPLEINSERT = "SimpleInsert";
/****************************************导入公共判断******************************************************/
/**

@ -299,11 +299,6 @@ public class ImportExcelUtil {
return workbook;
}
//移除缓存的工作簿
public static void removeWorkBookMapByKey(String workBookKey){
workBookMap.remove(workBookKey);
}
public static void copy(Object source, Object dest) throws Exception {
Class destClz = dest.getClass();

@ -9,17 +9,17 @@ import java.util.Map;
public class CacheManager {
private static HashMap cacheMap = new HashMap();
private static HashMap cacheExceptionMap = new HashMap();
private static HashMap<String,HashMap<String,Integer>> loginUserCacheMap = new HashMap();
//无异常数量
//private static HashMap cacheExceptionMap = new HashMap();
//private static HashMap<String,HashMap<String,Integer>> loginUserCacheMap = new HashMap();
/*//无异常数量
private static Integer noExcCount = 0;
//异常数量
private static Integer excCount = 0;
private static Integer excCount = 0;*/
//添加用户登录缓存
public synchronized static void addloginUserCount(String date,String userName){
public static void addloginUserCount(String date,String userName){
//取出当天数据
HashMap<String,Integer> map = loginUserCacheMap.get(date);
/*HashMap<String,Integer> map = loginUserCacheMap.get(date);
if(null == map){
map = new HashMap<>();
//首次登录
@ -36,81 +36,52 @@ public class CacheManager {
map.put(userName,count);
}
//重置
loginUserCacheMap.put(date,map);
loginUserCacheMap.put(date,map);*/
}
//获取当天用户集合
public static HashMap getCurrentDayCount(String date){
//取出当天数据
HashMap map = loginUserCacheMap.get(date);
return map;
/* HashMap map = loginUserCacheMap.get(date);
return map;*/
return null;
}
//添加异常数量
public synchronized static void addExcCount(String type){
if("noExc".equals(type)){
noExcCount++;
cacheExceptionMap.put(type,noExcCount);
/*noExcCount++;
cacheExceptionMap.put(type,noExcCount);*/
}
if("exc".equals(type)){
excCount++;
cacheExceptionMap.put(type,excCount);
/*excCount++;
cacheExceptionMap.put(type,excCount);*/
}
}
//取异常数量
public synchronized static Integer getExcCount(String type){
return (Integer)cacheExceptionMap.get(type);
public static Integer getExcCount(String type){
return 0;
//return (Integer)cacheExceptionMap.get(type);
}
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) {
private static Cache getCache(String key) {
return (Cache) cacheMap.get(key);
}
private synchronized static boolean hasCache(String key) {
private static boolean hasCache(String key) {
return cacheMap.containsKey(key);
}
public synchronized static void clearAll() {
public static void clearAll() {
cacheMap.clear();
}
public synchronized static void clearAll(String type) {
public static void clearAll(String type) {
Iterator i = cacheMap.entrySet().iterator();
String key;
ArrayList<String> arr = new ArrayList<String>();
@ -130,41 +101,24 @@ public class CacheManager {
}
}
public synchronized static void clearOnly(String key) {
public static void clearOnly(String key) {
cacheMap.remove(key);
}
public synchronized static void putCache(String key, Cache obj) {
public 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
}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) {
@ -180,62 +134,8 @@ public class CacheManager {
}
}
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()) {
Map.Entry entry = (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()) {
Map.Entry entry = (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()) {
Map.Entry entry = (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;
public static void removeCacheByObject(Power_UserVo obj) {
ArrayList<String> arr = new ArrayList<String>();
try {
Iterator i = cacheMap.entrySet().iterator();
@ -254,5 +154,4 @@ public class CacheManager {
}
} catch (Exception ex) {}
}
}

@ -4,27 +4,17 @@ import org.java_websocket.WebSocket;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
import javax.websocket.Session;
import java.io.IOException;
import java.net.InetSocketAddress;
public class WebServer extends WebSocketServer {
private Session session;
public WebServer(int port) {
super(new InetSocketAddress(port));
}
public WebServer(InetSocketAddress address) {
super(address);
}
@Override
public void onOpen(WebSocket conn, ClientHandshake handshake) {
// ws连接的时候触发的代码onOpen中我们不做任何操作
}
public void sendMessage(String message) throws IOException {
this.session.getBasicRemote().sendText("2");
}
@Override
public void onClose(WebSocket conn, int code, String reason, boolean remote) {

@ -8,16 +8,6 @@ import java.util.*;
public class WsPool {
private static final Map<WebSocket, String> wsUserMap = new HashMap<WebSocket, String>();
/**
* websocket
*
* @param conn
* @return
*/
public static String getUserByWs(WebSocket conn) {
return wsUserMap.get(conn);
}
/**
* userNameWebSocket,list,
* websocketuserNameclosewebsocket
@ -44,20 +34,6 @@ public class WsPool {
wsUserMap.put(conn, userName); // 添加连接
}
/**
* setuser
*
* @return
*/
public static Collection<String> getOnlineUser() {
List<String> setUsers = new ArrayList<String>();
Collection<String> setUser = wsUserMap.values();
for (String u : setUser) {
setUsers.add(u);
}
return setUsers;
}
/**
*
*

Loading…
Cancel
Save