Commit aacb3ce7 by admin

渠道添加日数据

parent 10d994c0
......@@ -215,6 +215,18 @@
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version> 3.2.4.RELEASE </version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -12,44 +12,49 @@ public interface DataDao {
public void insert(Data data);
public List<Data> findByPtDay(Date startTime, Date endTime, String pt);
public List<Data> findByPt(Date startTime, Date endTime, String pt);
public List<Data> findBySource(Date startTime, Date endTime, String source);
public List<Data> findBytempName(Date startTime, Date endTime, String tempName);
public List<Data> findByMethod(Date startTime,Date endTime,String method,Object value);
public List<Data> findByMethod(Date startTime, Date endTime, String method, Object value);
public int findBySourceFromLibrary(Date startTime, Date endTime, String source);
public int findBySpId(Date startTime, Date endTime, String syId);
/**
* 根据数据来源来搜索数据
*
* @param startTime
* @param endTime
* @param source
* @return List
*/
public List<EasyNews> findByAccurateSource(String startTime, String endTime, String source);
public int findByAccurateType(Date startTime, Date endTime, String type);
/**
* 根据可视化模板的id去搜索数据
*
* @param startTime
* @param endTime
* @param SpId
* @return List
*/
public List<EasyNews> findByAccurateSpId(String startTime, String endTime, String SpId);
public List<String> findSourceByLikeParam(String param);
public List<String> findTmpNameByLikeParam(String param);
public List<String> findTmpNameByLikeParam(String param);
public List<String> findTypeByLikeParam(String param);
public long finCountByDayData(Date startTime,Date endTime,Template temp);
public long finCountByDayData(Date startTime,Date endTime,String pt);
public long finCountByDayData(Date startTime, Date endTime, Template temp);
public long finCountByDayData(Date startTime, Date endTime, String pt);
}
......@@ -14,6 +14,8 @@ import javax.annotation.Resource;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
......@@ -50,7 +52,8 @@ import com.zhiwei.manage.util.MongoConnect;
@SuppressWarnings({ "all" })
@Component
public class DataDaoImpl implements DataDao {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH");
@Resource(name = "mongoTemplate")
private MongoTemplate mongo;
@Resource(name = "newmongoTemplate")
......@@ -64,7 +67,13 @@ public class DataDaoImpl implements DataDao {
criteria.and("tempName").exists(false);
return mongo.find(Query.query(criteria), Data.class, "Data");
}
@Override
public List<Data> findByPtDay(Date startTime, Date endTime, String pt) {
Criteria criteria = new Criteria();
criteria.and("pt").is(pt);
criteria.and("time").gt(startTime).lt(endTime);
return mongo.find(Query.query(criteria).with(new Sort(Direction.ASC,"time")), Data.class, "DayData");
}
@Override
public List<Data> findBySource(Date startTime, Date endTime, String source) {
Criteria criteria = new Criteria();
......@@ -84,7 +93,6 @@ public class DataDaoImpl implements DataDao {
@Override
public void insert(Data data) {
Data d = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date today = null;
try {
today = sdf.parse(sdf.format(data.getTime()));
......@@ -121,9 +129,20 @@ public class DataDaoImpl implements DataDao {
}
}
mongo.updateFirst(Query.query(Criteria.where("_id").is(d.getDataId())), update, Data.class);
Calendar cal=Calendar.getInstance();
try {
data.setTime(sdf2.parse(sdf2.format(cal.getTime())));
} catch (ParseException e) {
e.printStackTrace();
}
mongo.insert(data, "DayData");
}
}
public void insertTest(Data data) {
mongo.insert(data, "DayData");
}
@Override
public List<EasyNews> findByAccurateSource(String startTime, String endTime, String source) {
Calendar c = Calendar.getInstance();
......@@ -225,11 +244,13 @@ public class DataDaoImpl implements DataDao {
end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
System.out.println(end);
}
MongoClient mongoClient =null;
if(ser.getPt().equals("微信全量")){
mongoClient = new MongoClient(new MongoClientURI("mongodb://sjzzc:sjzzc1q2w3e4r@"+ser.getDbHost()+":"+ser.getDbPort()+"/admin"));
}else{
mongoClient = new MongoClient(new MongoClientURI("mongodb://sjzno:sjzno1q2w3e4r@"+ser.getDbHost()+":"+ser.getDbPort()+"/admin"));
MongoClient mongoClient = null;
if (ser.getPt().equals("微信全量")) {
mongoClient = new MongoClient(new MongoClientURI(
"mongodb://sjzzc:sjzzc1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() + "/admin"));
} else {
mongoClient = new MongoClient(new MongoClientURI(
"mongodb://sjzno:sjzno1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() + "/admin"));
}
// if (ser.getDbUsername() != null &&
// ser.getDbUsername().length() > 2) {
......
......@@ -13,28 +13,32 @@ public interface DataService {
public List<Data> findByPt(Date startTime, Date endTime, String pt);
public List<Data> findByPtDay(Date startTime, Date endTime, String pt);
public List<Data> findBySource(Date startTime, Date endTime, String source);
public List<Data> findBytempName(Date startTime, Date endTime, String tempName);
public List<Data> findByMethod(Date startTime, Date endTime,String method,Object value);
public List<Data> findByMethod(Date startTime, Date endTime, String method, Object value);
public int findBySourceFromLibrary(Date startTime, Date endTime, String source);
public List<EasyNews> findByAccurateSource(String startTime, String endTime, String source);
public List<EasyNews> findByAccurateSpId(String startTime, String endTime, String SpId);
public int findByAccurateType(Date startTime, Date endTime, String type);
public int findByTempName(Date startTime, Date endTime, String tempName);
public List<String> findSourceByLikeParam(String param);
public List<String> findTmpNameByLikeParam(String param);
public List<String> findTypeByLikeParam(String param);
//根据配置获取数据
public long finCountByDayData(Date startDate,Date endDate,Template temp);
public long finCountByDayData(Date startDate,Date endDate,String pt);
// 根据配置获取数据
public long finCountByDayData(Date startDate, Date endDate, Template temp);
public long finCountByDayData(Date startDate, Date endDate, String pt);
}
......@@ -93,4 +93,9 @@ public class DataServiceImpl implements DataService {
return dataDao.finCountByDayData(startDate, endDate, pt);
}
@Override
public List<Data> findByPtDay(Date startTime, Date endTime, String pt) {
return dataDao.findByPtDay(startTime, endTime, pt);
}
}
......@@ -58,10 +58,11 @@ public class DataController {
@RequestMapping(value = "/getDataBySource", produces = "application/json;charset=utf-8")
@ResponseBody
public String getDataBySource(HttpServletRequest request, HttpServletResponse response,@RequestBody Map<String, Object> map) {
long start=(long) map.get("start");
long end=(long) map.get("end");
String source=(String) map.get("source");
public String getDataBySource(HttpServletRequest request, HttpServletResponse response,
@RequestBody Map<String, Object> map) {
long start = (long) map.get("start");
long end = (long) map.get("end");
String source = (String) map.get("source");
Calendar startd = Calendar.getInstance();
startd.setTimeInMillis(start);
Calendar endd = Calendar.getInstance();
......@@ -72,12 +73,12 @@ public class DataController {
@RequestMapping(value = "/getDataByTempName", produces = "application/json;charset=utf-8")
@ResponseBody
public String getDataByTempName(HttpServletRequest request, HttpServletResponse response,@RequestBody Map<String, Object> map)
throws UnsupportedEncodingException {
long start=(long) map.get("start");
long end=(long) map.get("end");
String timeType=(String) map.get("timeType");
String method=(String) map.get("method");
public String getDataByTempName(HttpServletRequest request, HttpServletResponse response,
@RequestBody Map<String, Object> map) throws UnsupportedEncodingException {
long start = (long) map.get("start");
long end = (long) map.get("end");
String timeType = (String) map.get("timeType");
String method = (String) map.get("method");
Calendar startd = Calendar.getInstance();
Calendar endTime = Calendar.getInstance();
if (method == null) {
......@@ -91,21 +92,21 @@ public class DataController {
startd.setTimeInMillis(start);
endTime.setTimeInMillis(start);
}
Calendar ds=Calendar.getInstance();
Calendar ds = Calendar.getInstance();
ds.setTimeInMillis(end);
String source = "";
List<Data> list = new ArrayList<Data>();
startd.add(Calendar.HOUR, -8);
endTime.add(Calendar.HOUR, -7);
ds.add(Calendar.HOUR, -6);
String spid=crService.getSpIdByConfigName((String) map.get("tempName"));
String spid = crService.getSpIdByConfigName((String) map.get("tempName"));
while (endTime.getTime().before(ds.getTime())) {
endTime.add(Calendar.HOUR, 1);
int count=0;
if(method.equals("type")){
source=(String) map.get("type");
count=dataService.findByAccurateType(startd.getTime(), endTime.getTime(), source);
}else{
int count = 0;
if (method.equals("type")) {
source = (String) map.get("type");
count = dataService.findByAccurateType(startd.getTime(), endTime.getTime(), source);
} else {
if (method.equals("source")) {
source = (String) map.get("source");
count = dataService.findBySourceFromLibrary(startd.getTime(), endTime.getTime(), source);
......@@ -150,8 +151,8 @@ public class DataController {
@RequestMapping(value = "/getDataAll", produces = "application/json;charset=utf-8")
@ResponseBody
public String getAllData(@RequestBody Map<String, Object> map) {
long start=(long) map.get("start");
long end=(long) map.get("end");
long start = (long) map.get("start");
long end = (long) map.get("end");
try {
if (start == 0) {
List<Channel> channel = serverService.findDisChannel();
......@@ -160,7 +161,7 @@ public class DataController {
start = startTime.getTimeInMillis() - 1000 * 3600 * 24 * 7;
startTime.setTimeInMillis(start);
Calendar endTime = Calendar.getInstance();
for(Channel chan:channel){
for (Channel chan : channel) {
List<Data> weixin = dataService.findByPt(startTime.getTime(), endTime.getTime(), chan.getPt());
chan.setList(weixin);
chan.setPt(chan.getPt());
......@@ -177,12 +178,11 @@ public class DataController {
endTime.setTimeInMillis(end);
List<Channel> channel = serverService.findDisChannel();
List<Channel> list = new ArrayList<>();
for(Channel chan:channel){
for (Channel chan : channel) {
List<Data> weixin = dataService.findByPt(startTime.getTime(), endTime.getTime(), chan.getPt());
chan.setList(weixin);
list.add(chan);
}
System.out.println("kil2:"+list);
JsonResult result = new JsonResult(true, 200, "请求成功", list);
return JSON.toJSONString(result);
}
......@@ -192,21 +192,49 @@ public class DataController {
}
}
@RequestMapping(value = "/getDayDataByChannel", produces = "application/json;charset=utf-8")
@ResponseBody
public String getDayData(HttpServletRequest request, HttpServletResponse response,long start,long end,String pt) {
// long start = (long) map.get("start");
// long end = (long) map.get("end");
// String pt = String.valueOf(map.get("pt")) ;
try {
System.out.println(start);
Calendar startTime = Calendar.getInstance();
startTime.setTimeInMillis(start);
Calendar endTime = Calendar.getInstance();
endTime.setTimeInMillis(end);
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(endTime.getTime()));
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(startTime.getTime()));
System.out.println(pt);
List<Data> datas = dataService.findByPtDay(startTime.getTime(), endTime.getTime(), pt);
for(Data d:datas) {
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH").format(d.getTime()));
}
System.out.println("datas:"+datas.size());
JsonResult result = new JsonResult(true, 200, "请求成功", datas);
return JSON.toJSONString(result);
} catch (Exception e) {
JsonResult result = new JsonResult(false, 500, e.getMessage(), "");
return JSON.toJSONString(result);
}
}
@RequestMapping(value = "/getSource", produces = "application/json;charset=utf-8")
@ResponseBody
public String getAllDataCountByTime(@RequestBody Map<String, Object> map) {
String value=(String) map.get("value");
String method=(String) map.get("method");
String value = (String) map.get("value");
String method = (String) map.get("method");
if (method != null) {
if (method.equals("tempName")) {
List<String> list = dataService.findTmpNameByLikeParam(value);
JsonResult result = new JsonResult(true, 200, "请求成功", list);
return JSON.toJSONString(result);
} else if(method.equals("type")){
} else if (method.equals("type")) {
List<String> list = dataService.findTypeByLikeParam(value);
JsonResult result = new JsonResult(true, 200, "请求成功", list);
return JSON.toJSONString(result);
}else{
} else {
JsonResult result = new JsonResult(true, 200, "请求成功", new ArrayList<String>());
return JSON.toJSONString(result);
}
......
......@@ -209,10 +209,8 @@ public class ESUtil {
SearchResponse response = srb.execute().actionGet();
SearchHits searchHits = response.getHits();
System.out.println(searchHits.getTotalHits());
for (SearchHit hit : searchHits.getHits()) {
Map<String, Object> map = hit.getSource();
}
log.info("结束");
esClient.close();
} catch (Exception e) {
log.error("es检索出错,错误信息【{}】", e);
}
......
......@@ -12,7 +12,7 @@ module.exports = {
assetsPublicPath: '/',
proxyTable: {
'/datamanage': {
target: 'http://192.168.0.245:8081',
target: 'http://192.168.0.245:8023',
changeOrigin: true,
pathRewrite: {
'^/datamanage': '/datamanage'
......
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>数据管理系统</title><link rel=stylesheet href=./static/css/style.ini.css><link rel=stylesheet href=./static/datepicker/css/datepicker.css><link rel=stylesheet href=./static/datepicker/css/layout.css><link href=./static/css/app.9b4aea3851f5b6e1eb674f9463251a60.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.1c1dd5cd2fcca323c6b4.js></script><script type=text/javascript src=./static/js/vendor.c00def797876150978d2.js></script><script type=text/javascript src=./static/js/app.ff17a705b8009599f890.js></script></body><script src=./static/js/jquery-1.12.4.min.js></script><script src=./static/js/jquery.easing-master/jquery.easing.min.js></script><script src=./static/js/jquery.transit.js></script><script src=./static/datepicker/js/datepicker.js></script><script src=./static/datepicker/js/eye.js></script><script src=./static/datepicker/js/utils.js></script></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>数据管理系统</title><link rel=stylesheet href=./static/css/style.ini.css><link rel=stylesheet href=./static/datepicker/css/datepicker.css><link rel=stylesheet href=./static/datepicker/css/layout.css><link href=./static/css/app.1110b43b4d6602e1038e54a0673af68d.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.924ae89cf33ce54f2bd0.js></script><script type=text/javascript src=./static/js/vendor.c00def797876150978d2.js></script><script type=text/javascript src=./static/js/app.2eb11249cf067d55eb92.js></script></body><script src=./static/js/jquery-1.12.4.min.js></script><script src=./static/js/jquery.easing-master/jquery.easing.min.js></script><script src=./static/js/jquery.transit.js></script><script src=./static/datepicker/js/datepicker.js></script><script src=./static/datepicker/js/eye.js></script><script src=./static/datepicker/js/utils.js></script></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var i,u,f,s=0,l=[];s<t.length;s++)u=t[s],o[u]&&l.push(o[u][0]),o[u]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,a);l.length;)l.shift()();if(a)for(s=0;s<a.length;s++)f=n(n.s=a[s]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(u);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+"static/js/"+e+"."+{0:"c00def797876150978d2",1:"ff17a705b8009599f890"}[e]+".js";var u=setTimeout(r,12e4);return i.onerror=i.onload=r,a.appendChild(i),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="./",n.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=manifest.1c1dd5cd2fcca323c6b4.js.map
\ No newline at end of file
......@@ -56,7 +56,7 @@
</div>
</nav>
<section :class="{ 'loginPage': $route.path === '/' }">
<router-view :user-info="userInfo" :all-fields="allFields" :pt-selected-data="ptSelectedData" v-if="ptSelectedData.pt" />
<router-view :user-info="userInfo" :all-fields="allFields" :pt-selected-data="ptSelectedData" v-if="ptListData.length && ptSelectedData.pt" />
<!-- <footer>&copy;2012-2017 zhiweidata.com, All Rights Reserved.京ICP备13015804号-1备案京公网安备11010502034130号</footer> -->
</section>
......
......@@ -10,9 +10,10 @@
<!-- <button type="button" class="btn2" @click="echartsUpdate()">搜索</button> -->
</div>
<div class="table">
<span class="detailBack" v-show="showDetailData" @click="showDetailData = false, echartsUpdate()">&lt;&lt; Back</span>
<div id="myECharts"></div>
<div class="select">
(单位:)
(单位:{{ showDetailData ? '小时' : '天' }})
<!-- <select class="" name="">
<option value="day">天</option>
<option value="hours">小时</option>
......@@ -26,7 +27,7 @@
import echarts from 'echarts'
import moment from 'moment'
import _ from 'lodash'
import { bus, requestGetDataAll } from '@/vuex/request.js'
import { bus, requestGetDataAll, requestGetDayDataByChannel } from '@/vuex/request.js'
export default {
data () {
......@@ -37,7 +38,8 @@ export default {
endTime: (new Date(moment().format('YYYY-MM-DD'))).getTime(),
colorList: ['#4FCF94', '#F8656B', '#ffbb22', '#4CB1F5', '#ED1941', '#F47920', '#F173AC', '#5c7a29', '#6950a1', '#cd9a5b'],
data: [],
defaultTimeLine: moment(new Date().getTime() - 1000 * 60 * 60 * 24 * 7).format('YYYY/MM/DD') + ' - ' + moment(new Date()).format('YYYY/MM/DD')
defaultTimeLine: moment(new Date().getTime() - 1000 * 60 * 60 * 24 * 7).format('YYYY/MM/DD') + ' - ' + moment(new Date()).format('YYYY/MM/DD'),
showDetailData: false
}
},
mounted () {
......@@ -101,7 +103,7 @@ export default {
},
axisPointer: {
show: true,
snap: true,
snap: false,
triggerTooltip: false,
lineStyle: {
type: 'dashed'
......@@ -161,6 +163,58 @@ export default {
this.echartsUpdate()
},
methods: {
myChartClickEvt (evt) {
this.myChart.clear()
this.option.legend.data = []
this.option.legend.selected = {}
this.option.series = []
let params = {
pt: evt.seriesName,
start: evt.value[0] - (1000 * 60 * 60 * 24 * 3),
end: evt.value[0]
}
requestGetDayDataByChannel(params, {}, (res) => {
if (res.data) {
if (res.data.state) {
this.showDetailData = true
this.data = res.data.data
if (!this.data.length) {
bus.$emit('alert', '返回数据为空!')
return false
}
this.option.legend.data = [this.data[0].pt]
this.option.legend.selected[this.data[0].pt] = true
this.option.series.push({
name: this.data[0].pt,
type: 'line',
smooth: true,
symbolSize: 10,
itemStyle: {
normal: {
borderWidth: 3,
color: evt.color
}
},
lineStyle: {
normal: {
width: 3,
color: evt.color
}
},
data: this.data.map((n, i) => {
return [n.time, n.count]
})
})
this.myChart.setOption(this.option)
this.myChart.off('click', this.myChartClickEvt)
} else {
bus.$emit('alert', res.data.message)
}
} else {
bus.$emit('alert', res + '.')
}
})
},
echartsUpdate () {
this.option.legend.data = []
this.option.legend.selected = {}
......@@ -202,6 +256,7 @@ export default {
})
}
this.myChart.setOption(this.option)
this.myChart.on('click', this.myChartClickEvt)
} else {
bus.$emit('alert', response.data.message)
}
......@@ -241,6 +296,14 @@ export default {
}
.table{
position: relative;
.detailBack{
position: absolute;
cursor: pointer;
z-index: 1;
&:hover{
text-decoration: underline;
}
}
.select{
position: absolute;
right: 10%;
......
......@@ -509,3 +509,16 @@ export let requestStartAll = (params, data, callback) => {
callback(response)
})
}
// -------------------- 数据管理系统 - 渠道数据 - 查看详情 ------------------ getDayDataByChannel
export let requestGetDayDataByChannel = (params, data, callback) => {
axios({
url: dataUrl + 'getDayDataByChannel',
method: requestMethodAuto(params, data),
params: params,
data: data
}).then((response) => {
callback(response)
}).catch((response) => {
callback(response)
})
}
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