Bhaskar 8 months ago
commit 2dc6a64bf7

@ -1163,6 +1163,26 @@ exports.installmotorswitch = async (request, reply) => {
}
};
exports.updateSensorById = async (req, reply) => {
try {
const _id = req.params._id;
const updateData = req.body;
const updatedSensor = await Insensors.findByIdAndUpdate(_id, updateData, { new: true });
if (!updatedSensor) {
return reply.code(404).send({ message: 'Sensor not found' });
}
return reply.code(200).send(updatedSensor);
} catch (error) {
console.error('Error updating sensor:', error);
return reply.code(500).send({ message: 'Internal Server Error' });
}
};
exports.getpumpswitchqc = async (req, reply) => {
try {
await MotorSwitchSensor.find({storeId: req.params.storeId,motorId:req.body.motorId})

@ -274,6 +274,10 @@ const insensorsSchema = new mongoose.Schema({
});
const sensorquotationSchema = new mongoose.Schema({
customerId: { type: String },
installationId: { type: String, default: null },

@ -1109,6 +1109,53 @@ fastify.post("/api/createwaterlevelSensorintime/:storeId", {
handler: storeController.createSensor,
})
fastify.post("/api/updateSensorById/:_id", {
schema: {
description: "This is for editing Sensors after time",
tags: ["Store-Data"],
summary: "This is for editing Sensors after time",
params: {
required: ["_id"],
type: "object",
properties: {
_id: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
batchno: { type: "string", description: "Batch number of the sensor" },
model: { type: "string", description: "Model of the sensor" },
type: { type: "string", description: "Type of sensor" },
quantity: { type: "number", description: "Quantity of sensors" },
indate: { type: "string", description: "Date of sensor entry" },
hardwareId_company: { type: "string", description: "Company name of hardware ID" },
hardwareId: { type: "string", nullable: true, description: "Hardware ID (if applicable)" },
masterId: { type: "string", nullable: true, description: "Master ID reference" },
qccheck: { type: "string", nullable: true, description: "QC check status" },
qccheckdate: { type: "string", nullable: true, description: "QC check date" },
qcby: { type: "string", nullable: true, description: "QC checked by" },
comment: { type: "string", default: "0", description: "Comment field" },
outforrepairdate: { type: "string", default: "0", description: "Date sensor sent for repair" },
sendto: { type: "string", nullable: true, description: "Destination for repair" },
repairfeedback: { type: "string", default: "0", description: "Repair feedback" },
dateofinstallation: { type: "string", nullable: true, description: "Installation date" },
installedby: { type: "string", default: "0", description: "Person who installed the sensor" },
customerId: { type: "string", default: "0", description: "Customer ID" },
comments: { type: "string", default: "0", description: "Additional comments" },
sensor_type: { type: "string", enum: ["slaves", "motorswitch", "master"], description: "Type of sensor" }
},
},
},
handler: storeController.updateSensorById,
});
fastify.get("/api/getbatchnumbers/:storeId/:type", {
schema: {
tags: ["Store-Data"],
@ -1142,7 +1189,7 @@ fastify.get("/api/getiots/:storeId/:type", {
schema: {
tags: ["Store-Data"],
description: "This is to Get iots of particular store",
summary: "This is to iots of particular store",
summary: "This is to get iots of particular store",
params: {
type: "object",
properties: {

Loading…
Cancel
Save