maochaoying 2 years ago
parent
commit
cc7c668d38
  1. 10
      src/service/coop.service.js

10
src/service/coop.service.js

@ -3,6 +3,7 @@ const Chicken = require("../model/chicken.model.js");
const Coop = require("../model/coop.model"); const Coop = require("../model/coop.model");
const { findDiffArr } = require("../utils/common"); const { findDiffArr } = require("../utils/common");
const { getHouseById } = require("./house.service"); const { getHouseById } = require("./house.service");
const { changeStatus } = require("./device.service");
class CoopService { class CoopService {
async getCoopListById(house_id) { async getCoopListById(house_id) {
const res = await Coop.findAll({ const res = await Coop.findAll({
@ -21,6 +22,15 @@ class CoopService {
chicken_number, chicken_number,
house_id, 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; return res ? res.dataValues : null;
} }

Loading…
Cancel
Save