Commit d16b3545 authored by 莫林毅's avatar 莫林毅

监控运营 /协查单管理 /定制分析

新增 '定制分析'界面
parent 53f3bc53
......@@ -1484,174 +1484,32 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: p6spy:p6spy:1.3" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.xfire:xfire-xmpp:1.2.6" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.xfire:xfire-aegis:1.2.6" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.xfire:xfire-core:1.2.6" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: javax.mail:mail:1.4" level="project" />
<orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: jaxen:jaxen:1.1-beta-9" level="project" />
<orderEntry type="library" name="Maven: xerces:xmlParserAPIs:2.6.2" level="project" />
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.ws.commons:XmlSchema:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.woodstox:wstx-asl:3.2.0" level="project" />
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.0" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.stax-utils:stax-utils:20040917" level="project" />
<orderEntry type="library" name="Maven: jivesoftware:smackx:1.5.0" level="project" />
<orderEntry type="library" name="Maven: jivesoftware:smack:1.5.0" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.2" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: org.docx4j:docx4j:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.plutext:jaxb-svg11:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.plutext:jaxb-xslfo:1.0.1" level="project" />
<orderEntry type="library" name="Maven: org.plutext:jaxb-xmldsig-core:1.0.0" level="project" />
<orderEntry type="library" name="Maven: net.engio:mbassador:1.1.10" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:xmlgraphics-commons:1.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:fop:1.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-svg-dom:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-anim:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-css:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-dom:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-parser:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-util:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-bridge:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-script:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-js:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-xml:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-awt-util:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-gvt:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-transcoder:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-svggen:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-extension:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-ext:1.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.avalon.framework:avalon-framework-api:4.3.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.avalon.framework:avalon-framework-impl:4.3.1" level="project" />
<orderEntry type="library" name="Maven: xalan:xalan:2.7.1" level="project" />
<orderEntry type="library" name="Maven: xalan:serializer:2.7.1" level="project" />
<orderEntry type="library" name="Maven: net.arnx:wmf2svg:0.9.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-scratchpad:3.8" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.3" level="project" />
<orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.10-FINAL" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.10-FINAL" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.3.0" level="project" />
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.10-FINAL" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:itextpdf:5.5.6" level="project" />
<orderEntry type="library" name="Maven: r:REngine:1.1.0" level="project" />
<orderEntry type="library" name="Maven: r:Rserve:1.1.0" level="project" />
<orderEntry type="library" name="Maven: r:Rsession:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache:elasticsearch:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-analyzers-common:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-core:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-highlighter:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-join:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-queries:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-queryparser:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:lucene-sandbox:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache:elasticsearch-mapper-attachments:2.0.0" level="project" />
<orderEntry type="library" name="Maven: org.springside:springside-core:4.1.0.GA" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.7.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.aspectj:aspectjweaver:1.7.3" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:4.2.3.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.0.GA" level="project" />
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.2.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.15.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.2.3.Final" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:axis:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:activation:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:axis-ant:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:axis-schema:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:commons-discovery-0.2:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:commons-logging-1.0.4:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:jaxrpc:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:mailapi:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:saaj:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:wsdl4j-1.5.1:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.hp.service:xmlsec-1.3.0:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:1.3.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.5.1.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:3.2.3.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.tomcat:tomcat-jdbc:7.0.42" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.tomcat:tomcat-juli:7.0.42" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.hp:vertica:7.0.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:3.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:3.2.3.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: opensymphony:sitemesh:2.4.2" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:jstl:1.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-spring:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-core:1.2.2" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-web:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-ehcache:1.2.2" level="project" />
<orderEntry type="library" name="Maven: net.sf.ehcache:ehcache-core:2.6.6" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.8" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:4.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.0.0.GA" level="project" />
<orderEntry type="library" name="Maven: com.google:gson:2.2.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.1.5" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.1.5" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.1.5" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.1.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: ch.qos.logback:logback-classic:1.0.13" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: ch.qos.logback:logback-core:1.0.13" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:log4j-over-slf4j:1.7.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:jcl-over-slf4j:1.7.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:jul-to-slf4j:1.7.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:1.15" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:14.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springside:springside-test:4.1.0.GA" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.9.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:3.2.3.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-java:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-chrome-driver:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-firefox-driver:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-ie-driver:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-support:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.webbitserver:webbit:0.4.14" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: io.netty:netty:3.5.2.Final" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-remote-driver:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.json:json:20080701" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.seleniumhq.selenium:selenium-api:2.33.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.httpcomponents:httpclient:4.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.httpcomponents:httpcore:4.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.commons:commons-exec:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.java.dev.jna:jna:3.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.java.dev.jna:platform:3.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.h2database:h2:1.3.172" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.aggregate:jetty-webapp:7.6.11.v20130520" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:javax.servlet:2.5.0.v201103041518" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty:jetty-jsp:7.6.11.v20130520" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:javax.servlet.jsp:2.1.0.v201105211820" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:org.apache.jasper.glassfish:2.1.0.v201110031002" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:javax.servlet.jsp.jstl:1.2.0.v201105211821" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:org.apache.taglibs.standard.glassfish:1.2.0.v201112081803" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:javax.el:2.1.0.v201105211819" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:com.sun.el:1.0.0.v201105211818" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.eclipse.jetty.orbit:org.eclipse.jdt.core:3.7.1" level="project" />
<orderEntry type="library" name="Maven: commons-net:commons-net:3.1" level="project" />
<orderEntry type="library" name="Maven: sun.misc:BASE64Decoder:1.0" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Program Files/R/R-3.5.0/library/Rserve/java/REngine.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Program Files/R/R-3.5.0/library/Rserve/java/Rserve.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="/file">
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="file://E:/ftp1" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
package com.hp.cmsz.service.monitoroperation;
import com.hp.cmsz.entity.Business;
import com.hp.cmsz.entity.DimKpi;
import com.hp.cmsz.repository.BusinessDao;
import com.hp.cmsz.repository.ChannelDataSourceMapDao;
import com.hp.cmsz.repository.DimKpiDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @编写人: m01
* @创建时间: 2018/5/10 0010 上午 9:21
* @描述:
* @备注:
**/
@Service(value ="workingOrderCustomAnalysisService" )
@Transactional
public class WorkingOrderCustomAnalysisService {
@Autowired
private ChannelDataSourceMapDao channelDataSourceMapDao;
@Autowired
private DimKpiDao dimKpiDao;
@Autowired
private BusinessDao businessDao;
public List<Long> findChannelDataSourceMapIdListByChannelIdListAndDataSourceIdList(List<Long> dataSourceList, List<Long> channelList) {
List<Long> longList = new ArrayList<Long>();
List<Object> objectList = channelDataSourceMapDao.findChannelDataSourceMapIdByChannelIdListAndDataSourceIdList(dataSourceList, channelList);
if (objectList == null || objectList.size() < 1) {
return longList;
} else {
for (Object o : objectList) {
longList.add((Long) o);
}
}
return longList;
}
public List<Business> findBusinessListBychannelDataSourceMapIdListAndIsActived(List<Long> channelDataSourceMapIdList, String isActived) {
List<Object[]>list=businessDao.findBusinessListBychannelDataSourceMapIdListAndIsActived2(channelDataSourceMapIdList, isActived);
List<Business>list1=new ArrayList<Business>();
for (Object[] objects : list) {
Business business=new Business();
System.out.println("=========");
System.out.println(objects[0]);
System.out.println("=========");
business.setBusinessId(new BigInteger(objects[0].toString()).longValue());
business.setBusinessName(objects[1].toString());
list1.add(business);
}
return list1;
}
public List<Map<String,Object>> findDimKpiListBybusnameIdList(List<Long> busnameIdList,String isActive) {
List<Object[]>list= dimKpiDao.findDimKpiListBybusnameIdList2(busnameIdList,isActive);
List<Map<String,Object>>list1=new ArrayList<Map<String, Object>>();
for (Object[] objects : list) {
Map<String,Object>map=new HashMap<String,Object>();
map.put("kpiName",objects[0]);
map.put("kpiId",objects[1]);
list1.add(map);
}
return list1;
}
}
package com.hp.cmsz.web.monitoroperation;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hp.cmsz.entity.*;
import com.hp.cmsz.repository.ChannelDao;
import com.hp.cmsz.repository.DataSourceDao;
import com.hp.cmsz.repository.ProvinceDao;
import com.hp.cmsz.service.BusinessService;
import com.hp.cmsz.service.ChannelService;
import com.hp.cmsz.service.DataSourceService;
import com.hp.cmsz.service.ProvinceService;
import com.hp.cmsz.service.monitoroperation.WorkingOrderCustomAnalysisService;
import com.hp.cmsz.web.PageURLController;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Font;
import org.jfree.util.HashNMap;
import org.rosuda.REngine.RList;
import org.rosuda.REngine.Rserve.RConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.*;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* @编写人: m01
* @创建时间: 2018/5/8 0008 下午 3:37
* @描述: 定制分析 界面
* @备注:
**/
@Controller
@RequestMapping(value = "/MonitorOperation/CustomAnalysis")
public class WorkingOrderCustomAnalysisController {
private final static String BASEPICURL = "/image/";
private final static String BASEPICURL_LINUX = "/home/rprog/R/timebyselect/";
private final static String BASEDATAURL = "/image/";
private final static String BASEDATAURL_LINUX = "/home/rprog/R/timebyselect/";
private final static String RSHELLPATH = "/image/";
private final static String RESULTCSVFILEPATH = "/home/rprog/R/timebyselect/result.csv";
@Autowired
private ProvinceService provinceService;
@Autowired
private DataSourceService dataSourceService;
@Autowired
private ChannelService channelService;
@Autowired
private BusinessService businessService;
@Autowired
private WorkingOrderCustomAnalysisService workingOrderCustomAnalysisService;
@RequestMapping(method = RequestMethod.GET)
public String index(Map map) {
/**
*@编写人: m01
*@编写时间: 2018/5/8 0008 下午 3:46
*@描述: 定制分析 默认界面
*@参数: []
*@参数类型:
*@参数描述:
*@返回值:
*@返回类型:
*@返回值描述:
*@修改人: 暂无
*@修改时间: 2018/5/8 0008 下午 3:46
*@备注:
**/
List<Province> provinceList = provinceService.getProvinceList();
List<DataSource> dataSourceList = dataSourceService.getAllDataSources();
List<Channel> channelList = channelService.getAllChannels();
List<Business> businessList = businessService.getAllBusiness();
map.put("provinceList", provinceList);
map.put("datasourceList", dataSourceList);
map.put("channelList", channelList);
map.put("businessList", businessList);
return PageURLController.CustomAnalysis;
}
private static void writeDataToFile(String data, String fileName) {
System.out.println("写数据 " + data + " 到文件 " + fileName);
File file = new File(fileName);
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(file);
outputStream.write(data.getBytes());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
private static void writeDataToCSV(String data, String filename) {
File file = new File(filename);
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(file, false));
writer.write(data);
writer.newLine();
writer.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (Exception e) {
}
}
}
}
@RequestMapping(value = "/submit/{timzStr}/{provinceStr}/{kpiStr}", method = RequestMethod.GET)
@ResponseBody
public List<Map<String, String>> submit(@PathVariable(value = "timzStr") String timzStr,
@PathVariable(value = "provinceStr") String provinceStr,
@PathVariable(value = "kpiStr") String kpiStr
) {
/**
*@编写人: m01
*@编写时间: 2018/5/9 0009 上午 9:09
*@描述: 处理 带参请求
*@参数: []
*@参数类型:
*@参数描述:
*@返回值:
*@返回类型:
*@返回值描述:
*@修改人: 暂无
*@修改时间: 2018/5/9 0009 上午 9:09
*@备注:
**/
System.out.println("timzStr = " + timzStr);
System.out.println("provinceStr = " + provinceStr);
System.out.println("kpiStr = " + kpiStr);
String params = timzStr + "|" + provinceStr + "|" + kpiStr;
System.out.println(params);
String[] timzArr = timzStr.split("&");
// String[] kpiArr=kpiStr.split(",");
// 写数据到文件
String data = kpiStr + "/n" + provinceStr + " /n" + timzArr[0] + "/n" + timzArr[1];
String fileName = BASEPICURL_LINUX + "arg.txt";
System.out.println("开始写文件!");
// writeDataToFile(data, fileName);
data = "\"" + kpiStr + "\"" + "," + "\"" + provinceStr + "\"" + "," + "\"" + timzArr[0] + "\"" + "," + "\"" + timzArr[1] + "\"";
fileName = BASEPICURL_LINUX + "arg.csv";
writeDataToCSV(data, fileName);
System.out.println("写文件成功!");
//执行 R脚本
// String rShell = " Rscript /home/rprog/R/timebyselect/ForecastByTime.r " + kpiStr + " " + provinceStr + " " + "'" + timzArr[0] + "'" + " " + "'" + timzArr[1] + "'" + " >> /home/mly.log ";
String rShell = " Rscript /home/rprog/R/timebyselect/ForecastByTime.r ";
System.out.println("rShell " + rShell);
// String rResult = runR(rShell);
String result = null;
StringBuffer sb = new StringBuffer();
BufferedInputStream in = null;
BufferedReader br = null;
Process p = null;
try {
p = Runtime.getRuntime().exec(rShell);
in = new BufferedInputStream(p.getInputStream());
br = new BufferedReader(new InputStreamReader(in));
String line = "";
while ((line = br.readLine()) != null) {
sb.append(line);
}
result = sb.toString();
p.waitFor();
} catch (Exception e) {
result = null;
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (br != null) {
try {
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (p != null) {
p.destroy();
}
}
System.out.println(" R脚本 返回结果 === " + result);
//读取 result文件
String resultCSVFile = RESULTCSVFILEPATH;// "E:/url.csv";
List<Map<String, String>> list1 = readResultCsv(resultCSVFile);
System.out.println(list1.size());
for (Map<String, String> map : list1) {
Set<String> key = map.keySet();
Iterator<String> it = key.iterator();
while (it.hasNext()) {
String keyV = it.next();
System.out.println(keyV + " --- " + map.get(keyV));
}
}
return list1;
}
@RequestMapping(value = "/getPicById/{id}", method = RequestMethod.GET)
public void getPicById(@PathVariable(value = "id") String id,
HttpServletRequest request,
HttpServletResponse response) {
/**
*@编写人: m01
*@编写时间: 2018/5/8 0008 下午 7:38
*@描述: 根据图片编号 返回图片给页面
*@参数: [id, request, response]
*@参数类型:
*@参数描述:
*@返回值:
*@返回类型:
*@返回值描述:
*@修改人: 暂无
*@修改时间: 2018/5/8 0008 下午 7:38
*@备注:
**/
try {
byte[] picData = getPicData(id);//图片数据
response.setContentType("img/jpeg");
response.setCharacterEncoding("utf-8");
OutputStream out = response.getOutputStream();
InputStream input = new ByteArrayInputStream(picData);
int len = 0;
byte[] buf = new byte[1024];
while ((len = input.read(buf, 0, 1024)) != -1) {
out.write(buf, 0, len);
}
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void outputExcel(HSSFWorkbook wb, HttpServletResponse response, String fileName) {
System.out.println("// 下载文件时要设置的头信息");
// 下载文件时要设置的头信息
/*response.setHeader("Content-Disposition", "attachment;fileName="
+ fileName + ".xls");*/
//中文乱码
System.out.println("fileName === " + fileName);
try {
fileName = new String(fileName.getBytes("gb2312"), "ISO-8859-1");
} catch (Exception e) {
e.printStackTrace();
}
response.setHeader("Content-Disposition", "attachment;fileName="
+ fileName + ".xls");
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
wb.write(os);
} catch (IOException e) {
e.printStackTrace();
}
byte[] content = os.toByteArray();
OutputStream ops = null;
try {
ops = response.getOutputStream();// 用于下载的输出流
ops.write(content);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
ops.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
// 下载1 excel
@RequestMapping(value = "/downloadData1", method = RequestMethod.POST)
public void downloadData1(@RequestParam(value = "excelName") String excelName,
@RequestParam(value = "fileStr") String fileStr,
HttpServletRequest request,
HttpServletResponse response) throws IOException {
System.out.println("excelName ==== " + excelName);//
System.out.println("fileStr == " + fileStr);
fileStr = fileStr.replaceAll("\\|", "/");
System.out.println("fileStr ==" + fileStr);
//fileStr=fileName&图片地址@fileName&图片地址...
HSSFWorkbook workbook = excelCreate(fileStr.split("@"));
outputExcel(workbook, response, excelName);
/*
File file = new File(excelName);
FileOutputStream fileOutputStream = new FileOutputStream(file);
workbook.write(fileOutputStream);
byte[] body = null;
fileOutputStream.flush();
fileOutputStream.close();
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + excelName);
long downloadedLength = 0l;
InputStream inputStream =null;
try {
//打开本地文件流
inputStream = new FileInputStream(file);
//激活下载操作
OutputStream os = response.getOutputStream();
//循环写入输出流
byte[] b = new byte[2048];
int length;
while ((length = inputStream.read(b)) > 0) {
os.write(b, 0, length);
downloadedLength += b.length;
}
// 这里主要关闭。
os.close();
inputStream.close();
} catch (Exception e){
e.printStackTrace();
}finally {
if(inputStream!=null){
inputStream.close();
}
}
file.delete();
System.out.println("download File is ok");*/
}
// 下载 excel
@RequestMapping(value = "/downloadData/{excelName}/{fileStr:.+}", method = RequestMethod.GET)
public ResponseEntity<byte[]> downloadData(@PathVariable(value = "excelName") String excelName,
@PathVariable(value = "fileStr") String fileStr,
HttpServletRequest request) throws IOException {
System.out.println("excelName " + excelName);//
System.out.println("fileStr " + fileStr);
fileStr = fileStr.replaceAll("\\|", "/");
System.out.println("fileStr ==" + fileStr);
//fileStr=fileName&图片地址@fileName&图片地址...
HSSFWorkbook workbook = excelCreate(fileStr.split("@"));
File file = new File(excelName);
FileOutputStream fileOutputStream = new FileOutputStream(file);
workbook.write(fileOutputStream);
byte[] body = null;
fileOutputStream.flush();
fileOutputStream.close();
InputStream inputStream = new FileInputStream(file);
body = new byte[inputStream.available()];
inputStream.read(body);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Content-Disposition", "attchement;filename=" + file.getName());
HttpStatus status = HttpStatus.OK;
ResponseEntity<byte[]> entity = new ResponseEntity<byte[]>(body, httpHeaders, status);
inputStream.close();
file.delete();
System.out.println(excelName + " 文件已生成");
return entity;
}
//执行R脚本
private final static String runR(final String rPath) {
/**
*@编写人: m01
*@编写时间: 2018/5/8 0008 下午 7:42
*@描述: 执行R脚本 获取返回执行结果
*@参数: [rPath]
*@参数类型:
*@参数描述:
*@返回值:
*@返回类型:
*@返回值描述:
*@修改人: 暂无
*@修改时间: 2018/5/8 0008 下午 7:42
*@备注:
**/
String result = null;
/*try {
RConnection r = new RConnection("hg-computer");
String str = r.eval("R.version.string").asString();
RList l = r.eval("").asList();
System.out.println(str);
} catch (Exception e) {
e.printStackTrace();
}*/
StringBuffer sb = new StringBuffer();
BufferedInputStream in = null;
BufferedReader br = null;
Process p = null;
try {
p = Runtime.getRuntime().exec(rPath);
in = new BufferedInputStream(p.getInputStream());
br = new BufferedReader(new InputStreamReader(in));
String line = "";
while ((line = br.readLine()) != null) {
sb.append(line);
}
result = sb.toString();
p.waitFor();
} catch (Exception e) {
result = null;
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (br != null) {
try {
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (p != null) {
p.destroy();
}
}
System.out.println("result " + result);
return result;
}
@RequestMapping(value = {"/getBusinessByChannelIdListAndDataSourceIdList/{dataSourceId}/{channelId}"},
method = RequestMethod.GET)
@ResponseBody
public List<Business> getBusinessByChannelIdListAndDataSourceIdList
(@PathVariable("dataSourceId") String dataSourceIdList,
@PathVariable("channelId") String channelIdList) {
System.out.println("dataSourceIdList =" + dataSourceIdList);
System.out.println("channelIdList =" + channelIdList);
List<Business> businessList = new ArrayList<Business>();
if ("".equals(dataSourceIdList.trim()) || "".equals(channelIdList.trim())) {
return businessList;
}
String[] arrdataSourceId = dataSourceIdList.split("-");
String[] arrchannelId = channelIdList.split("-");
List<Long> dataSourceList = new CopyOnWriteArrayList<Long>();
List<Long> channelList = new CopyOnWriteArrayList<Long>();
for (int i = 0; i < arrdataSourceId.length; i++) {
dataSourceList.add(Long.parseLong(arrdataSourceId[i]));
}
for (int i = 0; i < arrchannelId.length; i++) {
channelList.add(Long.parseLong(arrchannelId[i]));
}
List<Long> channelDataSourceMapIdList = workingOrderCustomAnalysisService.
findChannelDataSourceMapIdListByChannelIdListAndDataSourceIdList(dataSourceList, channelList);
if (channelDataSourceMapIdList == null || channelDataSourceMapIdList.size() < 1) {
return businessList;
}
businessList = workingOrderCustomAnalysisService.
findBusinessListBychannelDataSourceMapIdListAndIsActived(channelDataSourceMapIdList, "Y");
return businessList;
}
@RequestMapping("/getDimKpiListByBusinessIdList/{businessIdList}")
@ResponseBody
public List<Map<String, Object>> getDimKpiListByBusinessIdList(
@PathVariable(value = "businessIdList") String businessIdList
) {
System.out.println("businessIdList =" + businessIdList);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String str = "";
if ("".equalsIgnoreCase(businessIdList)) {
return list;
}
String[] businessIdarr = businessIdList.split("-");
List<Long> businessIdlist = new CopyOnWriteArrayList<Long>();
for (int i = 0; i < businessIdarr.length; i++) {
businessIdlist.add(Long.parseLong(businessIdarr[i]));
}
list = workingOrderCustomAnalysisService.findDimKpiListBybusnameIdList(businessIdlist, "Y");
return list;
}
private static byte[] getPicData(final String picPath) throws Exception {
/**
*@编写人: m01
*@编写时间: 2018/5/8 0008 下午 7:38
*@描述: 图片转 byte[]
*@参数: [picPath]
*@参数类型:
*@参数描述:
*@返回值:
*@返回类型:
*@返回值描述:
*@修改人: 暂无
*@修改时间: 2018/5/8 0008 下午 7:38
*@备注:
**/
File f = new File(picPath);
if (!f.exists()) {
throw new FileNotFoundException(picPath);
}
FileChannel channel = null;
FileInputStream fs = null;
try {
fs = new FileInputStream(f);
channel = fs.getChannel();
ByteBuffer byteBuffer = ByteBuffer.allocate((int) channel.size());
return byteBuffer.array();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
try {
channel.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
fs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
//
private static HSSFWorkbook excelCreate(String[] files) {
HSSFWorkbook workbook = new HSSFWorkbook();
//设置字体
Font headFont = workbook.createFont();
headFont.setFontName("黑体");
headFont.setFontHeightInPoints((short) 9);
headFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
CellStyle headStyle = workbook.createCellStyle();
headStyle.setFillBackgroundColor(
HSSFColor.YELLOW.index);
headStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headStyle.setFont(headFont);
headStyle.setAlignment(CellStyle.ALIGN_CENTER);
headStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
headStyle.setWrapText(true);
headStyle.setBorderRight(CellStyle.BORDER_THIN);
headStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
headStyle.setFillForegroundColor(HSSFColor.LEMON_CHIFFON.index);
headStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
headStyle.setBorderBottom(CellStyle.BORDER_THIN);
headStyle.setBorderRight(CellStyle.BORDER_THIN);
headStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
headStyle.setBorderTop(CellStyle.BORDER_THIN);
headStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.LEMON_CHIFFON.index);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
for (int i = 0; i < files.length; i++) {
String[] shellNameAndData = files[i].split("_");
HSSFSheet sheet = workbook.createSheet(shellNameAndData[0]);
//读写csv文件 
System.out.println(" 未处理前 dataName " + shellNameAndData[1]);
String dataName = BASEDATAURL_LINUX + shellNameAndData[1].substring(shellNameAndData[1].lastIndexOf("/") + 1);
System.out.println(" 最终 dataName " + dataName);
readAndWriteFile(sheet, headStyle, cellStyle, dataName);
}
return workbook;
}
private static List readResultCsv(String csvFileName) {
/**
*@编写人: m01
*@编写时间: 2018/5/16 0016 下午 4:16
*@描述: 读取CSV 文件
*@参数: []
*@参数类型:
*@参数描述:
*@返回值:
*@返回类型:
*@返回值描述:
*@修改人: 暂无
*@修改时间: 2018/5/16 0016 下午 4:16
*@备注:
**/
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
File csv = new File(csvFileName);
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(
new FileInputStream(csvFileName)));
String line = "";
String everyLine = "";
int column = 0;
while ((line = br.readLine()) != null) {
everyLine = line;
if (column != 0) {
System.out.println("header " + everyLine);
String[] dataHeader = everyLine.split(",");
Map<String, String> map = new HashMap<String, String>();
String picUrl = dataHeader[0];
String dataUrl = dataHeader[1];
picUrl = BASEPICURL + picUrl.substring(picUrl.lastIndexOf("/") + 1);
dataUrl = BASEDATAURL + dataUrl.substring(dataUrl.lastIndexOf("/") + 1);
map.put("picUrl", picUrl);
map.put("dataUrl", dataUrl);
System.out.println(picUrl + " " + dataUrl);
list.add(map);
}
column = column + 1;
}
} catch (Exception e) {
e.printStackTrace();
list.clear();
} finally {
if (br != null) {
try {
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return list;
}
}
private static void readAndWriteFile(HSSFSheet sheet, CellStyle headStyle, CellStyle cellStyle, String fileName) {
File csv = new File(fileName);
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(
new FileInputStream(fileName), "gbk"));
String line = "";
String everyLine = "";
int column = 0;
while ((line = br.readLine()) != null) {
everyLine = line;
System.out.println("column " + column);
if (column == 0) {
System.out.println("header " + everyLine);
Row firstRow = sheet.createRow(column);
String[] dataHeader = everyLine.split(",");
for (int d = 0; d < dataHeader.length; d++) {
Cell cell = firstRow.createCell(d);
cell.setCellValue(dataHeader[d]);
cell.setCellStyle(headStyle);
}
for (int d = 0; d < dataHeader.length; d++) {
sheet.setColumnWidth(d, 18 * 256);
}
} else {
System.out.println("content " + everyLine);
String[] dataContent = everyLine.split(",");
System.out.println(Arrays.toString(dataContent));
Row row = sheet.createRow(column);
row.setHeight((short) 400);
for (int i = 0; i < dataContent.length; i++) {
Cell cell = row.createCell(i);
cell.setCellValue(dataContent[i]);
cell.setCellStyle(cellStyle);
}
}
column = column + 1;
}
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] s) throws Exception {
String china = "中国啊";
System.out.println(china.getBytes());
System.out.println(new String(china.getBytes("GBK"), "GBK").toString());
System.out.println(new String(china.getBytes(), "utf-8").toString());
String beginTime = "2018-05-02 09:46:37";//开始时间
String endTime = "2018-05-15 09:46:39"; //结束时间
String provinceId = "31"; //省ID
String kpiId = "98-2826-3555";//指标ID 用 - 连接
String rStr = " Rscript **.r " + beginTime + " " + endTime + " " + provinceId + " " + kpiId;
/*File csv = new File("E:/lesson.csv"); // CSV文件路径
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(
new FileInputStream(csv), "gbk"));
} catch (Exception e) {
e.printStackTrace();
}
String line = "";
String everyLine = "";
try {
List<String> allString = new ArrayList<String>();
while ((line = br.readLine()) != null) //读取到的内容给line变量
{
everyLine = line;
System.out.println(everyLine);
allString.add(everyLine);
}
System.out.println("csv表格中所有行数:" + allString.size());
} catch (IOException e) {
e.printStackTrace();
}*/
/* String fileStr = "shell1&E:/lesson.csv@shell2&E:/lesson.csv";
fileStr = "E:/lesson.csv";
fileStr = fileStr.substring(fileStr.lastIndexOf("/") + 1);
System.out.println("fileStr == " + fileStr);
String excelName = "E:/lessons.xls";
HSSFWorkbook workbook = excelCreate(fileStr.split("@"));
File file = new File(excelName);
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
workbook.write(fileOutputStream);
byte[] body = null;
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
}
Province province = new Province();
province.setProvinceCode("12");
province.setProvinceId(1l);
province.setProvinceName("henam");
Gson gson = new Gson();
String jsonStr = gson.toJson(province);
System.out.println(jsonStr);
jsonStr = "[{'图片地址':'***','数据地址':'***', '其他值': '***'}, {'图片地址':'***','数据地址':'***', '其他值': '***'}]";
List<Map<String, Object>> list = gson.fromJson(jsonStr, List.class);
System.out.println(list.get(0).get("provinceName"));
fileStr = "guanxi.jpg&|image|aaa.csv@guanxi.jpg&|image|a1.csv@meihuo.jpg&|image|a2.csv";
fileStr = fileStr.replaceAll("\\|", "/");
System.out.println("fileStr " + fileStr);
String[] a = {"12", "123", "1233", "123ere"};
System.out.println(a.toString());*/
String data = "10-23-3" + "\n" + "232" + "\n" + "2018.32" + "\n" + "2010.32";
String fileName = "D:/idea_programs/monitorAnalysis/target/" + "arg.txt";
writeDataToFile(data, fileName);
String kpiStr = "moi";
String provinceStr = "mo22i";
String[] timzArr = {"moi3232", "sdgddssgds"};
data = "\"" + kpiStr + "\"" + "," + "\"" + provinceStr + "\"" + "," + "\"" + timzArr[0] + "\"" + "," + "\"" + timzArr[1] + "\"";
fileName = "D:/idea_programs/monitorAnalysis/target/" + "arg.csv";
writeDataToCSV(data, fileName);
}
}
<%@tag pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%--************************************************分析报告 by m01 20180508***************************************** --%>
<div>
<label for="">分析报告</label>
<div id="reports_item_div">
<div class="checkbox-inline">
<input type="radio" name="report" class="report" title="有" value="1" >有
</div>
<div class="checkbox-inline">
<input type="radio" name="report" class="report" title="无" value="0" >无
</div>
</div>
</div>
<script type="text/javascript">
function reportsReset(){
/* $("input[name='reports']:checkbox").each(function () {
$(this).attr('checked',false);
});*/
$('input[name="report"]').attr('checked',false);
}
function getReportCheckedValues(){
/*var reportsArray = new Array();
$("input[name='reports']:checked").each(function () {
reportsArray.push($(this).val())
});
return reportsArray;*/
var val=$('input[name="report"]:checked').val();
val =val?val:"-";
return val;
}
</script>
\ No newline at end of file
<%@tag pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div id="business_div" class="slide-menu-option">
<label for="">业务</label>
<div id ="allBusiness_div" class="checkbox-inline">
<label>
<input type="checkbox" name="allBusiness" id="allBusiness" > 全选
</label>
</div>
<div id="businessList_div">
</div>
</div>
<script type="text/javascript">
//全选 复选框
$('input[name="allBusiness"]').on('click',function () {
$("#allKpi_div").prop("checked",false);//指标 取消全选
$("#kpiList_div").empty();//清空
if($(this).prop('checked')){//已勾选
$('input[name="businesss"]').prop('checked',true);
loadKpi();
}else{
$('input[name="businesss"]').prop('checked',false);
loadKpi();
}
});
//业务 复选框
function businessClick(e) {
$("#allKpi_div").prop("checked",false);//指标 取消全选
$("#kpiList_div").empty();//清空
var isAllSelected=true;
$('input[name="businesss"]').each(function () {
if(!$(this).prop('checked')){
isAllSelected=false;
}
});
if(isAllSelected){
$('input[name="allBusiness"]').prop('checked',true);
}else {
$('input[name="allBusiness"]').prop('checked',false);
}
loadKpi();
}
$("input[name='businesss']").on('click',function () {
$("#businessList_div").empty();//清空 业务
$("#allBusiness").prop("checked",false);//取消选择 ‘全选’
$("#kpiList_div").empty();//清空
$("#allKpi_div").prop("checked",false);//取消全选
if($(this).prop('checked')){//已勾选
$(this).prop('checked',true);
loadKpi();
}else{
$(this).prop('checked',false);
loadKpi();
}
var isAllSelected=true;
$('input[name="businesss"]').each(function () {
if(!$(this).prop('checked')){
isAllSelected=false;
}
});
if(isAllSelected){
$('input[name="allBusiness"]').prop('checked',true);
}else {
$('input[name="allBusiness"]').prop('checked',false);
}
});
//初始化
function initBusiness() {
$("#allBusiness_div").hide();
$("#businessList_div").empty();
}
//选择的业务
function getSelectedBusiness() {
var businessArray=new Array();
$('input[name="businesss"]').each(function () {
if($(this).prop('checked')){
businessArray.push($(this).val());
}
});
return businessArray;
}
</script>
<%@tag pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<div class="slide-menu-option">
<label id="labelChannel" for="">渠道</label>
<div class="checkbox-inline">
<label>
<input type="checkbox" name="allChannel" id="allChannel"> 全选
</label>
</div>
<div>
<c:forEach var="channel" items="${channelList}">
<div class="checkbox-inline">
<input type="checkbox" name="channel"
title="${channel.channelName}" value="${channel.channelId}">${channel.channelName}
</div>
</c:forEach>
</div>
</div>
<script type="text/javascript">
//全选 复选框
$('input[name="allChannel"]').on('click',function () {
cancelselectbusinessandkpi();
if($(this).prop('checked')){//已勾选
$('input[name="channel"]').prop('checked',true);
getBusinessByDatasource();
}else{
$('input[name="channel"]').prop('checked',false);
getBusinessByDatasource();
}
});
// 渠道 复选框
$('input[name="channel"]').on('click',function () {
cancelselectbusinessandkpi();
if($(this).prop('checked')){
$(this).prop('checked',true);
getBusinessByDatasource();
}else{
$(this).prop('checked',false);
getBusinessByDatasource();
}
var isAll=true;
$('input[name="channel"]').each(function () {
if(!$(this).prop('checked')){
isAll=false;
}
});
if (isAll){
$('input[name="allChannel"]').prop('checked',true);
}else{
$('input[name="allChannel"]').prop('checked',false);
}
});
function initChannel(){
$('input[name="allChannel"]').prop('checked',false);
$('input[name="channel"]').prop('checked',false);
}
function getSelectedChannels(){
var channelArray=new Array();
$('input[name="channel"]').each(function () {
if($(this).prop('checked')){
channelArray.push($(this).val());
}
});
return channelArray;
}
// 联合 数据来源查找 业务
function getBusinessByDatasource(){
// 清空 业务 和指标
initBusiness();
initKpi();
var selectedDataSourceArr=getSelectedDataSources();
if (selectedDataSourceArr.length ===0){return;}
var selectedDataSourceStr=selectedDataSourceArr.join('-');
var selectedChannelsArr=getSelectedChannels();
if (selectedChannelsArr.length ===0){return;}
var selectedChannelStr=selectedChannelsArr.join("-");
// alert("selectedDataSourceStr "+selectedDataSourceStr);
// alert("selectedChannelStr "+selectedChannelStr);
var url = "${ctx}/MonitorOperation/CustomAnalysis/getBusinessByChannelIdListAndDataSourceIdList/"+selectedDataSourceStr+"/"+selectedChannelStr;
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
timeout: 3000,
cache: false,
error: solveDataSourceError,
success: useDataSourceData
});
}
function solveDataSourceError() {
initChannel();//初始化 渠道
initBusiness();//初始化 业务
initKpi();//初始化 指标
}
function useDataSourceData(data){
// alert(data);
loadBusiness(data);
}
</script>
<%@tag pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<div class="slide-menu-option">
<label for="">数据来源</label>
<div class="checkbox-inline">
<label> <input type="checkbox" name="allDataSource" id="allDataSource"
> 全选
</label>
</div>
<div >
<c:forEach var="datasource" items="${datasourceList}">
<div class="checkbox-inline">
<label>
<input type="checkbox" name="datasource" class="datasource"
title="${datasource.dataSourceName}" value="${datasource.dataSourceId}"
>${datasource.dataSourceName}
</label>
</div>
</c:forEach>
</div>
</div>
<script type="text/javascript">
//全选 复选框
$('input[name="allDataSource"]').on('click', function () {
cancelselectbusinessandkpi();
if ($(this).prop("checked")) {
$("input[name='datasource']").prop("checked",true);
getBusinessByChannel();
} else {
$("input[name='datasource']").prop("checked",false);
// alert('getBusinessByChannel all 2');
getBusinessByChannel();
}
});
// 资源 复选框
$("input[name='datasource']").on('click', function () {
cancelselectbusinessandkpi();
if ($(this).prop("checked")) {
$(this).prop("checked",true);
getBusinessByChannel();
} else {
$(this).prop("checked",false);
getBusinessByChannel();
}
var clickFlag = true;//是否全部选中
$("input[name='datasource']").each(function () {
if (!$(this).prop('checked')) {
clickFlag = false;
}
});
if (clickFlag) {
$('input[name="allDataSource"]').prop("checked",true);
} else {
$('input[name="allDataSource"]').prop("checked",false);
}
});
// 初始化
function initDataSource(){
$('input[name="allDataSource"]').prop("checked",false);
$('input[name="datasource"]').prop("checked",false);
}
function getSelectedDataSources(){
var dataSourceArray=new Array();
$("input[name='datasource']").each(function(){
if($(this).prop('checked')){
dataSourceArray.push($(this).val());
}
});
return dataSourceArray;
}
// 联合 渠道查找 业务
function getBusinessByChannel(){
// 清空 业务 和指标
initBusiness();
initKpi();
var selectedChannelsArr=getSelectedChannels();
// alert("selectedChannelsArr.length ="+selectedChannelsArr.length );
if (selectedChannelsArr.length ===0){return;}
var selectedChannelStr=selectedChannelsArr.join("-");
var selectedDataSourceArr=getSelectedDataSources();
// alert("selectedDataSourceArr.length ="+selectedDataSourceArr.length);
if (selectedDataSourceArr.length ===0){return;}
var selectedDataSourceStr=selectedDataSourceArr.join('-');
// alert("selectedDataSourceStr "+selectedDataSourceStr);
// alert("selectedChannelStr "+selectedChannelStr);
var url = "${ctx}/MonitorOperation/CustomAnalysis/getBusinessByChannelIdListAndDataSourceIdList/"+selectedDataSourceStr+"/"+selectedChannelStr;
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
timeout: 3000,
cache: false,
error: solveDataSourceError,
success: useDataSourceData
});
}
function solveDataSourceError(){//若果请求 错误 就初始化 数据来源请求框
initDataSource();
}
function useDataSourceData(data){//将业务数据 显示到界面上
// alert(data);
loadBusiness(data);
}
function loadBusiness(data){
$("#businessList_div").empty();//清除 已显示的业务
var content="";
for (var key in data){
var businessId=data[key].businessId;
var businessName=data[key].businessName;
var contentChild="<div class='checkbox-inline'>" +
"<label><input type='checkbox' class='businessStats' title='"+businessName+"' value='"+businessId+"' name='businesss' onclick='businessClick(this)'>"+businessName+ "</label></div>";
content=content+contentChild;
}
if(content !==''){
$("#allBusiness_div").show();
}
$("#businessList_div").append(content);
}
</script>
\ No newline at end of file
<%@tag pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div>
<label for="">分析报告</label>
<div id="report_div">
<div class="checkbox-inline">
<input type="radio" name="report" class="report" title="有" value="1" >有
</div>
<div class="checkbox-inline">
<input type="radio" name="report" class="report" title="无" value="0" >无
</div>
</div>
</div>
<script type="text/javascript">
function getSelectedReport(){
var selectedReport=$('input[name="report"]:checked').val();
return selectedReport;
}
function initReport(){
$('input[name="report"]').removeAttr('checked',false);
}
</script>
\ No newline at end of file
<%@tag pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div id="business_div" class="slide-menu-option">
<label for="">指标</label>
<div id="allKpi_div" class="checkbox-inline" >
<label>
<input type="checkbox" name="allKpi" id="allKpi" > 全选
</label>
</div>
<div id="kpiList_div">
</div>
</div>
<script type="text/javascript">
function initKpi() {
$("#allKpi_div").prop("checked",false);//取消全选
$("#allKpi_div").hide();//隐藏全选
$("#kpiList_div").empty();//清空
}
function getSelectedKpi() {//获取已选择的指标
var kpiArray = new Array();
$("input[name='kpi']").each(function () {
if ($(this).prop('checked')) {
kpiArray.push($(this).val());
}
});
return kpiArray;
}
function getSelectedKpiName() {//获取已选择的指标
var kpiArray = new Array();
$("input[name='kpi']").each(function () {
if ($(this).prop('checked')) {
kpiArray.push($(this).prop('title'));
}
});
return kpiArray;
}
$("input[name='allKpi']").on('click', function () {//全选按钮
if ($(this).prop('checked')) {
$("input[name='kpi']").prop('checked', true);
} else {
$("input[name='kpi']").prop('checked', false);
}
});
function kpiClick(e){
var clickFlag = true;//是否全部选中
$("input[name='kpi']").each(function () {
if (!$(this).prop('checked')) {
clickFlag = false;
}
});
if (clickFlag) {
$("input[name='allKpi']").prop('checked', true);
} else {
$("input[name='allKpi']").prop('checked', false);
}
}
function loadKpi() {
// 初始化指标
initKpi();
//获取已选择的业务
var selectedBusinessArr = getSelectedBusiness();
// alert("selectedBusinessArr.length = "+selectedBusinessArr.length);
if (selectedBusinessArr.length === 0) {
return;
}
var selectedBusinessStr = selectedBusinessArr.join('-');
// alert("selectedBusinessStr = "+selectedBusinessStr);
var url = "${ctx}/MonitorOperation/CustomAnalysis/getDimKpiListByBusinessIdList/" + selectedBusinessStr;
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
timeout: 3000,
cache: false,
error: solveChannelError,
success: useChannelData
});
}
function solveChannelError() {
$("#allKpi_div").hide();//隐藏全选
}
function useChannelData(data) {
$("#kpiList_div").empty();
var content = "";
for (var key in data) {
var kpiName = data[key].kpiName;
var kpiId = data[key].kpiId;
var contentChild = "<div class='checkbox-inline'>" +
"<label><input type='checkbox' class='businessStats' title='"+kpiName+"' value='"+kpiId+"' name='kpi' onclick='kpiClick(this)'>"+kpiName+"</label></div>";
content = content + contentChild;
}
// alert(content);
if(content !==''){
$("#allKpi_div").show();//显示全选
}
$("#kpiList_div").append(content);
}
</script>
<%@tag pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="slide-menu-option">
<label for="">省份</label>
<%--<div class="checkbox-inline">
<label>
<input type="checkbox" name="allProvince" id="allProvince"
title="allSelect" checked/>全选
</label>
</div>--%>
<div>
<c:forEach items="${provinceList}" var="province">
<div class="checkbox-inline">
<label>
<input type="radio" name="province" class="province" title="${province.provinceName}"
value="${province.provinceId}" />${province.provinceName}
</label>
</div>
</c:forEach>
</div>
</div>
<script type="text/javascript">
//全选和不全选所有的省
$('input[name="allProvince"]').on('click', function () {
if ($("#allProvince").prop("checked")) {//已全选
alert("1");
$('input[name="province"]').prop("checked", true);
} else {
alert("122");
$('input[name="province"]').prop("checked", false);
}
});
//选中勾选了的省
$('input[name="province"]').on('click', function () {
if ($(this).prop("checked")) {
// $(this).prop("checked", false);
} else {
$//(this).prop("checked", true);
}
});/*var clickFlag = true;//是否全部选中
$('input[name="province"]').each(function () {
if (!$(this).prop("checked")) {
clickFlag = false;
}
});
if (clickFlag) {
$('input[name="allProvince"]').prop("checked",true);
} else {
$('input[name="allProvince"]').prop("checked",false);
}*/
function initProvince() {
// $('input[name="allProvince"]').prop("checked", true);
$("input[name='province']").prop("checked", false);
}
function getSelectedProvinces() {
/*var provinceArray = new Array();
$("input[name='province']:checked").each(function () {
provinceArray.push($(this).val())
});
return provinceArray;*/
return $("input[name='province']:checked").val();
}
function getSelectedProvinceName() {
return $("input[name='province']:checked").prop('title');
}
</script>
<%@tag pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--时间范围筛选项 ,最大跨度为三个月,只能取到截止到目前的最近三个月--%>
<%--要引入此tag需要在要引入的页面中添加
<script language="javascript" type="text/javascript" src="${ctx}/static/My97DatePicker/WdatePicker.js"></script>
--%>
<div class="date">
<label for="">时间范围</label><!-- 默认的时间范围为最近 1个月-->
<input id="d1Stats" class="Wdate" type="text" value=""
onFocus="var d2Stats=$dp.$('d2Stats');WdatePicker({onpicked:function(){d2Stats.focus();},minDate:'{%y-3}-%M-%d %H:%m:%s',maxDate:'#F{$dp.$D(\'d2Stats\')||\'%y-%M-%d %H:%m:%s\'}'})">
--
<input id="d2Stats" class="Wdate" type="text" value=""
onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d1Stats\')||\'{%y-3}-%M-%d %H:%m:%s\'}',maxDate:'%y-%M-%d %H:%m:%s'})">
</div>
<script type="text/javascript">
function initStartTimeStats() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm;
clock += ":" + "00";
return (clock);
}
function initEndTimeStats() {
var date = new Date();
var daysInMonth = new Array([0], [31], [28], [31], [30], [31], [30], [31], [31], [30], [31], [30], [31]);
var strYear = date.getFullYear();
var strDay = date.getDate();
var strMonth = date.getMonth() + 1;
var hh = date.getHours(); //时
var mm = date.getMinutes(); //分
if (strYear % 4 == 0 && strYear % 100 != 0) {
daysInMonth[2] = 29;
}
if (strMonth - 1 == 0) {
strYear -= 1;
strMonth = 12;
}
else {
strMonth -= 1;
}
strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth];
if (strMonth < 10) {
strMonth = "0" + strMonth;
}
if (strDay < 10) {
strDay = "0" + strDay;
}
var clock = strYear + "-" + strMonth + "-" + strDay;
clock += " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm;
clock += ":" + "00";
return (clock);
}
//初始化时间控件的默认值,需要在页面加载时调用此初始化方法
function initDateStats() {
$("#timeStats #d1Stats").val(initEndTimeStats());
$("#timeStats #d2Stats").val(initStartTimeStats());
}
//获取选取的时间段,返回结果为字符串数组
function getPeriodStats() {
var period = new Array();
period[0] = $("#d1Stats").val();
period[1] = $("#d2Stats").val();
return period;
}
//返回结果为以逗号分隔的字符串类型
function getStatsPeriodString() {
var StatStr = "";
var period = getPeriodStats();
var regu = "^[ ]+$";
var re = new RegExp(regu);
if( re.test(period[0])||re.test(period[1])){
StatStr="";
// console.log('is kong')
}else{
StatStr = StatStr + period[0] + "," + period[1];
}
if($.trim(period) ===","){
StatStr="";
}else{
StatStr = StatStr + period[0] + "," + period[1];
}
return StatStr;
}
//返回结果为以~分隔的字符串,若全为空则返回空|Add by Charmy 02-17|Last modified by Charmy 02-18
function getStatsPeriodStr() {
var StatStr = "";
var period = getPeriodStats();
if (period[1] == "" && period[0] == "") {
str = "";
} else {
StatStr = StatStr + period[0] + "~" + period[1];
}
return StatStr;
}
</script>
......@@ -10,12 +10,12 @@
--
<input id="d2Stats" class="Wdate" type="text" value="" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d1Stats\')||\'{%y-3}-%M-%d %H:%m:%s\'}',maxDate:'%y-%M-%d %H:%m:%s'})">
<!--
<input id="d1" class="Wdate" type="text" width="36px" onFocus="var d2=$dp.$('d2');WdatePicker({onpicked:function(){d2.focus();},minDate:'%y-{%M-3}-%d %H:%m:%s',maxDate:'#F{$dp.$D(\'d2\')||\'%y-%M-%d %H:%m:%s\'}'})">
<!--
<input id="d1" class="Wdate" type="text" width="36px" onFocus="var d2=$dp.$('d2');WdatePicker({onpicked:function(){d2.focus();},minDate:'%y-{%M-3}-%d %H:%m:%s',maxDate:'#F{$dp.$D(\'d2\')||\'%y-%M-%d %H:%m:%s\'}'})">
--
<input id="d2" class="Wdate" type="text" width="36px" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d1\')||\'%y-{%M-3}-%d %H:%m:%s\'}',maxDate:'%y-%M-%d %H:%m:%s'})">
-->
</div>
<script type="text/javascript">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment