Bhaskar 5 months ago
commit ef9df5556a

@ -1317,14 +1317,14 @@ exports.updateSensorQC = async (req, reply) => {
// Ensure qccheck is handled properly
if (filteredUpdateData.qccheck) {
const qccheckLower = filteredUpdateData.qccheck.toLowerCase();
filteredUpdateData.status = qccheckLower === 'ok' ? 'available' : 'qcfailed';
filteredUpdateData.status = qccheckLower === 'Pass' ? 'available' : 'qcfailed';
}
// Update qccheckdate with the current date in "DD-MMM-YYYY - HH:MM" format
filteredUpdateData.qccheckdate = moment().format('DD-MMM-YYYY - HH:mm');
// Find the sensor by ID
const updatedSensor = await Insensors.findByIdAndUpdate(
const updatedSensor = await Insensors.findOneAndUpdate(
hardwareId,
filteredUpdateData,
{ new: true }
@ -2319,6 +2319,7 @@ exports.acceptQuotation = async (req, reply) => {
status: "blocked",
customerId,
connected_to: masterHardwareId,
tankhardwareId: `tank-${j + 1}`,
hardwareId: slave.hardwareId,
tankName: tank.tankName || "",
tankLocation: tank.tankLocation || "",

@ -2880,8 +2880,35 @@ exports.motoractiontest = async (req, reply) => {
}
};
exports.motoractiontestbeforeqc = async (req, reply) => {
try {
const { motor_id, action } = req.body;
if (action === "start") {
await this.publishMotorStopStatus(motor_id, "2");
} else if (action === "stop") {
await this.publishMotorStopStatus(motor_id, "1");
} else {
return reply.status(400).send({ success: false, message: "Invalid action" });
}
return reply.send({ success: true, message: `Motor ${action} command sent.` });
} catch (error) {
console.error("Error fetching data:", error);
return reply.status(500).send({ success: false, message: "Internal Server Error" });
}
};
const motorIntervals = {};
async function calculateTotalPumpedWater(customerId, motorId, start_instance_id) {

@ -27,7 +27,7 @@ const fastify = require("fastify")({
// const Fastify = require("fastify");
fastify.register(cors, {
origin: 'http://localhost:3001', // Allow only your frontend URL
origin: 'http://armintaaqua.com:3000', // Allow only your frontend URL
methods: ['GET', 'POST', 'PUT', 'DELETE'], // Allowed HTTP methods
});

@ -469,6 +469,9 @@ lora_last_disconnect_time : { type: String, default: null },
power_check: { result: String },
master_connecting_gsm: { result: String },
slave_connecting: { result: String },
motor_start: { result: String },
motor_stop: { result: String },
motor_starting: {
result: String,
steps: [
@ -602,10 +605,11 @@ const orderSchema = new mongoose.Schema({
datetime: { type: String, default: null },
updated_at: { type: String, default: null },
assignedTeamMembers: [{ type: String }],
tankhardwareId: [{ type: String,default: null }],
master_connections: [
{
master_name: { type: String, default: null },
hardwareId: { type: String, default: null },
slaves: { type: String, default: null },
location: { type: String, default: null },
googleLocation: { type: String, default: null },

@ -1220,7 +1220,7 @@ fastify.post('/api/updateSensorQC/:hardwareId', {
tags: ['Store-Data'],
summary: 'Update QC fields of a sensor',
params: {
required: ['_ihardwareIdd'],
required: ['hardwareId'],
type: 'object',
properties: {
hardwareId: { type: 'string', description: 'Sensor ID' },
@ -1243,6 +1243,8 @@ fastify.post('/api/updateSensorQC/:hardwareId', {
power_check: { type: 'string' },
master_connecting_gsm: { type: 'string' },
slave_connecting: { type: 'string' },
motor_start: { type: 'string' },
motor_stop: { type: 'string' },
motor_starting: {
type: 'object',
properties: {

@ -415,6 +415,41 @@ module.exports = function (fastify, opts, next) {
});
fastify.route({
method: "PUT",
url: "/api/motoractiontestbeforeqc",
schema: {
tags: ["Install"],
summary: "This is for start and stop test before qc",
body: {
type: "object",
// required: ['phone'],
properties: {
motor_id:{type:"string"},
action:{type:"string"},
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
//preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.motoractiontestbeforeqc,
});
// fastify.route({
// method: "PUT",
// url: "/api/consumption/:customerId",

Loading…
Cancel
Save