=============================================================================================================
//返回更新时间
DateFormat df =new SimpleDateFormat(“yyyy-MM-dd hh:mm:ss”);
Long lastModified = helpFile.lastModified();
Date date = new Date(lastModified);
fileUpdateTime = df.format(date);
=============================================================================================================
(“#file_zh”).fileinput({
uploadUrl: ‘<%=path%>/cmi/user_uploadHelpFile.action?fileType=1’,
allowedFileExtensions : [‘pdf’],
maxFileSize: 0,//单位是KB,0表示不限制文件大小
autoReplace: true,
maxFileCount: 1,
uploadAsync: false,
})on(“filebatchselected”, function(event, files) {(this).fileinput(“upload”);
}).on(“filebatchuploadsuccess”, function(event, data) {//上传成功后回调函数
alert(‘处理成功’);
$(“#superZhFile”).text(‘’);
});
uploadAsync: false的时候回调函数如果要生效,只能用filebatchuploadsuccess
=============================================================================================================
超链接
a {
text-decoration:none;
}
a:link {
color:#000000;
text-decoration:none;
}
a:visited {
color:#000000
}
a:hover {
text-decoration:none;
color:#DDDDDD;
“type”: “post”,
“url”: “{pageContext.request.contextPath}/cmi/user_isExist.action?t=” + (new Date()).valueOf(), “dataType”: “json”, “data”: {“fileType”:fileType}, “success”: function(resp){ if(resp.result == 0){//文件存在即下载 window.location.href=”{path}/cmi/fileDownload.action?number=”+fileType;
}else{.umapMessager.alert(“”,””); } } }); } 对应的action类方法如下: /* * 判断文件是否存在 * */ public String isExist(){ switch (fileType) { case 1: fileFileName = SUPER_ZH_FILE; break; case 2: fileFileName = SUPER_EN_FILE; break; case 3: fileFileName = CP_ZH_FILE; break; default: fileFileName = CP_EN_FILE; break; } String url = root + File.separator + fileFileName; JSONObject resp = new JSONObject(); if(new File(url).exists()){ resp.put(“result”, 0); }else{ resp.put(“result”, 1); } CommonUtils.writeJson(resp.toString()); return NONE; } 圆满解决。 ================================================================================
================================================================================
加组信息的是operatorstore.action,但是在struts-cmi.xml文件中却找不到。
从数据库看
组信息主要在oper_grpscript2中看,因为UTV是要安装cmi版本后看的,所以只能根据描述来判断UTV组,而不是opergrpid。
操作员信息则是在oper_rights2中看,操纵员id:operid和虚拟组id:opergrpid
虚拟组id和实际组id之间有一个映射,是在oper_virtual_grpdef中看。
查询的sql语句
SELECT COUNT(1) FROM oper_rights2 a WHERE a.operid=’13’ AND a.opergrpid=
(SELECT b.v_opergrpid FROM oper_virtual_grpdef b WHERE b.opergrpid=
(SELECT c.opergrpid FROM oper_grpscript2 c WHERE c.grpscript IN (‘UTV’,’utv’))
“type”: “post”,
“url”: “{pageContext.request.contextPath}/cmi/select_oper.action?t=” + (new Date()).valueOf(), “dataType”: “json”, “success”: function(resp){ resp.data.splice(0,0,{“value”:”“,”text”:””}); (“select[name=′operid′]”).selectpicker(‘reloadData′,resp.data); (“select[name=’operid’]”).selectpicker(‘val’,”); } }); }else{ var operid = (“input[name=′operid′]”).val();varservicetype= (“select[name=’servicetype’]”).selectpicker(‘val’); getNode(operid); getWebsite(operid,servicetype); getChannel(operid); } ================================================================================ UTV里面查询UTV组的CP SELECT operid VALUE ,NAME TEXT FROM zxcdn_cmi.t_cp WHERE operid IN (SELECT operid FROM zxinsys.oper_rights2 WHERE opergrpid IN (SELECT v_opergrpid FROM zxinsys.oper_virtual_grpdef WHERE opergrpid IN (SELECT opergrpid FROM zxinsys.oper_grpscript2 WHERE grpscript IN (‘utv’,’UTV’)))) ================================================================================ 帮助》用户指南:UTV用户数统计为undefined的问题 在package_en.properties里面添加help.cdn.menu.description.utvonlineuser_init=. 在package_zh_CN.properties里面添加help.cdn.menu.description.utvonlineuser_init= 在userHelpAction.java添加 private String[] keys = {“initlist”, “roleManage_list”, “operGrpManage_list”, “safelevel_list”, “saferule_list”, “sysparam_init”, “Website_init”, “domainview_init”, “toJspCpInfo”, “traffic_init”, “bytehit_init”, “requesthit_init”, “log_initlog”, “CAcert_init”, “CAkey_init”, “upstreamcode_init”, “Circuit_init”, “Cpfiles_init”, “servicesuccessrate_init”, “utv_init”, “urlreplace_init”, “Regex_init”, “requestconnect_init”, “utvonlineuser_init”}; ================================================================================ 在请求数链接数的报表里面,cmi.analysis.domain竟然是加速对象的意思,cmi.title.servicetype是加速对象类型的意思。 直接把字段名字改为accelobject即可 ================================================================================ utv在线用户数统计查询的post()方法, 除了需要配置StatsticConsts.java中的public static final String USERONLINE_CODE = “useronline”; //UTV在线用户数统计 还要配置rest-interface.xml: ================================================================================ UTVCP的频道同步改在对操作员信息进行确认修改后执行, 修改operator_edit.jsp页面 可以同时给onclick绑定两个事件 οnclick=”onSubmit();updateUTVCP();” 写js方法,利用ajax调用后台函数 function updateUTVCP(){ .ajax({
“type”: “post”,
“url”: “{pageContext.request.contextPath}/cmi/utvonlineuser_updateUTVCP.action”, “dataType”: “json”, “success”: function(resp){ alert(“11”); } }); } 对应的action类中定义方法 public String updateUTVCP(){ MessageEventInit.publish(JobConsts.UTV_CP_EVENT, 0); return NONE; } ================================================================================ UTV在线用户数的节点 在cmi: SELECT DISTINCT a.nodeid VALUE, a.nodename TEXT FROM zxcdn_cmi.t_node a, zxcdn_cmi.t_cp_node b, zxcdn_cmi.t_cp c WHERE a.nodeid = b.nodeid AND b.cpid = c.cpid AND c.operid = 12 或 SELECT nodeid VALUE, nodename TEXT FROM zxcdn_cmi.t_node 在iam,节点和cpid没有关联,只能全部展示 SELECT a.* FROM zxcdn_iam.r_node a, zxcdn_iam.t_agent_group b, zxcdn_iam.t_agent_cachenode c WHERE a.entid = c.nodeid AND b.groupid = c.groupid ================================================================================= 加速对象查询,一开始用 //加速对象 public List } ================================================================================== 【故障描述】 mlb管理-总存储容量管理页面 1.饼图,无论是已用容量还是剩余容量,鼠标移到饼图位置显示的数字后面都有(100.00%),详见附件中的图片 2.饼图下面的标记的汉字显示不全 检查了MFSQueryAction.java的查询方法query() resultMsg=CommonUtil.sendUrl(url, task.toString()); 既不是DCF上报的,也不是大数据的,而是直接到设备上去查的 没办法演示数据,只能直接改totalstorage.jsp页面的样式了 把饼图的series.radius=’50%’、series.center=[‘50%’, ‘50%’]和title.x=’right’修改了。 ================================================================================== 1.mlb管理-存储配置页面,告警阈值都写成了告警阀值; 2.mlb管理-存储配置页面,重置有,全部为空,应该保留上次保留的配置数据 原因是重置按钮绑定了reset()事件,函数名改为resetAll()并在其中加上query()语句即可 function resetAll(){ //(“#disknum”).val(null);
//(“#jboddisknum”).val(null); //(“#mfsalarmrate”).val(null);
//(“#jbodmfsalarmrate”).val(null); //(“#diskalarmrate”).val(null);
//(“#jboddiskalarmrate”).val(null); query(); } ===================================================================================== 为了让UTV报表只针对super用户和UTV用户显示,需要在zxinsys_data.sql里面添加 CALL proc_res_op_function(22590,1,1551,155106,’UTV在线用户数统计’); 155106为对应的role id。 ===================================================================================== 只有super才能看到客户名称组,utv用户也看不到,所以这段代码可以不用了: ===================================================================================== CMI报表必须有CP才可以查询 (“#queryBtn”).click(function(){
//必须有CP才可以查询
var operid =(“[name=’operid’]”).val(); if(operid == null){ $.umapMessager.alert(“”,””); return; } … ===================================================================================== param.put(“cp”, dao.getCpIdByOperId(operid)); getCpIdByOperId可以直接返回String类型的对象 方法如下: public String getCpIdByOperId(String operid){ String sql =”select cpid from ” + DBUtil.getDbName() + “t_cp where 1=1 “; List param = new ArrayList(); if(StringUtils.isNotBlank(operid)){ sql += ” and operid = ?”; param.add(operid); } return jdbcTemplate.queryForObject(sql,param.toArray(),String.class); } ===================================================================================== “umapSort”:false, ===================================================================================== Request URL:http://10.47.232.233:8080/cmi/fileDownload.action?number=2 Request Method:GET Status Code:404 Not Found Remote Address:10.47.232.233:8080 下载异常是因为 path和 {pageContext.request.contextPath}不一致, 后者可以找到地址+端口+项目路径,而前者只能找到地址+端口,对于iam来说,两者是一样的 ===================================================================================== jquery的页面离开事件,不生效 $(window).bind(‘beforeunload’,function(){ alert(“11”); return ‘您输入的内容尚未保存,确定离开此页面吗?’; }); ===================================================================================== //添加上传前的事件 if( } ==================================================================================== 在jsp页面的filebatchselected()方法中下入如下代码: //添加上传前的事件 .ajax({
“type”: “post”,
“url”: “${pageContext.request.contextPath}/cmi/user_isExist.action?t=” + (new Date()).valueOf(),
“dataType”: “json”,
“data”: {“fileType”:1},
“success”: function(resp){
if(resp.result == 0){//文件存在即下载
$(“#file_zh”).fileinput(“upload”);
}else if(resp.result == 2){//文件被锁
$.umapMessager.alert(“”,””);
}else{
$.umapMessager.alert(“”,””);
}
}
});
//(this).fileinput(“upload”); 在每一次上传的时候都操作application对象, request.getSession().getServletContext().setAttribute(“uploadstatus”, “1”); request.getSession().getServletContext().setAttribute(“uploadstatus”, “0”); ===================================================================================== 想让OTT服务配置项的一个input输入框变得灰色,且不可编辑,不可选中,加如下样式 readonly=”true” style=”cursor: not-allowed;background-color: #eee;opacity: 1” ===================================================================================== isLocked()是ReentrantLock类的功能,可以实现对同一个代码段进行加锁。 在一个action类里面定义private static ReentrantLock lock = new ReentrantLock(); 在要执行操作的代码段前加上lock.lock();执行结束时加上lock().unlock();//注意unlock一般要放在finally中。 其他线程可以通过lock.isLocked()方法来判断是否被锁。 ===================================================================================== CMI_web:中英文界面都有的问题,super账号登陆CMI,对CP账号增加、修改或者删除的URL替换配置进行审核时, 审核人的名称可以修改,建议改成不可以修改审核人 ===================================================================================== 项目部署路径在myeclipse里面可以改,注意cmi连的数据库端口是5516 ===================================================================================== URL替换审批,火狐浏览器不支持function()里面直接调用event,加入function(event)解决 ===================================================================================== CMI ciruitid输入框不能左移 原因是circuitid输入框用了onkeyup事件,作用是不让输入非字母 οnkeyup=”value=value.replace(/[\W|_]/g, ”)” 但是这种方法在chrome下会导致不能左移。 换一种方法: οnkeyup=”cdnreplace(/[^\w]/g,this)” function cdnreplace(regexvalue,obj) { var objvalue = obj.value; if(objvalue.search(regexvalue) != -1) { while(objvalue.search(regexvalue) != -1) { objvalue = objvalue.replace(regexvalue,”); } obj.value = objvalue; } } 成功解决。 ===================================================================================== 文件下载的时候要能够同时锁定文件,之前的方法不可取。 之前的方式是直接通过struts2自带的stream流实现文件的下载。 attachment;filename=”${fileName}” downloadFile package com.zte.anyservice.cmi.frame.action; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import org.apache.struts2.ServletActionContext; import com.zte.anyservice.cmi.common.OperConst; import com.zte.anyservice.os.OsServiceAccess; import com.zte.anyservice.os.operlog.OperResult; import com.zte.anyservice.support.struts.GridActionSupport; public class FileDownloadAction extends GridActionSupport { private int number; private String fileName; private String root = ServletActionContext.getServletContext().getRealPath(“/helpdoc”); private String SUPER_ZH_FILE = “智能加速缓存系统 CMI操作指导(Super用户)中文版.pdf”; private String SUPER_EN_FILE = “Intelligent Accelerate Cache System CMI Manual For Super User.pdf”;//”智能加速缓存系统 CMI操作指导(Super用户)英文版.pdf”; private String CP_ZH_FILE = “智能加速缓存系统 CMI操作指导(CP用户)中文版.pdf”; private String CP_EN_FILE = “Intelligent Accelerate Cache System CMI Manual For CP User.pdf”;//”智能加速缓存系统 CMI操作指导(CP用户)英文版.pdf”; public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public String getFileName() { return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public InputStream getDownloadFile() throws Exception { switch (number) { case 1: this.fileName = SUPER_ZH_FILE; break; case 2: this.fileName = SUPER_EN_FILE; break; case 3: this.fileName = CP_ZH_FILE; break; default: this.fileName = CP_EN_FILE; break; } // this.fileName = new String(this.fileName.getBytes(),”ISO8859-1”); // InputStream is= ServletActionContext.getServletContext().getResourceAsStream(“helpdoc/”+this.fileName); String url = root + File.separator + this.fileName; if(!(new File(url).exists())){ return null; } InputStream is= new FileInputStream(url); String orginFileName = this.fileName; // this.fileName = new String(this.fileName.getBytes(“GBK”),”ISO8859-1”);//防止中文乱码问题 this.fileName = java.net.URLEncoder.encode(this.fileName.replaceAll(” “, “”), “UTF-8”).replaceAll(“%25”, “%”);//防止中文乱码问题 //CMI所有操作都要写入操作日志 String opername = (String)this.getSession().get(“OPERNAME”); OperResult ret = OperResult.SUCCESS;//OperResult ret = OperResult.FAILURE; String message = getOperLogText(“cmi.helpfile.downloadfile”,new String[]{opername,orginFileName}); OsServiceAccess.getInstance().getLogService().writeLog(getSession(), OperConst.OPER_MANUAL, ret, message); return is; } @Override public String execute() throws Exception { return SUCCESS; } } 全部都要换。 ======================================================================================================= 火狐中文名下载乱码的问题: import org.apache.commons.net.util.Base64; 。。。 String agent = (String)request.getHeader(“USER-AGENT”); if(agent != null && agent.toLowerCase().indexOf(“firefox”) > 0) { fileName_convert = “=?UTF-8?B?” + (new String(Base64.encodeBase64(fileName.getBytes(“UTF-8”)))) + “?=”; } else { fileName_convert = URLEncoder.encode(this.fileName.replaceAll(” “, “”), “UTF-8”).replaceAll(“%25”, “%”); } ======================================================================================================= /* * 文件下载 * */ public String downloadFile(){ switch (fileType) { case 1: fileName = SUPER_ZH_FILE;break; case 2: fileName = SUPER_EN_FILE;break; case 3: fileName = CP_ZH_FILE;break; default: fileName = CP_EN_FILE;break; } String fileName_convert = null; FileInputStream is = null; OutputStream out = null; try { lock.lock(); String agent = (String)request.getHeader(“USER-AGENT”); //解决火狐浏览器导出中文名乱码的问题 if(agent != null && agent.toLowerCase().indexOf(“firefox”) > 0) { fileName_convert = “=?UTF-8?B?” + (new String(Base64.encodeBase64(fileName.getBytes(“UTF-8”)))) + “?=”; } else { fileName_convert = URLEncoder.encode(this.fileName.replaceAll(” “, “”), “UTF-8”).replaceAll(“%25”, “%”); } HttpServletResponse response = ServletActionContext.getResponse(); response.setHeader(“Content-Disposition”, “attachment;filename=” + fileName_convert); response.setContentType(“application/pdf”); out = response.getOutputStream(); is= new FileInputStream(new File(root, fileName)); //写文件 int b = 0; byte[] buffer = new byte[512]; while (b != -1){ b = is.read(buffer); out.write(buffer,0,b); }//写文件结束 } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally{ try { if(is != null){ is.close(); } if(out != null){ out.close(); } } catch (IOException e) { e.printStackTrace(); } lock.unlock(); } return NONE; } ====================================================================================================== 12-27 14:07:53:388 F[WebExchangeConfigDao.java] L[66] N[] sql: select itemvalue from zxcdn_iam.t_mgrconfig where 1=1 and itemname = ‘STAT_ACCESS_URL’ and modulename = ‘STAT’ 12-27 14:07:53:391 F[ReportRestClient.java] L[38] I[] REST request url[http://10.46.173.142:8080/logmanagernull] param[{“granularity”:”0”,”starttime”:”20161226160000”,”endtime”:”20161227060640”,”cp”:”qq000000001”,”node”:”qq000000001”,”channel”:”简写名称”,”accelobject”:”bbbb,bbbb,fdaf”}] ====================================================================================================== 对于tableexample的pannel方法, 只要修改umap.ibright.min.css ====================================================================================================== //删除源文件再改名 lock.lock(); File tempFile = new File(root, fileName); if(tempFile.exists()){ tempFile.delete(); } new File(root, “temp”+fileName).renameTo(tempFile); lock.unlock(); ===================================================================================================== 自测UTV IAM: param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”“,”node”:”“,”channel”:”“,”accelobject”:”24,39,62,67,67,67,67,69,68,68,gwwtest,16,17,22,40,41,42,43,44,45,46,47,5,66”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”“,”node”:”“,”channel”:”“,”accelobject”:”24,39,62,67,67,67,67,69,68,68,gwwtest,16,17,22,40,41,42,43,44,45,46,47,5,66”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”02”,”channel”:”beijing”,”accelobject”:”16,17,22,40,41,42,43,44,45,46,47,5,66”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”02”,”channel”:”beijing”,”accelobject”:”16,17,22,40,41,42,43,44,45,46,47,5,66”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”cache170”,”channel”:”entertainment”,”accelobject”:”17,22”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”“,”channel”:”entertainment”,”accelobject”:”17,22,5”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”17,22,5”}] param[{“granularity”:”1”,”starttime”:”20161130160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”16,17,22,40,41,42,43,44,45,46,47,5,66”}] param[{“granularity”:”1”,”starttime”:”20161224160000”,”endtime”:”20161228110314”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”16,17,22,40,41,42,43,44,45,46,47,5,66”}] param[{“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228113243”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”16,17,22,40,41,42,43,44,45,46,47,5,66”}] CMI: {“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228111226”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”5,16,17,22”} {“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228111529”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”5,16,17,22”} {“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228113756”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”16,17”} {“granularity”:”0”,”starttime”:”20161227160000”,”endtime”:”20161228113756”,”cp”:”utv1233”,”node”:”“,”channel”:”“,”accelobject”:”5,16,17,22”} ===================================================================================================== 2017年1月1日,开始智能运维 原来的项目移至crawler目录, “/iam/weightthreshold_query.action”直接404, 改为”${pageContext.request.contextPath}/iam/weightthreshold_query.action”即可。 ===================================================================================================== 重启tomcat之后报错 严重: StandardWrapper.Throwable java.lang.Error: IOException occured when reading ‘D:\Tomcat%206.0\webapps\crawler\WEB-INF\classes\vas-inoc-extensiondesc.xml’ 。。。 Caused by: java.io.FileNotFoundException: D:\Tomcat%206.0\webapps\crawler\WEB-INF\classes\vas-inoc-extensiondesc.xml (系统找不到指定的路径。) 不知道什么原因。 内存溢出 -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m无法启动jvm 改成-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=256m至少可以启动tomcat了 ===================================================================================================== ???String index=CommonUtil.getTableIndex(domain); ===================================================================================================== 昊总使用bootstrap的typeahead方法实现输入字符搜索提示 (“#domain”).typeahead({
items:10,
source: function (query, process) {.post("${pageContext.request.contextPath}/iam/cacheanalyze_queryDomain.action”, {“domain”:query}, function (resp) { process(resp.list); },”json”); } } ); ===================================================================================================== 昊总修改了我的可缓存性分析页面 直接将内容显示判断写在了sql语句里面: SELECT a.domain, ROUND((1-a.t1)*100 ,2) t1 , ROUND(a.s*100 ,2) s , a.port, CASE WHEN ifcontainhttps=1 THEN ‘是’ ELSE ‘否’ END ifcontainhttps, CASE WHEN ifcontainhttps=0 AND PORT=0 THEN ‘可服务’ ELSE ‘不可服务’ END canservice , CASE WHEN ifcontainhttps=0 AND PORT=0 AND t1 FROM zxcdn_spider.t_domainres a LIMIT 0,10 ===================================================================================================== 昊总查询拨测任务信息的sql查询语句 SELECT a.*, (SELECT b.itemvalue FROM zxcdn_iam.t_code b WHERE b.itemkey=a.status AND b.codeid=2018 LIMIT 1)statusname, DATE_FORMAT(a.createtime,’%Y-%m-%d %T’) createtimestr, (SELECT COUNT(1) FROM zxcdn_spider.t_taskurl b,zxcdn_spider.t_seedurl c WHERE b.url=c.url AND b.taskid=a.taskid AND STATUS=’2’ ) finish, (SELECT COUNT(1) FROM zxcdn_spider.t_taskurl b,zxcdn_spider.t_seedurl c WHERE b.url=c.url AND b.taskid=a.taskid ) total FROM zxcdn_spider.t_task a WHERE 1=1 ORDER BY createtime DESC LIMIT 0,10 ===================================================================================================== 删除的时候注意如果批量匹配删除应该是用in DELETE FROM zxcdn_spider.t_seedurl WHERE url IN (SELECT a.url FROM zxcdn_spider.t_taskurl a WHERE a.taskid=10); ===================================================================================================== 任务名称不能以dom开头,可以使用如下代码 if((document.getElementById(“task.name”).value.indexOf(“dom”)==0) || (document.getElementById(“task.name”).value.indexOf(“dpi”)==0)){ $.umapMessager.alert(“”,”爬虫任务名称不能使用dom和dpi开头”); return ; } ===================================================================================================== ********************************************************************************************************* ********************************************************************************************************* ********************************************************************************************************* 建表要合的的代码: 一、zxcdn_iam: 1、修改t_code 见草稿,已问过昊总可以改 同时添加一个状态 INSERT INTO zxcdn_iam.t_code (codeid,itemkey,itemvalue) VALUE (2022,0,’待转换’); INSERT INTO zxcdn_iam.t_code (codeid,itemkey,itemvalue) VALUE (2022,1,’执行中’); INSERT INTO zxcdn_iam.t_code (codeid,itemkey,itemvalue) VALUE (2022,2,’不需转换’); INSERT INTO zxcdn_iam.t_code (codeid,itemkey,itemvalue) VALUE (2022,3,’转换成功’); INSERT INTO zxcdn_iam.t_code (codeid,itemkey,itemvalue) VALUE (2022,4,’部分转换成功’); INSERT INTO zxcdn_iam.t_code (codeid,itemkey,itemvalue) VALUE (2022,5,’转换失败’); 2、修改t_identity 增加数据:t_dpidevice idvalue=0 REPLACE INTO t_identity (tabname,idvalue) VALUE (‘t_dpidevice’,0); 增加数据:t_ptdomain REPLACE INTO t_identity (tabname,idvalue) VALUE (‘t_ptdomain’,0); 增加数据:t_dpitask 增加数据:t_dconvtask 二、zxcdn_spider中: 1、新增t_taskdomain, 建表语句: SELECT ‘create table t_taskdomain’ AS prompt; DROP TABLE IF EXISTS t_taskdomain ; CREATE TABLE t_taskdomain ( taskid INT(11) NOT NULL, domain VARCHAR(200) NOT NULL, url VARCHAR(1024) NOT NULL, wsname VARCHAR(256) NOT NULL, casenum VARCHAR(256) NOT NULL, status int(11) NOT NULL, PRIMARY KEY (taskid,domain) ) ENGINE=INNODB DEFAULT CHARSET=utf8 2、修改t_domainres,增加ifcontainpost,wsname,casenum字段 3、修改t_domainidx_*,增加ifcontainpost字段 ALTER TABLE zxcdn_spider.t_domainidx_1 ADD COLUMN ifcontainpost INT(11) NULL AFTER ifcontainhttps; 4、增加t_dpidevice, 建表语句: SELECT ‘create table t_dpidevice’ AS prompt; DROP TABLE IF EXISTS t_dpidevice ; CREATE TABLE t_dpidevice ( deviceid INT(11) NOT NULL, devicename INT(11) NOT NULL, ip VARCHAR(50) NOT NULL, capturenet VARCHAR(20) NOT NULL, PRIMARY KEY (deviceid) ) ENGINE=INNODB DEFAULT CHARSET=utf8 5、增加t_comconf 建表语句: SELECT ‘create table t_comconf’ AS prompt; DROP TABLE IF EXISTS t_comconf ; CREATE TABLE t_comconf ( taskdepth INT(11) default ‘3’ NOT NULL, leastpagenum int(11) default ‘3’ not null ) ENGINE=INNODB DEFAULT CHARSET=utf8 6、增加t_ptdomain 建表语句: SELECT ‘create table t_ptdomain’ AS prompt; DROP TABLE IF EXISTS t_ptdomain ; CREATE TABLE t_ptdomain ( domain VARCHAR(200) NOT NULL, matchtype INT(11) NOT NULL, addtype INT(11) DEFAULT ‘1’ NOT NULL, PRIMARY KEY (domain) ) 7、增加t_dconvtask DROP TABLE IF EXISTS t_dconvtask ; CREATE TABLE t_dconvtask ( taskid INT(11) NOT NULL, NAME VARCHAR(256) NOT NULL, number VARCHAR(64) NOT NULL, createtime DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, STATUS FLOAT NOT NULL, urlnumber VARCHAR(64) NULL, PRIMARY KEY (taskid) ) 三、去掉爬虫的代理 四、权重阈值配置和通用配置管理的表要初始化值 ********************************************************************************************************* ********************************************************************************************************* ********************************************************************************************************* ===================================================================================================== 修改可缓存分析的查询语句 增加ifcontainpost和wsname字段的查询,修改可服务和可缓存的判断条件, SELECT a.domain, ROUND((1-a.t1)*100 ,2) t1 , ROUND(a.s*100 ,2) s , a.port, CASE WHEN ifcontainpost=1 THEN ‘是’ ELSE ‘否’ END ifcontainpost, CASE WHEN ifcontainhttps=1 THEN ‘是’ ELSE ‘否’ END ifcontainhttps, CASE WHEN ifcontainhttps=0 AND ifcontainpost=0 AND PORT=0 THEN ‘可服务’ ELSE ‘不可服务’ END canservice , CASE WHEN ifcontainhttps=0 AND ifcontainpost=0 AND PORT=0 AND t1 FROM zxcdn_spider.t_domainres a LIMIT 0,10 ===================================================================================================== 从A可缓存性分析页面跳转到B域名资源分析页面,现在增加从B域名资源分析页面返回到A可缓存性分析页面 使用,在B域名资源分析页面添加函数: function resAnalyze(domain){ var domain = form1.domain.value; if(domain==”“){ .umapMessager.alert(“”,””,”info”);
return ;
}
window.location=”{pageContext.request.contextPath}/iam/cacheadvice_init.action?domain=” + domain; } A可缓存性分析页面需要注意的是: 用 代替原来的 , 否则跳过来的页面不带domain信息。 ===================================================================================================== 如果在输入框只输入部分字符就给提示: 引入 添加js代码: (“#domain”).typeahead({
items:10,
source: function (query, process) {.post("${pageContext.request.contextPath}/iam/cacheanalyze_queryDomain.action”, {“domain”:query}, function (resp) { process(resp.list); },”json”); } }); 需要action类提供支持: public String queryDomain() { List domainList = cacheAnalyzeService.queryDomain(domain); JSONObject obj = new JSONObject(); obj.put(“list”, domainList); CommonUtil.writeoutJSONObject(obj); return NONE; } 对应dao类: public List queryDomain(String domain){ String sql=”select domain from zxcdn_spider.t_domainres where domain like ? limit 10”; return jdbcTemplate.queryForList(sql, String.class, new Object[]{ “%”+domain+”%”}); } ===================================================================================================== UTV报表频道channel取的有问题,师傅的备份方法 2017-01-05 15:27:51*[李青川10117882]说: _utv_channel SET fieldname = channelnum; 2017-01-05 15:27:51*[李青川10117882]说: CREATE TABLE t_utv_channel_3141 SELECT * FROM t_utv_channel; UPDATE t ===================================================================================================== 分析结果至t_domainres 昊总原来的代码: replace into zxcdn_spider.t_domainres( domain ,cp,status, totalcount,t1,t2,t3,t4,t5 ,s, result , lasttime,port,ifcontainhttps) select ?’domain’,null , ‘4’ , b.total, b.t1/b.total,b.t2/staticount,b.t3/b.staticount,b.t4/b.staticount ,b.t5/b.staticount , null,null,now(),?’port’,?’ifcontainhttps’ from (select count(1) total ,sum(case when ifstatic =0 then 1 else 0 end ) t1 , sum(ifstatic) staticount , sum(case when ifcachecode=1 and ifstatic=1 then 1 else 0 end ) t2 , sum( case when ifstaticcache =0 and ifstatic=1 then 1 else 0 end )t3, sum(case when ( contentlength >= ?’Fmax’ or contentlength
}
增加延迟启动,可以直接在数据库里面操作时间延迟
REPLACE INTO zxcdn_spider.t_dpitask (taskid,deviceid,duration,top,STATUS,createtime,starttime)
VALUE (‘16’,’1’,’180’,’3000’,’1’,NOW(),DATE_ADD(NOW(), INTERVAL 120 MINUTE))
四舍五入函数
SELECT duration ,ROUND(duration/60) FROM zxcdn_spider.t_dpitask
自己写的用get方法请求的测试方法
package Amazn;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
public class Main {
private static String HTTPURL = "http://icp.chinaz.com";
// private static String HTTPURL = “http://it.zte.com.cn“;
// private static String HTTPURL = “http://www.163.com/“;
//http://it.zte.com.cn:8080/its/app/articlePub/RkmArticlePub/getOneClass.action?type=searchJsp&searchValue=google
public static void main(String[] args) {
System.out.println("=============爬虫开始=============");
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
// HttpClient httpClient = new DefaultHttpClient();
HttpGet httpRequest = new HttpGet(HTTPURL);
HttpResponse response = null;
//设置代理(可选)
HttpHost proxy = new HttpHost(“proxysz.zte.com.cn”, 80, “http”);
//超时设置
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000)
.setSocketTimeout(50000)//setSocketTimeout()设置的太小可能会出现Read timed out超时异常
.setProxy(proxy).build();
httpRequest.setConfig(requestConfig);
try {
response = httpClient.execute(httpRequest);
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
//获取响应实体
HttpEntity entity = response.getEntity();
//获取响应的body部分
String strResult = EntityUtils.toString(entity);
System.out.println("body:"+strResult);
//获取响应的媒体类型
String contentMimeType = ContentType.getOrDefault(entity).getMimeType();
System.out.println("MimeType:"+contentMimeType);
}else{
System.out.println("请求错误!");
}
} catch (Exception e) {
e.printStackTrace();
} finally{
httpClient.getConnectionManager().shutdown();
}
}
}
=====================================================================================================
有待改进的post方法请求
private static String HTTPURL = “http://icp.chinaz.com/searchs“;
public static String CONTENT_ENCODE = “UTF-8”;
public static void main(String[] args) {
System.out.println(“=============爬虫开始=============”);
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost(HTTPURL);
CloseableHttpResponse response = null;
//设置代理(可选)
HttpHost proxy = new HttpHost(“proxysz.zte.com.cn”, 80, “http”);
//超时设置
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000)
.setSocketTimeout(50000)//setSocketTimeout()设置的太小可能会出现Read timed out超时异常
.setProxy(proxy).build();
httpPost.setConfig(requestConfig);
//设置请求头
httpPost.setHeader(“Content-Type”, “application/x-www-form-urlencoded”);
List params = new ArrayList();
params.add(new BasicNameValuePair(“urls”, “163.com”+”\r\n”+”youkuaiyun.com”));
params.add(new BasicNameValuePair(“btn_search”, “查询”));
try {
//添加参数
httpPost.setEntity(new UrlEncodedFormEntity(params,CONTENT_ENCODE));
//发送post请求
System.out.println(“发送post请求:” + httpPost.getURI());
response = httpClient.execute(httpPost);
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
//获取响应实体
HttpEntity entity = response.getEntity();
//获取响应的body部分
System.out.println(“————————————————–”);
String html = EntityUtils.toString(entity);
System.out.println(“body:”+html);
System.out.println(“————————————————–”);
//获取响应的媒体类型
String contentMimeType = ContentType.getOrDefault(entity).getMimeType();
System.out.println(“MimeType:”+contentMimeType);//MimeType:text/html
}else{
System.out.println(“请求错误!”);
}
} catch (Exception e) {
e.printStackTrace();
} finally{
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
=====================================================================================================
INSERT INTO zxcdn_spider.t_domaininfo(domain) SELECT ‘sohu.com’ FROM DUAL WHERE NOT EXISTS(SELECT domain FROM zxcdn_spider.t_domaininfo WHERE domain=’sohu.com’);
插入前检测重复字段,如果有就不插入,区别于replace into是覆盖式替换
可缓存分析页面的导出文件加了等待提示
这是原来的代码,备份一下
/*可缓存性分析-导出结果
* 分普通查询导出和高级查询导出两种方式
* */
public String exportDomainRes(){
boolean queryFlag;
if(StringUtils.isEmpty(domainList)){
queryFlag = true;//普通查询
}else{
queryFlag = false;//高级查询
}
int pageSize=4000;
SXSSFWorkbook wb = new SXSSFWorkbook();
Sheet sheet = wb.createSheet();
Row head = sheet.createRow(0);
head.createCell(0).setCellValue(getText(“iam.nodereport.domain”));
head.createCell(1).setCellValue(getText(“iam.analyze.staticproportion”));
head.createCell(2).setCellValue(“HTTPS”);
head.createCell(3).setCellValue(getText(“iam.analyze.cacheproportion”));
head.createCell(4).setCellValue(getText(“iam.analyze.port”));
head.createCell(5).setCellValue(getText(“iam.analyze.serveable”));
head.createCell(6).setCellValue(getText(“iam.analyze.cacheadvice”));
head.createCell(7).setCellValue(“站点名称”);
head.createCell(8).setCellValue(“备案号”);
head.createCell(9).setCellValue(getText(“iam.please.explanation”));
int j=1;
List
HttpServletResponse response = ServletActionContext.getResponse();
response.addHeader("Content-Disposition", "attachment;filename=" +"report.xlsx");
response.setContentType("application/octet-stream");
try {
wb.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
return NONE;
}
/*可缓存性分析-导出原始数据
* */
public String exportDomainResOriginal(){
int pageSize=4000;
SXSSFWorkbook wb = new SXSSFWorkbook();
Sheet sheet = wb.createSheet();
Row head = sheet.createRow(0);
head.createCell(0).setCellValue(“domain”);
head.createCell(1).setCellValue(“cp”);
head.createCell(2).setCellValue(“status”);
head.createCell(3).setCellValue(“totalcount”);
head.createCell(4).setCellValue(“t1”);
head.createCell(5).setCellValue(“t2”);
head.createCell(6).setCellValue(“t3”);
head.createCell(7).setCellValue(“t4”);
head.createCell(8).setCellValue(“t5”);
head.createCell(9).setCellValue(“s”);
head.createCell(10).setCellValue(“result”);
head.createCell(11).setCellValue(“port”);
head.createCell(12).setCellValue(“ifcontaihttps”);
head.createCell(13).setCellValue(“lasttime”);
head.createCell(14).setCellValue(“ifcontainpost”);
head.createCell(15).setCellValue(“wsname”);
head.createCell(16).setCellValue(“casenum”);
int j=1;
for (int i = 0;; i++) {
List
HttpServletResponse response = ServletActionContext.getResponse();
response.addHeader("Content-Disposition", "attachment;filename=" +"reportOriginal.xlsx");
response.setContentType("application/octet-stream");
try {
wb.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
return NONE;
}
导出excel添加页面变灰等待提示
function exportOriginExcel(){
//if((‘#exportForm’).length<=0){
//var exportForm = ‘‘;
//exportForm+=’‘;
//$(‘body’).append(exportForm);
//}
//varform = (‘#exportForm’).attr(‘action’, ‘{pageContext.request.contextPath}/iam/cacheanalyze_exportDomainResOriginal.action’);
//form.get(0).submit();
layer.load(2,{
shade: [0.2, ‘#000’] //打开load,设置0.5透明度的白色背景
});.ajax({
“type”: “post”,
“url”: “{pageContext.request.contextPath}/iam/cacheanalyze_prepareExportDomainResOriginal.action?t=” + (new Date()).valueOf(),
“dataType”: “json”,
“data”: {},
“success”: function(resp){
layer.closeAll();//关闭load
if(resp.result == 0){//文件准备完成即下载
window.location.href=”{pageContext.request.contextPath}/cacheDoc/reportOriginal.xlsx”;
}else{//文件不存在
$.umapMessager.alert(“”,””);
}
}
});
}
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================
=====================================================================================================