考核考试系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

732 lines
18 KiB

import { Injectable } from '@angular/core';
import {ReplaySubject} from 'rxjs';
import { Observable } from 'rxjs';
import { GameMode } from './working-area/model/gameMode';
@Injectable({
providedIn: 'root'
})
export class CanvasShareDataService {
constructor() { }
private _sendMessage: ReplaySubject<any> = new ReplaySubject<any>(1);
GameMode: any;
isChange = false; // 数据 是否改动
selectTemplateData: any; // 选择当前 模板数据
// 总平面图/建筑 楼层
selectStorey: any = {area: '', details: ''}; // 选择当前 楼层 数据
originalcompanyBuildingData: any; // 单位/建筑 数据
originaleveryStoreyData: any; // 总平面图/楼层/区域 楼层数据
// 总平面图/建筑 楼层
// 处置 节点
allDisposalNode: any = []; // 所有 处置节点
allNodeMarkers: any; // 灾情 标签信息
selectPanelPoint: DisposalNodeData = new DisposalNodeData();
selectPanelPointBaseData: any = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''}; // 当前 数据节点 所对应的 天气,详情 数据节点
// 处置 节点
/**
* 游戏模式
*/
gameMode: GameMode = GameMode.Assignment;
facilityAssetsName = new Map<string, string>([
[ '消防水池', '消防水池'],
[ '疏散楼梯', '疏散楼梯'],
[ '消防电梯', '消防电梯'],
[ '避难区域', '避难区域'],
[ '安全出口', '安全出口'],
[ '地上消火栓', '室外消火栓' ],
[ '地下消火栓', '室外消火栓' ],
[ '室内消火栓', '室内消火栓' ],
[ '供水管网', '供水管网'],
[ '湿式自动喷淋系统', '湿式自动喷淋系统'],
[ '水幕系统', '水幕系统' ],
[ '消防泵房', '消防泵房'],
[ '水泵接合器(地上)', '水泵接合器'],
[ '水泵接合器(地下)', '水泵接合器'],
[ '水泵接合器(墙壁)', '水泵接合器'],
[ '消防水泵房', '消防水泵房'],
[ '箱式消火栓', '箱式消火栓'],
[ '固定水炮', '消防水炮' ],
[ '消防水罐', '储水罐'],
[ '消防水罐2', '储水罐'],
[ '卧式水罐', '储水罐'],
[ '消防泵', '水泵' ],
[ '泡沫泵', '水泵' ],
[ '泡沫泵房', '泡沫站'],
[ '泡沫栓', '泡沫栓' ],
[ '泡沫枪', '泡沫枪'],
[ '泡沫发生器', '泡沫发生器' ],
[ '消防管网', '消防管网'],
[ 'DCS控制室', 'DCS控制室']
]);
/** * 向其他组件发送信息 *
* @param message 需要发送的信息 * @returns {Observavle<any>} */
public sendMessage(message: any) {
this._sendMessage.next(message);
}
public getMessage(): Observable <any> {
return this._sendMessage.asObservable();
}
// 处置节点 筛选出 匹配数据 匹配不到 return undefined
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;
} else { // 匹配 id
const returnData = this.allDisposalNode.find(item => item.id === parentId);
return returnData;
}
}
/**
* 获取单位毗邻信息
*/
public getCompanyAdjoinInfo(): CompanyAdjoinInfo[] {
const list: CompanyAdjoinInfo[] = [];
Object.keys(this.originalcompanyBuildingData.data).forEach((key) => {
const item = this.originalcompanyBuildingData.data[key];
if (item.Name === '毗邻') {
const adjoin = new CompanyAdjoinInfo();
adjoin.AssetId = item.Id;
adjoin.Id = '';
adjoin.ImageUrls = [];
adjoin.CompanyId = sessionStorage.getItem('companyId');
item.PropertyInfos.forEach(element => {
if (element.PropertyName === '方向') {
adjoin.Direction = Number(element.PropertyValue);
} else if (element.PropertyName === '名称/编号') {
adjoin.Name = element.PropertyValue;
} else if (element.PropertyType === PropertyType.Image) {
adjoin.ImageUrls.push(element.PropertyValue);
}
});
list.push(adjoin);
}
});
return list;
}
/**
* 获取建筑毗邻信息
*/
public getBuildingAdjoinInfo(): BuildingAdjoinInfo[] {
const list: BuildingAdjoinInfo[] = [];
Object.keys(this.originalcompanyBuildingData.data).forEach((key) => {
const item = this.originalcompanyBuildingData.data[key];
if (item.Name === '毗邻') {
const adjoin = new BuildingAdjoinInfo();
adjoin.AssetId = item.Id;
adjoin.Id = '';
adjoin.BuildingId = this.selectStorey.buildingId;
adjoin.ImageUrls = [];
item.PropertyInfos.forEach(element => {
if (element.PropertyName === '方向') {
adjoin.Direction = Number(element.PropertyValue);
} else if (element.PropertyName === '名称/编号') {
adjoin.Name = element.PropertyValue;
} else if (element.PropertyType === PropertyType.Image) {
adjoin.ImageUrls.push(element.PropertyValue);
}
});
list.push(adjoin);
}
});
return list;
}
/**
* 获取单位重点部位
*/
public getCompanyImportantLocations(): CompanyImportantLocationInfo[] {
const list: CompanyImportantLocationInfo[] = [];
Object.keys(this.originalcompanyBuildingData.data).forEach((key) => {
const item = this.originalcompanyBuildingData.data[key];
if (item.Name === '重点部位') {
const important = new CompanyImportantLocationInfo();
important.AssetId = item.Id;
important.Id = '';
important.ImageUrls = [];
important.CompanyId = sessionStorage.getItem('companyId');
item.PropertyInfos.forEach(element => {
if (element.PropertyName === '名称/编号') {
important.Name = element.PropertyValue;
} else if (element.PropertyType === PropertyType.Image) {
important.ImageUrls.push(element.PropertyValue);
} else if (element.PropertyName === '主要危险性') {
important.Hazards = element.PropertyValue;
} else if (element.PropertyName === '使用性质') {
important.Nature = element.PropertyValue;
} else if (element.PropertyName === '所在位置') {
important.Position = element.PropertyValue;
} else if (element.PropertyName === '建筑结构') {
important.Structure = element.PropertyValue;
}
});
list.push(important);
}
});
return list;
}
/**
* 获取建筑重点部位
*/
public getBuildingImportantLocations(): BuildingImportantLocationInfo[] {
const list: BuildingImportantLocationInfo[] = [];
Object.keys(this.originalcompanyBuildingData.data).forEach((key) => {
const item = this.originalcompanyBuildingData.data[key];
if (item.Name === '重点部位') {
const important = new BuildingImportantLocationInfo();
important.AssetId = item.Id;
important.Id = '';
important.ImageUrls = [];
important.BuildingId = this.selectStorey.buildingId;
item.PropertyInfos.forEach(element => {
if (element.PropertyName === '名称/编号') {
important.Name = element.PropertyValue;
} else if (element.PropertyType === PropertyType.Image) {
important.ImageUrls.push(element.PropertyValue);
} else if (element.PropertyName === '主要危险性') {
important.Hazards = element.PropertyValue;
} else if (element.PropertyName === '使用性质') {
important.Nature = element.PropertyValue;
} else if (element.PropertyName === '所在位置') {
important.Position = element.PropertyValue;
} else if (element.PropertyName === '建筑结构') {
important.Structure = element.PropertyValue;
}
});
list.push(important);
}
});
return list;
}
/**
* 获取单位消防设施
*/
public getAllCompanyFacilityAssetInfo(): CompanyFacilityAssetInfo[] {
const list: CompanyFacilityAssetInfo[] = [];
Object.keys(this.originalcompanyBuildingData.data).forEach((key) => {
const item = this.originalcompanyBuildingData.data[key];
if (this.facilityAssetsName.has(item.Name)) {
const facility = new CompanyFacilityAssetInfo();
facility.CompanyId = sessionStorage.getItem('companyId');
facility.AssetId = item.Id;
facility.Id = '';
facility.Name = this.facilityAssetsName.get(item.Name);
facility.AssetName = item.Name;
facility.PropertyInfos = item.PropertyInfos;
facility.SitePlanId = item.FloorId;
list.push(facility);
}
});
return list;
}
/**
* 获取建筑消防设施
*/
public getAllBuildingFacilityAssetInfo(): BuildingFacilityAssetInfo[] {
const list: BuildingFacilityAssetInfo[] = [];
Object.keys(this.originalcompanyBuildingData.data).forEach((key) => {
const item = this.originalcompanyBuildingData.data[key];
if (this.facilityAssetsName.has(item.Name)) {
const facility = new BuildingFacilityAssetInfo();
facility.BuildingId = this.selectStorey.buildingId;
facility.AssetId = item.Id;
facility.Id = '';
facility.Name = this.facilityAssetsName.get(item.Name);
facility.AssetName = item.Name;
facility.PropertyInfos = item.PropertyInfos;
facility.BuildingAreaId = item.FloorId;
list.push(facility);
}
});
return list;
}
/**
* 反序列化对象
* @param json 字符串
*/
public deserialize<T>(json: any): T {
const obj: T = JSON.parse(
json,
(_, val) => {
if (val === null) { return null; }
if (Array.isArray(val) || typeof val !== 'object') {
return val;
}
return Object.entries(val).reduce((a, [key, val]) => {
const count = key.length;
if (count > 1) {
a[key[0].toUpperCase() + key.substring(1, count)] = val;
} else {
a[key] = val;
}
return a;
}, {});
}
);
return obj;
}
}
/**
* 单位毗邻
*/
export class CompanyAdjoinInfo {
public CompanyId: string;
public Id: string;
public Name: string;
public Direction: number;
public ImageUrls: string[] = [];
public AssetId: string;
}
/**
* 建筑毗邻
*/
export class BuildingAdjoinInfo {
public BuildingId: string;
public Id: string;
public Name: string;
public Direction: number;
public ImageUrls: string[];
public AssetId: string;
}
/**
* 建筑重点部位
*/
export class BuildingImportantLocationInfo {
public BuildingId: string;
public Id: string;
public Name: string;
public Position: string;
public Structure: string;
public Nature: string;
public Hazards: string;
public ImageUrls: string[];
public AssetId: string;
}
/**
* 单位重点部位
*/
export class CompanyImportantLocationInfo {
public CompanyId: string;
public Id: string;
public Name: string;
public Position: string;
public Structure: string;
public Nature: string;
public Hazards: string;
public ImageUrls: string[];
public AssetId: string;
}
/**
* 单位消防素材信息
*/
export class CompanyFacilityAssetInfo {
public Id: string;
public Name: string;
public AssetName: string;
public PropertyInfos: string;
public AssetId: string;
public CompanyId: string;
public SitePlanId: string;
}
/**
* 建筑消防素材信息
*/
export class BuildingFacilityAssetInfo {
public Id: string;
public Name: string;
public AssetName: string;
public PropertyInfos: string;
public AssetId: string;
public BuildingId: string;
public BuildingAreaId: string;
}
/**
* 属性
*/
export class PropertyInfo {
// 标记位
public Tag: string;
// 属性书序
public Order: number;
// 是否启用
public Enabled: boolean;
// 是否可见
public Visible: boolean;
// 必填
public Required: boolean;
// 验证规则名称
public RuleName: string;
// 验证规则值
public RuleValue: string;
// 物理单位
public PhysicalUnit: string;
// 属性名称
public PropertyName: string;
// 属性类型
public PropertyType: PropertyType;
// 属性值
public PropertyValue: string;
}
/**
* 属性类型。
*/
export enum PropertyType {
// 单行文本。
SingleText,
// 多行文本。
MultipleText,
// 数值。
Numeric,
// 图片。
Image,
// 图片数值,专用于描述图片数量。
ImageNumeric,
// 方向
Direction,
// 布尔类型。
Boolean,
// 供给区域
SupplyArea,
// 供给类型
SupplyType
}
/**
* 处置节点
*/
export class DisposalNode {
/**
* 编号
*/
public Id: string;
/**
* 名称
*/
public Name: string;
/**
* 等级
*/
public Level: number;
/**
* 排序
*/
public Order: number;
/**
* 详情
*/
public Description: string;
/**
* 注意事项
*/
public Notes: string;
/**
* 天气
*/
public Weather: string;
/**
* 气温
*/
public AirTemperature?: number;
/**
* 风向
*/
public WindDirection: Direction;
/**
* 风力等级
*/
public WindScale: WindScale;
/**
* 图片名称
*/
public ImageNames: string[];
/**
* 图片地址
*/
public ImageUrls: string[];
/**
* 父节点编号
*/
public ParentId: string;
/**
* 灾情编号
*/
public DisasterId: string;
/**
* 预案组件编号
*/
public PlanComponentId: string;
/**
* 单位编号
*/
public CompanyId: string;
/**
* 总平面图编号
*/
public SitePlanId: string;
/**
* 建筑编号
*/
public BuildingId: string;
/**
* 建筑区域编号
*/
public BuildingAreaId: string;
}
/**
* 方向。
*/
export enum Direction {
/**
* 东
*/
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
}
/**
* 处置节点数据
*/
export class DisposalNodeData {
/**
* 编号
*/
public Id: string;
/**
* 数据
*/
public Data: any;
/**
* 版本号
*/
public Version: string;
/**
* 处置节点编号
*/
public DisposalNodeId: string;
/**
* 预案组件编号
*/
public PlanComponentId: string;
}
/**
* 楼层节点数据
*/
export class FloorNodeData {
/**
* 存量
*/
public Stock: Map<string, AssetData> = new Map<string, AssetData>();
/**
* 增量
*/
public Increment: Map<string, AssetData> = new Map<string, AssetData>();
/**
* 用户定义的增量。
*/
public DefinedIncrement: Map<string, AssetData> = new Map<string, AssetData>();
}
/**
* 素材数据
*/
export class AssetData {
/// <summary>
/// 模板编号
/// </summary>
public TemplateId: string;
/// <summary>
/// 编号
/// </summary>
public Id: string;
/// <summary>
/// 名称
/// </summary>
public Name: string;
/// <summary>
/// 角度
/// </summary>
public Angle: number;
/// <summary>
/// 颜色
/// </summary>
public Color: string;
/// <summary>
/// 坐标
/// </summary>
public Point: PIXI.Point;
/// <summary>
/// 宽度
/// </summary>
public Width: number;
/// <summary>
/// 高度
/// </summary>
public Height: number;
/// <summary>
/// 是否启用
/// </summary>
public Enabled: boolean;
/// <summary>
/// 填充方式
/// </summary>
public FillMode: FillMode;
/// <summary>
/// 图片地址
/// </summary>
public ImageUrl: string;
/// <summary>
/// 是否固定大小
/// </summary>
public FixedSize: boolean;
/// <summary>
/// 点路径
/// </summary>
public MultiPoint: PIXI.Point[];
/// <summary>
/// 建筑ID
/// </summary>
public BuildingId: string;
/// <summary>
/// 单位ID
/// </summary>
public CompanyId: string;
/// <summary>
/// 楼层编号
/// </summary>
public FloorId: string;
/// <summary>
/// 楼层名称
/// </summary>
public FloorName: string;
/// <summary>
/// 消防要素编号
/// </summary>
public FireElementId: string;
/// <summary>
/// 属性列表
/// </summary>
public PropertyInfos: PropertyInfo[];
/// <summary>
/// 交互方式
/// </summary>
public InteractiveMode: InteractiveMode;
/// <summary>
/// 是否来自建筑
/// </summary>
public IsFromBuilding: boolean;
/// <summary>
/// 渲染方式。
/// </summary>
public DrawMode: ImageType;
/// <summary>
/// 9宫格边框数值。
/// </summary>
public Border: Border;
/// <summary>
/// 厚度。
/// </summary>
public Thickness: number;
/// <summary>
/// 素材类型
/// </summary>
public GameMode: GameMode;
}
/**
* 填充模式
*/
export enum FillMode {
Color,
Image
}
/**
* 交互方式
*/
export enum InteractiveMode {
/**
* 单点。
*/
Single,
/**
* 多点不闭合。
*/
Multiple,
/**
* 多点闭合。
*/
MultipleClosed
}
/**
* 图片显示类型
*/
export enum ImageType {
Simple = 0,
Sliced = 1,
Tiled = 2,
Filled = 3
}
/**
* 边框
*/
export class Border {
public x: number;
public y: number;
public z: number;
public w: number;
}