test.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:chicken_farm/apis/index.dart';
  2. import 'package:chicken_farm/core/utils/logger.dart';
  3. class Test {
  4. Future<void> insetTestData() async {
  5. for (int i = 0; i < 2; i++) {
  6. apis.breeding.submitApi
  7. .bindChicken({
  8. 'rfids': ['test_1$i', 'test_2$i', 'test_3$i'],
  9. 'batchNum': '666',
  10. 'familyId': '888',
  11. 'date': '2025-12-11',
  12. })
  13. .then(
  14. (r) => {
  15. if (r.success)
  16. {logger.d('submitApi bindChicken: success')}
  17. else
  18. {logger.d('submitApi bindChicken: fail $i ${r.message}')},
  19. },
  20. );
  21. apis.breeding.submitApi
  22. .cageChange({
  23. 'rfids': ['test_1$i', 'test_2$i', 'test_3$i'],
  24. 'targetCage': '23333',
  25. 'date': '2025-12-11',
  26. })
  27. .then(
  28. (r) => {
  29. if (r.success)
  30. {logger.d('submitApi cageChange: success')}
  31. else
  32. {logger.d('submitApi cageChange: fail $i ${r.message}')},
  33. },
  34. );
  35. apis.breeding.submitApi
  36. .weight({'rfid': 'test_$i', 'weight': '1.23', 'date': '2025-12-11'})
  37. .then(
  38. (r) => {
  39. if (r.success)
  40. {logger.d('submitApi weight: success')}
  41. else
  42. {logger.d('submitApi weight: fail $i ${r.message}')},
  43. },
  44. );
  45. apis.breeding.submitApi
  46. .cull({
  47. 'rfid': 'test_$i',
  48. 'cullReason': '1',
  49. 'disposalMethod': '1',
  50. 'date': '2025-12-11',
  51. })
  52. .then(
  53. (r) => {
  54. if (r.success)
  55. {logger.d('submitApi cull: success')}
  56. else
  57. {logger.d('submitApi cull: fail $i ${r.message}')},
  58. },
  59. );
  60. apis.breeding.submitApi
  61. .batchCull({
  62. 'rfids': ['test_1$i', 'test_2$i', 'test_3$i'],
  63. 'cullReason': '1',
  64. 'disposalMethod': '1',
  65. 'date': '2025-12-11',
  66. })
  67. .then(
  68. (r) => {
  69. if (r.success)
  70. {logger.d('submitApi batchCull: success')}
  71. else
  72. {logger.d('submitApi batchCull: fail $i ${r.message}')},
  73. },
  74. );
  75. }
  76. }
  77. }