|
@@ -7,12 +7,13 @@ import { ShadeItem } from "./ShadeItem";
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
import { intersect, polygon, segments, combine, selectIntersect, selectUnion, selectDifference, selectDifferenceRev, difference } from "polybooljs";
|
|
import { intersect, polygon, segments, combine, selectIntersect, selectUnion, selectDifference, selectDifferenceRev, difference } from "polybooljs";
|
|
import { DrawZoneItem } from "./DrawZoneItem";
|
|
import { DrawZoneItem } from "./DrawZoneItem";
|
|
-import { SItemStatus } from "@persagy-web/big/lib";
|
|
|
|
|
|
+import { SItemStatus, unzip } from "@persagy-web/big/lib";
|
|
import { Wall } from "@persagy-web/big/lib/types/floor/Wall";
|
|
import { Wall } from "@persagy-web/big/lib/types/floor/Wall";
|
|
import { CustomWall } from "./CustomWall";
|
|
import { CustomWall } from "./CustomWall";
|
|
import { SGraphItem, SGraphStyleItem } from "@persagy-web/graph/lib";
|
|
import { SGraphItem, SGraphStyleItem } from "@persagy-web/graph/lib";
|
|
-import { remove } from "js-cookie";
|
|
|
|
import { SWallItem } from "@persagy-web/big/lib/items/floor/SWallItem";
|
|
import { SWallItem } from "@persagy-web/big/lib/items/floor/SWallItem";
|
|
|
|
+// @ts-ignore
|
|
|
|
+import pako from "pako";
|
|
|
|
|
|
export class DivideFloorScene extends FloorScene {
|
|
export class DivideFloorScene extends FloorScene {
|
|
/** 划分item */
|
|
/** 划分item */
|
|
@@ -561,4 +562,106 @@ export class DivideFloorScene extends FloorScene {
|
|
clearCmdStatus() {
|
|
clearCmdStatus() {
|
|
this.drawCmd = ''
|
|
this.drawCmd = ''
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生成txt文件流
|
|
|
|
+ *
|
|
|
|
+ * @param fName 文件名
|
|
|
|
+ */
|
|
|
|
+ generateFile(fName: string) {
|
|
|
|
+ if (this.json) {
|
|
|
|
+ // const zip = new JSZip();
|
|
|
|
+ // // // // // // 名称-文件内容
|
|
|
|
+ // zip.file(fName, this.json)
|
|
|
|
+ // // console.log(zip);
|
|
|
|
+ // zip.generateAsync({ type: "blob", compression: "DEFLATE" }).then(blob => {
|
|
|
|
+ // // console.log(blob);
|
|
|
|
+ // unzip(blob);
|
|
|
|
+ // // this.upload('testmap4.jsonz', blob)
|
|
|
|
+ // // let url = URL.createObjectURL(blob);
|
|
|
|
+ // // SNetUtil.downLoad('12312312', url);
|
|
|
|
+ // let xxx = new JSZip()
|
|
|
|
+ // xxx.loadAsync(blob).then(res => {
|
|
|
|
+ // // console.log(res.files)
|
|
|
|
+ // // for(let i in res.files) {
|
|
|
|
+ // // console.log(res.files[i]);
|
|
|
|
+ // // res.files[i].async('nodebuffer').then(con => {
|
|
|
|
+ // // console.log(con);
|
|
|
|
+
|
|
|
|
+ // // })
|
|
|
|
+ // // }
|
|
|
|
+ // xxx.file('1').async("string").then(resp => {
|
|
|
|
+ // // console.log(resp)
|
|
|
|
+ // })
|
|
|
|
+ // });
|
|
|
|
+ // }, err => {
|
|
|
|
+ // console.log(err)
|
|
|
|
+ // });
|
|
|
|
+ //
|
|
|
|
+ const json = this.getMapObject()
|
|
|
|
+ // 生成压缩的字符串
|
|
|
|
+ const bl = this.zip(json);
|
|
|
|
+ // const blob = new File([bl], '1')
|
|
|
|
+ // 生成blob对象
|
|
|
|
+ const blob = new Blob([bl], { type: 'application/octet-stream' })
|
|
|
|
+ // let url = URL.createObjectURL(new Blob([bl]))
|
|
|
|
+ // SNetUtil.downLoad('12312312', url)
|
|
|
|
+ // 测试能否正常解压
|
|
|
|
+ // unzip(blob);
|
|
|
|
+ // console.log(blob)
|
|
|
|
+ // const file = new File([bl], '111')
|
|
|
|
+ this.upload(fName, blob)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传
|
|
|
|
+ *
|
|
|
|
+ * @param key 当前显示的楼层平面图的key
|
|
|
|
+ * @param blob 上传的blob对象
|
|
|
|
+ */
|
|
|
|
+ upload(key: string, blob: Blob) {
|
|
|
|
+ let reader = new FileReader();
|
|
|
|
+ reader.onloadstart = function () {
|
|
|
|
+ // 这个事件在读取开始时触发
|
|
|
|
+ console.log('start');
|
|
|
|
+ };
|
|
|
|
+ reader.onprogress = function (p) {
|
|
|
|
+ // 这个事件在读取进行中定时触发
|
|
|
|
+ console.log('onprogress--------', p);
|
|
|
|
+ };
|
|
|
|
+ reader.onload = function () {
|
|
|
|
+ // 这个事件在读取成功结束后触发
|
|
|
|
+ console.log('onload');
|
|
|
|
+ };
|
|
|
|
+ reader.onloadend = function () {
|
|
|
|
+ var xhr = new XMLHttpRequest();
|
|
|
|
+ xhr.open(
|
|
|
|
+ "POST",
|
|
|
|
+ `/image-service/common/file_upload?systemId=revit&secret=63afbef6906c342b&overwrite=true&key=${key}`
|
|
|
|
+ );
|
|
|
|
+ xhr.send(reader.result);
|
|
|
|
+ xhr.onreadystatechange = function () {
|
|
|
|
+ if (xhr.readyState == 4) {
|
|
|
|
+ console.log(xhr)
|
|
|
|
+ if (xhr.status == 200) {
|
|
|
|
+ console.log(324234);
|
|
|
|
+ } else {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ reader.readAsArrayBuffer(blob);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 压缩文件
|
|
|
|
+ *
|
|
|
|
+ * @param str 要压缩的字符串
|
|
|
|
+ */
|
|
|
|
+ zip(str: string): string {
|
|
|
|
+ var binaryString = pako.deflate(str)
|
|
|
|
+ // var binaryString = pako.gzip(escape(str), { to: 'string' });
|
|
|
|
+ return binaryString;
|
|
|
|
+ }
|
|
}
|
|
}
|