From cc7c668d38bcb74e4db403d69ecb87ec5f3c923f Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Sun, 16 Apr 2023 13:15:43 +0800 Subject: [PATCH] 123 --- src/service/coop.service.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/service/coop.service.js b/src/service/coop.service.js index f4de413..021b180 100644 --- a/src/service/coop.service.js +++ b/src/service/coop.service.js @@ -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; }