Merge pull request 'wisdom' (#11) from wisdom into main

Reviewed-on: #11
This commit is contained in:
2025-10-28 09:46:55 +00:00
4 changed files with 16 additions and 11 deletions

View File

@@ -21,6 +21,8 @@ const createErrorCodeDb = async (brandId, data) => {
error_code: data.error_code,
error_code_name: data.error_code_name,
error_code_description: data.error_code_description,
error_code_color: data.error_code_color,
path_icon: data.path_icon,
is_active: data.is_active,
created_by: data.created_by
};

View File

@@ -94,15 +94,8 @@ const getHistoryEventDb = async (searchParams = {}) => {
SELECT
COUNT(*) OVER() AS total_data,
a.*,
b.tag_name,
b.tag_number,
b.lim_low_crash,
b.lim_low,
b.lim_high,
b.lim_high_crash,
c.status_color
FROM alarm_history a
LEFT JOIN m_tags b ON a.tagnum = b.tag_number AND b.deleted_at IS NULL
FROM event_alarm a
LEFT JOIN m_status c ON a.status = c.status_number AND c.deleted_at IS NULL
WHERE a.datetime IS NOT NULL
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}
@@ -234,7 +227,7 @@ const getHistoryValueReportPivotDb = async (tableName, searchParams = {}) => {
SELECT
DATEADD(MINUTE, DATEDIFF(MINUTE, 0, CAST(a.datetime AS DATETIME)) / @intervalParam * @intervalParam, 0) AS waktu_group,
b.tag_name,
AVG(a.val) AS avg_val
ROUND(AVG(a.val), 4) AS avg_val
FROM ${tableName} a
LEFT JOIN m_tags b ON a.tagnum = b.tag_number AND b.deleted_at IS NULL
WHERE a.datetime BETWEEN @fromParam AND @toParam
@@ -319,7 +312,7 @@ const getHistoryValueTrendingPivotDb = async (tableName, searchParams = {}) => {
SELECT
DATEADD(MINUTE, DATEDIFF(MINUTE, 0, CAST(a.datetime AS DATETIME)) / @intervalParam * @intervalParam, 0) AS waktu_group,
b.tag_name,
AVG(a.val) AS avg_val
ROUND(AVG(a.val), 4) AS avg_val
FROM ${tableName} a
LEFT JOIN m_tags b ON a.tagnum = b.tag_number AND b.deleted_at IS NULL
WHERE a.datetime BETWEEN @fromParam AND @toParam

View File

@@ -144,6 +144,8 @@ class BrandService {
error_code: errorCodeData.error_code,
error_code_name: errorCodeData.error_code_name,
error_code_description: errorCodeData.error_code_description,
error_code_color: errorCodeData.error_code_color,
path_icon: errorCodeData.path_icon,
is_active: errorCodeData.is_active,
created_by: data.created_by
});
@@ -229,6 +231,8 @@ class BrandService {
await updateErrorCodeDb(existingEC.brand_id, existingEC.error_code, {
error_code_name: errorCodeData.error_code_name,
error_code_description: errorCodeData.error_code_description,
error_code_color: errorCodeData.error_code_color,
path_icon: errorCodeData.path_icon,
is_active: errorCodeData.is_active,
updated_by: data.updated_by
});
@@ -276,6 +280,8 @@ class BrandService {
error_code: errorCodeData.error_code,
error_code_name: errorCodeData.error_code_name,
error_code_description: errorCodeData.error_code_description,
error_code_color: errorCodeData.error_code_color,
path_icon: errorCodeData.path_icon,
is_active: errorCodeData.is_active,
created_by: data.updated_by
});

View File

@@ -15,6 +15,8 @@ const insertBrandSchema = Joi.object({
error_code: Joi.string().max(100).required(),
error_code_name: Joi.string().max(100).required(),
error_code_description: Joi.string().optional().allow(''),
error_code_color: Joi.string().optional().allow(''),
path_icon: Joi.string().optional().allow(''),
is_active: Joi.boolean().required(),
what_action_to_take: Joi.string().optional().allow(''),
solution: Joi.array().items(
@@ -51,6 +53,8 @@ const updateBrandSchema = Joi.object({
error_code: Joi.string().max(100).required(),
error_code_name: Joi.string().max(100).required(),
error_code_description: Joi.string().optional().allow(''),
error_code_color: Joi.string().optional().allow(''),
path_icon: Joi.string().optional().allow(''),
is_active: Joi.boolean().required(),
what_action_to_take: Joi.string().optional().allow(''),
solution: Joi.array().items(