|
@@ -15,13 +15,12 @@ import com.huimv.manager.result.RRException;
|
|
import com.huimv.manager.utils.Constant;
|
|
import com.huimv.manager.utils.Constant;
|
|
import com.huimv.manager.utils.PageUtils;
|
|
import com.huimv.manager.utils.PageUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -40,9 +39,12 @@ import java.util.stream.Collectors;
|
|
@RequestMapping("/prepareTrans")
|
|
@RequestMapping("/prepareTrans")
|
|
public class PreparePigController {
|
|
public class PreparePigController {
|
|
|
|
|
|
- private final int breeding = 50;
|
|
|
|
- private final int childbirth = 50;
|
|
|
|
- private final int threadshold = 5;
|
|
|
|
|
|
+ @Value("${local.prepare-trans.breeding}")
|
|
|
|
+ private int breeding;
|
|
|
|
+ @Value("${local.prepare-trans.childbirth}")
|
|
|
|
+ private int childbirth;
|
|
|
|
+ @Value("${local.prepare-trans.threshold}")
|
|
|
|
+ private int threshold;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private MovePigpenDao movePigpenDao;
|
|
private MovePigpenDao movePigpenDao;
|
|
@@ -51,16 +53,17 @@ public class PreparePigController {
|
|
private PigBasicInformationDao pigBasicInformationDao;
|
|
private PigBasicInformationDao pigBasicInformationDao;
|
|
|
|
|
|
@RequestMapping("/prepareCountAndDetail")
|
|
@RequestMapping("/prepareCountAndDetail")
|
|
- public R countPrepareAmountAndListPigDetail(Integer type,
|
|
|
|
|
|
+ public R countPrepareAmountAndListPigDetail(@RequestParam(name = "type") Integer type,
|
|
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
|
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
int breed = Constant.Stage.PEIZHONG.getType();
|
|
int breed = Constant.Stage.PEIZHONG.getType();
|
|
- if (type != null && type != breed && type != Constant.Stage.FENMIAN.getType()) {
|
|
|
|
|
|
+ if (type != 0 && type != breed && type != Constant.Stage.FENMIAN.getType()) {
|
|
throw new RRException("type参数有误,请检查");
|
|
throw new RRException("type参数有误,请检查");
|
|
}
|
|
}
|
|
|
|
|
|
LambdaQueryWrapper<MovePigpenEntity> lambdaQuery = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<MovePigpenEntity> lambdaQuery = Wrappers.lambdaQuery();
|
|
lambdaQuery.eq(MovePigpenEntity::getStage, breed);
|
|
lambdaQuery.eq(MovePigpenEntity::getStage, breed);
|
|
|
|
+
|
|
List<MovePigpenEntity> breedingList = movePigpenDao.selectList(lambdaQuery);
|
|
List<MovePigpenEntity> breedingList = movePigpenDao.selectList(lambdaQuery);
|
|
|
|
|
|
List<String> prepareToTransList = filterEligibleEartags(breedingList, breeding);
|
|
List<String> prepareToTransList = filterEligibleEartags(breedingList, breeding);
|
|
@@ -73,8 +76,8 @@ public class PreparePigController {
|
|
List<String> weaningList = filterEligibleEartags(childbirthList, childbirth);
|
|
List<String> weaningList = filterEligibleEartags(childbirthList, childbirth);
|
|
int weaningNum = weaningList.size();
|
|
int weaningNum = weaningList.size();
|
|
|
|
|
|
- List<String> list = CollUtil.newArrayList(prepareToTransList);
|
|
|
|
- if (type == null) {
|
|
|
|
|
|
+ List<String> list = CollUtil.newArrayList();
|
|
|
|
+ if (type == 0) {
|
|
list.addAll(prepareToTransList);
|
|
list.addAll(prepareToTransList);
|
|
list.addAll(weaningList);
|
|
list.addAll(weaningList);
|
|
} else if (type == breed) {
|
|
} else if (type == breed) {
|
|
@@ -89,7 +92,9 @@ public class PreparePigController {
|
|
IPage<PigBasicInformationEntity> page = new Page<>(pageNum, pageSize);
|
|
IPage<PigBasicInformationEntity> page = new Page<>(pageNum, pageSize);
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
eartagLambdaQuery.in(PigBasicInformationEntity::getEartagNo, list);
|
|
eartagLambdaQuery.in(PigBasicInformationEntity::getEartagNo, list);
|
|
- page = pigBasicInformationDao.selectPage(iPage, eartagLambdaQuery);
|
|
|
|
|
|
+ page = pigBasicInformationDao.selectPage(iPage, eartagLambdaQuery);
|
|
|
|
+// List<PigBasicInformationEntity> records = page.getRecords();
|
|
|
|
+// records.forEach(PigBasicInformationEntity::setDayAge);
|
|
}
|
|
}
|
|
|
|
|
|
PageUtils pageUtils = new PageUtils(page);
|
|
PageUtils pageUtils = new PageUtils(page);
|
|
@@ -98,8 +103,8 @@ public class PreparePigController {
|
|
|
|
|
|
private List<String> filterEligibleEartags(List<MovePigpenEntity> list, Integer type) {
|
|
private List<String> filterEligibleEartags(List<MovePigpenEntity> list, Integer type) {
|
|
return list.stream()
|
|
return list.stream()
|
|
- .filter(movePigpenEntity -> DateUtil.betweenDay(movePigpenEntity.getMoveDate(), new Date(), false) > type - threadshold)
|
|
|
|
- .sorted((o1, o2) -> (int) (o2.getMoveDate().getTime() - o1.getMoveDate().getTime()))
|
|
|
|
|
|
+ .filter(movePigpenEntity -> DateUtil.betweenDay(movePigpenEntity.getMoveDate(), new Date(), false) >= type - threshold && DateUtil.betweenDay(movePigpenEntity.getMoveDate(), new Date(), false) <= type)
|
|
|
|
+ .sorted((o1, o2) -> (int) (o1.getMoveDate().getTime() - o2.getMoveDate().getTime()))
|
|
.map(MovePigpenEntity::getEartagNo)
|
|
.map(MovePigpenEntity::getEartagNo)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
}
|
|
}
|