| | |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | |
| | | |
| | | /** |
| | | * 查询种养记录列表(不分页) |
| | | * @param farmPlant |
| | | * @return |
| | | */ |
| | | @GetMapping("/getFarmPlantList") |
| | | public R getFarmPlantList(FarmPlantVO farmPlant) { |
| | | return R.data(farmplantService.getFarmPlantList(farmPlant)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 分页统计 |
| | | */ |
| | | @GetMapping("/pageCount") |
| | |
| | | if (res.get(i).getStrainId().equals(count.get(j).getStrainId())){ |
| | | FarmPlantVO data = new FarmPlantVO(); |
| | | data.setStrainId(res.get(i).getStrainId()); |
| | | data.setArea((Double.parseDouble(res.get(i).getArea()) + Double.parseDouble(count.get(j).getArea()))+""); |
| | | BigDecimal b1 = new BigDecimal(res.get(i).getArea()); |
| | | BigDecimal b2 = new BigDecimal(count.get(j).getArea()); |
| | | data.setArea(b1.add(b2).doubleValue()+""); |
| | | data.setStrainName(res.get(i).getStrainName()); |
| | | count.set(j,data); |
| | | type = false; |
| | |
| | | */ |
| | | @GetMapping("/pagePalnt") |
| | | public R pagePalnt(FarmPlantVO farmPlant, Query query) { |
| | | int i = farmplantService.selectCount(); |
| | | int num = farmplantService.selectCount(farmPlant); |
| | | IPage<FarmPlantVO> pages = farmplantService.selectFarmPlantPage(Condition.getPage(query), farmPlant); |
| | | List<FarmPlantVO> res = pages.getRecords(); |
| | | List<FarmPlantVO> count = new ArrayList<>(); |
| | | //按种类合并种植物 |
| | | for (int i = 0; i < res.size(); i++) { |
| | | if (i == 0){ |
| | | count.add(res.get(0)); |
| | | }else { |
| | | boolean type = false; |
| | | for (int j = 0; j < count.size(); j++) { |
| | | if (res.get(i).getStrainId().equals(count.get(j).getStrainId())){ |
| | | FarmPlantVO data = new FarmPlantVO(); |
| | | data.setStrainId(res.get(i).getStrainId()); |
| | | BigDecimal b1 = new BigDecimal(res.get(i).getArea()); |
| | | BigDecimal b2 = new BigDecimal(count.get(j).getArea()); |
| | | data.setArea(b1.add(b2).doubleValue()+""); |
| | | data.setStrainName(res.get(i).getStrainName()); |
| | | data.setUrl(res.get(i).getUrl()); |
| | | count.set(j,data); |
| | | type = false; |
| | | break; |
| | | }else{ |
| | | type = true; |
| | | } |
| | | } |
| | | if (type){ |
| | | count.add(res.get(i)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Map map = new HashMap<>(); |
| | | map.put("num", i); |
| | | map.put("page", pages); |
| | | map.put("num", num); |
| | | map.put("page", count); |
| | | return R.data(map); |
| | | } |
| | | |