From 9200567a17b5a567ed14529fa0208618b4867938 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Thu, 05 Jul 2018 16:03:25 +0800
Subject: [PATCH] 设备型号配置优化
---
src/app/business/services/http/device.service.ts | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/src/app/business/services/http/device.service.ts b/src/app/business/services/http/device.service.ts
index 9fc6c5e..83c70d2 100644
--- a/src/app/business/services/http/device.service.ts
+++ b/src/app/business/services/http/device.service.ts
@@ -3,7 +3,7 @@
import { Injectable } from '@angular/core';
import { ResultBean, PageBean } from '@business/entity/grid';
import { Observable } from 'rxjs/Observable';
-import { ExampleService } from '@business/services/util/example.service';
+import { ExampleService, Criteria } from '@business/services/util/example.service';
import { Device } from '@business/entity/data';
@Injectable()
@@ -12,16 +12,36 @@
list: environment.SERVER_BASH_URL + 'device/page-list',
save: environment.SERVER_BASH_URL + 'device/add-or-modify',
delete: environment.SERVER_BASH_URL + 'device/delete-by-ids',
- count: environment.SERVER_BASH_URL +'device/count-by-example'
+ count: environment.SERVER_BASH_URL + 'device/count-by-example'
};
public getListUrl () {
return this.urls.list;
}
- public getSqlParams(queryText: string) {
+ public getSqlParams(queryMap: {[key: string]: number|string}) {
const example = new ExampleService();
- if (queryText != null && queryText !== '') {
- example.or().andLike({name: 'name', value: '%' + queryText + '%'});
- example.or().andLike({name: 'mac', value: '%' + queryText + '%'});
+ const orgId = !!queryMap.orgId ? queryMap.orgId : null;
+ const mpointId = !!queryMap.mpointId ? queryMap.mpointId : null;
+ const devMacOrName = !!queryMap.devMacOrName && !!(<string>queryMap.devMacOrName).trim() ? queryMap.devMacOrName : null;
+ let criWithMac: Criteria = null;
+ let criWithName: Criteria = null;
+ if (!!devMacOrName) {
+ criWithName = example.or().andLike({name: 'name', value: '%' + devMacOrName + '%'});
+ criWithMac = example.or().andLike({name: 'mac', value: '%' + devMacOrName + '%'});
+ }
+ if (!!mpointId) {
+ if (!!devMacOrName) {
+ criWithName.andEqualTo({name: 'monitorPointId', value: mpointId});
+ criWithMac.andEqualTo({name: 'monitorPointId', value: mpointId});
+ }else {
+ example.or().andEqualTo({name: 'monitorPointId', value: mpointId});
+ }
+ } else if (!!orgId) {
+ if (!!devMacOrName) {
+ criWithName.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`);
+ criWithMac.andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`);
+ }else {
+ example.or().andCondition(`monitor_point_id in (select id from monitor_point where organization_id = ${orgId})`);
+ }
}
return example.getSqlParam();
}
@@ -34,7 +54,7 @@
}
public countByExample(example: ExampleService): Observable<ResultBean<number>> {
return this.http.get(this.urls.count, { queryParams: example.getSqlParam()});
- };
+ }
public getPageByExample(page: PageBean, example: ExampleService): Observable<PageBean> {
let orderByClause = '';
const _queryParams = !!example ? example.getSqlParam() : '';
--
Gitblit v1.8.0