添加邮件号段管理及查询后台管理模块
wawe
wawe4560@
MySQL
-- 后台菜单
select * from TB_GLOBAL_MENUS t ;
添加SID:10033 10034
-- 角色菜单包
select * FROM tb_global_role_r_menus t;
添加SID:1550 1551
添加:jar包:
添加脚本:/shipping-platform/src/configAli/MAXsequences.lua
添加jsp页面:shipping-platform\web\pages\mailNumQuery\mailSegmentQuery.jsp ---jsp名及包名
添加Java代码:shipping-platform\src\com\teamsun\oms\internat\action\MailSegmentQueryAction--Java类名
package com.teamsun.oms.internat.action;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.roc.japp.core.mybatis.dialect.Page;
import com.teamsun.common.help.AppServiceHelper;
import com.teamsun.common.util.CopyUtils;
import com.teamsun.common.web.SuperBaseAction;
import net.sf.json.JSONObject;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* 邮件号段查询
* @author XING
*
*/
@UrlBinding("/mail/segmentquery.action")
public class MailSegmentQueryAction extends SuperBaseAction {
private static final Log _log = LogFactory.getLog(PrintMngAction.class);
private static final Log logeer = LogFactory.getLog(MailSegmentQueryAction.class);
private static JedisPool jedisPool;
@DefaultHandler
public Resolution index(){
return new ForwardResolution("/pages/mailNumQuery/mailSegmentQuery.jsp");
}
//-----------
public static JedisPool getJredis(){
if(jedisPool==null){
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(10);
poolConfig.setMaxTotal(2000);
poolConfig.setMaxWaitMillis(9000);
poolConfig.setTestOnBorrow(false);
//jedisPool=new JedisPool(poolConfig,"r-2ze5d836dbca4f64.redis.rds.aliyuncs.com",6379,9000,"ShipRedis654321",2);
jedisPool=new JedisPool(poolConfig,"47.95.49.40",6379,9000,"ShipRedis654321",2);
}
return jedisPool;
}
public Resolution findByPage() {
String[] sequ=new String[16];
sequ[0]="GETMAIL:SQ_LY_API_MAILNUM";
sequ[1]="GETMAIL:SQ_LM_API_MAILNUM";
sequ[2]="GETMAIL:SQ_LZ_API_MAILNUM";
sequ[3]="GETMAIL:SQ_A_API_MAILNUM";
sequ[4]="GETMAIL:SQ_CX_API_MAILNUM";
sequ[5]="GETMAIL:SQ_LH_API_MAILNUM";
sequ[6]="GETMAIL:SQ_EZ_ES_MAILNUM";
sequ[7]="GETMAIL:SQ_AS_API_MAILNUM";
sequ[8]="GETMAIL:SQ_LF_API_MAILNUM";
sequ[9]="GETMAIL:SQ_EZ_KR_MAILNUM";
sequ[10]="GETMAIL:SQ_EV_API_MAILNUM";
sequ[11]="GETMAIL:SQ_RX_API_MAILNUM";
sequ[12]="GETMAIL:SQ_API_MAILNUM";
sequ[13]="GETMAIL:SQ_EA_API_MAILNUM";
sequ[14]="GETMAIL:SQ_LS_API_MAILNUM";
sequ[15]="GETMAIL:SQ_CY_API_MAILNUM";
Jedis jedis = getJredis().getResource();
InputStream in = MailSegmentQueryAction.class.getClassLoader().getResourceAsStream("MAXsequences.lua");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder sb = new StringBuilder();
String line = null;
String mailnum = null;
final List<Map<String, String>> list=new ArrayList<Map<String,String>>();
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
String hash = jedis.scriptLoad(sb.toString());
//判断查询的邮件段号字段是否为空
if(sequ.length>0){
for (int i = 0; i < sequ.length; i++) {//循环拿取邮件号并放在map中,最后放在一个大的list中
Map<String, String> map=new HashMap<String, String>();
mailnum = String.valueOf(jedis.evalsha(hash, 1, sequ[i]));
List<String> result = Arrays.asList(mailnum.split(":"));
String current = result.get(1).toString();
if (current.length()<8) {
if(current.length()==7){
current="0"+current;
}
if(current.length()==6){
current="00"+current;
}
if(current.length()==5){
current="000"+current;
}
if(current.length()==4){
current="0000"+current;
}
if(current.length()==3){
current="00000"+current;
}
if(current.length()==2){
current="000000"+current;
}
if(current.length()==1){
current="0000000"+current;
}
}
String min = result.get(3).toString();
if (min.length()<8) {
if(min.length()==7){
min="0"+min;
}
if(min.length()==6){
min="00"+min;
}
if(min.length()==5){
min="000"+min;
}
if(min.length()==4){
min="0000"+min;
}
if(min.length()==3){
min="00000"+min;
}
if(min.length()==2){
min="000000"+min;
}
if(min.length()==1){
min="0000000"+min;
}
}
map.put("numtype", result.get(0).toString());
map.put("currentnum", current);
map.put("maxnum", result.get(2).toString());
map.put("minnum", min);
list.add(map);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (jedis != null) {
jedis.close();
}
in.close();
} catch (IOException e) {
e.printStackTrace();
logeer.error(e);
}
}
return findByPage(new DoPage(){
@Override
public JSONObject doInitPage(JSONObject jsonData, Page page) {
Map<String, Object> params = CopyUtils.copyMap(getQm());
_log.debug("##########params=" + params);
/*
List pageList = AppServiceHelper.getSuperService().selectByPage("com.teamsun.oms.entity.Role.find", params, page);
*/
jsonData.put(ROWS, list);
return jsonData;
}
});
}
}