Asset point updated for the vehicle and conveyor widget 3D update delete routing completed
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user