|
|
@ -3,6 +3,7 @@ const Chicken = require("../model/chicken.model.js"); |
|
|
|
const Coop = require("../model/coop.model"); |
|
|
|
const { findDiffArr } = require("../utils/common"); |
|
|
|
const { getHouseById } = require("./house.service"); |
|
|
|
const { changeStatus } = require("./device.service"); |
|
|
|
class CoopService { |
|
|
|
async getCoopListById(house_id) { |
|
|
|
const res = await Coop.findAll({ |
|
|
@ -21,6 +22,15 @@ class CoopService { |
|
|
|
chicken_number, |
|
|
|
house_id, |
|
|
|
}); |
|
|
|
// 创建新鸡舍时初始化 环控 和 设备表
|
|
|
|
const deviceRes = await changeStatus({ |
|
|
|
house_id: res?.dataValues?.house_id, |
|
|
|
coop_id: res?.dataValues?.id, |
|
|
|
egg_gathering: 0, |
|
|
|
illumination: 0, |
|
|
|
air_conditioner: 0, |
|
|
|
}); |
|
|
|
|
|
|
|
return res ? res.dataValues : null; |
|
|
|
} |
|
|
|
|
|
|
|