Merge branch 'PR' into develop

pull/102/MERGE
13621160019@163.com 2021-12-20 20:25:40 +08:00
commit 3045e8d4f0
10 changed files with 107 additions and 70 deletions

View File

@ -30,15 +30,16 @@ app.controller('TextMessageOptionController', function(
}; };
$scope.execute = function() { $scope.execute = function() {
var datestart,dateend; var startdatetime, enddatetime;
var query = { var query = {
datestart: $scope.daterange.startDate.format().slice(0, 10), startdatetime: $scope.daterange.startDate.format().slice(0, 19),
dateend: $scope.daterange.endDate.format().slice(0, 10) enddatetime: $scope.daterange.endDate.format().slice(0, 19)
}; };
$scope.$emit('handleEmitTextMessageOptionChanged', { $scope.$emit('handleEmitTextMessageOptionChanged', {
load: true, load: true,
period:$scope.currentPeriod period:$scope.currentPeriod
}); });
console.log(query)
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
TextMessageAnalysisService.getAnalysisResult(query, headers, function (response) { TextMessageAnalysisService.getAnalysisResult(query, headers, function (response) {
if (angular.isDefined(response.status) && response.status === 200) { if (angular.isDefined(response.status) && response.status === 200) {

View File

@ -30,14 +30,16 @@ app.controller('WebMessageOptionController', function(
}; };
$scope.execute = function() { $scope.execute = function() {
var startdatetime, enddatetime;
var query = { var query = {
datestart: $scope.daterange.startDate.format().slice(0, 10), startdatetime: $scope.daterange.startDate.format().slice(0, 19),
dateend: $scope.daterange.endDate.format().slice(0, 10) enddatetime: $scope.daterange.endDate.format().slice(0, 19)
}; };
$scope.$emit('handleEmitWebMessageOptionChanged', { $scope.$emit('handleEmitWebMessageOptionChanged', {
load: true, load: true,
period:$scope.currentPeriod period:$scope.currentPeriod
}); });
console.log(query)
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
WebMessageAnalysisService.getAnalysisResult(query, headers, function (response) { WebMessageAnalysisService.getAnalysisResult(query, headers, function (response) {
if (angular.isDefined(response.status) && response.status === 200) { if (angular.isDefined(response.status) && response.status === 200) {

View File

@ -30,14 +30,16 @@ app.controller('WechatMessageOptionController', function(
}; };
$scope.execute = function() { $scope.execute = function() {
var startdatetime, enddatetime;
var query = { var query = {
datestart: $scope.daterange.startDate.format().slice(0, 10), startdatetime: $scope.daterange.startDate.format().slice(0, 19),
dateend: $scope.daterange.endDate.format().slice(0, 10) enddatetime: $scope.daterange.endDate.format().slice(0, 19)
}; };
$scope.$emit('handleEmitWechatMessageOptionChanged', { $scope.$emit('handleEmitWechatMessageOptionChanged', {
load: true, load: true,
period:$scope.currentPeriod period:$scope.currentPeriod
}); });
console.log(query)
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
WechatMessageAnalysisService.getAnalysisResult(query, headers, function (response) { WechatMessageAnalysisService.getAnalysisResult(query, headers, function (response) {
if (angular.isDefined(response.status) && response.status === 200) { if (angular.isDefined(response.status) && response.status === 200) {

View File

@ -3,7 +3,7 @@ app.factory('TextMessageAnalysisService', function($http) {
return { return {
getAnalysisResult: function(query, headers, callback) { getAnalysisResult: function(query, headers, callback) {
$http.get(getAPI()+"textmessages"+"/from/"+query.datestart+"/to/"+query.dateend, {headers}) $http.get(getAPI()+"textmessages?" + 'startdatetime=' + query.startdatetime + '&enddatetime=' + query.enddatetime, {headers})
.then(function (response) { .then(function (response) {
callback(response); callback(response);
}, function (response) { }, function (response) {

View File

@ -3,7 +3,7 @@ app.factory('WebMessageAnalysisService', function($http) {
return { return {
getAnalysisResult: function(query, headers, callback) { getAnalysisResult: function(query, headers, callback) {
$http.get(getAPI()+"webmessages"+"/from/"+query.datestart+"/to/"+query.dateend, {headers}) $http.get(getAPI()+"webmessages?" + "startdatetime=" + query.startdatetime + "&enddatetime=" + query.enddatetime, {headers})
.then(function (response) { .then(function (response) {
callback(response); callback(response);
}, function (response) { }, function (response) {

View File

@ -2,7 +2,7 @@
app.factory('WechatMessageAnalysisService', function($http) { app.factory('WechatMessageAnalysisService', function($http) {
return { return {
getAnalysisResult: function(query, headers, callback) { getAnalysisResult: function(query, headers, callback) {
$http.get(getAPI()+"wechatmessages"+"/from/"+query.datestart+"/to/"+query.dateend, {headers}) $http.get(getAPI()+"wechatmessages?" + 'startdatetime=' + query.startdatetime + '&enddatetime=' + query.enddatetime, {headers})
.then(function (response) { .then(function (response) {
callback(response); callback(response);
}, function (response) { }, function (response) {

View File

@ -442,7 +442,7 @@ api.add_route('/tenanttypes',
api.add_route('/tenanttypes/{id_}', api.add_route('/tenanttypes/{id_}',
tenanttype.TenantTypeItem()) tenanttype.TenantTypeItem())
api.add_route('/textmessages/from/{startdate}/to/{enddate}', api.add_route('/textmessages',
textmessage.TextMessageCollection()) textmessage.TextMessageCollection())
api.add_route('/textmessages/{id_}', api.add_route('/textmessages/{id_}',
textmessage.TextMessageItem()) textmessage.TextMessageItem())
@ -472,14 +472,14 @@ api.add_route('/virtualmeters',
api.add_route('/virtualmeters/{id_}', api.add_route('/virtualmeters/{id_}',
virtualmeter.VirtualMeterItem()) virtualmeter.VirtualMeterItem())
api.add_route('/webmessages/from/{startdate}/to/{enddate}', api.add_route('/webmessages',
webmessage.WebMessageCollection()) webmessage.WebMessageCollection())
api.add_route('/webmessagesnew', api.add_route('/webmessagesnew',
webmessage.WebMessageStatusNewCollection()) webmessage.WebMessageStatusNewCollection())
api.add_route('/webmessages/{id_}', api.add_route('/webmessages/{id_}',
webmessage.WebMessageItem()) webmessage.WebMessageItem())
api.add_route('/wechatmessages/from/{startdate}/to/{enddate}', api.add_route('/wechatmessages',
wechatmessage.WechatMessageCollection()) wechatmessage.WechatMessageCollection())
api.add_route('/wechatmessages/{id_}', api.add_route('/wechatmessages/{id_}',
wechatmessage.WechatMessageItem()) wechatmessage.WechatMessageItem())

View File

@ -13,35 +13,46 @@ class TextMessageCollection:
pass pass
@staticmethod @staticmethod
def on_options(req, resp, startdate, enddate): def on_options(req, resp):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_get(req, resp, startdate, enddate): def on_get(req, resp):
access_control(req) access_control(req)
try:
start_datetime_local = datetime.strptime(startdate, '%Y-%m-%d') print(req.params)
except Exception: start_datetime_local = req.params.get('startdatetime')
raise falcon.HTTPError(falcon.HTTP_400, end_datetime_local = req.params.get('enddatetime')
title='API.BAD_REQUEST',
description='API.INVALID_START_DATE_FORMAT')
try:
end_datetime_local = datetime.strptime(enddate, '%Y-%m-%d')
except Exception:
raise falcon.HTTPError(falcon.HTTP_400,
title='API.BAD_REQUEST',
description='API.INVALID_END_DATE_FORMAT')
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6]) timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
if config.utc_offset[0] == '-': if config.utc_offset[0] == '-':
timezone_offset = -timezone_offset timezone_offset = -timezone_offset
start_datetime_utc = start_datetime_local.replace(tzinfo=timezone.utc) if start_datetime_local is None:
start_datetime_utc -= timedelta(minutes=timezone_offset) raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_START_DATETIME_FORMAT")
else:
start_datetime_local = str.strip(start_datetime_local)
try:
start_datetime_utc = datetime.strptime(start_datetime_local,
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
timedelta(minutes=timezone_offset)
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_START_DATETIME_FORMAT")
end_datetime_utc = end_datetime_local.replace(tzinfo=timezone.utc) if end_datetime_local is None:
end_datetime_utc -= timedelta(minutes=timezone_offset) raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
end_datetime_utc += timedelta(days=1) description="API.INVALID_END_DATETIME_FORMAT")
else:
end_datetime_local = str.strip(end_datetime_local)
try:
end_datetime_utc = datetime.strptime(end_datetime_local,
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
timedelta(minutes=timezone_offset)
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_END_DATETIME_FORMAT")
if start_datetime_utc >= end_datetime_utc: if start_datetime_utc >= end_datetime_utc:
raise falcon.HTTPError(falcon.HTTP_400, raise falcon.HTTPError(falcon.HTTP_400,

View File

@ -13,34 +13,44 @@ class WebMessageCollection:
pass pass
@staticmethod @staticmethod
def on_options(req, resp, startdate, enddate): def on_options(req, resp):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_get(req, resp, startdate, enddate): def on_get(req, resp):
try: print(req.params)
start_datetime_local = datetime.strptime(startdate, '%Y-%m-%d') start_datetime_local = req.params.get('startdatetime')
except Exception: end_datetime_local = req.params.get('enddatetime')
raise falcon.HTTPError(falcon.HTTP_400,
title='API.BAD_REQUEST',
description='API.INVALID_START_DATE_FORMAT')
try:
end_datetime_local = datetime.strptime(enddate, '%Y-%m-%d')
except Exception:
raise falcon.HTTPError(falcon.HTTP_400,
title='API.BAD_REQUEST',
description='API.INVALID_END_DATE_FORMAT')
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6]) timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
if config.utc_offset[0] == '-': if config.utc_offset[0] == '-':
timezone_offset = -timezone_offset timezone_offset = -timezone_offset
start_datetime_utc = start_datetime_local.replace(tzinfo=timezone.utc) if start_datetime_local is None:
start_datetime_utc -= timedelta(minutes=timezone_offset) raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_START_DATETIME_FORMAT")
else:
start_datetime_local = str.strip(start_datetime_local)
try:
start_datetime_utc = datetime.strptime(start_datetime_local,
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
timedelta(minutes=timezone_offset)
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_START_DATETIME_FORMAT")
end_datetime_utc = end_datetime_local.replace(tzinfo=timezone.utc) if end_datetime_local is None:
end_datetime_utc -= timedelta(minutes=timezone_offset) raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
end_datetime_utc += timedelta(days=1) description="API.INVALID_END_DATETIME_FORMAT")
else:
end_datetime_local = str.strip(end_datetime_local)
try:
end_datetime_utc = datetime.strptime(end_datetime_local,
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
timedelta(minutes=timezone_offset)
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_END_DATETIME_FORMAT")
if start_datetime_utc >= end_datetime_utc: if start_datetime_utc >= end_datetime_utc:
raise falcon.HTTPError(falcon.HTTP_400, raise falcon.HTTPError(falcon.HTTP_400,

View File

@ -13,35 +13,46 @@ class WechatMessageCollection(object):
pass pass
@staticmethod @staticmethod
def on_options(req, resp, startdate, enddate): def on_options(req, resp):
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_get(req, resp, startdate, enddate): def on_get(req, resp):
access_control(req) access_control(req)
try:
start_datetime_local = datetime.strptime(startdate, '%Y-%m-%d') print(req.params)
except Exception: start_datetime_local = req.params.get('startdatetime')
raise falcon.HTTPError(falcon.HTTP_400, end_datetime_local = req.params.get('enddatetime')
title='API.BAD_REQUEST',
description='API.INVALID_START_DATE_FORMAT')
try:
end_datetime_local = datetime.strptime(enddate, '%Y-%m-%d')
except Exception:
raise falcon.HTTPError(falcon.HTTP_400,
title='API.BAD_REQUEST',
description='API.INVALID_END_DATE_FORMAT')
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6]) timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
if config.utc_offset[0] == '-': if config.utc_offset[0] == '-':
timezone_offset = -timezone_offset timezone_offset = -timezone_offset
start_datetime_utc = start_datetime_local.replace(tzinfo=timezone.utc) if start_datetime_local is None:
start_datetime_utc -= timedelta(minutes=timezone_offset) raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_START_DATETIME_FORMAT")
else:
start_datetime_local = str.strip(start_datetime_local)
try:
start_datetime_utc = datetime.strptime(start_datetime_local,
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
timedelta(minutes=timezone_offset)
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_START_DATETIME_FORMAT")
end_datetime_utc = end_datetime_local.replace(tzinfo=timezone.utc) if end_datetime_local is None:
end_datetime_utc -= timedelta(minutes=timezone_offset) raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
end_datetime_utc += timedelta(days=1) description="API.INVALID_END_DATETIME_FORMAT")
else:
end_datetime_local = str.strip(end_datetime_local)
try:
end_datetime_utc = datetime.strptime(end_datetime_local,
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
timedelta(minutes=timezone_offset)
except ValueError:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description="API.INVALID_END_DATETIME_FORMAT")
if start_datetime_utc >= end_datetime_utc: if start_datetime_utc >= end_datetime_utc:
raise falcon.HTTPError(falcon.HTTP_400, raise falcon.HTTPError(falcon.HTTP_400,