get for quality check

master
varun 1 year ago
parent 9fb34945e9
commit 5caf396cb0

@ -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,
@ -571,6 +571,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 +609,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 = {

@ -155,8 +155,9 @@ const installationschema = new mongoose.Schema({
},
updatedBy: ObjectId,
}, { versionKey: false });
module.exports = mongoose.model('Store', storeSchema);

@ -212,6 +212,37 @@ fastify.get("/api/getHardware/:storeId", {
handler: storeController.getHardware,
});
fastify.put("/api/getHardwareqc/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get Quality Check Hardware Data",
summary: "This is to Get Quality Check Hardware Data",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: storeController.getHardwareqc,
});
fastify.post("/api/addSlave/:hardwareId", {

Loading…
Cancel
Save