|
@@ -1,22 +1,27 @@
|
|
|
-//package com.huimv.apiservice;
|
|
|
-//
|
|
|
-//import cn.hutool.core.date.DateTime;
|
|
|
-//import cn.hutool.core.date.DateUtil;
|
|
|
-//import com.huimv.apiservice.dao.IndoorEnvironmentDao;
|
|
|
-//import com.huimv.apiservice.dao.OutdoorEnvironmentDao;
|
|
|
-//import com.huimv.apiservice.dao.PigDao;
|
|
|
-//import com.huimv.apiservice.entity.IndoorEnvironmentEntity;
|
|
|
-//import com.huimv.apiservice.entity.OutdoorEnvironmentEntity;
|
|
|
-//import org.junit.jupiter.api.Test;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-//
|
|
|
-//import java.math.BigDecimal;
|
|
|
-//import java.util.*;
|
|
|
-//
|
|
|
-//@SpringBootTest
|
|
|
-//class HuimvSmartApiserviceApplicationTests {
|
|
|
-//
|
|
|
+package com.huimv.apiservice;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.huimv.apiservice.dao.FeedRecordDao;
|
|
|
+import com.huimv.apiservice.dao.IndoorEnvironmentDao;
|
|
|
+import com.huimv.apiservice.dao.OutdoorEnvironmentDao;
|
|
|
+import com.huimv.apiservice.dao.PigDao;
|
|
|
+import com.huimv.apiservice.entity.FeedRecordEntity;
|
|
|
+import com.huimv.apiservice.entity.IndoorEnvironmentEntity;
|
|
|
+import com.huimv.apiservice.entity.OutdoorEnvironmentEntity;
|
|
|
+import com.huimv.apiservice.entity.vo.FeedRecordVo;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@SpringBootTest
|
|
|
+class HuimvSmartApiserviceApplicationTests {
|
|
|
+
|
|
|
// @Autowired
|
|
|
// private IndoorEnvironmentDao indoorEnvironmentDao;
|
|
|
//
|
|
@@ -25,14 +30,27 @@
|
|
|
//
|
|
|
// @Autowired
|
|
|
// private PigDao pigDao;
|
|
|
-//
|
|
|
-//
|
|
|
-// @Test
|
|
|
-// void contextLoads() {
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FeedRecordDao feedRecordDao;
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void contextLoads() {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<FeedRecordEntity> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(FeedRecordEntity::getPmsPig__earNumber, "156000020947069")
|
|
|
+ .ge(FeedRecordEntity::getStartTime, DateUtil.offsetDay(DateUtil.date(), -1));
|
|
|
+
|
|
|
+ List<FeedRecordVo> feedRecordVos = feedRecordDao.queryFeedRecords(query);
|
|
|
+ System.out.println(feedRecordVos);
|
|
|
+
|
|
|
+// List<FeedRecordEntity> feedRecordEntities = feedRecordDao.select(query);
|
|
|
+// System.out.println(feedRecordEntities);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// @Test
|
|
|
// void createIndoorEnv() {
|
|
|
//
|
|
@@ -118,77 +136,77 @@
|
|
|
//
|
|
|
// outdoorEnvironmentDao.batchInsertData(list);
|
|
|
// }
|
|
|
+
|
|
|
+
|
|
|
+// @Test
|
|
|
+// void createPigData() {
|
|
|
//
|
|
|
+// String[] breeds = {"黑猪","金华两头乌","杜巴嘉","巴嘉","杜洛克","嘉兴黑猪","大白猪"};
|
|
|
+// String[] originPlace = {"金华","杭州"};
|
|
|
//
|
|
|
-//// @Test
|
|
|
-//// void createPigData() {
|
|
|
-////
|
|
|
-//// String[] breeds = {"黑猪","金华两头乌","杜巴嘉","巴嘉","杜洛克","嘉兴黑猪","大白猪"};
|
|
|
-//// String[] originPlace = {"金华","杭州"};
|
|
|
-////
|
|
|
-//// List<YearPigBaseEntity> all = new ArrayList<>();
|
|
|
-//// List<YearPigBaseEntity> mothers = new ArrayList<>();
|
|
|
-//// List<YearPigBaseEntity> fathers = new ArrayList<>();
|
|
|
-////
|
|
|
-//// Random random = new Random();
|
|
|
-//// for (int i = 5; i < 2001; i++) {
|
|
|
-//// YearPigBaseEntity entity = new YearPigBaseEntity();
|
|
|
-//// String number = String.valueOf(i);
|
|
|
-//// String earTag = "N00000".substring(0, 6 - number.length()) + number;
|
|
|
-//// entity.setEartag(earTag);
|
|
|
-//// int dayAge = random.nextInt(200) + 50;
|
|
|
-//// entity.setDayAge(dayAge);
|
|
|
-//// entity.setUnitId(random.nextInt(4) + 1);
|
|
|
-//// BigDecimal bigDecimal = new BigDecimal(dayAge);
|
|
|
-//// BigDecimal weight = bigDecimal.multiply(new BigDecimal(0.8)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-//// entity.setWeight(weight.doubleValue());
|
|
|
-//// entity.setBreed(breeds[random.nextInt(breeds.length)]);
|
|
|
-//// String sex = i % 2 == 0 ? "公" : "母";
|
|
|
-//// entity.setSex(sex);
|
|
|
-//// if (dayAge >= 150 && "母".equals(sex)) {
|
|
|
-//// mothers.add(entity);
|
|
|
-//// }
|
|
|
-//// if (dayAge >= 150 && "公".equals(sex)) {
|
|
|
-//// fathers.add(entity);
|
|
|
-//// }
|
|
|
-//// entity.setBirthday(DateUtil.offsetDay(DateUtil.date(),i % 200));
|
|
|
-//// entity.setOriginPlace(originPlace[random.nextInt(2)]);
|
|
|
-//// //System.out.println(entity.getDayAge() + " " + " " + entity.getUnitId() + " " + entity.getWeight());
|
|
|
-//// entity.setPigstyId(random.nextInt(4) + 1);
|
|
|
-//// entity.setPeriodId(1);
|
|
|
-//// entity.setInFenceTime(DateUtil.offsetDay(DateUtil.parseDate("2021-01-01"),random.nextInt(91) - 30));
|
|
|
-//// all.add(entity);
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// for (YearPigBaseEntity yearPigBaseEntity : all) {
|
|
|
-//// if (yearPigBaseEntity.getDayAge() < 150) {
|
|
|
-//// yearPigBaseEntity.setMotherEartag(mothers.get(random.nextInt(mothers.size())).getEartag());
|
|
|
-//// yearPigBaseEntity.setFatherEartag(fathers.get(random.nextInt(fathers.size())).getEartag());
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-//// pigDao.batchInsertData(all);
|
|
|
-////
|
|
|
-//// List<SowChildbirthEntity> sowChildbirthEntityList = new ArrayList<>();
|
|
|
-//// for (YearPigBaseEntity mother : mothers) {
|
|
|
-//// SowChildbirthEntity entity = new SowChildbirthEntity();
|
|
|
-//// entity.setEartag(mother.getEartag());
|
|
|
-//// entity.setChildbirthWeight(mother.getWeight());
|
|
|
-//// entity.setPregnancyDate(DateUtil.offsetMonth(mother.getInFenceTime(),3));
|
|
|
-//// entity.setChildbirthCount(random.nextInt(10) + 5);
|
|
|
-//// sowChildbirthEntityList.add(entity);
|
|
|
-//// }
|
|
|
-//// sowChildbirthDao.batchInsertData(sowChildbirthEntityList);
|
|
|
-////
|
|
|
-////
|
|
|
-////
|
|
|
-////
|
|
|
-//// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//}
|
|
|
+// List<YearPigBaseEntity> all = new ArrayList<>();
|
|
|
+// List<YearPigBaseEntity> mothers = new ArrayList<>();
|
|
|
+// List<YearPigBaseEntity> fathers = new ArrayList<>();
|
|
|
+//
|
|
|
+// Random random = new Random();
|
|
|
+// for (int i = 5; i < 2001; i++) {
|
|
|
+// YearPigBaseEntity entity = new YearPigBaseEntity();
|
|
|
+// String number = String.valueOf(i);
|
|
|
+// String earTag = "N00000".substring(0, 6 - number.length()) + number;
|
|
|
+// entity.setEartag(earTag);
|
|
|
+// int dayAge = random.nextInt(200) + 50;
|
|
|
+// entity.setDayAge(dayAge);
|
|
|
+// entity.setUnitId(random.nextInt(4) + 1);
|
|
|
+// BigDecimal bigDecimal = new BigDecimal(dayAge);
|
|
|
+// BigDecimal weight = bigDecimal.multiply(new BigDecimal(0.8)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+// entity.setWeight(weight.doubleValue());
|
|
|
+// entity.setBreed(breeds[random.nextInt(breeds.length)]);
|
|
|
+// String sex = i % 2 == 0 ? "公" : "母";
|
|
|
+// entity.setSex(sex);
|
|
|
+// if (dayAge >= 150 && "母".equals(sex)) {
|
|
|
+// mothers.add(entity);
|
|
|
+// }
|
|
|
+// if (dayAge >= 150 && "公".equals(sex)) {
|
|
|
+// fathers.add(entity);
|
|
|
+// }
|
|
|
+// entity.setBirthday(DateUtil.offsetDay(DateUtil.date(),i % 200));
|
|
|
+// entity.setOriginPlace(originPlace[random.nextInt(2)]);
|
|
|
+// //System.out.println(entity.getDayAge() + " " + " " + entity.getUnitId() + " " + entity.getWeight());
|
|
|
+// entity.setPigstyId(random.nextInt(4) + 1);
|
|
|
+// entity.setPeriodId(1);
|
|
|
+// entity.setInFenceTime(DateUtil.offsetDay(DateUtil.parseDate("2021-01-01"),random.nextInt(91) - 30));
|
|
|
+// all.add(entity);
|
|
|
+// }
|
|
|
+//
|
|
|
+// for (YearPigBaseEntity yearPigBaseEntity : all) {
|
|
|
+// if (yearPigBaseEntity.getDayAge() < 150) {
|
|
|
+// yearPigBaseEntity.setMotherEartag(mothers.get(random.nextInt(mothers.size())).getEartag());
|
|
|
+// yearPigBaseEntity.setFatherEartag(fathers.get(random.nextInt(fathers.size())).getEartag());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// pigDao.batchInsertData(all);
|
|
|
+//
|
|
|
+// List<SowChildbirthEntity> sowChildbirthEntityList = new ArrayList<>();
|
|
|
+// for (YearPigBaseEntity mother : mothers) {
|
|
|
+// SowChildbirthEntity entity = new SowChildbirthEntity();
|
|
|
+// entity.setEartag(mother.getEartag());
|
|
|
+// entity.setChildbirthWeight(mother.getWeight());
|
|
|
+// entity.setPregnancyDate(DateUtil.offsetMonth(mother.getInFenceTime(),3));
|
|
|
+// entity.setChildbirthCount(random.nextInt(10) + 5);
|
|
|
+// sowChildbirthEntityList.add(entity);
|
|
|
+// }
|
|
|
+// sowChildbirthDao.batchInsertData(sowChildbirthEntityList);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|