| | |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | *首页当前种养产品总和 |
| | | */ |
| | | @GetMapping("/strainCount") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入farmPlant") |
| | | public R<IPage<FarmPlantVO>> strainCount(FarmPlantVO farmPlant, Query query) { |
| | | IPage<FarmPlantVO> pages = farmplantService.selectFarmPlantPageCount(Condition.getPage(query), farmPlant); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询种养记录列表(不分页) |
| | |
| | | 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; |
| | |
| | | return R.status(status); |
| | | } |
| | | |
| | | @PostMapping("/overAll") |
| | | public R overAll(@RequestBody FarmPlantVO farmPlantVO){ |
| | | boolean status = false; |
| | | for (int i=0;i<farmPlantVO.getIds().length;i++){ |
| | | FarmPlant farmPlant = new FarmPlant(); |
| | | farmPlant.setId(farmPlantVO.getIds()[i]); |
| | | farmPlant.setEndPlantTime(farmPlantVO.getEndPlantTime()); |
| | | farmPlant.setStatus("2"); |
| | | status = farmplantService.updateById(farmPlant); |
| | | //判断该地块是否还有种植的农产品 |
| | | FarmPlant farmPlant2 = farmplantService.getById(farmPlant.getId()); |
| | | FarmPlant farmPlant1 = new FarmPlant(); |
| | | farmPlant1.setLandId(farmPlant2.getLandId()); |
| | | farmPlant1.setStatus("1"); |
| | | List<FarmPlant> list = farmplantService.list(new QueryWrapper<>(farmPlant1)); |
| | | if (list.size() < 1) { |
| | | //更新该地块的耕种状态 |
| | | Land land = new Land(); |
| | | land.setType(1); |
| | | land.setId(Long.parseLong(farmPlant2.getLandId())); |
| | | landService.updateById(land); |
| | | } |
| | | } |
| | | return R.data(status); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | |
| | | */ |
| | | @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); |
| | | } |
| | | |