石墨消解仪后端用nodejs编写,与嵌入式端交互和前端交互均用ws
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
829 B

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. const FeedConversion = require("../model/feedConversion.model");
  2. const { updateRatioById } = require("./coop.service");
  3. class FeedConversionService {
  4. async createFeed(
  5. batch_id,
  6. coop_id,
  7. fodder_total,
  8. weight_increment,
  9. log_user_id
  10. ) {
  11. // 插入料肉比记录
  12. const res = await FeedConversion.create({
  13. batch_id,
  14. coop_id,
  15. fodder_total,
  16. weight_increment,
  17. log_user_id,
  18. });
  19. // 像对应的coop中插入料肉比
  20. // 计算料肉比
  21. if (weight_increment != 0 && fodder_total != 0) {
  22. try {
  23. const ratio = (fodder_total / weight_increment).toFixed(2);
  24. const coopRes = await updateRatioById(coop_id, ratio);
  25. } catch (err) {
  26. console.log(err);
  27. }
  28. }
  29. return res;
  30. }
  31. }
  32. module.exports = new FeedConversionService();