|
@@ -18,7 +18,6 @@ import com.huimv.apiservice.entity.vo.*;
|
|
|
import com.huimv.apiservice.service.PigService;
|
|
|
import com.huimv.common.exception.RRException;
|
|
|
import com.huimv.common.utils.PageUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -42,6 +41,9 @@ public class PigServiceImpl extends ServiceImpl<PigDao, YearPigBaseEntity> imple
|
|
|
private EatTimeDao eatTimeDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private PeriodDao periodDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private IndoorEnvironmentDao indoorEnvironmentDao;
|
|
|
|
|
|
@Autowired
|
|
@@ -63,16 +65,19 @@ public class PigServiceImpl extends ServiceImpl<PigDao, YearPigBaseEntity> imple
|
|
|
|
|
|
Map<String, Object> result = new LinkedHashMap<>(16);
|
|
|
List<Map<String, Object>> temperature = new ArrayList<>();
|
|
|
-// List<Map<String, Object>> healthStatus = new ArrayList<>();
|
|
|
List<Map<String, Object>> feedingStatus = new ArrayList<>();
|
|
|
List<Map<String, Object>> sleepStatus = new ArrayList<>();
|
|
|
List<Map<String, Object>> sportStatus = new ArrayList<>();
|
|
|
result.put("temperature", temperature);
|
|
|
-// result.put("healthStatus", healthStatus);
|
|
|
result.put("feedingStatus", feedingStatus);
|
|
|
+
|
|
|
+ boolean health = baseMapper.selectHealthStatus(pigEarTagNo);
|
|
|
+ result.put("healthStatus", health ? "健康" : "不健康");
|
|
|
+
|
|
|
result.put("sleepStatus", sleepStatus);
|
|
|
result.put("sportStatus", sportStatus);
|
|
|
|
|
|
+
|
|
|
//公用时间 -> 当前日期
|
|
|
String today = DateUtil.format(DateUtil.date(), "yyyy-MM-dd");
|
|
|
|
|
@@ -180,19 +185,25 @@ public class PigServiceImpl extends ServiceImpl<PigDao, YearPigBaseEntity> imple
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public PageUtils getListByBreed(String breedName) {
|
|
|
+ public PageUtils getPageByBreedAndFence(String breedName, Integer currentPage, Integer pageSize, String period) {
|
|
|
|
|
|
- if (StringUtils.isEmpty(breedName)) {
|
|
|
- throw new RRException("品种名称不能为空!",1001);
|
|
|
- }
|
|
|
+// if (StringUtils.isEmpty(breedName)) {
|
|
|
+// throw new RRException("品种名称不能为空!", 1001);
|
|
|
+// }
|
|
|
|
|
|
Integer count = baseMapper.selectCount(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getBreed, breedName));
|
|
|
if (count <= 0) {
|
|
|
- throw new RRException("品种名称不存在,请检查!",1001);
|
|
|
+ throw new RRException("品种名称不存在,请检查!", 1001);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer periodId = periodDao.selectIdByPeriodNumber(period);
|
|
|
+ if (periodId == null) {
|
|
|
+ throw new RRException("栏期编号不存在,请检查!", 1001);
|
|
|
}
|
|
|
|
|
|
- IPage<PigBaseVo> page = new Page<>(1, 10);
|
|
|
- IPage<PigBaseVo> pigBaseVoList = baseMapper.selectPagePigBaseVoByBreedName(page, breedName);
|
|
|
+
|
|
|
+ IPage<PigBaseVo> page = new Page<>(currentPage, pageSize);
|
|
|
+ IPage<PigBaseVo> pigBaseVoList = baseMapper.selectPagePigBaseVoByBreedName(page, breedName, periodId);
|
|
|
|
|
|
return new PageUtils(pigBaseVoList);
|
|
|
}
|
|
@@ -273,18 +284,18 @@ public class PigServiceImpl extends ServiceImpl<PigDao, YearPigBaseEntity> imple
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void outFence(String pigEarTagNo, Integer status) {
|
|
|
+ public void outFence(String pigEarTagNo, Integer status) {
|
|
|
|
|
|
checkPigEarTagNo(pigEarTagNo);
|
|
|
|
|
|
if (!status.equals(1) && !status.equals(2) && !status.equals(3)) {
|
|
|
- throw new RRException("出栏状态有误,请检查!",1001);
|
|
|
+ throw new RRException("出栏状态有误,请检查!", 1001);
|
|
|
}
|
|
|
|
|
|
LambdaUpdateWrapper<YearPigBaseEntity> pigBaseLambdaUpdate = Wrappers.lambdaUpdate();
|
|
|
pigBaseLambdaUpdate.eq(YearPigBaseEntity::getEartag, pigEarTagNo)
|
|
|
- .set(YearPigBaseEntity::getDeleted,true)
|
|
|
- .set(YearPigBaseEntity::getFosterStatus,false)
|
|
|
+ .set(YearPigBaseEntity::getDeleted, true)
|
|
|
+ .set(YearPigBaseEntity::getFosterStatus, false)
|
|
|
.set(YearPigBaseEntity::getOutFenceStatus, status);
|
|
|
|
|
|
update(pigBaseLambdaUpdate);
|
|
@@ -298,8 +309,6 @@ public class PigServiceImpl extends ServiceImpl<PigDao, YearPigBaseEntity> imple
|
|
|
*/
|
|
|
private void checkPigEarTagNo(String pigEarTagNo) {
|
|
|
|
|
|
-//
|
|
|
-
|
|
|
Integer count = baseMapper.selectCount(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, pigEarTagNo));
|
|
|
if (count <= 0) {
|
|
|
throw new RRException("耳标信息不存在,请检查!", 1001);
|