| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 首页秧苗产品总和 |
| | | */ |
| | | @GetMapping("/strainCountYM") |
| | | public R<IPage<FarmPlantVO>> strainCountYM(FarmPlantVO farmPlant, Query query) { |
| | | IPage<FarmPlantVO> pages = farmplantService.selectFarmPlantPageCountYM(Condition.getPage(query), farmPlant); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询种养记录列表(不分页) |
| | | * @param farmPlant |
| | | * @return |
| | | */ |
| | | @GetMapping("/getFarmPlantList") |
| | | public R getFarmPlantList(FarmPlantVO farmPlant) { |
| | | return R.data(farmplantService.getFarmPlantList(farmPlant)); |
| | | } |
| | | |
| | | /** |
| | | * 查询种养记录列表(秧苗)(不分页) |
| | | * @param farmPlant |
| | | * @return |
| | | */ |
| | | @GetMapping("/getFarmPlantYMList") |
| | | public R getFarmPlantYMList(FarmPlantVO farmPlant) { |
| | | return R.data(farmplantService.getFarmPlantYMList(farmPlant)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 分页统计 |
| | |
| | | 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; |
| | |
| | | if (farmPlant.getPlantingWay().equals("1")) { |
| | | //直播 |
| | | record.setType("11"); |
| | | } |
| | | if(farmPlant.getPlantingWay().equals("2")){ |
| | | //秧苗 |
| | | record.setType("13"); |
| | | } |
| | | record.setLandId(farmPlant.getLandId()); |
| | | record.setOperator(farmPlant.getCreateUser()); |
| | |
| | | } |
| | | //更新并返回 |
| | | 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); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/getFarmPlantStatisticsCountx") |
| | | public R getFarmPlantStatisticsCountx(FarmPlantVO farmPlant, Query query) { |
| | | Double num = 0.0; |
| | | // Double num = 0.0; |
| | | IPage<FarmPlantVO> pages = farmplantService.getFarmPlantStatisticsCountz(Condition.getPage(query), farmPlant); |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | String area = pages.getRecords().get(i).getArea(); |
| | | Double a = Double.parseDouble(area); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String format = df.format(a); |
| | | pages.getRecords().get(i).setArea(format); |
| | | num += a; |
| | | } |
| | | Map map = new HashMap(); |
| | | List list = new ArrayList(); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String format = df.format(num); |
| | | map.put("znum", format); |
| | | list.add(map); |
| | | list.add(pages); |
| | | return R.data(list); |
| | | // for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | // String area = pages.getRecords().get(i).getArea(); |
| | | // Double a = Double.parseDouble(area); |
| | | // DecimalFormat df = new DecimalFormat("#.00"); |
| | | // String format = df.format(a); |
| | | // pages.getRecords().get(i).setArea(format); |
| | | // num += a; |
| | | // } |
| | | // Map map = new HashMap(); |
| | | // List list = new ArrayList(); |
| | | // DecimalFormat df = new DecimalFormat("#.00"); |
| | | // String format = df.format(num); |
| | | // map.put("znum", format); |
| | | // list.add(map); |
| | | // list.add(pages); |
| | | // return R.data(list); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | |