|
@ -4,6 +4,7 @@ const Device = require("../model/device.model"); |
|
|
const { getDayLife } = require("../utils/common"); |
|
|
const { getDayLife } = require("../utils/common"); |
|
|
const Coop = require("../model/coop.model"); |
|
|
const Coop = require("../model/coop.model"); |
|
|
const { Op, Sequelize } = require("sequelize"); |
|
|
const { Op, Sequelize } = require("sequelize"); |
|
|
|
|
|
const { getConfigByHouseId } = require("./config.service"); |
|
|
const { getCoopListById } = require("./coop.service"); |
|
|
const { getCoopListById } = require("./coop.service"); |
|
|
class ControlService { |
|
|
class ControlService { |
|
|
async getSettingByCoopId(house_id, coop_id) { |
|
|
async getSettingByCoopId(house_id, coop_id) { |
|
@ -16,6 +17,25 @@ class ControlService { |
|
|
return res ? res.dataValues : null; |
|
|
return res ? res.dataValues : null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async getSettingInfoById(house_id, coop_id) { |
|
|
|
|
|
const res = await Control.findOne({ |
|
|
|
|
|
where: { |
|
|
|
|
|
house_id, |
|
|
|
|
|
coop_id, |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
if (res) { |
|
|
|
|
|
res.dataValues.hasData = true; |
|
|
|
|
|
return res.dataValues; |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果没有配置过默认信息
|
|
|
|
|
|
// 则需要在config表中查找该鸡场的默认信息返回
|
|
|
|
|
|
const configInfo = await getConfigByHouseId(house_id); |
|
|
|
|
|
configInfo.hasData = false; |
|
|
|
|
|
return configInfo; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async getControlInfoList(house_id, batch_number = "", coop_ids) { |
|
|
async getControlInfoList(house_id, batch_number = "", coop_ids) { |
|
|
const res = await getCoopListById(house_id); |
|
|
const res = await getCoopListById(house_id); |
|
|
// 查询该舍的环控信息
|
|
|
// 查询该舍的环控信息
|
|
|