mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
Compare commits
4 Commits
ef21b589c0
...
fix/integr
Author | SHA1 | Date | |
---|---|---|---|
5bf44a18e1 | |||
2b2772e4ca | |||
13c0f87fc6 | |||
c9d794d988 |
@ -276,9 +276,11 @@ SELECT
|
|||||||
p.good_ch2o_percentage, p.moderate_ch2o_percentage, p.unhealthy_sensitive_ch2o_percentage, p.unhealthy_ch2o_percentage, p.very_unhealthy_ch2o_percentage, p.hazardous_ch2o_percentage,
|
p.good_ch2o_percentage, p.moderate_ch2o_percentage, p.unhealthy_sensitive_ch2o_percentage, p.unhealthy_ch2o_percentage, p.very_unhealthy_ch2o_percentage, p.hazardous_ch2o_percentage,
|
||||||
a.daily_avg_ch2o,a.daily_max_ch2o, a.daily_min_ch2o
|
a.daily_avg_ch2o,a.daily_max_ch2o, a.daily_min_ch2o
|
||||||
FROM daily_percentages p
|
FROM daily_percentages p
|
||||||
LEFT JOIN daily_averages a
|
LEFT JOIN daily_averages a
|
||||||
ON p.space_id = a.space_id AND p.event_date = a.event_date
|
ON p.space_id = a.space_id AND p.event_date = a.event_date
|
||||||
ORDER BY p.space_id, p.event_date)
|
WHERE p.space_id = (SELECT space_id FROM params)
|
||||||
|
AND p.event_date = (SELECT event_date FROM params)
|
||||||
|
ORDER BY p.space_id, p.event_date)
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO public."space-daily-pollutant-stats" (
|
INSERT INTO public."space-daily-pollutant-stats" (
|
||||||
|
@ -111,6 +111,7 @@ export class InviteUserService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const invitedUser = await queryRunner.manager.save(inviteUser);
|
const invitedUser = await queryRunner.manager.save(inviteUser);
|
||||||
|
const invitedRoleType = await this.getRoleTypeByUuid(roleUuid);
|
||||||
|
|
||||||
// Link user to spaces
|
// Link user to spaces
|
||||||
const spacePromises = validSpaces.map(async (space) => {
|
const spacePromises = validSpaces.map(async (space) => {
|
||||||
@ -128,7 +129,7 @@ export class InviteUserService {
|
|||||||
await this.emailService.sendEmailWithInvitationTemplate(email, {
|
await this.emailService.sendEmailWithInvitationTemplate(email, {
|
||||||
name: firstName,
|
name: firstName,
|
||||||
invitationCode,
|
invitationCode,
|
||||||
role: roleType,
|
role: invitedRoleType.replace(/_/g, ' '),
|
||||||
spacesList: spaceNames,
|
spacesList: spaceNames,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -162,6 +162,16 @@ export class ScheduleService {
|
|||||||
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
deviceDetails.productDevice.prodType == ProductType.CUR_2 &&
|
||||||
|
addScheduleDto.category != 'Timer'
|
||||||
|
) {
|
||||||
|
throw new HttpException(
|
||||||
|
'Invalid category for CUR_2 devices',
|
||||||
|
HttpStatus.BAD_REQUEST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Corrected condition for supported device types
|
// Corrected condition for supported device types
|
||||||
if (
|
if (
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
||||||
@ -182,6 +192,7 @@ export class ScheduleService {
|
|||||||
await this.addScheduleDeviceInTuya(
|
await this.addScheduleDeviceInTuya(
|
||||||
deviceDetails.deviceTuyaUuid,
|
deviceDetails.deviceTuyaUuid,
|
||||||
addScheduleDto,
|
addScheduleDto,
|
||||||
|
deviceDetails.productDevice.prodType as ProductType,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
@ -193,6 +204,7 @@ export class ScheduleService {
|
|||||||
async addScheduleDeviceInTuya(
|
async addScheduleDeviceInTuya(
|
||||||
deviceId: string,
|
deviceId: string,
|
||||||
addScheduleDto: AddScheduleDto,
|
addScheduleDto: AddScheduleDto,
|
||||||
|
deviceType: ProductType,
|
||||||
): Promise<addScheduleDeviceInterface> {
|
): Promise<addScheduleDeviceInterface> {
|
||||||
try {
|
try {
|
||||||
const convertedTime = convertTimestampToDubaiTime(addScheduleDto.time);
|
const convertedTime = convertTimestampToDubaiTime(addScheduleDto.time);
|
||||||
@ -212,7 +224,10 @@ export class ScheduleService {
|
|||||||
value: addScheduleDto.function.value,
|
value: addScheduleDto.function.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
category: `category_${addScheduleDto.category}`,
|
category:
|
||||||
|
deviceType == ProductType.CUR_2
|
||||||
|
? addScheduleDto.category
|
||||||
|
: `category_${addScheduleDto.category}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -254,7 +269,10 @@ export class ScheduleService {
|
|||||||
);
|
);
|
||||||
const result = schedules.result.map((schedule: any) => {
|
const result = schedules.result.map((schedule: any) => {
|
||||||
return {
|
return {
|
||||||
category: schedule.category.replace('category_', ''),
|
category:
|
||||||
|
deviceDetails.productDevice.prodType == ProductType.CUR_2
|
||||||
|
? schedule.category
|
||||||
|
: schedule.category.replace('category_', ''),
|
||||||
enable: schedule.enable,
|
enable: schedule.enable,
|
||||||
function: {
|
function: {
|
||||||
code: schedule.functions[0].code,
|
code: schedule.functions[0].code,
|
||||||
@ -318,6 +336,16 @@ export class ScheduleService {
|
|||||||
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
throw new HttpException('Device Not Found', HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
deviceDetails.productDevice.prodType == ProductType.CUR_2 &&
|
||||||
|
updateScheduleDto.category != 'Timer'
|
||||||
|
) {
|
||||||
|
throw new HttpException(
|
||||||
|
'Invalid category for CUR_2 devices',
|
||||||
|
HttpStatus.BAD_REQUEST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Corrected condition for supported device types
|
// Corrected condition for supported device types
|
||||||
if (
|
if (
|
||||||
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
deviceDetails.productDevice.prodType !== ProductType.THREE_G &&
|
||||||
@ -338,6 +366,7 @@ export class ScheduleService {
|
|||||||
await this.updateScheduleDeviceInTuya(
|
await this.updateScheduleDeviceInTuya(
|
||||||
deviceDetails.deviceTuyaUuid,
|
deviceDetails.deviceTuyaUuid,
|
||||||
updateScheduleDto,
|
updateScheduleDto,
|
||||||
|
deviceDetails.productDevice.prodType as ProductType,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
@ -349,6 +378,7 @@ export class ScheduleService {
|
|||||||
async updateScheduleDeviceInTuya(
|
async updateScheduleDeviceInTuya(
|
||||||
deviceId: string,
|
deviceId: string,
|
||||||
updateScheduleDto: UpdateScheduleDto,
|
updateScheduleDto: UpdateScheduleDto,
|
||||||
|
deviceType: ProductType,
|
||||||
): Promise<addScheduleDeviceInterface> {
|
): Promise<addScheduleDeviceInterface> {
|
||||||
try {
|
try {
|
||||||
const convertedTime = convertTimestampToDubaiTime(updateScheduleDto.time);
|
const convertedTime = convertTimestampToDubaiTime(updateScheduleDto.time);
|
||||||
@ -369,7 +399,10 @@ export class ScheduleService {
|
|||||||
value: updateScheduleDto.function.value,
|
value: updateScheduleDto.function.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
category: `category_${updateScheduleDto.category}`,
|
category:
|
||||||
|
deviceType == ProductType.CUR_2
|
||||||
|
? updateScheduleDto.category
|
||||||
|
: `category_${updateScheduleDto.category.replace('category_', '')}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user