Asset point updated for the vehicle and conveyor widget 3D update delete routing completed
This commit is contained in:
@@ -4,4 +4,5 @@ const router = express.Router();
|
||||
router.post("/3dwidget/save", widget3dService.add3Dwidget);
|
||||
router.get("/3dwidgetData/:zoneId/:organization", widget3dService.get3Dwiget);
|
||||
router.get("/widget3D/:id/:organization", widget3dService.getSingle3Dwidget);
|
||||
router.patch("/widget3D/delete", widget3dService.delete3Dwidget);
|
||||
export default router;
|
||||
|
||||
@@ -1,28 +1,10 @@
|
||||
import { Request, Response } from "express";
|
||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||
interface ITriggerConveyor {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
interface ITriggerVehicle {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
|
||||
interface IPointBase {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
connections: IConnection;
|
||||
}
|
||||
|
||||
interface IPointConveyor extends IPointBase {
|
||||
rotation: number[];
|
||||
actions: Array<{
|
||||
@@ -41,25 +23,27 @@ interface IPointConveyor extends IPointBase {
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}>;
|
||||
connections: {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: Array<{ pathUUID: string; pointUUID: string }>;
|
||||
};
|
||||
}
|
||||
|
||||
interface IPointVehicle extends IPointBase {
|
||||
actions: Array<{
|
||||
actions: {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
start: { x: number; y: number } | {};
|
||||
end: { x: number; y: number } | {};
|
||||
buffer: number;
|
||||
}>;
|
||||
triggers: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}>;
|
||||
};
|
||||
connections: {
|
||||
source: { modelUUID: string; pointUUID: string };
|
||||
targets: Array<{ pathUUID: string; pointUUID: string }>;
|
||||
};
|
||||
speed: number;
|
||||
}
|
||||
export class pointService {
|
||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||
@@ -188,31 +172,31 @@ export class pointService {
|
||||
const vehiclePoint: IPointVehicle = {
|
||||
uuid: "point1UUID",
|
||||
position: [0, 1.3, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "string",
|
||||
hitCount: 1,
|
||||
isUsed: false,
|
||||
start: "start",
|
||||
end: "end",
|
||||
buffer: 0,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{ uuid: "string", name: "string", type: "string", isUsed: false },
|
||||
],
|
||||
actions: {
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "string",
|
||||
hitCount: 1,
|
||||
start: { x: 0, y: 0 },
|
||||
end: { x: 0, y: 0 },
|
||||
buffer: 0,
|
||||
},
|
||||
connections: {
|
||||
source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
source: { modelUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
targets: [{ pathUUID: "modelUUID", pointUUID: "point1UUID" }],
|
||||
},
|
||||
speed: 2,
|
||||
};
|
||||
if ("rotation" in vehiclePoint) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Rotation not allowed for Vehicle points" });
|
||||
}
|
||||
if ("triggers" in vehiclePoint) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Triggers not allowed for Vehicle points" });
|
||||
}
|
||||
|
||||
await pointModel(organization).create({
|
||||
...baseData,
|
||||
@@ -248,56 +232,3 @@ export class pointService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to remove `_id` recursively
|
||||
// const removeIdRecursively = (obj: any): any => {
|
||||
// if (Array.isArray(obj)) {
|
||||
// return obj.map(removeIdRecursively);
|
||||
// } else if (obj !== null && typeof obj === "object") {
|
||||
// const { _id, ...rest } = obj; // Remove `_id`
|
||||
// return Object.keys(rest).reduce((acc, key) => {
|
||||
// acc[key] = removeIdRecursively(rest[key]); // Recursively clean nested objects
|
||||
// return acc;
|
||||
// }, {} as any);
|
||||
// }
|
||||
// return obj;
|
||||
// };
|
||||
// static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||
// const { modelfileID, organization } = req.params;
|
||||
// try {
|
||||
// const { ConveyorModel, VehicleModel } = pointModel(organization);
|
||||
|
||||
// const conveyorData = await ConveyorModel.findOne({ modelfileID })
|
||||
// .select("-_id -createdAt -updatedAt")
|
||||
// .lean();
|
||||
|
||||
// const vehicleData = await VehicleModel.findOne({ modelfileID })
|
||||
// .select("-_id -createdAt -updatedAt")
|
||||
// .lean();
|
||||
|
||||
// if (!conveyorData && !vehicleData) {
|
||||
// return res.status(404).json({ message: "Data not found" });
|
||||
// }
|
||||
|
||||
// const combinedData = [conveyorData, vehicleData].filter(Boolean);
|
||||
|
||||
// const formattedData = combinedData.map((data) => {
|
||||
// const typedData = data as any;
|
||||
|
||||
// return {
|
||||
// modelfileID: typedData.modelfileID,
|
||||
// type: typedData.type,
|
||||
// points: Array.isArray(typedData.points)
|
||||
// ? typedData.points.map((point: any) => ({
|
||||
// position: point.position,
|
||||
// rotation: point.rotation,
|
||||
// }))
|
||||
// : [],
|
||||
// };
|
||||
// });
|
||||
|
||||
// return res.status(200).json(formattedData);
|
||||
// } catch (error) {
|
||||
// res.status(500).json({ message: "Server error", error });
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,70 +1,8 @@
|
||||
import { Request, Response } from "express";
|
||||
// import assetModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||
interface ITriggerConveyor {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
interface ITriggerVehicle {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
|
||||
interface IPointBase {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
connections: IConnection;
|
||||
}
|
||||
interface IPointConveyor extends IPointBase {
|
||||
rotation: number[];
|
||||
actions: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
material: string;
|
||||
delay: number | string;
|
||||
spawnInterval: number | string;
|
||||
isUsed: boolean;
|
||||
}>;
|
||||
triggers: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface IPointVehicle extends IPointBase {
|
||||
actions: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
buffer: number;
|
||||
}>;
|
||||
triggers: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
export class assetsFloorservice {
|
||||
static async setFloorassets(req: Request, res: Response): Promise<any> {
|
||||
@@ -162,6 +100,7 @@ export class assetsFloorservice {
|
||||
// return res.send("Type mismatch");
|
||||
// }
|
||||
if (eventData.type === "Conveyor") {
|
||||
assetData.speed = eventData.speed;
|
||||
// console.log("eventData.points: ", typeof eventData.points);
|
||||
// if (!Array.isArray(eventData.points) || eventData.points) {
|
||||
// return res
|
||||
@@ -174,22 +113,27 @@ export class assetsFloorservice {
|
||||
// .json({ message: "Invalid Conveyor point structure" });
|
||||
// }
|
||||
} else if (eventData.type === "Vehicle") {
|
||||
console.log("eventData.points: ", typeof eventData.points);
|
||||
assetData.speed = eventData.points.speed;
|
||||
if (!eventData.points) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ message: "Vehicle points must be a single object" });
|
||||
}
|
||||
// if(eventData.poin)
|
||||
if (eventData.points.rotation) {
|
||||
return res.status(400).json({
|
||||
message: "Rotation is not allowed for Vehicle points",
|
||||
});
|
||||
}
|
||||
|
||||
if (eventData.points.triggers) {
|
||||
return res.status(400).json({
|
||||
message: "triggers is not allowed for Vehicle points",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log("eventData.points: ", eventData.points);
|
||||
assetData.points = eventData.points;
|
||||
assetData.speed = eventData.speed;
|
||||
assetData.type = eventData.type;
|
||||
}
|
||||
// if (eventData) {
|
||||
@@ -280,7 +224,10 @@ export class assetsFloorservice {
|
||||
}
|
||||
|
||||
const response = findValues.map((item) => {
|
||||
console.log("item.points: ", item.points);
|
||||
console.log("item: ", item);
|
||||
console.log("item: ", item.type);
|
||||
// console.log('findValues: ', findValues);
|
||||
// console.log("item.points: ", item.points);
|
||||
const responseItem: any = {
|
||||
modeluuid: item.modeluuid,
|
||||
modelname: item.modelname,
|
||||
@@ -300,7 +247,6 @@ export class assetsFloorservice {
|
||||
|
||||
if (item.type === "Vehicle" && item.points) {
|
||||
responseItem.eventData = {
|
||||
speed: item.speed,
|
||||
type: item.type,
|
||||
points: item.points,
|
||||
};
|
||||
@@ -311,7 +257,6 @@ export class assetsFloorservice {
|
||||
|
||||
return res.status(200).json(response);
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
@@ -330,7 +275,6 @@ export class assetsFloorservice {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
@@ -373,7 +317,6 @@ export class assetsFloorservice {
|
||||
}
|
||||
static async replaceEventDatas(req: Request, res: Response): Promise<any> {
|
||||
const { organization, modeluuid, eventData } = req.body;
|
||||
console.log("req.body: ", req.body);
|
||||
try {
|
||||
const existingModel = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
@@ -382,14 +325,20 @@ export class assetsFloorservice {
|
||||
if (!existingModel)
|
||||
return res.json({ message: "Model not for this UUID" });
|
||||
else {
|
||||
let speed;
|
||||
if (existingModel.type === "Conveyor") {
|
||||
speed = eventData?.speed;
|
||||
}
|
||||
// if (existingModel.type === "Vehicle") {
|
||||
// speed = eventData?.points?.speed;
|
||||
// }
|
||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid, isArchive: false },
|
||||
{
|
||||
$set: {
|
||||
points: eventData.points,
|
||||
speed: eventData.speed,
|
||||
type: eventData.type,
|
||||
},
|
||||
points: eventData?.points,
|
||||
// speed: speed,
|
||||
type: eventData?.type || existingModel?.type,
|
||||
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
@@ -398,7 +347,7 @@ export class assetsFloorservice {
|
||||
return res.status(200).json({ message: "Data updated successfully" });
|
||||
}
|
||||
} catch (error: any) {
|
||||
res.status(500).json({ message: "Server error", error: error.message });
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export class widget3dService {
|
||||
},
|
||||
{
|
||||
position: widget?.position,
|
||||
rotation: widget?.rotation,
|
||||
Data: {
|
||||
measurements: widget?.Data.measurements,
|
||||
duration: widget?.Data.duration,
|
||||
@@ -44,6 +45,7 @@ export class widget3dService {
|
||||
type: widget.type,
|
||||
widgetID: widget.id,
|
||||
position: widget.position,
|
||||
rotation: widget.rotation,
|
||||
zoneId,
|
||||
});
|
||||
if (newWidget3d)
|
||||
@@ -128,4 +130,37 @@ export class widget3dService {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
static async delete3Dwidget(req: Request, res: Response): Promise<any> {
|
||||
const { organization, id, zoneId } = req.body;
|
||||
try {
|
||||
const existingZone = await zoneSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingZone)
|
||||
return res.status(404).json({ message: "Zone not found" });
|
||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||
widgetID: id,
|
||||
isArchive: false,
|
||||
zoneId: zoneId,
|
||||
});
|
||||
if (!existing3Dwidget) {
|
||||
return res.send("3D widget not found for the ID");
|
||||
}
|
||||
const updateWidget = await widget3dModel(organization).findOneAndUpdate(
|
||||
{
|
||||
widgetID: id,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
},
|
||||
{ isArchive: true },
|
||||
{ new: true }
|
||||
);
|
||||
if (!updateWidget)
|
||||
return res.json({ message: "3DWidget delete unsuccessfull" });
|
||||
return res.status(200).json({ message: "3DWidget deleted successfully" });
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +102,6 @@ export class panelService {
|
||||
{ $pull: { panelOrder: existingPanel.panelName } }
|
||||
);
|
||||
console.log("zonepanelname: ", zonepanelname);
|
||||
// existingZone.panelOrder.splice(index1, 1);
|
||||
// existingZone.markModified("panelOrder"); // Mark modified
|
||||
// await existingZone.save();
|
||||
}
|
||||
|
||||
return res.status(200).json({ message: "Panel deleted successfully" });
|
||||
|
||||
@@ -2,30 +2,33 @@ import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
// Common Interfaces
|
||||
interface ITriggerConveyor {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
interface ITriggerVehicle {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}
|
||||
// interface ITriggerConveyor {
|
||||
// uuid: string;
|
||||
// name: string;
|
||||
// type: string;
|
||||
// isUsed: boolean;
|
||||
// bufferTime: number;
|
||||
// }
|
||||
// interface ITriggerVehicle {
|
||||
// uuid: string;
|
||||
// name: string;
|
||||
// type: string;
|
||||
// isUsed: boolean;
|
||||
// }
|
||||
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
// interface IConnectionConveyor {
|
||||
// source: { pathUUID: string; pointUUID: string };
|
||||
// targets: { pathUUID: string; pointUUID: string }[];
|
||||
// }
|
||||
// interface IConnectionVehicle {
|
||||
// source: { modelUUID: string; pointUUID: string };
|
||||
// targets: { pathUUID: string; pointUUID: string }[];
|
||||
// }
|
||||
|
||||
// Point Types
|
||||
interface IPointBase {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
connections: IConnection;
|
||||
}
|
||||
|
||||
interface IPointConveyor extends IPointBase {
|
||||
@@ -46,25 +49,27 @@ interface IPointConveyor extends IPointBase {
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}>;
|
||||
connections: {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: Array<{ pathUUID: string; pointUUID: string }>;
|
||||
};
|
||||
}
|
||||
|
||||
interface IPointVehicle extends IPointBase {
|
||||
actions: Array<{
|
||||
actions: {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
start: { x: number; y: number } | {};
|
||||
end: { x: number; y: number } | {};
|
||||
buffer: number;
|
||||
}>;
|
||||
triggers: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}>;
|
||||
};
|
||||
speed: number;
|
||||
connections: {
|
||||
source: { modelUUID: string; pointUUID: string };
|
||||
targets: Array<{ pathUUID: string; pointUUID: string }>;
|
||||
};
|
||||
}
|
||||
|
||||
// Main Document Interface
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface Widget3d extends Document {
|
||||
widgetID: string;
|
||||
widgetName: string;
|
||||
position: [];
|
||||
rotation: [];
|
||||
isArchive: boolean;
|
||||
zoneId: string;
|
||||
Data: {
|
||||
@@ -19,6 +20,7 @@ const Widget3dSchema: Schema = new Schema(
|
||||
widgetID: { type: String },
|
||||
widgetName: { type: String, default: "Widget3D" },
|
||||
position: { type: Array },
|
||||
rotation: { type: Array },
|
||||
zoneId: { type: String },
|
||||
Data: {
|
||||
measurements: { type: Object, default: {} },
|
||||
|
||||
@@ -1,45 +1,44 @@
|
||||
const swaggerAutogen = require('swagger-autogen')
|
||||
const swaggerAutogen = require("swagger-autogen");
|
||||
|
||||
const dotenv = require('dotenv')
|
||||
const dotenv = require("dotenv");
|
||||
const path = require("path");
|
||||
|
||||
const envPath = path.resolve(__dirname, "../../../.env");
|
||||
|
||||
|
||||
dotenv.config({ path: envPath });
|
||||
const ip = require('ip')
|
||||
const ip = require("ip");
|
||||
const PORT = process.env.API_PORT;
|
||||
|
||||
const doc = {
|
||||
info: {
|
||||
title: 'dwinzo documentation',
|
||||
description: 'Description'
|
||||
title: "dwinzo documentation",
|
||||
description: "Description",
|
||||
},
|
||||
host: '185.100.212.76:5000',
|
||||
basePath: '/api/v1',
|
||||
schemes: ['http'],
|
||||
|
||||
// host: "185.100.212.76:5000",
|
||||
host: "192.168.0.102:5000",
|
||||
// basePath: "/api/v1",
|
||||
schemes: ["http"],
|
||||
};
|
||||
|
||||
const outputFile = './../../../swagger-output.json';
|
||||
const outputFile = "./../../../swagger-output.json";
|
||||
const routes = [
|
||||
'./../../api-server/Routes/user-Routes.ts',
|
||||
'./../../api-server/Routes/camera-Routes.ts',
|
||||
'./../../api-server/Routes/environments-Routes.ts',
|
||||
'./../../api-server/Routes/flooritem-Routes.ts',
|
||||
'./../../api-server/Routes/lines-Routes.ts',
|
||||
'./../../api-server/Routes/share-Routes.ts',
|
||||
'./../../api-server/Routes/wallItems-Routes.ts',
|
||||
"./../../api-server/Routes/user-Routes.ts",
|
||||
"./../../api-server/Routes/camera-Routes.ts",
|
||||
"./../../api-server/Routes/environments-Routes.ts",
|
||||
"./../../api-server/Routes/flooritem-Routes.ts",
|
||||
"./../../api-server/Routes/lines-Routes.ts",
|
||||
"./../../api-server/Routes/share-Routes.ts",
|
||||
"./../../api-server/Routes/wallItems-Routes.ts",
|
||||
"./../../api-server/Routes/floadWidgetRoute.ts",
|
||||
"./../../api-server/Routes/panelRoutes.ts",
|
||||
"./../../api-server/Routes/templateRoutes.ts",
|
||||
"./../../api-server/Routes/widget3dRoutes.ts",
|
||||
"./../../api-server/Routes/widgetRoute.ts",
|
||||
"./../../api-server/Routes/assetfloorRoutes.ts",
|
||||
"./../../api-server/Routes/assetpointRoutes.ts",
|
||||
"./../../api-server/Routes/zoneRoutes.ts",
|
||||
];
|
||||
|
||||
|
||||
|
||||
swaggerAutogen()(outputFile, routes, doc).then(() => {
|
||||
console.log('Swagger documentation generated!');
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("Swagger documentation generated!");
|
||||
});
|
||||
|
||||
@@ -158,8 +158,6 @@ export const setAssetModel = async (data: any) => {
|
||||
organization,
|
||||
} = data;
|
||||
console.log("data: ", data);
|
||||
// const position=data.position
|
||||
// const rotation=data.rotation
|
||||
try {
|
||||
const findvalue = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
@@ -168,7 +166,6 @@ export const setAssetModel = async (data: any) => {
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
console.log("findvalue: ", findvalue);
|
||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, modelname: modelname, isArchive: false },
|
||||
{
|
||||
@@ -198,25 +195,10 @@ export const setAssetModel = async (data: any) => {
|
||||
};
|
||||
|
||||
if (eventData) {
|
||||
// console.log("checkpointType?.type: ", checkpointType?.type);
|
||||
// console.log("eventData.typ: ", eventData.type);
|
||||
// if (checkpointType?.type !== eventData.type) {
|
||||
// return res.send("Type mismatch");
|
||||
// }
|
||||
if (eventData.type === "Conveyor") {
|
||||
// console.log("eventData.points: ", typeof eventData.points);
|
||||
// if (!Array.isArray(eventData.points) || eventData.points) {
|
||||
// return res
|
||||
// .status(400)
|
||||
// .json({ message: "Points must be an array" });
|
||||
// }
|
||||
// if (!eventData.points.every(validateConveyorPoint)) {
|
||||
// return res
|
||||
// .status(400)
|
||||
// .json({ message: "Invalid Conveyor point structure" });
|
||||
// }
|
||||
assetData.speed = eventData.speed;
|
||||
} else if (eventData.type === "Vehicle") {
|
||||
console.log("eventData.points: ", typeof eventData.points);
|
||||
assetData.speed = eventData.points.speed;
|
||||
if (!eventData.points) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -231,29 +213,51 @@ export const setAssetModel = async (data: any) => {
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
if (eventData.points.triggers) {
|
||||
return {
|
||||
success: false,
|
||||
message: "triggers is not allowed for Vehicle points",
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
}
|
||||
assetData.points = eventData.points;
|
||||
assetData.speed = eventData.speed;
|
||||
assetData.type = eventData.type;
|
||||
}
|
||||
const assetDoc = await assetModel(organization).create(assetData);
|
||||
await assetDoc.save();
|
||||
// await assetDoc.save();
|
||||
// if(assetDoc.)
|
||||
const assetDatas = {
|
||||
modeluuid: assetDoc.modeluuid,
|
||||
modelname: assetDoc.modelname,
|
||||
modelfileID: assetDoc.modelfileID,
|
||||
position: assetDoc.position,
|
||||
rotation: assetDoc.rotation,
|
||||
isLocked: assetDoc.isLocked,
|
||||
isVisible: assetDoc.isVisible,
|
||||
eventData: {
|
||||
points: assetDoc.points,
|
||||
type: assetDoc.type,
|
||||
speed: assetDoc.speed,
|
||||
},
|
||||
};
|
||||
let assetDatas;
|
||||
if (assetDoc.type === "Conveyor") {
|
||||
assetDatas = {
|
||||
modeluuid: assetDoc.modeluuid,
|
||||
modelname: assetDoc.modelname,
|
||||
modelfileID: assetDoc.modelfileID,
|
||||
position: assetDoc.position,
|
||||
rotation: assetDoc.rotation,
|
||||
isLocked: assetDoc.isLocked,
|
||||
isVisible: assetDoc.isVisible,
|
||||
eventData: {
|
||||
points: assetDoc.points,
|
||||
type: assetDoc.type,
|
||||
speed: assetDoc.speed,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (assetDoc.type === "Vehicle") {
|
||||
assetDatas = {
|
||||
modeluuid: assetDoc.modeluuid,
|
||||
modelname: assetDoc.modelname,
|
||||
modelfileID: assetDoc.modelfileID,
|
||||
position: assetDoc.position,
|
||||
rotation: assetDoc.rotation,
|
||||
isLocked: assetDoc.isLocked,
|
||||
isVisible: assetDoc.isVisible,
|
||||
eventData: {
|
||||
points: assetDoc.points,
|
||||
type: assetDoc.type,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
message: "Model created successfully",
|
||||
@@ -304,3 +308,51 @@ export const deleteAssetModel = async (data: any) => {
|
||||
};
|
||||
}
|
||||
};
|
||||
export const replaceEventDatas = async (data: any) => {
|
||||
const { organization, modeluuid, eventData } = data;
|
||||
try {
|
||||
const existingModel = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingModel)
|
||||
return {
|
||||
success: false,
|
||||
message: "Model not for this UUID",
|
||||
organization: organization,
|
||||
};
|
||||
else {
|
||||
let speed;
|
||||
if (existingModel.type === "Conveyor") {
|
||||
speed = eventData?.speed;
|
||||
}
|
||||
// if (existingModel.type === "Vehicle") {
|
||||
// speed = eventData?.points?.speed;
|
||||
// }
|
||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid, isArchive: false },
|
||||
{
|
||||
points: eventData?.points,
|
||||
// speed: speed,
|
||||
type: eventData?.type || existingModel?.type,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
if (updatedModel)
|
||||
return {
|
||||
success: true,
|
||||
message: "Data updated successfully",
|
||||
data: updatedModel,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
message: error?.message || "Error occurred while ModelAsset",
|
||||
error,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,14 +5,66 @@
|
||||
"description": "Description",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"host": "185.100.212.76:5000",
|
||||
"basePath": "/api/v1",
|
||||
"schemes": [
|
||||
"http"
|
||||
"host": "192.168.0.102:5000",
|
||||
"schemes": ["http"],
|
||||
"tags": [
|
||||
{
|
||||
"name": "Authentication",
|
||||
"description": "User authentication endpoints"
|
||||
},
|
||||
{
|
||||
"name": "Camera",
|
||||
"description": "Camera management endpoints"
|
||||
},
|
||||
{
|
||||
"name": "Environment",
|
||||
"description": "Environment configuration"
|
||||
},
|
||||
{
|
||||
"name": "Floor Items",
|
||||
"description": "Floor items management"
|
||||
},
|
||||
{
|
||||
"name": "Lines",
|
||||
"description": "Line drawing operations"
|
||||
},
|
||||
{
|
||||
"name": "Walls",
|
||||
"description": "Wall items management"
|
||||
},
|
||||
{
|
||||
"name": "Zones",
|
||||
"description": "Zone operations"
|
||||
},
|
||||
{
|
||||
"name": "Users Management",
|
||||
"description": "User sharing and permissions"
|
||||
},
|
||||
{
|
||||
"name": "3D widgets",
|
||||
"description": "3D widgets operations"
|
||||
},
|
||||
{
|
||||
"name": "Panels",
|
||||
"description": "Panels operations"
|
||||
},
|
||||
{
|
||||
"name": "Floating Widgets",
|
||||
"description": "Floating widgets operations"
|
||||
},
|
||||
{
|
||||
"name": "Assets",
|
||||
"description": "ModelAssets operations"
|
||||
},
|
||||
{
|
||||
"name": "Asset Points",
|
||||
"description": "Asset based structure Points"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/signup": {
|
||||
"/api/v1/signup": {
|
||||
"post": {
|
||||
"tags": ["Authentication"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -50,8 +102,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/login": {
|
||||
"/api/v1/login": {
|
||||
"post": {
|
||||
"tags": ["Authentication"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -86,8 +139,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setCamera": {
|
||||
"/api/v1/setCamera": {
|
||||
"post": {
|
||||
"tags": ["Camera"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -125,8 +179,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/getCamera/{organization}/{userId}": {
|
||||
"/api/v1/getCamera/{organization}/{userId}": {
|
||||
"get": {
|
||||
"tags": ["Camera"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -155,8 +210,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/activeCameras/{organization}": {
|
||||
"/api/v1/activeCameras/{organization}": {
|
||||
"get": {
|
||||
"tags": ["Camera"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -176,8 +232,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setEvironments": {
|
||||
"/api/v1/setEvironments": {
|
||||
"post": {
|
||||
"tags": ["Environment"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -212,8 +269,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findEnvironments/{organization}/{userId}": {
|
||||
"/api/v1/findEnvironments/{organization}/{userId}": {
|
||||
"get": {
|
||||
"tags": ["Environment"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -242,8 +300,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setfloorItems": {
|
||||
"/api/v1/setfloorItems": {
|
||||
"post": {
|
||||
"tags": ["Floor Items"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -290,8 +349,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findfloorItems/{organization}": {
|
||||
"/api/v1/findfloorItems/{organization}": {
|
||||
"get": {
|
||||
"tags": ["Floor Items"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -314,8 +374,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deletefloorItem": {
|
||||
"/api/v1/deletefloorItem": {
|
||||
"delete": {
|
||||
"tags": ["Floor Items"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -350,8 +411,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setLine": {
|
||||
"/api/v1/setLine": {
|
||||
"post": {
|
||||
"tags": ["Lines"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -386,8 +448,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/updatePoint": {
|
||||
"/api/v1/updatePoint": {
|
||||
"post": {
|
||||
"tags": ["Lines"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -419,8 +482,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findLines/{organization}": {
|
||||
"/api/v1/findLines/{organization}": {
|
||||
"get": {
|
||||
"tags": ["Lines"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -443,8 +507,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deleteLine": {
|
||||
"/api/v1/deleteLine": {
|
||||
"delete": {
|
||||
"tags": ["Lines"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -482,8 +547,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deletePoint": {
|
||||
"/api/v1/deletePoint": {
|
||||
"delete": {
|
||||
"tags": ["Lines"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -521,8 +587,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deleteLayer": {
|
||||
"/api/v1/deleteLayer": {
|
||||
"post": {
|
||||
"tags": ["Lines"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -554,8 +621,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/shareUser": {
|
||||
"/api/v1/shareUser": {
|
||||
"post": {
|
||||
"tags": ["Users Management"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -590,8 +658,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findshareUsers": {
|
||||
"/api/v1/findshareUsers": {
|
||||
"get": {
|
||||
"tags": ["Users Management"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -613,8 +682,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/setWallItems": {
|
||||
"/api/v1/setWallItems": {
|
||||
"post": {
|
||||
"tags": ["Walls"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -664,8 +734,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/findWallItems/{organization}": {
|
||||
"/api/v1/findWallItems/{organization}": {
|
||||
"get": {
|
||||
"tags": ["Walls"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -688,8 +759,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/deleteWallItem": {
|
||||
"/api/v1/deleteWallItem": {
|
||||
"delete": {
|
||||
"tags": ["Walls"],
|
||||
"description": "",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -723,6 +795,149 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v2/zone/save": {
|
||||
"post": {
|
||||
"tags": ["Zones"],
|
||||
"description": "Create or update a zone",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"organization": {
|
||||
"type": "string",
|
||||
"example": "NEWORG"
|
||||
},
|
||||
"zonesdata": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"zonename": {
|
||||
"type": "string",
|
||||
"example": "Zone 2"
|
||||
},
|
||||
"zoneId": {
|
||||
"type": "string",
|
||||
"example": "576-65-6-659"
|
||||
},
|
||||
"points": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": "number" },
|
||||
"y": { "type": "number" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": [
|
||||
[{ "x": 5, "y": 5 }],
|
||||
[{ "x": 5, "y": 5 }],
|
||||
[{ "x": 0, "y": 0 }]
|
||||
]
|
||||
},
|
||||
"viewportPosition": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": "number" }
|
||||
}
|
||||
},
|
||||
"example": [{ "x": 0 }]
|
||||
},
|
||||
"viewPortCenter": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": "number" },
|
||||
"y": { "type": "number" }
|
||||
}
|
||||
},
|
||||
"userid": {
|
||||
"type": "string"
|
||||
},
|
||||
"layer": {
|
||||
"type": "number",
|
||||
"example": 1
|
||||
},
|
||||
"sceneID": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"zonename",
|
||||
"zoneId",
|
||||
"points",
|
||||
"viewportPosition",
|
||||
"layer"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["organization", "zonesdata"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": { "type": "string" },
|
||||
"zoneData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"zoneName": { "type": "string" },
|
||||
"points": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": "number" },
|
||||
"y": { "type": "number" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"viewPortposition": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": "number" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"viewPortCenter": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": "number" },
|
||||
"y": { "type": "number" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"201": {
|
||||
"description": "Created"
|
||||
},
|
||||
"404": {
|
||||
"description": "Zone not updated"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user