|
@ -103,7 +103,63 @@ class ControlService { |
|
|
current_co2, |
|
|
current_co2, |
|
|
current_nh3, |
|
|
current_nh3, |
|
|
current_h2s |
|
|
current_h2s |
|
|
) {} |
|
|
|
|
|
|
|
|
) { |
|
|
|
|
|
const settingInfo = await Control.findOne({ |
|
|
|
|
|
where: { |
|
|
|
|
|
house_id, |
|
|
|
|
|
coop_id, |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
if (settingInfo) { |
|
|
|
|
|
const configInfo = await getConfigByHouseId(house_id); |
|
|
|
|
|
const res = await Control.update( |
|
|
|
|
|
{ |
|
|
|
|
|
temperature_start, |
|
|
|
|
|
temperature_end, |
|
|
|
|
|
humidity_start, |
|
|
|
|
|
humidity_end, |
|
|
|
|
|
current_co2, |
|
|
|
|
|
current_nh3, |
|
|
|
|
|
current_h2s, |
|
|
|
|
|
temperature_default_start: configInfo.temperature_default_start, |
|
|
|
|
|
temperature_default_end: configInfo.temperature_default_end, |
|
|
|
|
|
humidity_default_start: configInfo.humidity_default_start, |
|
|
|
|
|
humidity_default_end: configInfo.humidity_default_end, |
|
|
|
|
|
default_co2: configInfo.default_co2, |
|
|
|
|
|
default_nh3: configInfo.default_nh3, |
|
|
|
|
|
default_h2s: configInfo.default_h2s, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
where: { |
|
|
|
|
|
house_id, |
|
|
|
|
|
coop_id, |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
return res; |
|
|
|
|
|
} else { |
|
|
|
|
|
const configInfo = await getConfigByHouseId(house_id); |
|
|
|
|
|
const res = Control.create({ |
|
|
|
|
|
house_id, |
|
|
|
|
|
coop_id, |
|
|
|
|
|
temperature_start, |
|
|
|
|
|
temperature_end, |
|
|
|
|
|
humidity_start, |
|
|
|
|
|
humidity_end, |
|
|
|
|
|
current_co2, |
|
|
|
|
|
current_nh3, |
|
|
|
|
|
current_h2s, |
|
|
|
|
|
temperature_default_start: configInfo.temperature_default_start, |
|
|
|
|
|
temperature_default_end: configInfo.temperature_default_end, |
|
|
|
|
|
humidity_default_start: configInfo.humidity_default_start, |
|
|
|
|
|
humidity_default_end: configInfo.humidity_default_end, |
|
|
|
|
|
default_co2: configInfo.default_co2, |
|
|
|
|
|
default_nh3: configInfo.default_nh3, |
|
|
|
|
|
default_h2s: configInfo.default_h2s, |
|
|
|
|
|
}); |
|
|
|
|
|
return res; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
module.exports = new ControlService(); |
|
|
module.exports = new ControlService(); |