Widget 3d position & rotation update, delete
This commit is contained in:
@@ -5,4 +5,5 @@ 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);
|
||||
router.patch("/modifyPR/widget3D", widget3dService.update3DpositionRotation);
|
||||
export default router;
|
||||
|
||||
@@ -42,46 +42,6 @@ export class assetsFloorservice {
|
||||
);
|
||||
return res.status(201).json(updatevalue);
|
||||
} else {
|
||||
// const validateConveyorPoint = (point: any): boolean => {
|
||||
// return (
|
||||
// Array.isArray(point?.rotation) &&
|
||||
// Array.isArray(point?.actions) &&
|
||||
// Array.isArray(point?.triggers)
|
||||
// // point.actions.every(
|
||||
// // (action: any) => action.uuid && action.name && action.type
|
||||
// // ) &&
|
||||
// // (!point.triggers ||
|
||||
// // point.triggers.every(
|
||||
// // (trigger: any) =>
|
||||
// // trigger.uuid &&
|
||||
// // trigger.name &&
|
||||
// // trigger.type &&
|
||||
// // trigger.bufferTime !== undefined
|
||||
// // ))
|
||||
// );
|
||||
// };
|
||||
|
||||
// const validateVehiclePoint = (point: any): boolean => {
|
||||
// return (
|
||||
// !point.rotation &&
|
||||
// Array.isArray(point?.actions) &&
|
||||
// Array.isArray(point?.triggers)
|
||||
// // point.actions.every(
|
||||
// // (action: any) =>
|
||||
// // action.uuid &&
|
||||
// // action.name &&
|
||||
// // action.type &&
|
||||
// // action.hitCount !== undefined &&
|
||||
// // action.start !== undefined &&
|
||||
// // action.end !== undefined &&
|
||||
// // action.buffer !== undefined
|
||||
// // ) &&
|
||||
// // (!point.triggers ||
|
||||
// // point.triggers.every(
|
||||
// // (trigger: any) => trigger.uuid && trigger.name && trigger.type
|
||||
// // ))
|
||||
// );
|
||||
// };
|
||||
let assetData: any = {
|
||||
modeluuid,
|
||||
modelname,
|
||||
@@ -94,24 +54,8 @@ export class assetsFloorservice {
|
||||
|
||||
console.log("eventData: ", eventData);
|
||||
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") {
|
||||
assetData.speed = eventData.speed;
|
||||
// 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" });
|
||||
// }
|
||||
} else if (eventData.type === "Vehicle") {
|
||||
assetData.speed = eventData.points.speed;
|
||||
if (!eventData.points) {
|
||||
@@ -119,7 +63,6 @@ export class assetsFloorservice {
|
||||
.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",
|
||||
@@ -136,66 +79,6 @@ export class assetsFloorservice {
|
||||
assetData.points = eventData.points;
|
||||
assetData.type = eventData.type;
|
||||
}
|
||||
// if (eventData) {
|
||||
// let pointRefs: any[] = [];
|
||||
|
||||
// if (Array.isArray(eventData.points)) {
|
||||
// for (const point of eventData.points) {
|
||||
// let actionRefs: any[] = [];
|
||||
// let triggerRefs: any[] = [];
|
||||
|
||||
// if (Array.isArray(point.actions)) {
|
||||
// for (const action of point.actions) {
|
||||
// const actionDoc = await actionModel(organization).create({
|
||||
// pointsUUID: point.uuid,
|
||||
// isArchive: false,
|
||||
// uuid: action.uuid,
|
||||
// name: action.name,
|
||||
// type: action.type,
|
||||
// material: action.material,
|
||||
// delay: action.delay,
|
||||
// spawn_Interval: action.spawn_Interval,
|
||||
// });
|
||||
// await actionDoc.save();
|
||||
// actionRefs.push(actionDoc._id);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (Array.isArray(point.triggers)) {
|
||||
// for (const trigger of point.triggers) {
|
||||
// const triggerDoc = await triggerModel(organization).create({
|
||||
// pointsUUID: point.uuid,
|
||||
// isArchive: false,
|
||||
// uuid: trigger.uuid,
|
||||
// name: trigger.name,
|
||||
// type: trigger.type,
|
||||
// bufferTime: trigger.bufferTime,
|
||||
// });
|
||||
// await triggerDoc.save();
|
||||
// triggerRefs.push(triggerDoc._id);
|
||||
// }
|
||||
// }
|
||||
// // point.connections{
|
||||
// // source:{
|
||||
|
||||
// // }
|
||||
// // }
|
||||
// pointRefs.push({
|
||||
// uuid: point.uuid,
|
||||
// position: point.position || [],
|
||||
// rotation: point.rotation || [],
|
||||
// actions: actionRefs,
|
||||
// triggers: triggerRefs,
|
||||
// connections: point.connections,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// assetData.speed = eventData.speed;
|
||||
// assetData.type = eventData.type;
|
||||
// assetData.points = pointRefs;
|
||||
// }
|
||||
|
||||
const assetDoc = await assetModel(organization).create(assetData);
|
||||
await assetDoc.save();
|
||||
|
||||
@@ -204,9 +87,6 @@ export class assetsFloorservice {
|
||||
modelId: assetDoc._id,
|
||||
});
|
||||
}
|
||||
// } else {
|
||||
// return res.json({ message: "Type not matched" });
|
||||
// }
|
||||
} catch (error) {
|
||||
console.error("Error creating flooritems:", error);
|
||||
res.status(500).json({ message: "Failed to create flooritems" });
|
||||
@@ -224,8 +104,8 @@ export class assetsFloorservice {
|
||||
}
|
||||
|
||||
const response = findValues.map((item) => {
|
||||
console.log("item: ", item);
|
||||
console.log("item: ", item.type);
|
||||
// console.log("item: ", item);
|
||||
// console.log("item: ", item.type);
|
||||
// console.log('findValues: ', findValues);
|
||||
// console.log("item.points: ", item.points);
|
||||
const responseItem: any = {
|
||||
@@ -329,16 +209,11 @@ export class assetsFloorservice {
|
||||
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 }
|
||||
);
|
||||
|
||||
@@ -26,7 +26,6 @@ export class widget3dService {
|
||||
},
|
||||
{
|
||||
position: widget?.position,
|
||||
rotation: widget?.rotation,
|
||||
Data: {
|
||||
measurements: widget?.Data.measurements,
|
||||
duration: widget?.Data.duration,
|
||||
@@ -78,40 +77,51 @@ export class widget3dService {
|
||||
type: widget.type,
|
||||
id: widget.widgetID,
|
||||
position: widget.position,
|
||||
rotation: widget?.rotation,
|
||||
}));
|
||||
return res.status(200).json(zonebasedWidget);
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
// static async update3Dposition(req: Request, res: Response): Promise<any> {
|
||||
// try {
|
||||
// const { organization, id, position, zoneId } = req.body;
|
||||
// const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||
// widgetID: id,
|
||||
// isArchive: false,
|
||||
// });
|
||||
// if (existing3Dwidget) {
|
||||
// const update3dwidget = await widget3dModel(
|
||||
// organization
|
||||
// ).findOneAndUpdate(
|
||||
// {
|
||||
// widgetID: id,
|
||||
// zoneId: zoneId,
|
||||
// isArchive: false,
|
||||
// },
|
||||
// { position: position },
|
||||
// { upsert: true, new: true }
|
||||
// );
|
||||
// if (update3dwidget)
|
||||
// return res.status(200).send("widget update successfully");
|
||||
// } else {
|
||||
// return res.status(404).send("widget not found");
|
||||
// }
|
||||
// } catch (error: any) {
|
||||
// return res.status(500).send(error.message);
|
||||
// }
|
||||
// }
|
||||
static async update3DpositionRotation(
|
||||
req: Request,
|
||||
res: Response
|
||||
): Promise<any> {
|
||||
try {
|
||||
const { organization, id, position, rotation, zoneId } = req.body;
|
||||
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,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (existing3Dwidget) {
|
||||
const update3dwidget = await widget3dModel(
|
||||
organization
|
||||
).findOneAndUpdate(
|
||||
{
|
||||
widgetID: id,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
},
|
||||
{ position: position, rotation: rotation },
|
||||
{ upsert: true, new: true }
|
||||
);
|
||||
if (update3dwidget)
|
||||
return res.status(200).json("widget3D update successfully");
|
||||
} else {
|
||||
return res.send("widget not found");
|
||||
}
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
static async getSingle3Dwidget(req: Request, res: Response): Promise<any> {
|
||||
const { organization, id } = req.params;
|
||||
try {
|
||||
|
||||
@@ -14,8 +14,8 @@ const doc = {
|
||||
title: "dwinzo documentation",
|
||||
description: "Description",
|
||||
},
|
||||
// host: "185.100.212.76:5000",
|
||||
host: "192.168.0.102:5000",
|
||||
host: "185.100.212.76:5000",
|
||||
// host: "192.168.0.102:5000",
|
||||
// basePath: "/api/v1",
|
||||
schemes: ["http"],
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "Description",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"host": "192.168.0.102:5000",
|
||||
"host": "185.100.212.76:5000",
|
||||
"schemes": ["http"],
|
||||
"tags": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user