Commit 50c5f4dd authored by 刘松's avatar 刘松

update

parent f95f1dfb
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,7 +14,7 @@ class Gather extends React.Component{ ...@@ -14,7 +14,7 @@ class Gather extends React.Component{
constructor(props){ constructor(props){
super(props); super(props);
this.range = [moment().subtract(6,'days').format('YYYYMMDD'), moment().format('YYYYMMDD')]; this.range = [moment().subtract(6,'days').format('YYYYMMDD'), moment().format('YYYYMMDD')];
this.state= { qdgathers :[],status:'pending',pagination:{current:1,pageSize:10,total:100},username:'channel',tody:{ tkl_count:0,count:0,schedule_count:0} ,none_tkls:[]}; this.state= { qdgathers :[],status:'pending',pagination:{current:1,pageSize:10,total:100},username:'channel',tody:{ tkl_count:0,count:0,schedule_count:0} ,none_tkls:[],list:[]};
} }
componentDidMount(){ componentDidMount(){
let data = { start:moment().add(-6,'days').format('YYYYMMDD'),end:moment().format('YYYYMMDD')}; let data = { start:moment().add(-6,'days').format('YYYYMMDD'),end:moment().format('YYYYMMDD')};
...@@ -22,9 +22,8 @@ class Gather extends React.Component{ ...@@ -22,9 +22,8 @@ class Gather extends React.Component{
this.setState({username:document.cookie.match('username=[a-zA-Z0-9]+')[0].split('=')[1]}); this.setState({username:document.cookie.match('username=[a-zA-Z0-9]+')[0].split('=')[1]});
} }
api('GET', 'gathers/qd').then((res) => { api('GET', 'gathers/qd').then((res) => {
this.setState({qdgathers:res.result,status:'ready',none_tkls:res.none_tkls}); this.setState({qdgathers:res.result,status:'ready',none_tkls:res.none_tkls,list:res.list});
this.handle(res.list,res.tkl_count) this.handle(res.list,res.tkl_count)
console.dir(res.result);
}); });
} }
...@@ -38,12 +37,10 @@ class Gather extends React.Component{ ...@@ -38,12 +37,10 @@ class Gather extends React.Component{
getQdGatherss(pagination){ getQdGatherss(pagination){
console.dir(pagination);
this.setState({status:'pending'}) this.setState({status:'pending'})
api('GET', 'gathers/qd?'+'skip='+ (pagination.current-1) + '&limit=' + pagination.pageSize).then((res) => { api('GET', 'gathers/qd?'+'skip='+ (pagination.current-1) + '&limit=' + pagination.pageSize).then((res) => {
this.setState({qdgathers:res.result,status:'ready',pagination:{current:res.pagination.skip,pageSize:res.pagination.limit,total:res.pagination.total},none_tkls:res.none_tkls}); this.setState({qdgathers:res.result,status:'ready',pagination:{current:res.pagination.skip,pageSize:res.pagination.limit,total:res.pagination.total},none_tkls:res.none_tkls,list:res.list});
this.handle(res.list,res.tkl_count); this.handle(res.list,res.tkl_count);
console.dir(res.result);
}); });
} }
...@@ -116,19 +113,32 @@ class Gather extends React.Component{ ...@@ -116,19 +113,32 @@ class Gather extends React.Component{
}); });
} }
var none_tkls = this.state.none_tkls; var none_tkls = this.state.none_tkls;
var list = this.state.list;
var sum = 0; var sum = 0;
var list_show = []; var list_show = [];
var sum_list_show = [];
for(var i in none_tkls){ for(var i in none_tkls){
sum += none_tkls[i]['times']; sum += none_tkls[i]['times'];
let qd = none_tkls[i]["qd"]; let qd = none_tkls[i]["qd"];
if(qd) if(qd) list_show.push(<p key={ qd['user'] }>{qd['user'] + " " +none_tkls[i]['times']}</p>)
list_show.push(<p>{qd['user'] + " " +none_tkls[i]['times']}</p>) }
var map2qd = {};
for(var k in list){
if(list[k] && list[k].qd && list[k]['qd']['user'])
map2qd[list[k]['qd']['user']] = (map2qd[list[k]['qd']['user']] ? (map2qd[list[k]['qd']['user']]+list[k]['sum']) : list[k]['sum']);
}
for(var j in map2qd){
sum_list_show.push(<p key={ j }>{j + " " +map2qd[j]}</p>);
} }
const content = ( const content = (
<div> <div>
{ list_show } { list_show }
</div> </div>
); );
const sum_content = (
<div>
{ sum_list_show }
</div>);
return ( return (
<div> <div>
...@@ -136,8 +146,13 @@ class Gather extends React.Component{ ...@@ -136,8 +146,13 @@ class Gather extends React.Component{
<Row> <Row>
<Col span="6"> <Col span="6">
<div className = "box" style={{ marginLeft:'0px'}}> <div className = "box" style={{ marginLeft:'0px'}}>
<h3>请求数</h3> <h3>请求数</h3>{
<span>{ this.state.tody.count }</span> this.state.username !== 'admin' ? <span>{ this.state.tody.count }</span> :
<Popover content={sum_content} title="详情">
<span>{ this.state.tody.count }</span>
</Popover>
}
</div> </div>
</Col> </Col>
<Col span="6"> <Col span="6">
......
module.exports = { module.exports = {
host: '0.0.0.0', host: '0.0.0.0',
port: process.env.PORT ? process.env.PORT : 9401, port: process.env.PORT ? process.env.PORT : 9401,
//mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle', mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle',
mongo:'mongodb://127.0.0.1:27017/taoarticle', //mongo:'mongodb://127.0.0.1:27017/taoarticle',
taobao: { taobao: {
host:"http://gw.api.taobao.com/router/rest", host:"http://gw.api.taobao.com/router/rest",
appKey:"24594025",//"23580470",//"23390725", appKey:"24594025",//"23580470",//"23390725",
......
...@@ -70,17 +70,24 @@ exports.logs = async (req, res, next) => { ...@@ -70,17 +70,24 @@ exports.logs = async (req, res, next) => {
let {limit = 100,skip = 0,sort = {'updatedAt': -1}} = req.query; let {limit = 100,skip = 0,sort = {'updatedAt': -1}} = req.query;
let options = {limit:parseInt(limit),skip:parseInt(skip)*limit,sort}; let options = {limit:parseInt(limit),skip:parseInt(skip)*limit,sort};
var session_body = await Session.findById(sess); var session_body = await Session.findById(sess);
var logs = [];
var total = 0;
if(session_body){ if(session_body){
var user = session_body.toJSON().user; var user = session_body.toJSON().user;
let qs = {}; let qs = {};
if(user != '5a1e81f8c86fa7aa4b51b18b'){ if(user != '5a1e81f8c86fa7aa4b51b18b'){
let schedules = await Schedule.find({qd:user},null,{limit:1000}); let schedules = await Schedule.find({qd:user},null,{limit:1000});
schedules = schedules.map(x => { return { schedule: x.toJSON()._id }}); schedules = schedules.map(x => { return { schedule: x.toJSON()._id }});
console.dir(schedules);
qs = { $or:schedules }; qs = { $or:schedules };
if( schedules && schedules.length ) {
total = await Log.count(qs,null);
logs = await Log.find(qs,null,options).populate({path:"schedule",select:"links qd",populate:{path:'qd',select:'user'}});
}
}
else{
logs = await Log.find(qs,null,options).populate({path:"schedule",select:"links qd",populate:{path:'qd',select:'user'}});
total = await Log.count(qs,null);
} }
var logs = await Log.find(qs,null,options).populate({path:"schedule",select:"links qd",populate:{path:'qd',select:'user'}});
let total = await Log.count(qs,null);
logs = logs.map(x => { var d = x.toJSON();d['updatedAt'] = dateFormat(d['updatedAt']);return d;}); logs = logs.map(x => { var d = x.toJSON();d['updatedAt'] = dateFormat(d['updatedAt']);return d;});
res.send({ status:'ok',result:logs,pagination:{total:total,skip:skip,limit:limit}}); res.send({ status:'ok',result:logs,pagination:{total:total,skip:skip,limit:limit}});
} }
...@@ -142,6 +149,11 @@ exports.getQdGatherData = async (req, res, next) => { ...@@ -142,6 +149,11 @@ exports.getQdGatherData = async (req, res, next) => {
} }
} }
]); ]);
var tasks = [];
list.forEach( async (item,i) => {
var schedule = await Schedule.findById(item._id).populate('qd','user');
list[i]['qd'] = schedule.toJSON().qd;
});
none_tkls = await Nonetkl.find({date:match_qs['date']}).populate('qd','user').limit(1000); none_tkls = await Nonetkl.find({date:match_qs['date']}).populate('qd','user').limit(1000);
} }
var gatherDatas = await GatherData.find(qs,null,options).populate('qd','user'); var gatherDatas = await GatherData.find(qs,null,options).populate('qd','user');
......
...@@ -42,6 +42,7 @@ exports.saveSchedule = async (data,cb) => { ...@@ -42,6 +42,7 @@ exports.saveSchedule = async (data,cb) => {
} }
exports.saveAgent = async (data,cb) => { exports.saveAgent = async (data,cb) => {
console.dir(data);
try { try {
var agent = new Agent(data); var agent = new Agent(data);
cb(null,await agent.save()) cb(null,await agent.save())
......
const crypto = require('crypto'); const crypto = require('crypto');
module.exports = (str, algo = 'sha256') => { module.exports = (str) => {
if (!str) return ''; if (!str) return '';
const hash = crypto.createHash(algo); return crypto.createHash('md5').update(str).digest('hex')
hash.update(str);
return hash.digest('hex');
}; };
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