邵佳豪 4 years ago
parent
commit
12ecb7cb3a
  1. 47
      src/app/canvas-share-data.service.ts
  2. 25
      src/app/ui/collection-tools-building/collection-tools.component.spec.ts
  3. 8
      src/app/ui/collection-tools-building/collection-tools.component.ts
  4. 25
      src/app/ui/collection-tools-plan/collection-tools.component.spec.ts
  5. 10
      src/app/ui/collection-tools-plan/collection-tools.component.ts
  6. 1
      src/app/ui/collection-tools-plan/leftFunctionalDomain.ts
  7. 2
      src/app/ui/collection-tools/collection-tools.component.html
  8. 25
      src/app/ui/collection-tools/collection-tools.component.spec.ts
  9. 14
      src/app/ui/collection-tools/collection-tools.component.ts
  10. 4
      src/app/ui/collection-tools/leftFunctionalDomain.ts
  11. 16
      src/app/ui/collection-tools/save.ts
  12. 93
      src/app/working-area/working-area.component.ts

47
src/app/canvas-share-data.service.ts

@ -1,3 +1,4 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {ReplaySubject} from 'rxjs';
import { Observable } from 'rxjs';
@ -7,7 +8,7 @@ import { GameMode } from './working-area/model/gameMode';
providedIn: 'root'
})
export class CanvasShareDataService {
constructor() { }
constructor(private http:HttpClient) { }
private _sendMessage: ReplaySubject<any> = new ReplaySubject<any>(1);
examDisposalNodesData; // 考生进入时获取当前试卷的处置节点
@ -20,7 +21,6 @@ export class CanvasShareDataService {
isChange:boolean = false; // 数据 是否改动
selectTemplateData:any; // 选择当前 模板数据
isMultiSelect:boolean = false; // 单选/多选 模板图标
// 总平面图/建筑 楼层
selectStorey: any = {area: '', details: ''}; // 选择当前 楼层 数据
@ -82,6 +82,49 @@ export class CanvasShareDataService {
return this._sendMessage.asObservable();
}
//分段上传
sectionUpload (companyId:string,file) {
let data = {filename: file.name}
return new Promise ((resolve, reject)=>{
this.http.post(`/api/NewMultipartUpload/PlanPlatform/${companyId}/DisposalNode`,{},{params:data}).subscribe(async (data:any)=>{ //初始化分段上传
let objectName = data.objectName
let uploadId = data.uploadId
let PartNumberETag = []; //每次返回需要保存的信息
//分块 处理
let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB一个分片
let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段
for (let i = 0;i < allSlice;i++) { //循环分段上传
let start = i * shardSize //切割文件开始位置
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
let formData = new FormData()
formData.append("file",file.slice(start, end))
//同步写法实现异步调用
let result = await new Promise((resolve, reject) => {
// await 需要后面返回一个 promise 对象
this.http.post(`/api/MultipartUpload/PlanPlatform/${objectName}?uploadId=${uploadId}&partNumber=${i+1}`,formData).subscribe((data:any)=>{
let msg = { "partNumber":data.partNumber || null, "eTag": data.eTag || null }
resolve(msg) // 调用 promise 内置方法处理成功
})
});
PartNumberETag.push(result)
if (PartNumberETag.length === allSlice) { //分块上传完成
let data = PartNumberETag
let paramsData = {uploadId:uploadId}
this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${objectName}`,data,{params:paramsData}).subscribe(data=>{
resolve(objectName)
})
}
}//for循环
//分块 处理
})
})
}
// 处置节点 筛选出 匹配数据 匹配不到 return undefined
findDisposalNode(parentId: string= null, name: string= null) {
if (parentId && name) { // 匹配 父id, name

25
src/app/ui/collection-tools-building/collection-tools.component.spec.ts

@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CollectionToolsComponent } from './collection-tools.component';
describe('CollectionToolsComponent', () => {
let component: CollectionToolsComponent;
let fixture: ComponentFixture<CollectionToolsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CollectionToolsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CollectionToolsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

8
src/app/ui/collection-tools-building/collection-tools.component.ts

@ -1806,14 +1806,14 @@ export class CollectionToolsBuildingComponent implements OnInit {
this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
})
} else { //楼层/区域
this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
})
}
@ -1957,7 +1957,7 @@ export class CollectionToolsBuildingComponent implements OnInit {
this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -1968,7 +1968,7 @@ export class CollectionToolsBuildingComponent implements OnInit {
this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';

25
src/app/ui/collection-tools-plan/collection-tools.component.spec.ts

@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CollectionToolsComponent } from './collection-tools.component';
describe('CollectionToolsComponent', () => {
let component: CollectionToolsComponent;
let fixture: ComponentFixture<CollectionToolsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CollectionToolsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CollectionToolsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

10
src/app/ui/collection-tools-plan/collection-tools.component.ts

@ -1735,7 +1735,7 @@ export class CollectionToolsPlanComponent implements OnInit {
let dialogRef = this.dialog.open(leftFunctionalDomainComponentPlan,{data});
dialogRef.afterClosed().subscribe(data=>{
if (data =='总平面图') {
this.renovateSitePlan()
this.sitePlanData.length? this.renovateSitePlan() : this.getSitePlan()
} else if (data =='建筑') {
this.renovateBuilding()
}
@ -1816,14 +1816,14 @@ export class CollectionToolsPlanComponent implements OnInit {
this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
})
} else { //楼层/区域
this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
})
}
@ -1967,7 +1967,7 @@ export class CollectionToolsPlanComponent implements OnInit {
this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -1978,7 +1978,7 @@ export class CollectionToolsPlanComponent implements OnInit {
this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';

1
src/app/ui/collection-tools-plan/leftFunctionalDomain.ts

@ -55,7 +55,6 @@ export class leftFunctionalDomainComponentPlan implements OnInit {
formData.append("file",this.file)
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{
let imgURL = '/api/Objects/WebPlan2D/' + data.objectName
console.log(imgURL)
if (!this.data.isBuilding) { //总平面图 创建平面图
let data = {
companyId: sessionStorage.getItem('companyId'),

2
src/app/ui/collection-tools/collection-tools.component.html

@ -15,7 +15,7 @@
</span>
<span class="marginLeftRight">
<mat-checkbox color="primary" [(ngModel)]="canvasData.isMultiSelect"></mat-checkbox> 多选
<mat-checkbox color="primary" [(ngModel)]="isMultiSelect" (change)='changeMultiSelect($event)'></mat-checkbox> 多选
</span>
<span class="marginLeftRight">
<mat-checkbox color="primary" [(ngModel)]="isShowLegend" (change)='changeLegend($event)' [disabled]='this.canvasData.selectPanelPoint.BackgroundImageUrl'></mat-checkbox> 显示图例

25
src/app/ui/collection-tools/collection-tools.component.spec.ts

@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CollectionToolsComponent } from './collection-tools.component';
describe('CollectionToolsComponent', () => {
let component: CollectionToolsComponent;
let fixture: ComponentFixture<CollectionToolsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CollectionToolsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CollectionToolsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

14
src/app/ui/collection-tools/collection-tools.component.ts

@ -1569,6 +1569,8 @@ export class CollectionToolsComponent implements OnInit {
beforeOneCheckedBuildingIsShow:boolean = false; //想定作业下 建筑是否显示
togglebeforeOneCheckedBuilding () { this.beforeOneCheckedBuildingIsShow = !this.beforeOneCheckedBuildingIsShow }
isMultiSelect:boolean = false; // 多选/单选 切换
changeMultiSelect (e) { this.canvas.setMulitSelect(this.isMultiSelect) }
isShowLegend:boolean = true; //图例是否显示
changeLegend (e) { this.canvasData.selectPanelPoint.BackgroundImageUrl? null : this.canvas.setLegendVisible(this.isShowLegend) }
@ -1594,7 +1596,7 @@ export class CollectionToolsComponent implements OnInit {
}
sitePlanData:any = []; //总平面图 楼层/区域 数据
selectingSitePlan:any; //选中的 平面图 楼层/区域
selectingSitePlan:any = {id:null}; //选中的 平面图 楼层/区域
selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index
//获取总平面图
@ -1842,14 +1844,14 @@ export class CollectionToolsComponent implements OnInit {
this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
})
} else { //楼层/区域
this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
})
}
@ -1993,7 +1995,7 @@ export class CollectionToolsComponent implements OnInit {
this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -2004,7 +2006,7 @@ export class CollectionToolsComponent implements OnInit {
this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle)
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -2123,6 +2125,7 @@ export class CollectionToolsComponent implements OnInit {
//获取所有处置节点
getDisposalNode () {
this.selectDisposalNode = ''
this.canvasData.selectPanelPoint = new DisposalNodeData();
let params = {disasterId: this.allFirePlan[0].id || ''}
this.http.get('/api/DisasterData/Markers',{params:params}).subscribe(data=>{ //灾情标签信息
this.canvasData.allNodeMarkers = data
@ -2398,6 +2401,7 @@ export class CollectionToolsComponent implements OnInit {
//自定义数据节点 时
async customizeNodes() {
this.canvasData.selectPanelPoint.BackgroundImageAngle = 0
await this.canvas.loadNoRelevantInformationDisposalPlan(this.canvasData.selectPanelPoint)
let other = {
children: [],

4
src/app/ui/collection-tools/leftFunctionalDomain.ts

@ -145,14 +145,14 @@ export class addBGCDisposalNodeComponent implements OnInit {
//上传图片
selectFile (e) {
if (e.target.files.length) {
let maxSize = 5*1024*1024
let maxSize = 10*1024*1024
if (e.target.files[0].size <= maxSize) {
this.file = e.target.files[0]
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传图片需小于5MB','确定',config);
this.snackBar.open('上传图片需小于10MB','确定',config);
}
}
}

16
src/app/ui/collection-tools/save.ts

@ -332,11 +332,17 @@ export class saveOneDialog {
return new Promise((resolve,reject)=>{
if (this.canvasData.selectPanelPoint.BackgroundImageUrl && !this.canvasData.selectPanelPoint.DisposalNodeId) { //新建逻辑
if (this.canvasData.customizeDisposalNode) {
let formData = new FormData()
formData.append("file",this.canvasData.customizeDisposalNode.file)
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}/DisposalNode`,formData).subscribe((data:any)=>{
resolve('/api/Objects/WebPlan2D/' + data.objectName)
})
let fiveSize = 5*1024*1024
if (this.canvasData.customizeDisposalNode.file.size <= fiveSize) { //小于5MB
let formData = new FormData()
formData.append("file",this.canvasData.customizeDisposalNode.file)
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}/DisposalNode`,formData).subscribe((data:any)=>{
resolve('/api/Objects/WebPlan2D/' + data.objectName)
})
} else { //大于5MB
let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'),this.canvasData.customizeDisposalNode.file)
upload.then(res=>{ resolve('/api/Objects/PlanPlatform/' + res) })
} //else
}
} else {
resolve(null)

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

@ -109,11 +109,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*
*/
private enterPaintEndButton = PIXI.Sprite.from('assets/images/enterPaintButton.png');
/**
*
*/
editorPointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png');
backgroundTexture: PIXI.Texture = PIXI.Texture.from('assets/images/noImg.png');
/**
*
*/
@ -159,24 +159,34 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
PIXI.utils.skipHello();
this.sayHello();
this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => {
event.stopPropagation();
if (event.keyCode === 17) {
this.isCtrlKeyClicked = true;
}
// event.stopPropagation();
// if (event.keyCode === 17) {
// this.isCtrlKeyClicked = true;
// }
});
this.eventManager.addGlobalEventListener('window', 'keyup', (event: any) => {
event.stopPropagation();
if (event.keyCode === 17) {
this.isCtrlKeyClicked = false;
this.rectToolGraphics.visible = false;
this.rectToolGraphics.clear();
}
// event.stopPropagation();
// if (event.keyCode === 17) {
// this.isCtrlKeyClicked = false;
// this.rectToolGraphics.visible = false;
// this.rectToolGraphics.clear();
// }
// 按Del键删除选中的图标
if (event.keyCode === 46) {
this.deleteSelectedShape();
}
});
}
public setMulitSelect(b: boolean) {
if (b) {
this.isCtrlKeyClicked = true;
} else {
this.isCtrlKeyClicked = false;
this.rectToolGraphics.visible = false;
this.rectToolGraphics.clear();
}
}
/**
*
*/
@ -877,43 +887,44 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
/**
*
*/
public async refreshBackgroundImage(imageUrl: string = this.canvasData.selectStorey.imageUrl, imageAngle: number = this.canvasData.selectStorey.imageAngle): Promise<void> {
public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise<void> {
if (imageAngle === undefined || imageAngle === null) {
imageAngle = 0;
}
this.backgroundImage.scale.set(1);
this.backgroundImage.pivot.set(0);
this.backgroundImage.x = this.app.view.width / 2;
this.backgroundImage.y = this.app.view.height / 2;
if (imageUrl === undefined || imageUrl === null || imageUrl === '') {
this.backgroundImage.visible = false;
this.backgroundImage.texture = this.backgroundTexture;
} else {
this.backgroundImage.visible = false;
this.backgroundImage.scale.set(1);
this.backgroundImage.pivot.set(0);
this.backgroundImage.x = this.app.view.width / 2;
this.backgroundImage.y = this.app.view.height / 2;
this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl);
this.backgroundImage.angle = imageAngle;
// 等待图片加载完成
const imageWidth = this.backgroundImage.texture.width;
const imageHeight = this.backgroundImage.texture.height;
const appWidth = this.app.view.width - 470;
const appHeight = this.app.view.height;
const wScale = appWidth / imageWidth;
const hScale = appHeight / imageHeight;
const scale = wScale < hScale ? wScale : hScale;
// 设置图片缩放
this.backgroundImage.scale.set(scale);
this.backgroundImage.visible = true;
this.backgroundImage.children.forEach((item) => {
if (item instanceof AxShape) {
item.refresh();
}
});
}
this.backgroundImage.angle = imageAngle;
// 等待图片加载完成
const imageWidth = this.backgroundImage.texture.width;
const imageHeight = this.backgroundImage.texture.height;
const appWidth = this.app.view.width - 470;
const appHeight = this.app.view.height;
const wScale = appWidth / imageWidth;
const hScale = appHeight / imageHeight;
const scale = wScale < hScale ? wScale : hScale;
// 设置图片缩放
this.backgroundImage.scale.set(scale);
// this.backgroundImage.visible = true;
this.backgroundImage.children.forEach((item) => {
if (item instanceof AxShape) {
item.refresh();
}
});
}
/**
*
* @param imageUrl
* @param imageAngle
*/
public async refresh(imageUrl: string = this.canvasData.selectStorey.imageUrl,
imageAngle: number = this.canvasData.selectStorey.imageAngle): Promise<void> {
await this.refreshBackgroundImage();
public async refresh(): Promise<void> {
await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl, this.canvasData.selectStorey.imageAngle);
// 清空所有图形
this.deselectAll();
const itemList = [];
@ -1319,7 +1330,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*
*/
public async onExamineeClickFloor() {
await this.refreshBackgroundImage();
await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl,this.canvasData.selectStorey.imageAngle);
// 清空所有图形
this.deselectAll();
const itemList = [];
@ -1346,7 +1357,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* -
*/
public async onExaminerClickFloor() {
await this.refreshBackgroundImage();
await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl,this.canvasData.selectStorey.imageAngle);
// 清空所有图形
this.deselectAll();
const itemList = [];
@ -1372,7 +1383,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* -
*/
public async onExaminerClickFloor_CreateTestpaper() {
await this.refreshBackgroundImage();
await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl,this.canvasData.selectStorey.imageAngle);
// 清空所有图形
this.deselectAll();
const itemList = [];

Loading…
Cancel
Save