API creation for Product EventDatas and updating asset files
This commit is contained in:
4
.env
4
.env
@@ -8,4 +8,6 @@ MONGO_PASSWORD=admin321
|
||||
MONGO_AUTH_DB=admin
|
||||
MONGO_URI=mongodb://mongo/
|
||||
API_PORT=5000
|
||||
SOCKET_PORT=8000
|
||||
SOCKET_PORT=8000
|
||||
NODE_ENV=development
|
||||
FRONTEND_ORIGIN_PROD=http://185.100.212.76:8200
|
||||
@@ -1,10 +1,12 @@
|
||||
import express from 'express';
|
||||
import { floorItems } from '../controller/assets/flooritem-Services.ts';
|
||||
import { assetsFloorservice } from '../controller/simulation/assetsFloorservice.ts';
|
||||
|
||||
const router = express.Router();
|
||||
router.post('/setfloorItems',floorItems.setFloorItems)
|
||||
router.get('/findfloorItems/:organization',floorItems.getFloorItems)
|
||||
router.delete('/deletefloorItem',floorItems.deleteFloorItems)
|
||||
// router.delete('/deletefloorItem',floorItems.deleteFloorItems)
|
||||
router.delete('/deletefloorItem',assetsFloorservice.deleteFloorItems)
|
||||
|
||||
|
||||
export default router;
|
||||
11
src/api-server/Routes/productRoutes.ts
Normal file
11
src/api-server/Routes/productRoutes.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as express from "express";
|
||||
import { productFlowservice } from "../controller/simulation/productService.ts";
|
||||
const productRouter = express.Router();
|
||||
productRouter.post("/UpsertProductOrEvent", productFlowservice.productAdd);
|
||||
productRouter.get("/productData", productFlowservice.getProductDatas);
|
||||
productRouter.patch("/EventDataDelete", productFlowservice.EventDataDelete);
|
||||
productRouter.patch("/productDataDelete", productFlowservice.productDataDelete);
|
||||
productRouter.get("/AllProducts/:organization", productFlowservice.AllProductDatas);
|
||||
productRouter.patch("/productRename", productFlowservice.productRename);
|
||||
export default productRouter;
|
||||
|
||||
@@ -18,10 +18,40 @@ import assetfloorRoutes from "./Routes/assetfloorRoutes.ts";
|
||||
import floadWidgetRoutes from "./Routes/floadWidgetRoute.ts";
|
||||
import templateRoutes from "./Routes/templateRoutes.ts";
|
||||
import widget3dRoutes from "./Routes/widget3dRoutes.ts";
|
||||
import productRouter from "./Routes/productRoutes.ts";
|
||||
// import productFlowRoutes from "./Routes/productFlowRouts.ts";
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
// const allowedOriginsDev = [
|
||||
// "http://localhost:3000",
|
||||
// "http://192.168.0.183:8200",
|
||||
// "http://192.168.0.101:8200",
|
||||
// "http://192.168.0.105:8200",
|
||||
// "http://192.168.0.134:8200"
|
||||
// ];
|
||||
// const allowedOrigin =
|
||||
// process.env.NODE_ENV === "production"
|
||||
// ? process.env.FRONTEND_ORIGIN_PROD
|
||||
// : allowedOriginsDev;
|
||||
// app.use(cors({
|
||||
// origin: (origin, callback) => {
|
||||
// if (!origin) return callback(null, true);
|
||||
// if (
|
||||
// Array.isArray(allowedOrigin) &&
|
||||
// allowedOrigin.includes(origin)
|
||||
// ) {
|
||||
// return callback(null, true);
|
||||
// }
|
||||
|
||||
// if (typeof allowedOrigin === "string" && origin === allowedOrigin) {
|
||||
// return callback(null, true);
|
||||
// }
|
||||
|
||||
// return callback(new Error("Not allowed by CORS"));
|
||||
// },
|
||||
// credentials: true
|
||||
// }));
|
||||
app.use(express.json());
|
||||
dotenv.config();
|
||||
app.get("/", (req, res) => {
|
||||
@@ -48,5 +78,6 @@ app.use("/api/v2", assetfloorRoutes);
|
||||
app.use("/api/v2", floadWidgetRoutes);
|
||||
app.use("/api/v2", templateRoutes);
|
||||
app.use("/api/v2", widget3dRoutes);
|
||||
app.use("/api/v2", productRouter);
|
||||
// app.use("/api/v2", productFlowRoutes);
|
||||
export default app;
|
||||
|
||||
@@ -5,8 +5,8 @@ export class floorItems {
|
||||
static async setFloorItems(req: Request, res: Response) {
|
||||
try {
|
||||
const {
|
||||
modeluuid,
|
||||
modelname,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
modelfileID,
|
||||
rotation,
|
||||
@@ -16,15 +16,15 @@ export class floorItems {
|
||||
} = req.body;
|
||||
|
||||
const findvalue = await floorItemsModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
modelUuid: modelUuid,
|
||||
modelName: modelName,
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await floorItemsModel(
|
||||
organization
|
||||
).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, modelname: modelname },
|
||||
{ modelUuid: modelUuid, modelName: modelName },
|
||||
{
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
@@ -36,9 +36,9 @@ export class floorItems {
|
||||
res.status(201).json(updatevalue);
|
||||
} else {
|
||||
const newValue = await floorItemsModel(organization).create({
|
||||
modeluuid,
|
||||
modelUuid,
|
||||
modelfileID,
|
||||
modelname,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
isLocked,
|
||||
@@ -72,11 +72,11 @@ export class floorItems {
|
||||
}
|
||||
static async deleteFloorItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { modeluuid, modelname, organization } = req.body;
|
||||
const { modelUuid, modelName, organization } = req.body;
|
||||
|
||||
const findValue = await floorItemsModel(organization).findOneAndDelete({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
modelUuid: modelUuid,
|
||||
modelName: modelName,
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
|
||||
@@ -5,16 +5,16 @@ import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
||||
export class wallItems {
|
||||
static async setWallItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { modeluuid, modelname, position, type, csgposition,csgscale,quaternion,scale,organization } = req.body
|
||||
const { modelUuid, modelName, position, type, csgposition,csgscale,quaternion,scale,organization } = req.body
|
||||
|
||||
|
||||
const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid})
|
||||
const findvalue = await wallItenmModel(organization).findOne({ modelUuid: modelUuid})
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid },
|
||||
{ modelUuid: modelUuid },
|
||||
{
|
||||
modelname,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
@@ -28,7 +28,7 @@ export class wallItems {
|
||||
|
||||
|
||||
} else {
|
||||
const newValue = await wallItenmModel(organization).create({ modeluuid,modelname, position, type, csgposition,csgscale,quaternion,scale });
|
||||
const newValue = await wallItenmModel(organization).create({ modelUuid,modelName, position, type, csgposition,csgscale,quaternion,scale });
|
||||
|
||||
|
||||
res.status(201).json(newValue);
|
||||
@@ -61,11 +61,11 @@ export class wallItems {
|
||||
}
|
||||
static async deleteWallItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { modeluuid,modelname,organization } = req.body;
|
||||
const { modelUuid,modelName,organization } = req.body;
|
||||
|
||||
|
||||
const findValue = await wallItenmModel
|
||||
(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
|
||||
(organization).findOneAndDelete({modelUuid:modelUuid,modelName:modelName})
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
} else {
|
||||
|
||||
@@ -3,13 +3,253 @@ 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";
|
||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||
|
||||
export class assetsFloorservice {
|
||||
// static async setFloorassets(req: Request, res: Response): Promise<any> {
|
||||
// try {
|
||||
// const {
|
||||
// modelUuid,
|
||||
// modelName,
|
||||
// position,
|
||||
// modelfileID,
|
||||
// rotation,
|
||||
// isLocked,
|
||||
// isVisible,
|
||||
// organization,
|
||||
// eventData,
|
||||
// } = req.body;
|
||||
// console.log("req.body: ", req.body);
|
||||
|
||||
// const findvalue = await assetModel(organization).findOne({
|
||||
// modelUuid,
|
||||
// // modelName,
|
||||
// isArchive: false,
|
||||
// });
|
||||
// const checkpointType = await pointModel(organization).findOne({
|
||||
// modelfileID: modelfileID,
|
||||
// isArchive: false,
|
||||
// });
|
||||
|
||||
// if (findvalue) {
|
||||
// const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
// { modelUuid, isArchive: false },
|
||||
// {
|
||||
// modelName: modelName,
|
||||
// position,
|
||||
// rotation,
|
||||
// isVisible,
|
||||
// isLocked,
|
||||
// },
|
||||
// { new: true }
|
||||
// );
|
||||
// return res.status(201).json(updatevalue);
|
||||
// } else {
|
||||
// let assetData: any = {
|
||||
// modelUuid,
|
||||
// modelName,
|
||||
// position,
|
||||
// modelfileID,
|
||||
// rotation,
|
||||
// isLocked,
|
||||
// isVisible,
|
||||
// };
|
||||
|
||||
// console.log("eventData: ", eventData);
|
||||
// if (eventData) {
|
||||
// if (eventData.type === "Conveyor") {
|
||||
// assetData.speed = eventData.speed;
|
||||
// } else if (eventData.type === "Vehicle") {
|
||||
// assetData.speed = eventData.points.speed;
|
||||
// if (!eventData.points) {
|
||||
// return res
|
||||
// .status(400)
|
||||
// .json({ message: "Vehicle points must be a single object" });
|
||||
// }
|
||||
// // 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",
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// // else if(eventData.type === "ArmBot"){
|
||||
// // assetData.speed = eventData.position;
|
||||
// // }else if(eventData.type === "StaticMachine"){
|
||||
// // assetData.speed = eventData.position;
|
||||
// // }
|
||||
|
||||
// assetData.points = eventData.points;
|
||||
// assetData.type = eventData.type;
|
||||
// }
|
||||
// const assetDoc = await assetModel(organization).create(assetData);
|
||||
// await assetDoc.save();
|
||||
|
||||
// return res.status(201).json({
|
||||
// message: "Model stored successfully",
|
||||
// modelId: assetDoc._id,
|
||||
// });
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error("Error creating flooritems:", error);
|
||||
// res.status(500).json({ message: "Failed to create flooritems" });
|
||||
// }
|
||||
// }
|
||||
// static async getFloorItems(req: Request, res: Response): Promise<any> {
|
||||
// try {
|
||||
// const { organization } = req.params;
|
||||
// const findValues = await assetModel(organization)
|
||||
// .find({ isArchive: false })
|
||||
// .select("-_id -isArchive");
|
||||
|
||||
// if (!findValues || findValues.length === 0) {
|
||||
// return res.status(200).json({ message: "floorItems not found" });
|
||||
// }
|
||||
|
||||
// const response = findValues.map((item) => {
|
||||
// // 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,
|
||||
// position: item.position,
|
||||
// rotation: item.rotation,
|
||||
// modelfileID: item.modelfileID,
|
||||
// isLocked: item.isLocked,
|
||||
// isVisible: item.isVisible,
|
||||
// };
|
||||
// if (item.type === "Conveyor" && item.points.length > 0) {
|
||||
// responseItem.eventData = {
|
||||
// speed: item.speed,
|
||||
// points: item.points,
|
||||
// type: item.type,
|
||||
// };
|
||||
// }
|
||||
|
||||
// if (item.type === "Vehicle" && item.points) {
|
||||
// responseItem.eventData = {
|
||||
// type: item.type,
|
||||
// points: item.points,
|
||||
// };
|
||||
// }
|
||||
// if (item.type === "ArmBot" && item.points) {
|
||||
// responseItem.eventData = {
|
||||
// type: item.type,
|
||||
// points: item.points,
|
||||
// };
|
||||
// }
|
||||
// if (item.type === "StaticMachine" && item.points) {
|
||||
// responseItem.eventData = {
|
||||
// type: item.type,
|
||||
// points: item.points,
|
||||
// };
|
||||
// }
|
||||
// return responseItem;
|
||||
// });
|
||||
|
||||
// return res.status(200).json(response);
|
||||
// } catch (error) {
|
||||
// res.status(500).json({ error: "Failed to get flooritems" });
|
||||
// }
|
||||
// }
|
||||
// static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
||||
// try {
|
||||
// const { modelUuid, modelName, organization } = req.body;
|
||||
|
||||
// const findValue = await assetModel(organization).findOneAndDelete({
|
||||
// modelUuid: modelUuid,
|
||||
// modelName: modelName,
|
||||
// isArchive: false,
|
||||
// });
|
||||
// if (!findValue) {
|
||||
// res.status(200).json("user not found");
|
||||
// } else {
|
||||
// res.status(201).json(findValue);
|
||||
// }
|
||||
// } catch (error) {
|
||||
// res.status(500).json({ error: "Failed to get flooritems" });
|
||||
// }
|
||||
// }
|
||||
static async updateAssetPositionRotation(
|
||||
req: Request,
|
||||
res: Response
|
||||
): Promise<any> {
|
||||
try {
|
||||
const {
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
modelfileID,
|
||||
rotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
organization,
|
||||
// eventData, // Optional
|
||||
} = req.body;
|
||||
|
||||
const existingAsset = await assetModel(organization).findOne({
|
||||
modelUuid: modelUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingAsset) return res.send("Asset not found");
|
||||
const updateAsset = await assetModel(organization).updateMany(
|
||||
{ modelUuid: modelUuid, modelName: modelName, isArchive: false },
|
||||
{
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
isVisible: isVisible,
|
||||
isLocked: isLocked,
|
||||
}
|
||||
);
|
||||
if (updateAsset)
|
||||
return res.status(200).json({ message: "Asset updated successfully" });
|
||||
} catch (error: any) {
|
||||
return res.send(error.message);
|
||||
}
|
||||
}
|
||||
static async replaceEventDatas(req: Request, res: Response): Promise<any> {
|
||||
const { organization, modelUuid, eventData } = req.body;
|
||||
try {
|
||||
const existingModel = await assetModel(organization).findOne({
|
||||
modelUuid: modelUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingModel)
|
||||
return res.json({ message: "Model not for this UUID" });
|
||||
else {
|
||||
let speed;
|
||||
if (existingModel.type === "Conveyor") {
|
||||
speed = eventData?.speed;
|
||||
}
|
||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||
{ modelUuid, isArchive: false },
|
||||
{
|
||||
points: eventData?.points,
|
||||
type: eventData?.type || existingModel?.type,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
if (updatedModel)
|
||||
return res.status(200).json({ message: "Data updated successfully" });
|
||||
}
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
//update setfoolrassets//getFloorItems//deleteFloorItems.........
|
||||
static async setFloorassets(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const {
|
||||
modeluuid,
|
||||
modelname,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
modelfileID,
|
||||
rotation,
|
||||
@@ -21,8 +261,8 @@ export class assetsFloorservice {
|
||||
console.log("req.body: ", req.body);
|
||||
|
||||
const findvalue = await assetModel(organization).findOne({
|
||||
modeluuid,
|
||||
// modelname,
|
||||
modelUuid,
|
||||
// modelName,
|
||||
isArchive: false,
|
||||
});
|
||||
const checkpointType = await pointModel(organization).findOne({
|
||||
@@ -32,9 +272,9 @@ export class assetsFloorservice {
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid, isArchive: false },
|
||||
{ modelUuid, isArchive: false },
|
||||
{
|
||||
modelname: modelname,
|
||||
modelName: modelName,
|
||||
position,
|
||||
rotation,
|
||||
isVisible,
|
||||
@@ -45,13 +285,14 @@ export class assetsFloorservice {
|
||||
return res.status(201).json(updatevalue);
|
||||
} else {
|
||||
let assetData: any = {
|
||||
modeluuid,
|
||||
modelname,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
modelfileID,
|
||||
rotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
eventData
|
||||
};
|
||||
|
||||
console.log("eventData: ", eventData);
|
||||
@@ -116,43 +357,45 @@ export class assetsFloorservice {
|
||||
// console.log('findValues: ', findValues);
|
||||
// console.log("item.points: ", item.points);
|
||||
const responseItem: any = {
|
||||
modeluuid: item.modeluuid,
|
||||
modelname: item.modelname,
|
||||
modelUuid: item.modelUuid,
|
||||
modelName: item.modelName,
|
||||
position: item.position,
|
||||
rotation: item.rotation,
|
||||
modelfileID: item.modelfileID,
|
||||
isLocked: item.isLocked,
|
||||
isVisible: item.isVisible,
|
||||
eventData: item.eventData,
|
||||
};
|
||||
if (item.type === "Conveyor" && item.points.length > 0) {
|
||||
responseItem.eventData = {
|
||||
speed: item.speed,
|
||||
points: item.points,
|
||||
type: item.type,
|
||||
};
|
||||
}
|
||||
// if (item.type === "Conveyor" && item.points.length > 0) {
|
||||
// responseItem.eventData = {
|
||||
// speed: item.speed,
|
||||
// points: item.points,
|
||||
// type: item.type,
|
||||
// };
|
||||
// }
|
||||
|
||||
if (item.type === "Vehicle" && item.points) {
|
||||
responseItem.eventData = {
|
||||
type: item.type,
|
||||
points: item.points,
|
||||
};
|
||||
}
|
||||
if (item.type === "ArmBot" && item.points) {
|
||||
responseItem.eventData = {
|
||||
type: item.type,
|
||||
points: item.points,
|
||||
};
|
||||
}
|
||||
if (item.type === "StaticMachine" && item.points) {
|
||||
responseItem.eventData = {
|
||||
type: item.type,
|
||||
points: item.points,
|
||||
};
|
||||
}
|
||||
// if (item.type === "Vehicle" && item.points) {
|
||||
// responseItem.eventData = {
|
||||
// type: item.type,
|
||||
// points: item.points,
|
||||
// };
|
||||
// }
|
||||
// if (item.type === "ArmBot" && item.points) {
|
||||
// responseItem.eventData = {
|
||||
// type: item.type,
|
||||
// points: item.points,
|
||||
// };
|
||||
// }
|
||||
// if (item.type === "StaticMachine" && item.points) {
|
||||
// responseItem.eventData = {
|
||||
// type: item.type,
|
||||
// points: item.points,
|
||||
// };
|
||||
// }
|
||||
return responseItem;
|
||||
});
|
||||
|
||||
// console.log('response: ', response);
|
||||
return res.status(200).json(response);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
@@ -160,87 +403,41 @@ export class assetsFloorservice {
|
||||
}
|
||||
static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { modeluuid, modelname, organization } = req.body;
|
||||
|
||||
const findValue = await assetModel(organization).findOneAndDelete({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
const { modelUuid, modelName, organization } = req.body;
|
||||
console.log('req.body:', req.body);
|
||||
|
||||
const asset = await assetModel(organization).findOne({
|
||||
modelUuid,
|
||||
modelName,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
|
||||
if (!asset) {
|
||||
return res.status(404).json({ message: "Model not found" });
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
static async updateAssetPositionRotation(
|
||||
req: Request,
|
||||
res: Response
|
||||
): Promise<any> {
|
||||
try {
|
||||
const {
|
||||
modeluuid,
|
||||
modelname,
|
||||
position,
|
||||
modelfileID,
|
||||
rotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
organization,
|
||||
// eventData, // Optional
|
||||
} = req.body;
|
||||
|
||||
const existingAsset = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingAsset) return res.send("Asset not found");
|
||||
const updateAsset = await assetModel(organization).updateMany(
|
||||
{ modeluuid: modeluuid, modelname: modelname, isArchive: false },
|
||||
{
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
isVisible: isVisible,
|
||||
isLocked: isLocked,
|
||||
}
|
||||
|
||||
const archivedAsset = await assetModel(organization).findOneAndUpdate(
|
||||
{ modelUuid, modelName },
|
||||
{ $set: { isArchive: true } },
|
||||
{ new: true }
|
||||
);
|
||||
if (updateAsset)
|
||||
return res.status(200).json({ message: "Asset updated successfully" });
|
||||
} catch (error: any) {
|
||||
return res.send(error.message);
|
||||
}
|
||||
}
|
||||
static async replaceEventDatas(req: Request, res: Response): Promise<any> {
|
||||
const { organization, modeluuid, eventData } = req.body;
|
||||
try {
|
||||
const existingModel = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingModel)
|
||||
return res.json({ message: "Model not for this UUID" });
|
||||
else {
|
||||
let speed;
|
||||
if (existingModel.type === "Conveyor") {
|
||||
speed = eventData?.speed;
|
||||
}
|
||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid, isArchive: false },
|
||||
{
|
||||
points: eventData?.points,
|
||||
type: eventData?.type || existingModel?.type,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
if (updatedModel)
|
||||
return res.status(200).json({ message: "Data updated successfully" });
|
||||
|
||||
if (!archivedAsset) {
|
||||
return res.status(500).json({ message: "Failed to archive asset" });
|
||||
}
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
|
||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
||||
{ modelUuid },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
console.log("Archived asset:", archivedAsset);
|
||||
console.log("Updated events:", updatedEvents.modifiedCount);
|
||||
|
||||
return res.status(200).json({ message: "delete Asset successfully" });
|
||||
} catch (error) {
|
||||
console.error("Error deleting floor items:", error);
|
||||
return res.status(500).json({ error: "Failed to delete floor items" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,21 @@
|
||||
// try {
|
||||
// const {
|
||||
// productName,
|
||||
// modeluuid,
|
||||
// modelname,
|
||||
// modelUuid,
|
||||
// modelName,
|
||||
// eventData,
|
||||
// organization,
|
||||
// productID,
|
||||
// } = req.body;
|
||||
|
||||
// // Validate required fields
|
||||
// if (!modeluuid || !modelname || !organization) {
|
||||
// if (!modelUuid || !modelName || !organization) {
|
||||
// return res.status(400).json({ message: "Missing required fields" });
|
||||
// }
|
||||
|
||||
// // Check if asset exists
|
||||
// const existingAsset = await assetModel(organization).findOne({
|
||||
// modeluuid: modeluuid,
|
||||
// modelUuid: modelUuid,
|
||||
// isArchive: false,
|
||||
// });
|
||||
// if (!existingAsset) {
|
||||
@@ -100,8 +100,8 @@
|
||||
// {
|
||||
// $push: {
|
||||
// ProductData: {
|
||||
// AssetName: modelname,
|
||||
// Assetuuid: modeluuid,
|
||||
// AssetName: modelName,
|
||||
// Assetuuid: modelUuid,
|
||||
// paths: {
|
||||
// Points: pointRefs,
|
||||
// },
|
||||
@@ -118,8 +118,8 @@
|
||||
// productName: productName,
|
||||
// ProductData: [
|
||||
// {
|
||||
// AssetName: modelname,
|
||||
// Assetuuid: modeluuid,
|
||||
// AssetName: modelName,
|
||||
// Assetuuid: modelUuid,
|
||||
// paths: {
|
||||
// Points: pointRefs,
|
||||
// },
|
||||
@@ -191,11 +191,11 @@
|
||||
// }
|
||||
// // static async deleteFloorItems(req: Request, res: Response): Promise<any> {
|
||||
// // try {
|
||||
// // const { modeluuid, modelname, organization } = req.body;
|
||||
// // const { modelUuid, modelName, organization } = req.body;
|
||||
|
||||
// // const findValue = await assetModel(organization).findOneAndDelete({
|
||||
// // modeluuid: modeluuid,
|
||||
// // modelname: modelname,
|
||||
// // modelUuid: modelUuid,
|
||||
// // modelName: modelName,
|
||||
// // isArchive: false,
|
||||
// // });
|
||||
// // if (!findValue) {
|
||||
@@ -214,8 +214,8 @@
|
||||
// // ): Promise<any> {
|
||||
// // try {
|
||||
// // const {
|
||||
// // modeluuid,
|
||||
// // modelname,
|
||||
// // modelUuid,
|
||||
// // modelName,
|
||||
// // position,
|
||||
// // modelfileID,
|
||||
// // rotation,
|
||||
@@ -226,12 +226,12 @@
|
||||
// // } = req.body;
|
||||
|
||||
// // const existingAsset = await assetModel(organization).findOne({
|
||||
// // modeluuid: modeluuid,
|
||||
// // modelUuid: modelUuid,
|
||||
// // isArchive: false,
|
||||
// // });
|
||||
// // if (!existingAsset) return res.send("Asset not found");
|
||||
// // const updateAsset = await assetModel(organization).updateMany(
|
||||
// // { modeluuid: modeluuid, modelname: modelname, isArchive: false },
|
||||
// // { modelUuid: modelUuid, modelName: modelName, isArchive: false },
|
||||
// // {
|
||||
// // position: position,
|
||||
// // rotation: rotation,
|
||||
|
||||
259
src/api-server/controller/simulation/productService.ts
Normal file
259
src/api-server/controller/simulation/productService.ts
Normal file
@@ -0,0 +1,259 @@
|
||||
import { Request, Response } from "express";
|
||||
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||
|
||||
export class productFlowservice {
|
||||
|
||||
static async productAdd(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { productName, productId, eventDatas, organization } = req.body;
|
||||
if (!organization) {
|
||||
return res
|
||||
.json({ message: "organization not found" });
|
||||
}
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
})
|
||||
if (existingProduct) {
|
||||
const existingEventData = await EventsDataModel(organization).findOne(
|
||||
{
|
||||
productId: productId,
|
||||
modelUuid: eventDatas.modelUuid,
|
||||
isArchive: false,
|
||||
})
|
||||
if (existingEventData) {
|
||||
const updateEventData = await EventsDataModel(organization).findOneAndUpdate(
|
||||
{
|
||||
modelUuid: eventDatas.modelUuid,
|
||||
isArchive: false,
|
||||
}
|
||||
, {
|
||||
modelUuid: eventDatas?.modelUuid,
|
||||
modelName: eventDatas?.modelName,
|
||||
position: eventDatas?.position,
|
||||
rotation: eventDatas?.rotation,
|
||||
type: eventDatas?.type,
|
||||
speed: eventDatas?.speed,
|
||||
point: eventDatas?.point,
|
||||
points: eventDatas?.points,
|
||||
})
|
||||
return res
|
||||
.status(200)
|
||||
.json({ message: "EventData updated successfully" });
|
||||
} else {
|
||||
const addEventData = await EventsDataModel(organization).create({
|
||||
productId: productId,
|
||||
modelUuid: eventDatas?.modelUuid,
|
||||
modelName: eventDatas?.modelName,
|
||||
position: eventDatas?.position,
|
||||
rotation: eventDatas?.rotation,
|
||||
type: eventDatas?.type,
|
||||
speed: eventDatas?.speed,
|
||||
point: eventDatas?.point,
|
||||
points: eventDatas?.points
|
||||
})
|
||||
return res
|
||||
.status(201)
|
||||
.json({ message: "EventData add successfully" });
|
||||
}
|
||||
} else {
|
||||
const newProduct = await ProductModel(organization).create({
|
||||
productId: productId,
|
||||
productName: productName
|
||||
|
||||
})
|
||||
if (newProduct) {
|
||||
|
||||
if (!eventDatas) {
|
||||
return res.status(404).json({ message: "eventData not found" });
|
||||
|
||||
} else {
|
||||
const addEventData = await EventsDataModel(organization).create({
|
||||
productId: productId,
|
||||
modelUuid: eventDatas?.modelUuid,
|
||||
modelName: eventDatas?.modelName,
|
||||
position: eventDatas?.position,
|
||||
rotation: eventDatas?.rotation,
|
||||
type: eventDatas?.type,
|
||||
speed: eventDatas?.speed,
|
||||
point: eventDatas?.point,
|
||||
points: eventDatas?.points,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
return res
|
||||
.status(201)
|
||||
.json({ message: "Product created successfully" });
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to create product" });
|
||||
}
|
||||
}
|
||||
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { productId, organization } = req.query
|
||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||
return res.status(400).json({ message: "Missing or invalid query parameters" });
|
||||
}
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
})
|
||||
|
||||
if (!existingProduct)
|
||||
return res.status(404).json({ message: "Product not found" });
|
||||
|
||||
|
||||
const existingEventDatas = await EventsDataModel(organization).find({ productId: productId }).select("-productId")
|
||||
|
||||
return res
|
||||
.status(200)
|
||||
.json(existingEventDatas);
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({ message: "Failed to get product" });
|
||||
}
|
||||
|
||||
}
|
||||
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { productId, organization } = req.query
|
||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||
return res.status(400).json({ message: "Missing or invalid query parameters" });
|
||||
}
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
})
|
||||
|
||||
if (!existingProduct)
|
||||
return res.status(404).json({ message: "Product not found" });
|
||||
|
||||
const productDelete = await ProductModel(organization).findOneAndUpdate(
|
||||
{ productId: productId },
|
||||
{
|
||||
isArchive: true,
|
||||
}, { new: true }
|
||||
|
||||
)
|
||||
const existingEventDatas = await EventsDataModel(organization).find({ productId: productId })
|
||||
if (existingEventDatas) {
|
||||
for (const event of existingEventDatas) {
|
||||
|
||||
await EventsDataModel(organization).updateMany(
|
||||
{ productId },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
return res.status(201).json({ message: "product deleted successfully" });
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to delete product" });
|
||||
}
|
||||
|
||||
}
|
||||
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { productId, organization, modelUuid } = req.body
|
||||
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
})
|
||||
|
||||
if (!existingProduct)
|
||||
return res.status(404).json({ message: "Product not found" });
|
||||
|
||||
|
||||
const existingEventDatas = await EventsDataModel(organization).findOneAndUpdate(
|
||||
{ productId: productId, modelUuid: modelUuid }, {
|
||||
isArchive: true,
|
||||
}, { new: true }
|
||||
|
||||
)
|
||||
|
||||
return res.status(201).json({ message: "EventData deleted successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to delete Eventdata" });
|
||||
}
|
||||
|
||||
}
|
||||
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { organization } = req.params
|
||||
|
||||
if (!organization) {
|
||||
return res
|
||||
.json({ message: "organization not found" });
|
||||
}
|
||||
|
||||
const existingProduct = await ProductModel(organization).find({
|
||||
isArchive: false,
|
||||
})
|
||||
if (!existingProduct) {
|
||||
return res.status(404).json({ message: 'No products found' });
|
||||
}
|
||||
const result = [];
|
||||
|
||||
for (const product of existingProduct) {
|
||||
|
||||
|
||||
// Fetch events data for each product, excluding productId field
|
||||
const eventDatas = await EventsDataModel(organization)
|
||||
.find({ productId: product.productId, isArchive: false })
|
||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||
|
||||
|
||||
|
||||
// Combine product and event data
|
||||
result.push({
|
||||
// product: {
|
||||
productName: product.productName,
|
||||
productId: product.productId,
|
||||
eventDatas,
|
||||
// },
|
||||
});
|
||||
}
|
||||
|
||||
// Return combined data
|
||||
return res.status(200).json(result);
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to get Allproduct" });
|
||||
}
|
||||
|
||||
}
|
||||
static async productRename(req: Request, res: Response): Promise<any> {
|
||||
|
||||
try {
|
||||
const { productId, productName, organization } = req.body
|
||||
|
||||
|
||||
const existingProduct = await ProductModel(organization).findOne({
|
||||
productId: productId,
|
||||
isArchive: false,
|
||||
})
|
||||
|
||||
if (!existingProduct)
|
||||
return res.status(404).json({ message: "Product not found" });
|
||||
|
||||
const productDelete = await ProductModel(organization).findOneAndUpdate(
|
||||
{ productId: productId },
|
||||
{
|
||||
productName: productName,
|
||||
}, { new: true }
|
||||
|
||||
)
|
||||
|
||||
return res.status(201).json({ message: "product Rename successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Failed to product Rename" });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ import MainModel from '../../connect/mongoose.ts';
|
||||
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface floorItenms extends Document {
|
||||
modeluuid: string;
|
||||
modelUuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string
|
||||
modelName: string
|
||||
isLocked:boolean
|
||||
isVisible:boolean
|
||||
position: []
|
||||
@@ -20,9 +20,9 @@ export interface floorItenms extends Document {
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const floorItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String },
|
||||
modelUuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
modelName: { type: String },
|
||||
position: { type: Array},
|
||||
isLocked:{type:Boolean},
|
||||
isVisible:{type:Boolean},
|
||||
|
||||
@@ -2,8 +2,8 @@ import mongoose, { Document, Schema } from 'mongoose';
|
||||
import MainModel from '../../connect/mongoose.ts';
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface wallitems extends Document {
|
||||
modeluuid: string;
|
||||
modelname: string
|
||||
modelUuid: string;
|
||||
modelName: string
|
||||
type: string
|
||||
csgposition: []
|
||||
csgscale: []
|
||||
@@ -16,8 +16,8 @@ export interface wallitems extends Document {
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const wallItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String,unique:true },
|
||||
modelname: { type: String},
|
||||
modelUuid: { type: String,unique:true },
|
||||
modelName: { type: String},
|
||||
type: { type: String },
|
||||
csgposition: { type: Array},
|
||||
csgscale: { type: Array,},
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
interface ICommonBase{
|
||||
type: string;
|
||||
}
|
||||
interface IPointsConveyor extends ICommonBase{
|
||||
points?: {
|
||||
Uuid:string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
}[];
|
||||
}
|
||||
interface IPoint extends ICommonBase{
|
||||
point?: {
|
||||
Uuid:string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
};
|
||||
}
|
||||
export interface assetData extends Document {
|
||||
modeluuid: string;
|
||||
modelUuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string;
|
||||
modelName: string;
|
||||
isLocked: boolean;
|
||||
type: string;
|
||||
isVisible: boolean;
|
||||
isArchive: false;
|
||||
points: [] | {};
|
||||
// points: [] | {};
|
||||
position: [];
|
||||
rotation: {
|
||||
x: number;
|
||||
@@ -17,15 +34,17 @@ export interface assetData extends Document {
|
||||
z: number;
|
||||
};
|
||||
speed: number | string;
|
||||
eventData: IPoint|IPointsConveyor
|
||||
}
|
||||
|
||||
|
||||
const assetDataSchema: Schema = new Schema({
|
||||
isArchive: { type: Boolean, default: false },
|
||||
modeluuid: { type: String },
|
||||
modelUuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
modelName: { type: String },
|
||||
type: { type: String },
|
||||
points: { type: Schema.Types.Mixed },
|
||||
// points: { type: Schema.Types.Mixed },
|
||||
position: { type: Array },
|
||||
rotation: {
|
||||
x: { type: Number },
|
||||
@@ -35,6 +54,10 @@ const assetDataSchema: Schema = new Schema({
|
||||
speed: { type: Schema.Types.Mixed },
|
||||
isLocked: { type: Boolean },
|
||||
isVisible: { type: Boolean },
|
||||
eventData: {
|
||||
type: Schema.Types.Mixed,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
// export default floorItemsModel;
|
||||
@@ -47,9 +70,9 @@ export default assetModel;
|
||||
// import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
// export interface assetData extends Document {
|
||||
// modeluuid: string;
|
||||
// modelUuid: string;
|
||||
// modelfileID: string;
|
||||
// modelname: string;
|
||||
// modelName: string;
|
||||
// isLocked: boolean;
|
||||
// type: string;
|
||||
// isVisible: boolean;
|
||||
@@ -92,9 +115,9 @@ export default assetModel;
|
||||
// // Define the Mongoose Schema
|
||||
// const assetDataSchema: Schema = new Schema({
|
||||
// isArchive: { type: Boolean, default: false },
|
||||
// modeluuid: { type: String },
|
||||
// modelUuid: { type: String },
|
||||
// modelfileID: { type: String },
|
||||
// modelname: { type: String },
|
||||
// modelName: { type: String },
|
||||
// type: { type: String },
|
||||
// // assetPosition: { type: Array },
|
||||
// points: [
|
||||
|
||||
@@ -2,8 +2,8 @@ import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface wallitems extends Document {
|
||||
modeluuid: string;
|
||||
modelname: string;
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
type: string;
|
||||
csgposition: [];
|
||||
csgscale: [];
|
||||
@@ -14,8 +14,8 @@ export interface wallitems extends Document {
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const wallItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String, unique: true },
|
||||
modelname: { type: String },
|
||||
modelUuid: { type: String, unique: true },
|
||||
modelName: { type: String },
|
||||
type: { type: String },
|
||||
csgposition: { type: Array },
|
||||
csgscale: { type: Array },
|
||||
|
||||
179
src/shared/model/simulation/eventsDataModel.ts
Normal file
179
src/shared/model/simulation/eventsDataModel.ts
Normal file
@@ -0,0 +1,179 @@
|
||||
// models/Product.ts
|
||||
import mongoose, { Schema, Document, Types } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
|
||||
interface AssetEventSchema {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
||||
};
|
||||
|
||||
interface TriggerSchema {
|
||||
triggerUuid: string;
|
||||
triggerName: string;
|
||||
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
||||
delay: number;
|
||||
triggeredAsset: {
|
||||
triggeredModel: { modelName: string, modelUuid: string };
|
||||
triggeredPoint: { pointName: string, pointUuid: string };
|
||||
triggeredAction: { actionName: string, actionUuid: string };
|
||||
} | null;
|
||||
}
|
||||
|
||||
interface ConveyorPointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "default" | "spawn" | "swap" | "despawn";
|
||||
material: string;
|
||||
delay: number | "inherit";
|
||||
spawnInterval: number | "inherit";
|
||||
spawnCount: number | "inherit";
|
||||
triggers: TriggerSchema[];
|
||||
};
|
||||
}
|
||||
|
||||
interface VehiclePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "travel";
|
||||
material: string | null;
|
||||
unLoadDuration: number;
|
||||
loadCapacity: number;
|
||||
pickUpPoint: { x: number; y: number, z: number } | null;
|
||||
unLoadPoint: { x: number; y: number, z: number } | null;
|
||||
triggers: TriggerSchema[];
|
||||
};
|
||||
}
|
||||
|
||||
interface RoboticArmPointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "pickAndPlace";
|
||||
process: { startPoint: [number, number, number]; endPoint: [number, number, number] };
|
||||
triggers: TriggerSchema[];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface MachinePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "process";
|
||||
processTime: number;
|
||||
swapMaterial: string;
|
||||
triggers: TriggerSchema[];
|
||||
};
|
||||
}
|
||||
|
||||
interface StoragePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "storage";
|
||||
materials: { materialName: string; materialId: string; }[];
|
||||
storageCapacity: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface ConveyorEventSchema extends AssetEventSchema {
|
||||
type: "transfer";
|
||||
speed: number;
|
||||
points: ConveyorPointSchema[];
|
||||
}
|
||||
|
||||
interface VehicleEventSchema extends AssetEventSchema {
|
||||
type: "vehicle";
|
||||
speed: number;
|
||||
point: VehiclePointSchema;
|
||||
}
|
||||
|
||||
interface RoboticArmEventSchema extends AssetEventSchema {
|
||||
type: "roboticArm";
|
||||
speed: number;
|
||||
point: RoboticArmPointSchema;
|
||||
}
|
||||
|
||||
interface MachineEventSchema extends AssetEventSchema {
|
||||
type: "machine";
|
||||
// speed: number;
|
||||
point: MachinePointSchema;
|
||||
}
|
||||
|
||||
interface StorageEventSchema extends AssetEventSchema {
|
||||
type: "storageUnit";
|
||||
// speed: number;
|
||||
point: StoragePointSchema;
|
||||
}
|
||||
interface IPointModel extends Document {
|
||||
modelUuid:String,
|
||||
modelName:String,
|
||||
position:String,
|
||||
rotation:String,
|
||||
state:String,
|
||||
productId:String,
|
||||
isArchive:boolean,
|
||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" |"storageUnit";
|
||||
speed: number;
|
||||
point: VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema
|
||||
points: ConveyorEventSchema[]
|
||||
|
||||
}
|
||||
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
|
||||
|
||||
|
||||
const BaseEventSchema = new Schema<IPointModel>(
|
||||
{
|
||||
modelUuid: { type: String, required: true },
|
||||
modelName: { type: String, required: true },
|
||||
position: { type: [Number], required: true },
|
||||
rotation: { type: [Number], required: true },
|
||||
speed: { type: Number,},
|
||||
state: {
|
||||
type: String,
|
||||
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||
default: "idle"
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"]
|
||||
},
|
||||
point:{
|
||||
type:Schema.Types.Mixed,
|
||||
|
||||
},
|
||||
points:{
|
||||
type:Schema.Types.Mixed,
|
||||
|
||||
},
|
||||
productId: { type:String,required: true },
|
||||
isArchive: { type: Boolean, default: false }
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
const EventsDataModel = (db: string) => {
|
||||
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||
};
|
||||
|
||||
export default EventsDataModel;
|
||||
24
src/shared/model/simulation/productModel.ts
Normal file
24
src/shared/model/simulation/productModel.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import mongoose, { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
export interface product extends Document {
|
||||
productName: string;
|
||||
productId: string;
|
||||
eventsData: [];
|
||||
isArchive: boolean;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Product Schema
|
||||
const ProductSchema = new Schema({
|
||||
productName: { type: String, required: true },
|
||||
productId: { type: String, required: true },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
|
||||
const ProductModel = (db: string) => {
|
||||
return MainModel(db, "Product", ProductSchema, "Product");
|
||||
};
|
||||
|
||||
export default ProductModel;
|
||||
@@ -1,11 +1,212 @@
|
||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||
|
||||
// export const setAssetModel = async (data: any) => {
|
||||
// const {
|
||||
// modelUuid,
|
||||
// modelName,
|
||||
// position,
|
||||
// rotation,
|
||||
// eventData,
|
||||
// modelfileID,
|
||||
// isLocked,
|
||||
// isVisible,
|
||||
// organization,
|
||||
// } = data;
|
||||
// try {
|
||||
// const findvalue = await assetModel(organization).findOne({
|
||||
// modelUuid: modelUuid,
|
||||
// // modelName: modelName,
|
||||
// isArchive: false,
|
||||
// });
|
||||
|
||||
// if (findvalue) {
|
||||
// const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
// { modelUuid: modelUuid, isArchive: false },
|
||||
// {
|
||||
// modelName: modelName,
|
||||
// position: position,
|
||||
// rotation: rotation,
|
||||
// isVisible: isVisible,
|
||||
// isLocked: isLocked,
|
||||
// },
|
||||
// { new: true }
|
||||
// );
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "Model updated successfully",
|
||||
// data: updatevalue,
|
||||
// organization: organization,
|
||||
// };
|
||||
// } else {
|
||||
// let assetData: any = {
|
||||
// modelUuid,
|
||||
// modelName,
|
||||
// position,
|
||||
// modelfileID,
|
||||
// rotation,
|
||||
// isLocked,
|
||||
// isVisible,
|
||||
// };
|
||||
|
||||
// if (eventData) {
|
||||
// if (eventData.type === "Conveyor") {
|
||||
// assetData.speed = eventData.speed;
|
||||
// } else if (eventData.type === "Vehicle") {
|
||||
// assetData.speed = eventData.points.speed;
|
||||
// if (!eventData.points) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Vehicle points must be a single object",
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// // if (eventData.points.rotation) {
|
||||
// // return {
|
||||
// // success: false,
|
||||
// // message: "Rotation is not allowed for Vehicle points",
|
||||
// // organization: organization,
|
||||
// // };
|
||||
// // }
|
||||
// if (eventData.points.triggers) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "triggers is not allowed for Vehicle points",
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// assetData.points = eventData.points;
|
||||
// assetData.type = eventData.type;
|
||||
// }
|
||||
// const assetDoc = await assetModel(organization).create(assetData);
|
||||
// await assetDoc.save();
|
||||
// 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,
|
||||
// },
|
||||
// };
|
||||
// } else 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,
|
||||
// },
|
||||
// };
|
||||
// } else if (assetDoc.type === "ArmBot") {
|
||||
// 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,
|
||||
// },
|
||||
// };
|
||||
// } else if (assetDoc.type === "StaticMachine") {
|
||||
// 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,
|
||||
// },
|
||||
// };
|
||||
// } else {
|
||||
// assetDatas = {
|
||||
// modelUuid: assetDoc.modelUuid,
|
||||
// modelName: assetDoc.modelName,
|
||||
// modelfileID: assetDoc.modelfileID,
|
||||
// position: assetDoc.position,
|
||||
// rotation: assetDoc.rotation,
|
||||
// isLocked: assetDoc.isLocked,
|
||||
// isVisible: assetDoc.isVisible,
|
||||
// };
|
||||
// }
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "Model created successfully",
|
||||
// data: assetDatas,
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// } catch (error: any) {
|
||||
// // console.error("Error creating flooritems:", error);
|
||||
// return {
|
||||
// success: false,
|
||||
// message: error?.message || "Error occurred while ModelAsset",
|
||||
// error,
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// };
|
||||
|
||||
// export const deleteAssetModel = async (data: any) => {
|
||||
// const { modelUuid, modelName, organization } = data;
|
||||
// try {
|
||||
// const findValue = await assetModel(organization).findOneAndDelete({
|
||||
// modelUuid: modelUuid,
|
||||
// modelName: modelName,
|
||||
// isArchive: false,
|
||||
// });
|
||||
// if (!findValue) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "model not found",
|
||||
// organization: organization,
|
||||
// };
|
||||
// } else {
|
||||
// return {
|
||||
// success: true,
|
||||
// message: "Model deleted successfully",
|
||||
// data: findValue,
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// } catch (error) {
|
||||
// // console.error('Error get flooritems:', error);
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Failed to delete asset",
|
||||
// error,
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// };
|
||||
//update 30/4..//setAssetModel//deleteAssetModel...........
|
||||
export const setAssetModel = async (data: any) => {
|
||||
const {
|
||||
modeluuid,
|
||||
modelname,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
eventData,
|
||||
@@ -16,20 +217,21 @@ export const setAssetModel = async (data: any) => {
|
||||
} = data;
|
||||
try {
|
||||
const findvalue = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
// modelname: modelname,
|
||||
modelUuid: modelUuid,
|
||||
// modelName: modelName,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, isArchive: false },
|
||||
{ modelUuid: modelUuid, isArchive: false },
|
||||
{
|
||||
modelname: modelname,
|
||||
modelName: modelName,
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
isVisible: isVisible,
|
||||
isLocked: isLocked,
|
||||
eventData: eventData
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
@@ -41,8 +243,8 @@ export const setAssetModel = async (data: any) => {
|
||||
};
|
||||
} else {
|
||||
let assetData: any = {
|
||||
modeluuid,
|
||||
modelname,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
modelfileID,
|
||||
rotation,
|
||||
@@ -50,107 +252,119 @@ export const setAssetModel = async (data: any) => {
|
||||
isVisible,
|
||||
};
|
||||
|
||||
if (eventData) {
|
||||
if (eventData.type === "Conveyor") {
|
||||
assetData.speed = eventData.speed;
|
||||
} else if (eventData.type === "Vehicle") {
|
||||
assetData.speed = eventData.points.speed;
|
||||
if (!eventData.points) {
|
||||
return {
|
||||
success: false,
|
||||
message: "Vehicle points must be a single object",
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
// if (eventData.points.rotation) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Rotation is not allowed for Vehicle points",
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
if (eventData.points.triggers) {
|
||||
return {
|
||||
success: false,
|
||||
message: "triggers is not allowed for Vehicle points",
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
}
|
||||
assetData.points = eventData.points;
|
||||
assetData.type = eventData.type;
|
||||
if (eventData?.type === 'Conveyor') {
|
||||
assetData.eventData = {
|
||||
type: eventData.type,
|
||||
// point:undefined,
|
||||
points: eventData.points,
|
||||
};
|
||||
} else {
|
||||
|
||||
assetData.eventData = {
|
||||
type: eventData.type,
|
||||
point: eventData.point,
|
||||
// points: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// if (eventData) {
|
||||
|
||||
// if (eventData.type === "Conveyor") {
|
||||
// assetData.speed = eventData.speed;
|
||||
// } else if (eventData.type === "Vehicle") {
|
||||
// assetData.speed = eventData.points.speed;
|
||||
// if (!eventData.points) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "Vehicle points must be a single object",
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// // if (eventData.points.rotation) {
|
||||
// // return {
|
||||
// // success: false,
|
||||
// // message: "Rotation is not allowed for Vehicle points",
|
||||
// // organization: organization,
|
||||
// // };
|
||||
// // }
|
||||
// if (eventData.points.triggers) {
|
||||
// return {
|
||||
// success: false,
|
||||
// message: "triggers is not allowed for Vehicle points",
|
||||
// organization: organization,
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// assetData.points = eventData.points;
|
||||
// assetData.type = eventData.type;
|
||||
// }
|
||||
const assetDoc = await assetModel(organization).create(assetData);
|
||||
await assetDoc.save();
|
||||
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,
|
||||
},
|
||||
};
|
||||
} else 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,
|
||||
},
|
||||
};
|
||||
} else if (assetDoc.type === "ArmBot") {
|
||||
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,
|
||||
},
|
||||
};
|
||||
} else if (assetDoc.type === "StaticMachine") {
|
||||
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,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
assetDatas = {
|
||||
modeluuid: assetDoc.modeluuid,
|
||||
modelname: assetDoc.modelname,
|
||||
modelfileID: assetDoc.modelfileID,
|
||||
position: assetDoc.position,
|
||||
rotation: assetDoc.rotation,
|
||||
isLocked: assetDoc.isLocked,
|
||||
isVisible: assetDoc.isVisible,
|
||||
};
|
||||
}
|
||||
// if (eventData.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:eventData
|
||||
// };
|
||||
// } else 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,
|
||||
// },
|
||||
// };
|
||||
// } else if (assetDoc.type === "ArmBot") {
|
||||
// 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,
|
||||
// },
|
||||
// };
|
||||
// } else if (assetDoc.type === "StaticMachine") {
|
||||
// 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,
|
||||
// },
|
||||
// };
|
||||
// } else {
|
||||
// assetDatas = {
|
||||
// modelUuid: assetDoc.modelUuid,
|
||||
// modelName: assetDoc.modelName,
|
||||
// modelfileID: assetDoc.modelfileID,
|
||||
// position: assetDoc.position,
|
||||
// rotation: assetDoc.rotation,
|
||||
// isLocked: assetDoc.isLocked,
|
||||
// isVisible: assetDoc.isVisible,
|
||||
// };
|
||||
// }
|
||||
return {
|
||||
success: true,
|
||||
message: "Model created successfully",
|
||||
@@ -170,27 +384,61 @@ export const setAssetModel = async (data: any) => {
|
||||
};
|
||||
|
||||
export const deleteAssetModel = async (data: any) => {
|
||||
const { modeluuid, modelname, organization } = data;
|
||||
const { modelUuid, modelName, organization } = data;
|
||||
try {
|
||||
const findValue = await assetModel(organization).findOneAndDelete({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
const asset = await assetModel(organization).findOne({
|
||||
modelUuid,
|
||||
modelName,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findValue) {
|
||||
// const findmodelValue = await assetModel(organization).findOne({
|
||||
// modelUuid: modelUuid,
|
||||
// modelName: modelName,
|
||||
// isArchive: false,
|
||||
// });
|
||||
if (!asset) {
|
||||
return {
|
||||
success: false,
|
||||
message: "model not found",
|
||||
organization: organization,
|
||||
};
|
||||
} else {
|
||||
}
|
||||
const archivedAsset = await assetModel(organization).findOneAndUpdate(
|
||||
{ modelUuid, modelName },
|
||||
{ $set: { isArchive: true } },
|
||||
{ new: true }
|
||||
);
|
||||
if (!archivedAsset) {
|
||||
return {
|
||||
success: true,
|
||||
message: "Model deleted successfully",
|
||||
data: findValue,
|
||||
success: false,
|
||||
message: "Failed to archive asset",
|
||||
organization: organization,
|
||||
};
|
||||
|
||||
}
|
||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
||||
{ modelUuid },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
// const findProductEventData = await EventsDataModel(organization).find(modelUuid)
|
||||
// console.log('findProductEventData: ', findProductEventData);
|
||||
// if (findProductEventData) {
|
||||
// for (const event of findProductEventData) {
|
||||
// console.log("Event ID:", event);
|
||||
// await EventsDataModel(organization).updateMany(
|
||||
// { modelUuid },
|
||||
// { $set: { isArchive: true } }
|
||||
// );
|
||||
|
||||
// }
|
||||
// }
|
||||
return {
|
||||
success: true,
|
||||
message: "Model deleted successfully",
|
||||
data: archivedAsset,
|
||||
organization: organization,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
// console.error('Error get flooritems:', error);
|
||||
return {
|
||||
@@ -202,10 +450,10 @@ export const deleteAssetModel = async (data: any) => {
|
||||
}
|
||||
};
|
||||
export const replaceEventDatas = async (data: any) => {
|
||||
const { organization, modeluuid, eventData } = data;
|
||||
const { organization, modelUuid, eventData } = data;
|
||||
try {
|
||||
const existingModel = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
modelUuid: modelUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingModel)
|
||||
@@ -223,7 +471,7 @@ export const replaceEventDatas = async (data: any) => {
|
||||
// speed = eventData?.points?.speed;
|
||||
// }
|
||||
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid, isArchive: false },
|
||||
{ modelUuid, isArchive: false },
|
||||
{
|
||||
points: eventData?.points,
|
||||
// speed: speed,
|
||||
|
||||
@@ -3,22 +3,22 @@ import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||
|
||||
export const setFloorItems = async (data: any) => {
|
||||
try {
|
||||
const { modelfileID,modeluuid, modelname, position, rotation,isLocked,isVisible, organization } = data
|
||||
const { modelfileID,modelUuid, modelName, position, rotation,isLocked,isVisible, organization } = data
|
||||
|
||||
|
||||
|
||||
const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid, modelname: modelname })
|
||||
const findvalue = await floorItemsModel(organization).findOne({ modelUuid: modelUuid, modelName: modelName })
|
||||
|
||||
if (findvalue) {
|
||||
|
||||
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, modelname: modelname }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true });
|
||||
{ modelUuid: modelUuid, modelName: modelName }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true });
|
||||
return { success: true, message: 'flooritems updated', data: updatevalue,organization:organization }
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
const newValue = await floorItemsModel(organization).create({ modeluuid, modelname, modelfileID,position, rotation,isLocked,isVisible });
|
||||
const newValue = await floorItemsModel(organization).create({ modelUuid, modelName, modelfileID,position, rotation,isLocked,isVisible });
|
||||
|
||||
|
||||
return { success: true, message: 'flooritem created', data: newValue,organization:organization }
|
||||
@@ -34,9 +34,9 @@ export const setFloorItems = async (data: any) => {
|
||||
|
||||
export const deleteFloorItems = async (data: any)=>{
|
||||
try {
|
||||
const { modeluuid,modelname,organization } = data;
|
||||
const { modelUuid,modelName,organization } = data;
|
||||
|
||||
const findValue = await floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
|
||||
const findValue = await floorItemsModel(organization).findOneAndDelete({modelUuid:modelUuid,modelName:modelName})
|
||||
if (!findValue) {
|
||||
return { success: false, message: 'model not found',organization:organization }
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@ import wallItenmModel from "../../../shared/model/assets/wallitems-Model.ts";
|
||||
|
||||
export const setWallItems = async (data: any) => {
|
||||
try {
|
||||
const { modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale, organization } = data
|
||||
const { modelUuid, modelName, position, type, csgposition, csgscale, quaternion, scale, organization } = data
|
||||
|
||||
|
||||
const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid })
|
||||
const findvalue = await wallItenmModel(organization).findOne({ modelUuid: modelUuid })
|
||||
if (findvalue) {
|
||||
|
||||
const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid },
|
||||
{ modelUuid: modelUuid },
|
||||
{
|
||||
modelname,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
@@ -28,7 +28,7 @@ export const setWallItems = async (data: any) => {
|
||||
|
||||
} else {
|
||||
|
||||
const newValue = await wallItenmModel(organization).create({ modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale });
|
||||
const newValue = await wallItenmModel(organization).create({ modelUuid, modelName, position, type, csgposition, csgscale, quaternion, scale });
|
||||
return { success: true, message: 'wallIitem created', data: newValue, organization: organization }
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ export const setWallItems = async (data: any) => {
|
||||
|
||||
export const deleteWallItems = async (data: any) => {
|
||||
try {
|
||||
const { modeluuid, modelname, organization } = data;
|
||||
const { modelUuid, modelName, organization } = data;
|
||||
|
||||
|
||||
const findValue = await wallItenmModel(organization).findOneAndDelete({ modeluuid: modeluuid, modelname: modelname })
|
||||
const findValue = await wallItenmModel(organization).findOneAndDelete({ modelUuid: modelUuid, modelName: modelName })
|
||||
if (!findValue) {
|
||||
return { success: false, message: 'model not found', organization: organization }
|
||||
|
||||
|
||||
@@ -311,10 +311,10 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"modelUuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"modelName": {
|
||||
"example": "any"
|
||||
},
|
||||
"position": {
|
||||
@@ -385,10 +385,10 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"modelUuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"modelName": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
@@ -693,10 +693,10 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"modelUuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"modelName": {
|
||||
"example": "any"
|
||||
},
|
||||
"position": {
|
||||
@@ -770,10 +770,10 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"modeluuid": {
|
||||
"modelUuid": {
|
||||
"example": "any"
|
||||
},
|
||||
"modelname": {
|
||||
"modelName": {
|
||||
"example": "any"
|
||||
},
|
||||
"organization": {
|
||||
|
||||
Reference in New Issue
Block a user