|
|
|
|
@ -513,7 +513,7 @@ exports.addStore = async (request, reply) => {
|
|
|
|
|
const { hardwareId,hardwareId_company, type, indate } = req.body;
|
|
|
|
|
var mater_seq_id = await generatewaterlevelsensorId();
|
|
|
|
|
const date = moment().format('MM-DD');
|
|
|
|
|
const prefix = 'AS-' + date + '--MALOV1-';
|
|
|
|
|
const prefix = 'AS' + date + 'MALOV1-';
|
|
|
|
|
var masterId = `${prefix}${mater_seq_id}`;
|
|
|
|
|
const newSensor = new WaterLeverSensor({
|
|
|
|
|
storeId,
|
|
|
|
|
@ -529,7 +529,33 @@ exports.addStore = async (request, reply) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.installwaterlevelSensor = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { storeId } = request.params;
|
|
|
|
|
const updateData = request.body;
|
|
|
|
|
|
|
|
|
|
// Find the document by hardwareId and update it with the fields received in the body
|
|
|
|
|
const updatedSensor = await WaterLeverSensor.findOneAndUpdate(
|
|
|
|
|
{ storeId:storeId,hardwareId: request.body.hardwareId, },
|
|
|
|
|
{ $set: updateData },
|
|
|
|
|
{ new: true } // Return the updated document
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!updatedSensor) {
|
|
|
|
|
return reply.status(404).send({ error: 'Sensor not found' });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return reply.status(200).send(updatedSensor);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
return reply.status(500).send({ error: 'An error occurred while updating the sensor' });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.qccheckwaterlevelSensor = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { hardwareId } = request.params;
|
|
|
|
|
@ -571,6 +597,22 @@ exports.addStore = async (request, reply) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getHardwareqc = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
await WaterLeverSensor.find({storeId: req.params.storeId,hardwareId:req.body.hardwareId})
|
|
|
|
|
.exec()
|
|
|
|
|
.then((docs) => {
|
|
|
|
|
reply.send({ status_code: 200, data: docs, count: docs.length });
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log(err);
|
|
|
|
|
reply.send({ error: err });
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.addSlave = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const hardwareId = req.params.hardwareId;
|
|
|
|
|
@ -593,7 +635,7 @@ exports.addStore = async (request, reply) => {
|
|
|
|
|
}
|
|
|
|
|
var slave_seq_id = await generatewaterlevelslavesensorId();
|
|
|
|
|
const date = moment().format('MM-DD');
|
|
|
|
|
const prefix = 'AS-' + date + '--SLAOV1-';
|
|
|
|
|
const prefix = 'AS' + date + 'SLAOV1-';
|
|
|
|
|
var slaveId = `${prefix}${slave_seq_id}`;
|
|
|
|
|
// Create new slave
|
|
|
|
|
const newSlave = {
|
|
|
|
|
|