Bhaskar 5 months ago
commit ef9df5556a

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

@ -27,7 +27,7 @@ const fastify = require("fastify")({
// const Fastify = require("fastify"); // const Fastify = require("fastify");
fastify.register(cors, { 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 methods: ['GET', 'POST', 'PUT', 'DELETE'], // Allowed HTTP methods
}); });

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

@ -1220,7 +1220,7 @@ fastify.post('/api/updateSensorQC/:hardwareId', {
tags: ['Store-Data'], tags: ['Store-Data'],
summary: 'Update QC fields of a sensor', summary: 'Update QC fields of a sensor',
params: { params: {
required: ['_ihardwareIdd'], required: ['hardwareId'],
type: 'object', type: 'object',
properties: { properties: {
hardwareId: { type: 'string', description: 'Sensor ID' }, hardwareId: { type: 'string', description: 'Sensor ID' },
@ -1243,6 +1243,8 @@ fastify.post('/api/updateSensorQC/:hardwareId', {
power_check: { type: 'string' }, power_check: { type: 'string' },
master_connecting_gsm: { type: 'string' }, master_connecting_gsm: { type: 'string' },
slave_connecting: { type: 'string' }, slave_connecting: { type: 'string' },
motor_start: { type: 'string' },
motor_stop: { type: 'string' },
motor_starting: { motor_starting: {
type: 'object', type: 'object',
properties: { 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({ // fastify.route({
// method: "PUT", // method: "PUT",
// url: "/api/consumption/:customerId", // url: "/api/consumption/:customerId",

Loading…
Cancel
Save