Browse Source

泡沫管网

develop
徐振升 4 years ago
parent
commit
fc2d157254
  1. 428
      src/app/canvas-share-data.service.ts

428
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<any> = new ReplaySubject<any>(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<string, string>([
[ '消防水池', '消防水池'],
[ '疏散楼梯', '疏散楼梯'],
[ '消防电梯', '消防电梯'],
[ '避难区域', '避难区域'],
[ '安全出口', '安全出口'],
[ '地上消火栓', '室外消火栓' ],
[ '地下消火栓', '室外消火栓' ],
[ '室内消火栓', '室内消火栓' ],
[ '供水管网', '供水管网'],
[ '湿式自动喷淋系统', '湿式自动喷淋系统'],
[ '水幕系统', '水幕系统' ],
[ '消防泵房', '消防泵房'],
[ '水泵接合器(地上)', '水泵接合器'],
[ '水泵接合器(地下)', '水泵接合器'],
[ '水泵接合器(墙壁)', '水泵接合器'],
[ '消防水泵房', '消防水泵房'],
[ '箱式消火栓', '箱式消火栓'],
[ '固定水炮', '消防水炮' ],
[ '消防水罐', '储水罐'],
[ '消防水罐2', '储水罐'],
[ '卧式水罐', '储水罐'],
[ '消防泵', '水泵' ],
[ '泡沫泵', '水泵' ],
[ '泡沫泵房', '泡沫站'],
[ '泡沫栓', '泡沫栓' ],
[ '泡沫枪', '泡沫枪'],
[ '泡沫发生器', '泡沫发生器' ],
[ '消防管网', '消防管网'],
[ '泡沫管网', '消防管网'],
[ 'DCS控制室', 'DCS控制室']
['消防水池', '消防水池'],
['疏散楼梯', '疏散楼梯'],
['消防电梯', '消防电梯'],
['避难区域', '避难区域'],
['安全出口', '安全出口'],
['地上消火栓', '室外消火栓'],
['地下消火栓', '室外消火栓'],
['室内消火栓', '室内消火栓'],
['供水管网', '供水管网'],
['湿式自动喷淋系统', '湿式自动喷淋系统'],
['水幕系统', '水幕系统'],
['消防泵房', '消防泵房'],
['水泵接合器(地上)', '水泵接合器'],
['水泵接合器(地下)', '水泵接合器'],
['水泵接合器(墙壁)', '水泵接合器'],
['消防水泵房', '消防水泵房'],
['箱式消火栓', '箱式消火栓'],
['固定水炮', '消防水炮'],
['消防水罐', '储水罐'],
['消防水罐2', '储水罐'],
['卧式水罐', '储水罐'],
['消防泵', '水泵'],
['泡沫泵', '水泵'],
['泡沫泵房', '泡沫站'],
['泡沫栓', '泡沫栓'],
['泡沫枪', '泡沫枪'],
['泡沫发生器', '泡沫发生器'],
['消防管网', '消防管网'],
['泡沫管网', '泡沫管网'],
['DCS控制室', 'DCS控制室']
]);
/** * *
@ -79,55 +79,55 @@ export class CanvasShareDataService {
public sendMessage(message: any) {
this._sendMessage.next(message);
}
public getMessage(): Observable <any> {
public getMessage(): Observable<any> {
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 {
/// <summary>
/// 模板编号
/// </summary>
/// <summary>
/// 模板编号
/// </summary>
public TemplateId: string;
/// <summary>
/// 编号
/// </summary>
/// <summary>
/// 编号
/// </summary>
public Id: string;
/// <summary>
/// 名称
/// </summary>
/// <summary>
/// 名称
/// </summary>
public Name: string;
/// <summary>
/// 角度
/// </summary>
/// <summary>
/// 角度
/// </summary>
public Angle: number;
/// <summary>
/// 颜色
/// </summary>
/// <summary>
/// 颜色
/// </summary>
public Color: string;
/// <summary>
/// 坐标
/// </summary>
/// <summary>
/// 坐标
/// </summary>
public Point: PIXI.Point;
/// <summary>
/// 宽度
/// </summary>
/// <summary>
/// 宽度
/// </summary>
public Width: number;
/// <summary>
/// 高度
/// </summary>
/// <summary>
/// 高度
/// </summary>
public Height: number;
/// <summary>
/// 是否启用
/// </summary>
/// <summary>
/// 是否启用
/// </summary>
public Enabled: boolean;
/// <summary>
/// 填充方式
/// </summary>
/// <summary>
/// 填充方式
/// </summary>
public FillMode: FillMode;
/// <summary>
/// 图片地址
/// </summary>
/// <summary>
/// 图片地址
/// </summary>
public ImageUrl: string;
/// <summary>
/// 是否固定大小
/// </summary>
public FixedSize: boolean;
/// <summary>
/// 点路径
/// </summary>
/// <summary>
/// 是否固定大小
/// </summary>
public FixedSize: boolean;
/// <summary>
/// 点路径
/// </summary>
public MultiPoint: PIXI.Point[];
/// <summary>
/// 建筑ID
/// </summary>
/// <summary>
/// 建筑ID
/// </summary>
public BuildingId: string;
/// <summary>
/// 单位ID
/// </summary>
/// <summary>
/// 单位ID
/// </summary>
public CompanyId: string;
/// <summary>
/// 楼层编号
/// </summary>
/// <summary>
/// 楼层编号
/// </summary>
public FloorId: string;
/// <summary>
/// 楼层名称
/// </summary>
/// <summary>
/// 楼层名称
/// </summary>
public FloorName: string;
/// <summary>
/// 消防要素编号
/// </summary>
/// <summary>
/// 消防要素编号
/// </summary>
public FireElementId: string;
/// <summary>
/// 属性列表
/// </summary>
/// <summary>
/// 属性列表
/// </summary>
public PropertyInfos: PropertyInfo[];
/// <summary>
/// 交互方式
/// </summary>
/// <summary>
/// 交互方式
/// </summary>
public InteractiveMode: InteractiveMode;
/// <summary>
/// 是否来自建筑
/// </summary>
/// <summary>
/// 是否来自建筑
/// </summary>
public IsFromBuilding: boolean;
/// <summary>
/// 渲染方式。
/// </summary>
/// <summary>
/// 渲染方式。
/// </summary>
public DrawMode: ImageType;
/// <summary>
/// 9宫格边框数值。
/// </summary>
/// <summary>
/// 9宫格边框数值。
/// </summary>
public Border: Border;
/// <summary>
/// 厚度。
/// </summary>
/// <summary>
/// 厚度。
/// </summary>
public Thickness: number;
/// <summary>
/// 素材类型
/// </summary>
/// <summary>
/// 素材类型
/// </summary>
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;

Loading…
Cancel
Save