const FeedConversion = require("../model/feedConversion.model"); const { updateRatioById } = require("./coop.service"); class FeedConversionService { async createFeed( batch_id, coop_id, fodder_total, weight_increment, log_user_id ) { // 插入料肉比记录 const res = await FeedConversion.create({ batch_id, coop_id, fodder_total, weight_increment, log_user_id, }); // 像对应的coop中插入料肉比 // 计算料肉比 if (weight_increment != 0 && fodder_total != 0) { try { const ratio = (fodder_total / weight_increment).toFixed(2); const coopRes = await updateRatioById(coop_id, ratio); } catch (err) { console.log(err); } } return res; } } module.exports = new FeedConversionService();