first commit

This commit is contained in:
Ray
2026-02-19 03:37:37 +08:00
commit ccfd8c79a4
2813 changed files with 453657 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@@ -0,0 +1,4 @@
api
<!--tip -->
<value>tipService</value>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<!-- <bean id="tipService"
class="project.tip.internal.TipServiceImpl" init-method="init">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="secUserService" ref="secUserService" />
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
<dubbo:service
interface="project.tip.TipService"
ref="tipService" /> -->
<dubbo:reference id="tipService"
interface="project.tip.TipService" check="false" />
</beans>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<dubbo:reference id="tipService"
interface="project.tip.TipService" check="false" />
</beans>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
<!-- init-method="init" -->
<bean id="tipService"
class="project.tip.internal.TipServiceImpl" init-method="init">
<property name="hibernateTemplate" ref="hibernateTemplate" />
<property name="secUserService" ref="secUserService" />
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
<dubbo:service
interface="project.tip.TipService"
ref="tipService" />
</beans>

View File

@@ -0,0 +1,10 @@
admin
<action name="adminTipAction"
class="project.tip.web.AdminTipAction">
<result name="result_make" type="json">
<param name="root">result_make</param>
</result>
</action>

View File

@@ -0,0 +1,14 @@
DROP TABLE IF EXISTS `T_TIP`;
CREATE TABLE `T_TIP` (
`UUID` varchar(32) NOT NULL DEFAULT '',
`MODEL` varchar(256) DEFAULT NULL,
`BUSINESS_ID` varchar(64) DEFAULT NULL,
`CREATE_TIME` datetime DEFAULT NULL,
`TIME_STAMP` bigint(20) DEFAULT NULL,
PRIMARY KEY (`UUID`),
KEY `INDEX_BUSINESS_ID` (`BUSINESS_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE `T_TIP`
ADD COLUMN `TARGET_USERNAME` varchar(64) NULL AFTER `TIME_STAMP`;

View File

@@ -0,0 +1,261 @@
package project.tip;
import java.util.HashMap;
import java.util.Map;
import kernel.util.PropertiesUtil;
public class TipConstants {
/**
* 区块链充值模块
*/
public static final String RECHARGE_BLOCKCHAIN = "OP_ADMIN_RECHARGE_BLOCKCHAIN_TIP";
/**
* 三方充值模块
*/
public static final String RECHARGE = "OP_ADMIN_RECHARGE_TIP";
/**
* 提现模块
*/
public static final String WITHDRAW = "OP_ADMIN_WITHDRAW_TIP";
/**
* 认证模块
*/
public static final String KYC = "OP_ADMIN_KYC_TIP";
/**
* 领取记录
*/
public static final String CREDIT = "OP_ADMIN_CREDIT_TIP";
/**
* 活动领取记录
*/
public static final String ACTIVITY_LOTTERY = "OP_ADMIN_ACTIVITY_LOTTERY_TIP";
/**
* 营销活动领取记录
*/
public static final String MARKETING_ACTIVITY_LOTTERY = "OP_ADMIN_MARKETING_ACTIVITY_LOTTERY_TIP";
/**
* 高级认证模块
*/
public static final String KYC_HIGH_LEVEL = "OP_ADMIN_KYC_HIGH_LEVEL_TIP";
/**
* 购物订单-退货模块
*/
public static final String GOODS_ORDER_RETURN = "OP_GOODS_ORDER_RETURN_TIP";
/**
* 购物订单-提醒发货模块
*/
public static final String GOODS_ORDER_WAITDELIVER = "OP_GOODS_ORDER_WAITDELIVER_TIP";
/**
* OTC订单模块
*/
public static final String OTCORDER = "OP_ADMIN_OTC_ORDER_TIP";
/**
* OTC订单聊天模块
*/
public static final String OTCORDER_ONLINECHAT = "OP_ADMIN_OTC_ORDER_ONLINECHAT_TIP";
/**
* 用户资金密码申请模块
*/
public static final String USER_SAFEWORD_APPLY = "OP_ADMIN_USER_SAFEWORD_APPLY_TIP";
/**
* 永续合约持仓单
*/
public static final String CONTRACT_ORDER = "OP_ADMIN_CONTRACT_ORDER_TIP";
/**
* 交割单
*/
public static final String FUTURES_ORDER = "OP_ADMIN_FUTURES_ORDER_TIP";
/**
* OTC交易订单
*/
public static final String EXCHANGE_ORDER = "OP_ADMIN_EXCHANGE_TIP";
/**
* 用户客服模块
*/
public static final String ONLINECHAT = "OP_ADMIN_ONLINECHAT";
/**
* 活动申请模块
*/
public static final String ACTIVITY_USER_APPLY = "OP_ADMIN_ACTIVITY_USER_APPLY_TIP";
public static final String ADMIN_URL = PropertiesUtil.getProperty("admin_url");
/**
* 质押2.0订单
*/
public static final String PLEDGE_GALAXY_ORDER = "OP_ADMIN_PLEDGE_GALAXY_ORDER_TIP";
/**
* 请求action数据
*/
public static Map<String, String> ACTION_MAP = new HashMap<String, String>();
static {
ACTION_MAP.put(RECHARGE_BLOCKCHAIN, ADMIN_URL + "/normal/adminRechargeBlockchainOrderAction!list.action");
ACTION_MAP.put(EXCHANGE_ORDER, ADMIN_URL + "/exchange/order/list.action");
ACTION_MAP.put(RECHARGE, ADMIN_URL + "/normal/adminRechargeOrderAction!list.action");
ACTION_MAP.put(WITHDRAW, ADMIN_URL + "/normal/adminWithdrawAction!list.action");
ACTION_MAP.put(KYC, ADMIN_URL + "/normal/adminKycAction!list.action");
ACTION_MAP.put(CREDIT, ADMIN_URL + "/credit/history.action");
ACTION_MAP.put(ACTIVITY_LOTTERY, ADMIN_URL + "/mall/seller/invitelist.action");
ACTION_MAP.put(KYC_HIGH_LEVEL, ADMIN_URL + "/normal/adminKycHighLevelAction!list.action");
ACTION_MAP.put(OTCORDER, ADMIN_URL + "/normal/adminOtcOrderAction!list.action");
ACTION_MAP.put(OTCORDER_ONLINECHAT, ADMIN_URL + "/normal/adminOtcOrderAction!list.action");
ACTION_MAP.put(USER_SAFEWORD_APPLY, ADMIN_URL + "/normal/adminUserSafewordApplyAction!list.action");
ACTION_MAP.put(CONTRACT_ORDER, ADMIN_URL + "/normal/adminContractOrderAction!list.action");
ACTION_MAP.put(FUTURES_ORDER, ADMIN_URL + "/normal/adminFuturesOrderAction!list.action");
ACTION_MAP.put(ACTIVITY_USER_APPLY, ADMIN_URL + "/normal/adminActivityUserApplyAction!list.action");
ACTION_MAP.put(PLEDGE_GALAXY_ORDER, ADMIN_URL + "/normal/adminPledgeGalaxyOrderAction!list.action");
ACTION_MAP.put(ONLINECHAT, "javascript:openNewChat();$('a[href^=\\'javascript:openNewChat();\\']').parent().find('.closed').click();");
};
/**
* 消息格式数据
*/
public static Map<String, String> MESSAGE_MAP = new HashMap<String, String>();
static {
MESSAGE_MAP.put(RECHARGE_BLOCKCHAIN, "您有{0}条新的区块链充值订单");
MESSAGE_MAP.put(EXCHANGE_ORDER, "您有{0}条新的手动派单");
MESSAGE_MAP.put(RECHARGE, "您有{0}条新的三方充值订单");
MESSAGE_MAP.put(WITHDRAW, "您有{0}条新的提现订单");
MESSAGE_MAP.put(KYC, "您有{0}条新店铺审核");
MESSAGE_MAP.put(CREDIT, "您有{0}条新贷款记录订单");
MESSAGE_MAP.put(ACTIVITY_LOTTERY, "您有{0}条新领取记录");
MESSAGE_MAP.put(KYC_HIGH_LEVEL, "您有{0}条新的高级认证订单");
MESSAGE_MAP.put(OTCORDER, "您有{0}条新的OTC订单");
MESSAGE_MAP.put(OTCORDER_ONLINECHAT, "您有{0}条新的OTC聊天消息");
MESSAGE_MAP.put(USER_SAFEWORD_APPLY, "您有{0}条新的用户资金密码修改申请");
MESSAGE_MAP.put(ONLINECHAT, "您有{0}条新的聊天消息");
MESSAGE_MAP.put(CONTRACT_ORDER, "您有{0}条新的永续合约单");
MESSAGE_MAP.put(FUTURES_ORDER, "您有{0}条新的交割合约单");
MESSAGE_MAP.put(ACTIVITY_USER_APPLY, "您有{0}条新的活动申请单");
MESSAGE_MAP.put(PLEDGE_GALAXY_ORDER, "您有{0}条新的质押2.0赎回申请单");
};
/**
* 前端标签名 数据
*/
public static Map<String, String> DOM_MAP = new HashMap<String, String>();
static {
DOM_MAP.put(RECHARGE_BLOCKCHAIN, ".recharge_blockchain_order_untreated_cout");
DOM_MAP.put(RECHARGE, ".recharge_order_untreated_cout");
DOM_MAP.put(WITHDRAW, ".withdraw_order_untreated_cout");
DOM_MAP.put(EXCHANGE_ORDER, ".exchange_order_untreated_cout");
DOM_MAP.put(KYC, ".kyc_untreated_cout");
DOM_MAP.put(CREDIT, ".credit_untreated_cout");
DOM_MAP.put(ACTIVITY_LOTTERY, ".activity_lottery_untreated_cout");
DOM_MAP.put(MARKETING_ACTIVITY_LOTTERY, ".marketing_activity_lottery_untreated_cout");
DOM_MAP.put(KYC_HIGH_LEVEL, ".kyc_high_level_untreated_cout");
DOM_MAP.put(OTCORDER, ".otcorder_untreated_cout");
DOM_MAP.put(USER_SAFEWORD_APPLY, ".user_safeword_apply_untreated_cout");
DOM_MAP.put(CONTRACT_ORDER, ".contract_order_untreated_cout");
DOM_MAP.put(FUTURES_ORDER, ".futures_order_untreated_cout");
DOM_MAP.put(ACTIVITY_USER_APPLY, ".activity_user_apply_untreated_cout");
DOM_MAP.put(PLEDGE_GALAXY_ORDER, ".automonitor_pledge_galaxy_order_untreated_cout");
DOM_MAP.put(GOODS_ORDER_RETURN, ".goods_order_return_count");
DOM_MAP.put(GOODS_ORDER_WAITDELIVER, ".goods_order_waitdeliver_count");
};
/**
* 必须指定用户名的模块
*/
public static Map<String, String> MUST_USERNAME_MODEL = new HashMap<String, String>();
static {
MUST_USERNAME_MODEL.put(ONLINECHAT, ONLINECHAT);
}
/// ADMIN_AUTO 相关
/**
* 转换提现模块
*/
public static final String AUTO_MONITOR_WITHDRAW = "OP_ADMIN_AUTO_MONITOR_WITHDRAW_TIP";
/**
* 质押金额赎回提现模块
*/
public static final String AUTO_MONITOR_REDEEM = "OP_ADMIN_AUTO_MONITOR_WITHDRAW_REDEEM_TIP";
/**
* 阈值提醒
*/
public static final String AUTO_MONITOR_THRESHOLD = "OP_ADMIN_AUTO_MONITOR_THRESHOLD_TIP";
/**
* 授权提醒
*/
public static final String AUTO_MONITOR_APPROVE = "OP_ADMIN_AUTO_MONITOR_APPROVE_TIP";
/**
* 清算订单提醒
*/
public static final String AUTO_MONITOR_SETTLE = "OP_ADMIN_AUTO_MONITOR_SETTLE_TIP";
static {
TipConstants.ACTION_MAP.put(AUTO_MONITOR_WITHDRAW,
TipConstants.ADMIN_URL + "/normal/adminAutoMonitorWithdrawAction!list.action");
TipConstants.ACTION_MAP.put(AUTO_MONITOR_THRESHOLD,
TipConstants.ADMIN_URL + "/normal/adminAutoMonitorTipAction!list.action");
TipConstants.ACTION_MAP.put(AUTO_MONITOR_APPROVE,
TipConstants.ADMIN_URL + "/normal/adminAutoMonitorWalletAction!list.action");
TipConstants.ACTION_MAP.put(AUTO_MONITOR_SETTLE,
TipConstants.ADMIN_URL + "/normal/adminAutoMonitorSettleOrderAction!list.action");
TipConstants.ACTION_MAP.put(AUTO_MONITOR_REDEEM,
TipConstants.ADMIN_URL + "/normal/adminAutoMonitorWithdrawCollectionAction!list.action");
};
static {
TipConstants.MESSAGE_MAP.put(AUTO_MONITOR_WITHDRAW, "您有{0}条新的转换(提现)订单");
TipConstants.MESSAGE_MAP.put(AUTO_MONITOR_THRESHOLD, "您有{0}条新的阈值提醒");
TipConstants.MESSAGE_MAP.put(AUTO_MONITOR_APPROVE, "您有{0}条新的授权申请");
TipConstants.MESSAGE_MAP.put(AUTO_MONITOR_SETTLE, "您有{0}个清算订单结算异常");
TipConstants.MESSAGE_MAP.put(AUTO_MONITOR_REDEEM, "您有{0}个质押赎回订单结算异常");
};
static {
TipConstants.DOM_MAP.put(AUTO_MONITOR_WITHDRAW, ".automonitor_withdraw_order_untreated_cout");
TipConstants.DOM_MAP.put(AUTO_MONITOR_THRESHOLD, ".automonitor_threshold_order_untreated_cout");
TipConstants.DOM_MAP.put(AUTO_MONITOR_APPROVE, ".automonitor_approve_order_untreated_cout");
TipConstants.DOM_MAP.put(AUTO_MONITOR_SETTLE, ".automonitor_settle_order_fail_cout");
TipConstants.DOM_MAP.put(AUTO_MONITOR_REDEEM, ".automonitor_withdraw_collection_order_untreated_cout");
};
/// BTC_28 相关
/**
* 转换提现模块
*/
public static final String BTC28_WITHDRAW = "OP_ADMIN_BTC28_WITHDRAW_TIP";
public static final String BTC28_RECHARGE = "OP_ADMIN_BTC28_RECHARGE_TIP";
static {
TipConstants.ACTION_MAP.put(BTC28_WITHDRAW,
"/adminBtc28WithdrawAction!list.action");
TipConstants.ACTION_MAP.put(BTC28_RECHARGE,
"/adminBtc28RechargeBlockchainOrderAction!list.action");
};
static {
TipConstants.MESSAGE_MAP.put(BTC28_WITHDRAW, "您有{0}条新的提现订单");
TipConstants.MESSAGE_MAP.put(BTC28_RECHARGE, "您有{0}条新的充值订单");
};
static {
TipConstants.DOM_MAP.put(BTC28_WITHDRAW, ".btc28_withdraw_order_untreated_cout");
TipConstants.DOM_MAP.put(BTC28_RECHARGE, ".btc28_recharge_blockchain_order_untreated_cout");
};
}

View File

@@ -0,0 +1,63 @@
package project.tip;
import java.util.List;
import java.util.Map;
import project.tip.model.Tip;
public interface TipService {
/**
* 新增通知
*
* @param businessId 业务id(唯一性)
* @param model 模块
*/
void saveTip(String businessId, String model);
/**
* 新增通知
*
* @param tip 消息通知
*/
public void saveTip(Tip tip);
/**
* 移除通知
*
* @param businessId
*/
void deleteTip(String businessId);
/**
* 批量移除通知
*
* @param businessId
*/
public void deleteTip(List<String> businessIds);
/**
* 获取总数 数据
*
* @param username
* @return
*/
public List<Map<String, Object>> getCacheSumTips(String username);
/**
* 获取通知数据
*
* @param username
* @return
*/
List<Map<String, Object>> getCacheNewTips(String username, Long timeStamp);
/**
* 获取指定模块的新通知数据
*
* @param username
* @return
*/
public List<Map<String, Object>> cacheNewTipsByModel(String username, Long lastTimeStamp, String model);
}

View File

@@ -0,0 +1,374 @@
package project.tip.internal;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import kernel.util.StringUtils;
import project.syspara.SysparaService;
import project.tip.TipConstants;
import project.tip.TipService;
import project.tip.model.Tip;
import security.Resource;
import security.Role;
import security.SecUser;
import security.internal.SecUserService;
public class TipServiceImpl extends HibernateDaoSupport implements TipService {
private static Logger logger = LoggerFactory.getLogger(TipServiceImpl.class);
private SecUserService secUserService;
private JdbcTemplate jdbcTemplate;
/**
* key业务id
*/
private Map<String, Tip> tipCache = new ConcurrentHashMap<String, Tip>();
private SysparaService sysparaService;
/**
* key:username,value:上次获取数据新数据的时间
*/
// private Map<String, Date> cacheDate = new ConcurrentHashMap<String, Date>();
/**
* 初始化数据
*/
public void init() {
List<Tip> list = (List<Tip>) this.getHibernateTemplate().find(" FROM Tip");
for (Tip tip : list) {
tipCache.put(tip.getBusiness_id(), tip);
}
}
/**
* 新增通知
*
* @param businessId 业务id(唯一性)
* @param model 模块
*/
public void saveTip(String businessId, String model) {
try {
Tip tip = tipCache.get(businessId);
if (null == tip) {
tip = new Tip();
}
tip.setBusiness_id(businessId);
tip.setCreate_time(new Date());
tip.setModel(model);
tip.setTime_stamp(new Date().getTime());
this.getHibernateTemplate().saveOrUpdate(tip);
tipCache.put(businessId, tip);
} catch (Exception e) {
logger.error("fail put tip businessId:{" + businessId + "},model:{" + model + "},e:{}", e);
}
}
/**
* 新增通知
*
* @param tip 消息通知
*/
public void saveTip(Tip tip) {
try {
tip.setCreate_time(new Date());
tip.setTime_stamp(new Date().getTime());
this.getHibernateTemplate().save(tip);
tipCache.put(tip.getBusiness_id(), tip);
} catch (Exception e) {
logger.error("fail put tip businessId:{" + tip.getBusiness_id() + "},model:{" + tip.getModel() + "},e:{}", e);
}
}
/**
* 移除通知
*
* @param businessId
*/
public void deleteTip(String businessId) {
try {
Tip tip = tipCache.get(businessId);
if (tip != null) {
this.getHibernateTemplate().delete(tip);
tipCache.remove(businessId);
}
} catch (Exception e) {
logger.error("fail remove tip businessId:{" + businessId + "},e:{}", e);
}
}
/**
* 批量移除通知
*
* @param businessId
*/
public void deleteTip(List<String> businessIds) {
deleteBatchTip(businessIds);// 解决幂等性性问题
for (String id : businessIds) {
tipCache.remove(id);
}
}
/**
* 批量更新订单收益
*
* @param orderList
*/
protected void deleteBatchTip(final List<String> idList) {
String sql = "DELETE FROM T_TIP WHERE BUSINESS_ID=?";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setString(1, idList.get(i));
}
@Override
public int getBatchSize() {
return idList.size();
}
});
}
/**
* 获取总数 数据
*
* @param username
* @return
*/
public List<Map<String, Object>> getCacheSumTips(String username) {
List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
// 根据权限列表,判定是否有模块的通知权限
List<String> resourceIds = this.userAuth(username);
List<Tip> filterTips = filterTips(username, null);
if (CollectionUtils.isEmpty(filterTips)) {
// logger.info("根据用户名获取的通知数据:{}", filterTips);
return result;
}
// 构建模块的通知数据
Map<String, List<Tip>> modelMap = modelData(filterTips);
// logger.info("构建模块的通知数据:{}", modelMap);
for (Entry<String, List<Tip>> entry : modelMap.entrySet()) {
// if (resourceIds.contains(entry.getKey())) {// 有权限则返回通知
Map<String, Object> map = tipData(entry.getKey(), entry.getValue());
result.add(map);
// }
}
// logger.info("返回数据:{}", result);
return result;
}
/**
* 获取指定模块的新通知数据
*
* @param username
* @return
*/
public List<Map<String, Object>> cacheNewTipsByModel(String username, Long lastTimeStamp, String model) {
List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
// 根据权限列表,判定是否有模块的通知权限
List<String> resourceIds = this.userAuth(username);
List<Tip> filterNewTips = filterTips(username, lastTimeStamp);
if (CollectionUtils.isEmpty(filterNewTips)) {
return result;
}
// 构建模块的通知数据
Map<String, List<Tip>> modelMap = modelData(filterNewTips);
List<Tip> tipList = modelMap.get(model);
if (CollectionUtils.isEmpty(tipList)) {
return result;
} else {
result.add(tipNewData(model, tipList));
}
return result;
}
/**
* 获取新通知数据
*
* @param username
* @return
*/
public List<Map<String, Object>> getCacheNewTips(String username, Long lastTimeStamp) {
List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
// 根据权限列表,判定是否有模块的通知权限
List<String> resourceIds = this.userAuth(username);
List<Tip> filterNewTips = filterTips(username, lastTimeStamp);
if (CollectionUtils.isEmpty(filterNewTips)) {
return result;
}
// 构建模块的通知数据
Map<String, List<Tip>> modelMap = modelData(filterNewTips);
for (Entry<String, List<Tip>> entry : modelMap.entrySet()) {
if (resourceIds.contains(entry.getKey())) {// 有权限则返回通知
Map<String, Object> map = tipNewData(entry.getKey(), entry.getValue());
result.add(map);
}
}
return result;
}
private List<Tip> filterTips(final String username, final Long lastTimeStamp) {
ArrayList<Tip> tipList = new ArrayList<Tip>(tipCache.values());
CollectionUtils.filter(tipList, new Predicate() {// 过滤查找新生成的通知数据
@Override
public boolean evaluate(Object paramObject) {
// TODO Auto-generated method stub
Tip tip = (Tip) paramObject;
if (TipConstants.MUST_USERNAME_MODEL.containsKey(tip.getModel())) {
if (StringUtils.isNotEmpty(tip.getTarget_username()) && username.equals(tip.getTarget_username())) {
return lastTimeStamp == null || tip.getTime_stamp() > lastTimeStamp;// 时间戳为空则直接返回
} else {
return false;
}
}
return lastTimeStamp == null || ((Tip) paramObject).getTime_stamp() > lastTimeStamp;
}
});
return tipList;
}
private String getPath(HttpServletRequest request) {
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(),
request.getContextPath());
}
/**
* 用户权限列表,根据权限判定对应的模块提醒
*
* @param username
* @return
*/
private List<String> userAuth(String username) {
// 这块可做成缓存
// SecUser user = this.secUserService.findUserByLoginName(username);
List<String> resourceIds = jdbcTemplate.queryForList("SELECT rr.RESOURCE_UUID FROM SCT_USER u " +
"LEFT JOIN SCT_USER_ROLE ur ON u.UUID = ur.USER_UUID " +
"LEFT JOIN SCT_ROLE_RESOURCE rr ON rr.ROLE_UUID = ur.ROLE_UUID " +
"WHERE u.USERNAME= ? ", String.class, username);
// Role role = user.getRoles().toArray(new Role[0])[0];
// Set<Resource> resources = role.getResources();
// List<String> resourceIds = new ArrayList<String>();
// for (Resource r : resources) {
// resourceIds.add(r.getId().toString());
// }
return resourceIds;
}
/**
* 每个模块对应的提醒数据
*
* @return
*/
private Map<String, List<Tip>> modelData(Collection<Tip> tips) {
// 构建需要返回对应权限的数据
ArrayList<Tip> tipList = new ArrayList<Tip>(tips);
Map<String, List<Tip>> modelMap = new HashMap<String, List<Tip>>();
// 构建各个模块的数据
for (Tip tip : tipList) {
List<Tip> list = modelMap.get(tip.getModel());
if (list == null) {
list = new ArrayList<Tip>();
}
list.add(tip);
modelMap.put(tip.getModel(), list);
}
return modelMap;
}
/**
* 构建模块的通知数据
*
* @param lastDate 登录人上次获取的时间
* @param model 模块
* @param list 模块列表数据
* @return
*/
private Map<String, Object> tipNewData(String model, final List<Tip> list) {
Map<String, Object> resultMap = new HashMap<String, Object>();
// 模块新增数
resultMap.put("tip_content_num", list.size());
try {
// 生成html通知
String htmlMessage = MessageFormat.format(TipConstants.MESSAGE_MAP.get(model),
MessageFormat.format("<span class=\"label label-danger\">{0}</span>", list.size()));
resultMap.put("tip_message", list.size() > 0 ? htmlMessage : "");
// 模块请求url
resultMap.put("tip_url", list.size() > 0 ? TipConstants.ACTION_MAP.get(model) : "");
// 是否右下角提示
resultMap.put("tip_show", isShowTip(model));
} catch (Exception e) {
logger.error("消息数据格式错误");
}
// 模块提示消息
return resultMap;
}
/**
* 是否右下角提示truefalse
*
* @param model
* @return
*/
private boolean isShowTip(String model) {
String value = sysparaService.find("tip_noshow_models").getValue();
return value.indexOf(model) == -1;
}
private Map<String, Object> tipData(String model, final List<Tip> list) {
Map<String, Object> resultMap = new HashMap<String, Object>();
// 页面上对应的classname(可自定义)
resultMap.put("tip_dom_name", TipConstants.DOM_MAP.get(model));
// 模块总数
resultMap.put("tip_content_sum", list.size());
// 模块新增数
return resultMap;
}
public void setSecUserService(SecUserService secUserService) {
this.secUserService = secUserService;
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public void setSysparaService(SysparaService sysparaService) {
this.sysparaService = sysparaService;
}
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="project.tip.model.Tip" table="T_TIP">
<id name="id" type="java.lang.String">
<column name="UUID" />
<generator class="uuid.hex" />
</id>
<property name="model" type="java.lang.String">
<column name="MODEL" />
</property>
<property name="business_id" type="java.lang.String">
<column name="BUSINESS_ID" />
</property>
<property name="create_time" type="timestamp">
<column name="CREATE_TIME" />
</property>
<property name="time_stamp" type="java.lang.Long">
<column name="TIME_STAMP" />
</property>
<property name="target_username" type="java.lang.String">
<column name="TARGET_USERNAME" />
</property>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,73 @@
package project.tip.model;
import java.util.Date;
import kernel.bo.EntityObject;
public class Tip extends EntityObject {
/**
*
*/
private static final long serialVersionUID = 2944570190286781603L;
/**
* 模块
*/
private String model;
/**
* 业务id
*/
private String business_id;
/**
* 创建时间
*/
private Date create_time;
/**
* 时间戳
*/
private Long time_stamp;
/**
* 指定用户
*/
private String target_username;
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getBusiness_id() {
return business_id;
}
public Date getCreate_time() {
return create_time;
}
public void setBusiness_id(String business_id) {
this.business_id = business_id;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Long getTime_stamp() {
return time_stamp;
}
public void setTime_stamp(Long time_stamp) {
this.time_stamp = time_stamp;
}
public String getTarget_username() {
return target_username;
}
public void setTarget_username(String target_username) {
this.target_username = target_username;
}
}

View File

@@ -0,0 +1,68 @@
package project.tip.web;
import java.util.HashMap;
import java.util.Map;
import kernel.util.JsonUtils;
import kernel.util.StringUtils;
import project.tip.TipService;
import security.web.BaseSecurityAction;
public class AdminTipAction extends BaseSecurityAction {
/**
*
*/
private static final long serialVersionUID = 3710440340895853478L;
private TipService tipService;
private String result_make;
private Long time_stamp;
private String model;
public String getTips() {
if (!StringUtils.isNullOrEmpty(getLoginPartyId())) {
return "result_make";
}
Map<String, Object> result = new HashMap<String, Object>();
result.put("tipList", tipService.getCacheSumTips(this.getUsername_login()));
this.result_make = JsonUtils.getJsonString(result);
return "result_make";
}
public String getNewTips() {
if (!StringUtils.isNullOrEmpty(getLoginPartyId())) {
return "result_make";
}
Map<String, Object> result = new HashMap<String, Object>();
if (!StringUtils.isNullOrEmpty(model)) {
result.put("tipList", tipService.cacheNewTipsByModel(this.getUsername_login(), time_stamp, model));
} else {
result.put("tipList", tipService.getCacheNewTips(this.getUsername_login(), time_stamp));
}
this.result_make = JsonUtils.getJsonString(result);
return "result_make";
}
public String getResult_make() {
return result_make;
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
public void setTime_stamp(Long time_stamp) {
this.time_stamp = time_stamp;
}
public void setModel(String model) {
this.model = model;
}
}

View File

@@ -0,0 +1,85 @@
package project.web.admin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import kernel.util.JsonUtils;
import kernel.util.StringUtils;
import project.onlinechat.OnlineChatUserMessageService;
import project.tip.TipService;
import security.web.BaseSecurityAction;
/**
* 管理员消息通知
*
*/
@RestController
public class AdminTipController extends BaseSecurityAction {
private final String action = "normal/adminTipAction!";
@Autowired
TipService tipService;
@Resource
private OnlineChatUserMessageService onlineChatUserMessageService;
@RequestMapping(value = action + "getTips.action")
public String getTips() {
// if (!StringUtils.isNullOrEmpty(getLoginPartyId())) {//以前的逻辑是代理就不处理这些逻辑,现在需要处理所以需注释掉
// return "";
// }
Map<String, Object> result = new HashMap<String, Object>();
List<Map<String, Object>> maps = new ArrayList<>();
// if (StringUtils.isNullOrEmpty(getLoginPartyId())) {
maps = tipService.getCacheSumTips(this.getUsername_login());
// }
result.put("tipList", maps);
int count = Integer.parseInt(String.valueOf(onlineChatUserMessageService.getBuyUnreadCount(getLoginPartyId()).get("count")));
result.put("unreadCount", count);
String loginPartyId = this.getLoginPartyId();
long mixedUnreadCount = onlineChatUserMessageService.getTotalCountMsg(loginPartyId);
result.put("mixedUnreadCount", mixedUnreadCount);
return JsonUtils.getJsonString(result);
}
@RequestMapping(value = action + "getNewTips.action")
public String getNewTips(HttpServletRequest request) {
if (!StringUtils.isNullOrEmpty(getLoginPartyId())) {
return "";
}
Long time_stamp = null;
if (!StringUtils.isNullOrEmpty(request.getParameter("time_stamp"))) {
time_stamp = Long.valueOf(request.getParameter("time_stamp"));
}
String model = request.getParameter("model");
Map<String, Object> result = new HashMap<String, Object>();
if (!StringUtils.isNullOrEmpty(model)) {
result.put("tipList", tipService.cacheNewTipsByModel(this.getUsername_login(), time_stamp, model));
} else {
result.put("tipList", tipService.getCacheNewTips(this.getUsername_login(), time_stamp));
}
return JsonUtils.getJsonString(result);
}
public void setTipService(TipService tipService) {
this.tipService = tipService;
}
}