| | |
| | | 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.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | 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.vo.StrainVO; |
| | | import org.springblade.modules.lang.entity.Land; |
| | | import org.springblade.modules.lang.service.ILandService; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springblade.modules.system.wrapper.UserWrapper; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.text.DecimalFormat; |
| | |
| | | record.setCreateTime(new Date()); |
| | | record.setJobWay(farmPlant.getJobWay()); |
| | | record.setTime(farmPlant.getTransplanTime()); |
| | | record.setDeptId(farmPlant.getDeptId()); |
| | | record.setTenantId(farmPlant.getTenantId()); |
| | | if (farmPlant.getPlantingWay().equals("0")) { |
| | | //移栽 |
| | | record.setType("10"); |
| | |
| | | } |
| | | record.setLandId(farmPlant.getLandId()); |
| | | record.setOperator(farmPlant.getCreateUser()); |
| | | record.setRemarks("品种: " + farmPlant.getVarieties()); |
| | | record.setContent("品种: " + farmPlant.getVarieties()); |
| | | //新增 |
| | | farmingRecordService.save(record); |
| | | |
| | |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | */ |
| | | @GetMapping("/pagex") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入farmPlant") |
| | | public R<IPage<FarmPlantVO>> pagex(FarmPlantVO farmPlant, Query query) { |
| | | IPage<FarmPlantVO> pages = farmplantService.selectFarmPlantPage(Condition.getPage(query), farmPlant); |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | //修改种养类型 |
| | | String plantingWay = pages.getRecords().get(i).getPlantingWay(); |
| | | if (plantingWay.equals("0")) { |
| | | pages.getRecords().get(i).setTy("移栽"); |
| | | } |
| | | else if (plantingWay.equals("1")) { |
| | | pages.getRecords().get(i).setTy("直播"); |
| | | } else { |
| | | pages.getRecords().get(i).setTy("秧苗"); |
| | | } |
| | | //计算天数 |
| | | Date transplanTime = pages.getRecords().get(i).getTransplanTime(); |
| | | Date date = new Date(); |
| | | Integer integer = daysBetween(transplanTime, date); |
| | | pages.getRecords().get(i).setFate(integer); |
| | | } |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 根据时间阶段计算天数 |
| | | * @param smdate 开始时间 |
| | | * @param bdate 结束时间 |
| | | * @return |
| | | */ |
| | | public static Integer daysBetween(Date smdate,Date bdate){ |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(smdate); |
| | | long time1 = cal.getTimeInMillis(); |
| | | cal.setTime(bdate); |
| | | long time2 = cal.getTimeInMillis(); |
| | | long between_days=(time2-time1)/(1000*3600*24); |
| | | return Integer.parseInt(String.valueOf(between_days))+1; |
| | | } |
| | | } |