| | |
| | | */ |
| | | package org.springblade.modules.farmplant.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springblade.modules.farmplant.entity.FarmPlant; |
| | | import org.springblade.modules.farmplant.service.FarmPlantService; |
| | | import org.springblade.modules.farmplant.vo.FarmPlantVO; |
| | | import org.springblade.modules.lang.entity.Land; |
| | | import org.springblade.modules.lang.service.ILandService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 农场养殖记录表控制器 |
| | |
| | | |
| | | |
| | | private final FarmingRecordService farmingRecordService; |
| | | |
| | | |
| | | private final ILandService landService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | record.setType("11"); |
| | | } |
| | | record.setLandId(farmPlant.getLandId()); |
| | | record.setTime(farmPlant.getTransplanTime()); |
| | | record.setOperator(farmPlant.getCreateUser()); |
| | | record.setRemarks("品种: "+farmPlant.getVarieties()); |
| | | //新增 |
| | | farmingRecordService.save(record); |
| | | |
| | | //更新地块是否已耕种 |
| | | Land land = new Land(); |
| | | land.setType(0); |
| | | land.setId(Long.parseLong(farmPlant.getLandId())); |
| | | landService.updateById(land); |
| | | } |
| | | return R.status(save); |
| | | } |
| | |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入farmPlant") |
| | | public R update(@Valid @RequestBody FarmPlant farmPlant) { |
| | | boolean status = false; |
| | | //如果是结束 |
| | | if (farmPlant.getStatus().equals("2")){ |
| | | //更新 |
| | | status = farmplantService.updateById(farmPlant); |
| | | //判断该地块是否还有种植的农产品 |
| | | FarmPlant farmPlant1 = new FarmPlant(); |
| | | farmPlant1.setLandId(farmPlant.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(farmPlant.getLandId())); |
| | | landService.updateById(land); |
| | | } |
| | | }else { |
| | | //更新 |
| | | status = farmplantService.updateById(farmPlant); |
| | | } |
| | | //更新并返回 |
| | | return R.status(farmplantService.updateById(farmPlant)); |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |