| | |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.farm.entity.FarmingRecord; |
| | | import org.springblade.modules.farm.service.FarmingRecordService; |
| | | import org.springblade.modules.farmplant.entity.FarmPlant; |
| | | import org.springblade.modules.farmplant.service.FarmPlantService; |
| | | import org.springblade.modules.farmplant.vo.FarmPlantVO; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | |
| | | public class FarmPlantController extends BladeController { |
| | | |
| | | private final FarmPlantService farmplantService; |
| | | |
| | | |
| | | private final FarmingRecordService farmingRecordService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入farmPlant") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R save(@Valid @RequestBody FarmPlant farmPlant) { |
| | | farmPlant.setCreateTime(new Date()); |
| | | return R.status(farmplantService.save(farmPlant)); |
| | | boolean save = farmplantService.save(farmPlant); |
| | | if (save){ |
| | | //同时生成农事记录 |
| | | FarmingRecord record = new FarmingRecord(); |
| | | record.setCreateTime(new Date()); |
| | | record.setJobWay(farmPlant.getJobWay()); |
| | | record.setTime(farmPlant.getTransplanTime()); |
| | | if(farmPlant.getPlantingWay().equals("0")){ |
| | | //移栽 |
| | | record.setType("10"); |
| | | } |
| | | if(farmPlant.getPlantingWay().equals("1")){ |
| | | //直播 |
| | | record.setType("11"); |
| | | } |
| | | record.setLandId(farmPlant.getLandId()); |
| | | record.setTime(farmPlant.getTransplanTime()); |
| | | record.setOperator(farmPlant.getCreateUser()); |
| | | record.setRemarks("品种: "+farmPlant.getVarieties()); |
| | | //新增 |
| | | farmingRecordService.save(record); |
| | | } |
| | | return R.status(save); |
| | | } |
| | | |
| | | /** |