|
|
@ -264,10 +264,14 @@ class ChickenService { |
|
|
|
return arr; |
|
|
|
} |
|
|
|
|
|
|
|
async getFeedConversionRatio(house_id) { |
|
|
|
async getFeedConversionRatio(house_id, batch_number = "") { |
|
|
|
// 需要根据batch_id进行模糊查询
|
|
|
|
const res = await Chicken.findAll({ |
|
|
|
where: { |
|
|
|
house_id, |
|
|
|
batch_number: { |
|
|
|
[Op.like]: `%${batch_number}%`, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
const arr = res.map((item) => item.dataValues); |
|
|
@ -276,12 +280,22 @@ class ChickenService { |
|
|
|
// 根据coop_ids 批量查询鸡舍信息
|
|
|
|
const coopInfo = await getBatchCoopByIds(coop_ids); |
|
|
|
item.coopInfo = coopInfo; |
|
|
|
// 料肉比=消耗饲料总量/增重总量
|
|
|
|
// 监测到的重量 - 进鸡时的重量 = 增重
|
|
|
|
// getTotalFeedingByCoopId()
|
|
|
|
// 需要计算出平均的料肉比
|
|
|
|
let total = 0; |
|
|
|
let length = 0; |
|
|
|
coopInfo.map((item) => { |
|
|
|
if (item.feed_conversion) { |
|
|
|
total += item.feed_conversion; |
|
|
|
length += 1; |
|
|
|
} |
|
|
|
}); |
|
|
|
if (length > 0) { |
|
|
|
item.average = total / length; |
|
|
|
} |
|
|
|
return item; |
|
|
|
}); |
|
|
|
const realRes = await Promise.all(p); |
|
|
|
|
|
|
|
return realRes; |
|
|
|
} |
|
|
|
|
|
|
|