Browse Source

[新增] bson-objectid 创建assetId

develop
徐振升 4 years ago
parent
commit
4b2c87b96c
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 107
      src/app/working-area/working-area.component.ts

5
package-lock.json generated

@ -5820,6 +5820,11 @@
"https-proxy-agent": "^2.2.1" "https-proxy-agent": "^2.2.1"
} }
}, },
"bson-objectid": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/bson-objectid/-/bson-objectid-1.3.1.tgz",
"integrity": "sha512-eQBNQXsisEAXlwiSy8zRNZdW2xDBJaEVkTPbodYR9hGxxtE548Qq7ilYOd8WAQ86xF7NRUdiWSQ1pa/TkKiE2A=="
},
"buffer": { "buffer": {
"version": "4.9.2", "version": "4.9.2",
"resolved": "https://registry.npm.taobao.org/buffer/download/buffer-4.9.2.tgz?cache=0&sync_timestamp=1573257749794&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbuffer%2Fdownload%2Fbuffer-4.9.2.tgz", "resolved": "https://registry.npm.taobao.org/buffer/download/buffer-4.9.2.tgz?cache=0&sync_timestamp=1573257749794&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbuffer%2Fdownload%2Fbuffer-4.9.2.tgz",

1
package.json

@ -25,6 +25,7 @@
"@types/cesium": "^1.59.5", "@types/cesium": "^1.59.5",
"@types/swiper": "^5.2.1", "@types/swiper": "^5.2.1",
"angular-calendar": "^0.28.2", "angular-calendar": "^0.28.2",
"bson-objectid": "^1.3.1",
"cesium": "^1.64.0", "cesium": "^1.64.0",
"date-fns": "^2.9.0", "date-fns": "^2.9.0",
"e-ngx-cesium": "^6.3.2", "e-ngx-cesium": "^6.3.2",

107
src/app/working-area/working-area.component.ts

@ -4,6 +4,8 @@ import { EventEmitter } from 'events';
import { EventManager } from '@angular/platform-browser'; import { EventManager } from '@angular/platform-browser';
import { OutlineFilter } from 'pixi-filters'; import { OutlineFilter } from 'pixi-filters';
import { CanvasShareDataService } from '../canvas-share-data.service'; import { CanvasShareDataService } from '../canvas-share-data.service';
import * as ObjectID from 'bson-objectid';
@Component({ @Component({
selector: 'app-working-area', selector: 'app-working-area',
@ -19,11 +21,17 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
@ViewChild('content') @ViewChild('content')
content: ElementRef; content: ElementRef;
// 画布程序 /**
* pixijs
*/
public app: PIXI.Application; public app: PIXI.Application;
// 加载器 /**
*
*/
public loader = PIXI.Loader.shared; public loader = PIXI.Loader.shared;
// 根目录 /**
*
*/
public backgroundImage: PIXI.Sprite; public backgroundImage: PIXI.Sprite;
/** /**
* *
@ -33,27 +41,46 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* 线 * 线
*/ */
public previewLineSegment = new PIXI.Graphics(); public previewLineSegment = new PIXI.Graphics();
// 圆形影子 /**
*
*/
public circleShadow = new PIXI.Graphics(); public circleShadow = new PIXI.Graphics();
// 鼠标位置 /**
*
*/
public mousePosition: PIXI.Point = new PIXI.Point(0, 0); public mousePosition: PIXI.Point = new PIXI.Point(0, 0);
/// 绘画模式 /**
*
*/
public paintMode: PaintMode; public paintMode: PaintMode;
// 选择器 /**
*
*/
public selection: Selection = new Selection(this); public selection: Selection = new Selection(this);
// 当前鼠标点击的点 /**
*
*/
public currentClickPoint: PIXI.Graphics = new PIXI.Graphics(); public currentClickPoint: PIXI.Graphics = new PIXI.Graphics();
// 绘制点集合 /**
*
*/
public paintPoints: PIXI.Point[] = []; public paintPoints: PIXI.Point[] = [];
// 绘制中图标 /**
*
*/
public paintingIcon: MultipointIcon; public paintingIcon: MultipointIcon;
// 绘制中的连线 /**
* 线
*/
public paintingLine: PIXI.Graphics = new PIXI.Graphics(); public paintingLine: PIXI.Graphics = new PIXI.Graphics();
// // 确认绘制完成按钮 /**
// public enterPaintEndButton: PIXI.Sprite = PIXI.Sprite.from('assets/images/caiji.jpg'); * 绿
*/
public outlineFilterGreen = new OutlineFilter(2, 0x00ff00); public outlineFilterGreen = new OutlineFilter(2, 0x00ff00);
// 拷贝数据 /**
copyData: any[] = []; *
*/
public copyData: any[] = [];
// 根据ID 找到图标 // 根据ID 找到图标
// 根据ID 找到数据 // 根据ID 找到数据
@ -91,7 +118,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
// 测试代码 // 测试代码
this.eventManager.addGlobalEventListener('window', 'keypress', (event: any) => { this.eventManager.addGlobalEventListener('window', 'keypress', (event: any) => {
if (event.keyCode === 97) { if (event.keyCode === 97) {
console.log(Guid.uuid2(24, 16)); console.log(ObjectID.default.generate());
} }
}); });
} }
@ -381,7 +408,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
FixedSize: this.canvasData.selectTemplateData.fixedSize, FixedSize: this.canvasData.selectTemplateData.fixedSize,
Height : 32, Height : 32,
Width : 32, Width : 32,
Id: Guid.uuid2(24, 16), Id: ObjectID.default.generate(),
ImageUrl: this.canvasData.selectTemplateData.imageUrl, ImageUrl: this.canvasData.selectTemplateData.imageUrl,
InteractiveMode: this.canvasData.selectTemplateData.interactiveMode, InteractiveMode: this.canvasData.selectTemplateData.interactiveMode,
MultiPoint : null, MultiPoint : null,
@ -432,7 +459,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
FixedSize: this.canvasData.selectTemplateData.fixedSize, FixedSize: this.canvasData.selectTemplateData.fixedSize,
Height: 32, Height: 32,
Width: 32, Width: 32,
Id: Guid.uuid2(24, 16), Id: ObjectID.default.generate(),
ImageUrl: this.canvasData.selectTemplateData.imageUrl, ImageUrl: this.canvasData.selectTemplateData.imageUrl,
InteractiveMode: this.canvasData.selectTemplateData.interactiveMode, InteractiveMode: this.canvasData.selectTemplateData.interactiveMode,
MultiPoint: JSON.parse(JSON.stringify(this.paintPoints)), MultiPoint: JSON.parse(JSON.stringify(this.paintPoints)),
@ -701,7 +728,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
FixedSize: this.canvasData.selectTemplateData.fixedSize, FixedSize: this.canvasData.selectTemplateData.fixedSize,
Height: 32, Height: 32,
Width: 32, Width: 32,
Id: Guid.uuid2(24, 16), Id: ObjectID.default.generate(),
ImageUrl: this.canvasData.selectTemplateData.imageUrl, ImageUrl: this.canvasData.selectTemplateData.imageUrl,
InteractiveMode: this.canvasData.selectTemplateData.interactiveMode, InteractiveMode: this.canvasData.selectTemplateData.interactiveMode,
MultiPoint: JSON.parse(JSON.stringify(this.paintPoints)), MultiPoint: JSON.parse(JSON.stringify(this.paintPoints)),
@ -743,7 +770,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.copyData.forEach(item => { this.copyData.forEach(item => {
item.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); item.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5);
const newData = JSON.parse(JSON.stringify(item)); const newData = JSON.parse(JSON.stringify(item));
newData.Id = Guid.uuid2(24, 16), newData.Id = ObjectID.default.generate(),
newData.CompanyId = companyId; newData.CompanyId = companyId;
newData.BuildingId = buildingId; newData.BuildingId = buildingId;
newData.FloorId = floorId; newData.FloorId = floorId;
@ -1327,46 +1354,6 @@ export class Selection {
}); });
} }
} }
/**
* guid
*/
export class Guid {
static uuid2(len, radix) {
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
// tslint:disable-next-line: one-variable-per-declaration
let uuid = [], i;
radix = radix || chars.length;
if (len) {
// Compact form
// tslint:disable-next-line: no-bitwise
for (i = 0; i < len; i++) { uuid[i] = chars[0 | Math.random() * radix]; }
} else {
// rfc4122, version 4 form
let r;
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
// tslint:disable-next-line: no-bitwise
r = 0 | Math.random() * 16;
// tslint:disable-next-line: no-bitwise
uuid[i] = chars[(i === 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
/** /**
* *
*/ */

Loading…
Cancel
Save