From fc2d157254d3c33348b10abe3c24a0acbf56f612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Sat, 6 Feb 2021 10:15:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A1=E6=B2=AB=E7=AE=A1=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/canvas-share-data.service.ts | 428 +++++++++++++-------------- 1 file changed, 214 insertions(+), 214 deletions(-) diff --git a/src/app/canvas-share-data.service.ts b/src/app/canvas-share-data.service.ts index 2c62212..cac236d 100644 --- a/src/app/canvas-share-data.service.ts +++ b/src/app/canvas-share-data.service.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import {ReplaySubject} from 'rxjs'; +import { ReplaySubject } from 'rxjs'; import { Observable } from 'rxjs'; import { GameMode } from './working-area/model/gameMode'; @@ -8,32 +8,32 @@ import { GameMode } from './working-area/model/gameMode'; providedIn: 'root' }) export class CanvasShareDataService { - constructor(private http:HttpClient) { } + constructor(private http: HttpClient) { } private _sendMessage: ReplaySubject = new ReplaySubject(1); examDisposalNodesData; // 考生进入时获取当前试卷的处置节点 - examFacilityAssetsData; // 考生进入时获取当前试卷要考察的消防设施 + examFacilityAssetsData; // 考生进入时获取当前试卷要考察的消防设施 examOriginaleveryStoreyData: any; // 考生答卷 总平面图/楼层/区域 楼层数据 hiddenBasicInfoFacilities: any = []; // 考生答卷 当前楼层需要隐藏的基本信息素材 - isChange:boolean = false; // 数据 是否改动 + isChange = false; // 数据 是否改动 - selectTemplateData:any; // 选择当前 模板数据 + selectTemplateData: any; // 选择当前 模板数据 // 总平面图/建筑 楼层 - selectStorey: any = {area: '', details: ''}; // 选择当前 楼层 数据 + selectStorey: any = { area: '', details: '' }; // 选择当前 楼层 数据 originalcompanyBuildingData: any; // 单位/建筑 数据 originaleveryStoreyData: any; // 总平面图/楼层/区域 楼层数据 // 总平面图/建筑 楼层 // 处置 节点 allDisposalNode: any = []; // 所有 处置节点 - allNodeMarkers: any = { highlightMarkers:{}, markers:{} }; // 灾情 标签信息 + allNodeMarkers: any = { highlightMarkers: {}, markers: {} }; // 灾情 标签信息 selectPanelPoint: DisposalNodeData = new DisposalNodeData(); // 当前数据节点 - selectPanelPointBaseData: any = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''}; // 当前 数据节点 对应 父级节点 - customizeDisposalNode:any; // 新建 自定义数据节点 底图+名称 + selectPanelPointBaseData: any = { description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: '' }; // 当前 数据节点 对应 父级节点 + customizeDisposalNode: any; // 新建 自定义数据节点 底图+名称 // 处置 节点 /** @@ -42,36 +42,36 @@ export class CanvasShareDataService { gameMode: GameMode = GameMode.BasicInformation; facilityAssetsName = new Map([ - [ '消防水池', '消防水池'], - [ '疏散楼梯', '疏散楼梯'], - [ '消防电梯', '消防电梯'], - [ '避难区域', '避难区域'], - [ '安全出口', '安全出口'], - [ '地上消火栓', '室外消火栓' ], - [ '地下消火栓', '室外消火栓' ], - [ '室内消火栓', '室内消火栓' ], - [ '供水管网', '供水管网'], - [ '湿式自动喷淋系统', '湿式自动喷淋系统'], - [ '水幕系统', '水幕系统' ], - [ '消防泵房', '消防泵房'], - [ '水泵接合器(地上)', '水泵接合器'], - [ '水泵接合器(地下)', '水泵接合器'], - [ '水泵接合器(墙壁)', '水泵接合器'], - [ '消防水泵房', '消防水泵房'], - [ '箱式消火栓', '箱式消火栓'], - [ '固定水炮', '消防水炮' ], - [ '消防水罐', '储水罐'], - [ '消防水罐2', '储水罐'], - [ '卧式水罐', '储水罐'], - [ '消防泵', '水泵' ], - [ '泡沫泵', '水泵' ], - [ '泡沫泵房', '泡沫站'], - [ '泡沫栓', '泡沫栓' ], - [ '泡沫枪', '泡沫枪'], - [ '泡沫发生器', '泡沫发生器' ], - [ '消防管网', '消防管网'], - [ '泡沫管网', '消防管网'], - [ 'DCS控制室', 'DCS控制室'] + ['消防水池', '消防水池'], + ['疏散楼梯', '疏散楼梯'], + ['消防电梯', '消防电梯'], + ['避难区域', '避难区域'], + ['安全出口', '安全出口'], + ['地上消火栓', '室外消火栓'], + ['地下消火栓', '室外消火栓'], + ['室内消火栓', '室内消火栓'], + ['供水管网', '供水管网'], + ['湿式自动喷淋系统', '湿式自动喷淋系统'], + ['水幕系统', '水幕系统'], + ['消防泵房', '消防泵房'], + ['水泵接合器(地上)', '水泵接合器'], + ['水泵接合器(地下)', '水泵接合器'], + ['水泵接合器(墙壁)', '水泵接合器'], + ['消防水泵房', '消防水泵房'], + ['箱式消火栓', '箱式消火栓'], + ['固定水炮', '消防水炮'], + ['消防水罐', '储水罐'], + ['消防水罐2', '储水罐'], + ['卧式水罐', '储水罐'], + ['消防泵', '水泵'], + ['泡沫泵', '水泵'], + ['泡沫泵房', '泡沫站'], + ['泡沫栓', '泡沫栓'], + ['泡沫枪', '泡沫枪'], + ['泡沫发生器', '泡沫发生器'], + ['消防管网', '消防管网'], + ['泡沫管网', '泡沫管网'], + ['DCS控制室', 'DCS控制室'] ]); /** * 向其他组件发送信息 * @@ -79,55 +79,55 @@ export class CanvasShareDataService { public sendMessage(message: any) { this._sendMessage.next(message); } - public getMessage(): Observable { + public getMessage(): Observable { 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 内置方法处理成功 - }) + // 分段上传 + sectionUpload(companyId: string, file) { + const data = { filename: file.name }; + return new Promise((resolve, reject) => { + this.http.post(`/api/NewMultipartUpload/PlanPlatform/${companyId}/DisposalNode`, {}, { params: data }).subscribe(async (data: any) => { // 初始化分段上传 + const objectName = data.objectName; + const uploadId = data.uploadId; + const PartNumberETag = []; // 每次返回需要保存的信息 + // 分块 处理 + const fileSize = file.size || null; // 上传文件的总大小 + const shardSize = 5 * 1024 * 1024; // 5MB一个分片 + const allSlice = Math.ceil(fileSize / shardSize); // 总文件/5MB===共分多少段 + + for (let i = 0; i < allSlice; i++) { // 循环分段上传 + const start = i * shardSize; // 切割文件开始位置 + const end = Math.min(fileSize, start + shardSize); // 切割文件结束位置 + const formData = new FormData(); + formData.append('file', file.slice(start, end)); + + // 同步写法实现异步调用 + const result = await new Promise((resolve, reject) => { + // await 需要后面返回一个 promise 对象 + this.http.post(`/api/MultipartUpload/PlanPlatform/${objectName}?uploadId=${uploadId}&partNumber=${i + 1}`, formData).subscribe((data: any) => { + const 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循环 + }); + PartNumberETag.push(result); - //分块 处理 - }) - }) + if (PartNumberETag.length === allSlice) { // 分块上传完成 + const data = PartNumberETag; + const paramsData = { 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) { + findDisposalNode(parentId: string = null, name: string = null) { if (parentId && name) { // 匹配 父id, name const returnData = this.allDisposalNode.find(item => item.parentId === parentId && item.name === name); return returnData; @@ -154,7 +154,7 @@ export class CanvasShareDataService { /** * 删除建筑数据中当前楼层的数据 */ - public deleteBuildingDataByCurrentFloorData():void { + public deleteBuildingDataByCurrentFloorData(): void { Object.keys(this.originaleveryStoreyData.data).forEach((key) => { // 删除建筑数据 delete this.originalcompanyBuildingData.data[key]; @@ -364,7 +364,7 @@ export class CompanyAdjoinInfo { * 建筑毗邻 */ export class BuildingAdjoinInfo { - public BuildingId: string; + public BuildingId: string; public Id: string; public Name: string; public Direction: number; @@ -558,62 +558,62 @@ export class DisposalNode { * 方向。 */ export enum Direction { - /** - * 东 - */ - East, - /** - * 西 - */ - West, - /** - * 南 - */ - South, - /** - * 北 - */ - North, - /** - * 东南 - */ - Southeast, - /** - * 西南 - */ - Southwest, - /** - * 东北 - */ - Northeast, - /** - * 西北 - */ - Northwest + /** + * 东 + */ + East, + /** + * 西 + */ + West, + /** + * 南 + */ + South, + /** + * 北 + */ + North, + /** + * 东南 + */ + Southeast, + /** + * 西南 + */ + Southwest, + /** + * 东北 + */ + Northeast, + /** + * 西北 + */ + Northwest } /** * 风力等级 */ export enum WindScale { - WS0, - WS1, - WS2, - WS3, - WS4, - WS5, - WS6, - WS7, - WS8, - WS9, - WS10, - WS11, - WS12, - WS13, - WS14, - WS15, - WS16, - WS17, - WS18 + WS0, + WS1, + WS2, + WS3, + WS4, + WS5, + WS6, + WS7, + WS8, + WS9, + WS10, + WS11, + WS12, + WS13, + WS14, + WS15, + WS16, + WS17, + WS18 } /** * 处置节点数据 @@ -635,9 +635,9 @@ export class DisposalNodeData { * 图片地址 */ public BackgroundImageUrl: string; - /** - * 图片地址 - */ + /** + * 图片地址 + */ public BackgroundImageAngle: number; /** * 处置节点编号 @@ -669,105 +669,105 @@ export class FloorNodeData { * 素材数据 */ export class AssetData { - /// - /// 模板编号 - /// + /// + /// 模板编号 + /// public TemplateId: string; - /// - /// 编号 - /// + /// + /// 编号 + /// public Id: string; - /// - /// 名称 - /// + /// + /// 名称 + /// public Name: string; - /// - /// 角度 - /// + /// + /// 角度 + /// public Angle: number; - /// - /// 颜色 - /// + /// + /// 颜色 + /// public Color: string; - /// - /// 坐标 - /// + /// + /// 坐标 + /// public Point: PIXI.Point; - /// - /// 宽度 - /// + /// + /// 宽度 + /// public Width: number; - /// - /// 高度 - /// + /// + /// 高度 + /// public Height: number; - /// - /// 是否启用 - /// + /// + /// 是否启用 + /// public Enabled: boolean; - /// - /// 填充方式 - /// + /// + /// 填充方式 + /// public FillMode: FillMode; - /// - /// 图片地址 - /// + /// + /// 图片地址 + /// public ImageUrl: string; - /// - /// 是否固定大小 - /// - public FixedSize: boolean; - /// - /// 点路径 - /// + /// + /// 是否固定大小 + /// + public FixedSize: boolean; + /// + /// 点路径 + /// public MultiPoint: PIXI.Point[]; - /// - /// 建筑ID - /// + /// + /// 建筑ID + /// public BuildingId: string; - /// - /// 单位ID - /// + /// + /// 单位ID + /// public CompanyId: string; - /// - /// 楼层编号 - /// + /// + /// 楼层编号 + /// public FloorId: string; - /// - /// 楼层名称 - /// + /// + /// 楼层名称 + /// public FloorName: string; - /// - /// 消防要素编号 - /// + /// + /// 消防要素编号 + /// public FireElementId: string; - /// - /// 属性列表 - /// + /// + /// 属性列表 + /// public PropertyInfos: PropertyInfo[]; - /// - /// 交互方式 - /// + /// + /// 交互方式 + /// public InteractiveMode: InteractiveMode; - /// - /// 是否来自建筑 - /// + /// + /// 是否来自建筑 + /// public IsFromBuilding: boolean; - /// - /// 渲染方式。 - /// + /// + /// 渲染方式。 + /// public DrawMode: ImageType; - /// - /// 9宫格边框数值。 - /// + /// + /// 9宫格边框数值。 + /// public Border: Border; - /// - /// 厚度。 - /// + /// + /// 厚度。 + /// public Thickness: number; - /// - /// 素材类型 - /// + /// + /// 素材类型 + /// public GameMode: GameMode; } /** @@ -808,9 +808,9 @@ export enum ImageType { */ export class Border { - public x: number; + public x: number; - public y: number; + public y: number; public z: number;