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("/3dwidgetData/:zoneId/:organization", widget3dService.get3Dwiget);
|
||||||
router.get("/widget3D/:id/:organization", widget3dService.getSingle3Dwidget);
|
router.get("/widget3D/:id/:organization", widget3dService.getSingle3Dwidget);
|
||||||
router.patch("/widget3D/delete", widget3dService.delete3Dwidget);
|
router.patch("/widget3D/delete", widget3dService.delete3Dwidget);
|
||||||
|
router.patch("/modifyPR/widget3D", widget3dService.update3DpositionRotation);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -42,46 +42,6 @@ export class assetsFloorservice {
|
|||||||
);
|
);
|
||||||
return res.status(201).json(updatevalue);
|
return res.status(201).json(updatevalue);
|
||||||
} else {
|
} 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 = {
|
let assetData: any = {
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
@@ -94,24 +54,8 @@ export class assetsFloorservice {
|
|||||||
|
|
||||||
console.log("eventData: ", eventData);
|
console.log("eventData: ", eventData);
|
||||||
if (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") {
|
if (eventData.type === "Conveyor") {
|
||||||
assetData.speed = eventData.speed;
|
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") {
|
} else if (eventData.type === "Vehicle") {
|
||||||
assetData.speed = eventData.points.speed;
|
assetData.speed = eventData.points.speed;
|
||||||
if (!eventData.points) {
|
if (!eventData.points) {
|
||||||
@@ -119,7 +63,6 @@ export class assetsFloorservice {
|
|||||||
.status(400)
|
.status(400)
|
||||||
.json({ message: "Vehicle points must be a single object" });
|
.json({ message: "Vehicle points must be a single object" });
|
||||||
}
|
}
|
||||||
// if(eventData.poin)
|
|
||||||
if (eventData.points.rotation) {
|
if (eventData.points.rotation) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
message: "Rotation is not allowed for Vehicle points",
|
message: "Rotation is not allowed for Vehicle points",
|
||||||
@@ -136,66 +79,6 @@ export class assetsFloorservice {
|
|||||||
assetData.points = eventData.points;
|
assetData.points = eventData.points;
|
||||||
assetData.type = eventData.type;
|
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);
|
const assetDoc = await assetModel(organization).create(assetData);
|
||||||
await assetDoc.save();
|
await assetDoc.save();
|
||||||
|
|
||||||
@@ -204,9 +87,6 @@ export class assetsFloorservice {
|
|||||||
modelId: assetDoc._id,
|
modelId: assetDoc._id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// } else {
|
|
||||||
// return res.json({ message: "Type not matched" });
|
|
||||||
// }
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating flooritems:", error);
|
console.error("Error creating flooritems:", error);
|
||||||
res.status(500).json({ message: "Failed to create flooritems" });
|
res.status(500).json({ message: "Failed to create flooritems" });
|
||||||
@@ -224,8 +104,8 @@ export class assetsFloorservice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = findValues.map((item) => {
|
const response = findValues.map((item) => {
|
||||||
console.log("item: ", item);
|
// console.log("item: ", item);
|
||||||
console.log("item: ", item.type);
|
// console.log("item: ", item.type);
|
||||||
// console.log('findValues: ', findValues);
|
// console.log('findValues: ', findValues);
|
||||||
// console.log("item.points: ", item.points);
|
// console.log("item.points: ", item.points);
|
||||||
const responseItem: any = {
|
const responseItem: any = {
|
||||||
@@ -329,16 +209,11 @@ export class assetsFloorservice {
|
|||||||
if (existingModel.type === "Conveyor") {
|
if (existingModel.type === "Conveyor") {
|
||||||
speed = eventData?.speed;
|
speed = eventData?.speed;
|
||||||
}
|
}
|
||||||
// if (existingModel.type === "Vehicle") {
|
|
||||||
// speed = eventData?.points?.speed;
|
|
||||||
// }
|
|
||||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid, isArchive: false },
|
{ modeluuid, isArchive: false },
|
||||||
{
|
{
|
||||||
points: eventData?.points,
|
points: eventData?.points,
|
||||||
// speed: speed,
|
|
||||||
type: eventData?.type || existingModel?.type,
|
type: eventData?.type || existingModel?.type,
|
||||||
|
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export class widget3dService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
position: widget?.position,
|
position: widget?.position,
|
||||||
rotation: widget?.rotation,
|
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data.measurements,
|
measurements: widget?.Data.measurements,
|
||||||
duration: widget?.Data.duration,
|
duration: widget?.Data.duration,
|
||||||
@@ -78,40 +77,51 @@ export class widget3dService {
|
|||||||
type: widget.type,
|
type: widget.type,
|
||||||
id: widget.widgetID,
|
id: widget.widgetID,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
|
rotation: widget?.rotation,
|
||||||
}));
|
}));
|
||||||
return res.status(200).json(zonebasedWidget);
|
return res.status(200).json(zonebasedWidget);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// static async update3Dposition(req: Request, res: Response): Promise<any> {
|
static async update3DpositionRotation(
|
||||||
// try {
|
req: Request,
|
||||||
// const { organization, id, position, zoneId } = req.body;
|
res: Response
|
||||||
// const existing3Dwidget = await widget3dModel(organization).findOne({
|
): Promise<any> {
|
||||||
// widgetID: id,
|
try {
|
||||||
// isArchive: false,
|
const { organization, id, position, rotation, zoneId } = req.body;
|
||||||
// });
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
// if (existing3Dwidget) {
|
zoneId: zoneId,
|
||||||
// const update3dwidget = await widget3dModel(
|
isArchive: false,
|
||||||
// organization
|
});
|
||||||
// ).findOneAndUpdate(
|
if (!existingZone)
|
||||||
// {
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
// widgetID: id,
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
// zoneId: zoneId,
|
widgetID: id,
|
||||||
// isArchive: false,
|
zoneId: zoneId,
|
||||||
// },
|
isArchive: false,
|
||||||
// { position: position },
|
});
|
||||||
// { upsert: true, new: true }
|
if (existing3Dwidget) {
|
||||||
// );
|
const update3dwidget = await widget3dModel(
|
||||||
// if (update3dwidget)
|
organization
|
||||||
// return res.status(200).send("widget update successfully");
|
).findOneAndUpdate(
|
||||||
// } else {
|
{
|
||||||
// return res.status(404).send("widget not found");
|
widgetID: id,
|
||||||
// }
|
zoneId: zoneId,
|
||||||
// } catch (error: any) {
|
isArchive: false,
|
||||||
// return res.status(500).send(error.message);
|
},
|
||||||
// }
|
{ 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> {
|
static async getSingle3Dwidget(req: Request, res: Response): Promise<any> {
|
||||||
const { organization, id } = req.params;
|
const { organization, id } = req.params;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ const doc = {
|
|||||||
title: "dwinzo documentation",
|
title: "dwinzo documentation",
|
||||||
description: "Description",
|
description: "Description",
|
||||||
},
|
},
|
||||||
// host: "185.100.212.76:5000",
|
host: "185.100.212.76:5000",
|
||||||
host: "192.168.0.102:5000",
|
// host: "192.168.0.102:5000",
|
||||||
// basePath: "/api/v1",
|
// basePath: "/api/v1",
|
||||||
schemes: ["http"],
|
schemes: ["http"],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"description": "Description",
|
"description": "Description",
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"host": "192.168.0.102:5000",
|
"host": "185.100.212.76:5000",
|
||||||
"schemes": ["http"],
|
"schemes": ["http"],
|
||||||
"tags": [
|
"tags": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user