| | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/8/19 8:35 |
| | | * @Description 作物蒸腾量 |
| | | * @Description 作物蒸散量 |
| | | */ |
| | | @TableName(value="md_et0", autoResultMap = true) |
| | | @Data |
| | |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Schema(name = "作物蒸腾量") |
| | | @Schema(name = "作物蒸散量") |
| | | public class MdEt0 implements BaseEntity { |
| | | |
| | | public static final long serialVersionUID = 202508190840001L; |
| | |
| | | public Date dt; |
| | | |
| | | /** |
| | | * 蒸腾量 |
| | | * 蒸散量 |
| | | */ |
| | | @Schema(description = "本日作物蒸腾量", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Schema(description = "本日作物蒸散量", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @JsonFormat(shape = JsonFormat.Shape.NUMBER, pattern = "0.00") |
| | | public Double et0; |
| | | |
| | |
| | | public Date dt; |
| | | |
| | | /** |
| | | * 蒸腾量 |
| | | * 蒸散量 |
| | | */ |
| | | @Schema(description = "本日作物蒸腾量", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Schema(description = "本日作物蒸散量", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @JsonFormat(shape = JsonFormat.Shape.NUMBER, pattern = "0.00") |
| | | public Double et0; |
| | | } |
| | |
| | | this.executeOnCrop(crop, voWeather); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("计算作物(id=" + crop.id + ")蒸腾数据时异常", e); |
| | | log.error("计算作物(id=" + crop.id + ")蒸散数据时异常", e); |
| | | } |
| | | } |
| | | } |
| | |
| | | if(tmps != null && tmps.size() > 0){ |
| | | VoWeatherMaxMinTmp voMmTmp = tmps.get(0);//只能有一条记录 |
| | | if(voMmTmp != null && voMmTmp.maxAirTemperature != null && voMmTmp.minAirTemperature != null){ |
| | | Double et0 = this.calculateEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor) ;//计算蒸腾数据 |
| | | Double et0 = this.calculateEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor) ;//计算蒸散数据 |
| | | this.saveEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor, et0) ; |
| | | } |
| | | } |
| | |
| | | * @Author: liurunyu |
| | | * @Date: 2025/8/6 9:32 |
| | | * @Description |
| | | * 作物蒸腾自动计算 |
| | | * 作物蒸散自动计算 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/8/22 10:20 |
| | | * @Description 不要删除!!! 为前端蒸腾量计算提供的服务 |
| | | * @Description 不要删除!!! 为前端蒸散量计算提供的服务 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "作物日蒸腾量计算测试", description = "作物日蒸腾量计算测试") |
| | | @Tag(name = "作物日蒸散量计算测试", description = "作物日蒸散量计算测试") |
| | | @RestController |
| | | @RequestMapping(path = "mdTest") |
| | | public class TestCtrl { |
| | |
| | | } |
| | | return BaseResponseUtils.buildSuccess(vo); |
| | | } catch (Exception e) { |
| | | log.error("查询所有作物的昨日蒸腾量异常", e); |
| | | log.error("查询所有作物的昨日蒸散量异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | |
| | | Double et0 = Hargreaves.ET0(qo.kc, qo.maxTmp, qo.minTmp, zenithRadiation); |
| | | return BaseResponseUtils.buildSuccess(et0); |
| | | } catch (Exception e) { |
| | | log.error("查询所有作物的昨日蒸腾量异常", e); |
| | | log.error("查询所有作物的昨日蒸散量异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Tag(name = "作物日蒸腾量", description = "作物日蒸腾量查询等操作") |
| | | @Tag(name = "作物日蒸散量", description = "作物日蒸散量查询等操作") |
| | | @RestController |
| | | @RequestMapping(path = "mdVapor") |
| | | public class VaporCtrl { |
| | |
| | | |
| | | |
| | | /** |
| | | * 客户端请求得到所有作物的昨日蒸腾量 |
| | | * @return 所有所有作物的昨日蒸腾量 |
| | | * 客户端请求得到所有作物的昨日蒸散量 |
| | | * @return 所有所有作物的昨日蒸散量 |
| | | */ |
| | | @Operation(summary = "获得作物的昨日蒸腾量", description = "返回所有作物的昨日蒸腾量数据") |
| | | @Operation(summary = "获得作物的昨日蒸散量", description = "返回所有作物的昨日蒸散量数据") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "返回作物的昨日蒸腾量数据(BaseResponse.content:QueryResultVo[{}])", |
| | | description = "返回作物的昨日蒸散量数据(BaseResponse.content:QueryResultVo[{}])", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = MdEt0.class))} |
| | | ) |
| | |
| | | List<MdEt0> res = this.sv.selectEt0(ymd) ; |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询所有作物的昨日蒸腾量异常", e); |
| | | log.error("查询所有作物的昨日蒸散量异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件作物查询一段时间内的蒸腾量 |
| | | * 根据指定条件作物查询一段时间内的蒸散量 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | @Schema(name = "作物日蒸腾查询条件") |
| | | @Schema(name = "作物日蒸散查询条件") |
| | | public class VaporQo extends QueryConditionVo { |
| | | /** |
| | | * 作物ID |
| | |
| | | return prIntakeMapper.getSupperByVillageId(vaId); |
| | | } |
| | | |
| | | /** |
| | | * 保存修改实体 |
| | | * |
| | | * @param po 实体 |
| | | * @return 数量 |
| | | */ |
| | | |
| | | public int update(PrIntake po) { |
| | | // if (po.getTownId() == null || po.getTownId() == 0) { |
| | | // Long townId = getSupperByVillageId(po.getVillageId()); |
| | |
| | | // return this.prIntakeMapper.updateByPrimaryKey(po); |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件获取取水口记录 |
| | | * |
| | | * @param queryVo 查询视图 |
| | | * @return 取水口记录列表 |
| | | */ |
| | | public QueryResultVo<List<VoIntake>> getIntakes(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | Long itemTotal = prIntakeMapper.getRecordCount(params); |
| | |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件导出取水口列表 |
| | | * |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public List<VoIntake> exportIntakes(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | List<VoIntake> rsVo = prIntakeMapper.getIntakes(params); |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 得到所有取水口 |
| | | * |
| | | * @return 所有取水口集合 |
| | | */ |
| | | public QueryResultVo<List<VoAllIntake>> selectAll() { |
| | | QueryResultVo<List<VoAllIntake>> rsVo = new QueryResultVo<>(); |
| | | rsVo.obj = this.prIntakeMapper.selectAll(); |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 得到一个取水口 |
| | | * |
| | | * @param id 取水口ID |
| | | * @return 取水口实体 |
| | | */ |
| | | public VoAllIntake selectById(Long id) { |
| | | return this.prIntakeMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | /** |
| | | * 逻辑删除实体 |
| | | * |
| | | * @param id 实体ID |
| | | * @return 数量 |
| | | */ |
| | | @Transactional |
| | | public int delete(Long id) { |
| | | return this.prIntakeMapper.deleteLogicById(id); |
| | | } |
| | | |
| | | /** |
| | | * 根据取水口编号获取未删除的取水口数量 |
| | | * |
| | | * @param intakeId |
| | | * @return |
| | | */ |
| | | public Integer getRecordCountOfIntake(Long intakeId) { |
| | | return prIntakeMapper.getRecordCountOfIntake(intakeId); |
| | | } |
| | | |
| | | /** |
| | | * 根据村Id获取全部地址 |
| | | * |
| | | * @param villageId 村Id |
| | | * @return address 全部五级地址 |
| | | */ |
| | | public String getAddressByVillageId(long villageId) { |
| | | return prIntakeMapper.getAddressByVillageId(villageId); |
| | | } |
| | | |
| | | /** |
| | | * 根据区域Id获取区域等级 |
| | | * |
| | | * @param regionId 区域Id |
| | | * @return Level 区域等级 |
| | | */ |
| | | public int getLevelByRegionId(long regionId) { |
| | | return prIntakeMapper.getLevelByRegionId(regionId); |
| | | } |
| | |
| | | return prIntakeMapper.getUsedIntakes(jsonArray.toJSONString(), operator); |
| | | } |
| | | |
| | | /** |
| | | * 发送命令 |
| | | * |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendCom2Mw(Command com) { |
| | | String url = UriComponentsBuilder.fromUriString(comSendUrl) |
| | | .build() |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取水口名称换取水口ID,验证是否重复名称使用 |
| | | * |
| | | * @param intakeName |
| | | * @return |
| | | */ |
| | | public List<Long> getIntakeIdsByName(String intakeName) { |
| | | return prIntakeMapper.getIntakeIdsByName(intakeName); |
| | | } |
| | | |
| | | /** |
| | | * 取水口名称换取水口ID,验证是否重复名称使用 |
| | | * |
| | | * @param intakeName |
| | | * @return |
| | | */ |
| | | public List<Long> getIntakeIdByNameExcludeId(Long id, String intakeName) { |
| | | return prIntakeMapper.getIntakeIdByNameExcludeId(id, intakeName); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * app修改取水口经纬度 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public int updateIntakeLngLat(IntakeUpdateLngLat po) { |
| | | return prIntakeMapper.updateByPrimaryKeySelective1(po); |
| | | } |
| | | |
| | | /** |
| | | * 获取未绑定到轮灌组的取水口列表 |
| | | * @return |
| | | */ |
| | | public List<VoIntakeSimple> getFreeIntakes(QoIntake queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | return prIntakeMapper.getFreeIntakes(params); |
| | |
| | | // VoUnclosedParam voUnclosedParam = new VoUnclosedParam(); |
| | | // return voUnclosedParam; |
| | | } |
| | | |
| | | if(jsonArray.size() == 0) { |
| | | return null; |
| | | } |
| | | return rmCommandHistoryMapper.getUncloseParam(jsonArray.toJSONString(), intakeId); |
| | | } |
| | | |
| | |
| | | this.env = env; |
| | | } |
| | | |
| | | /** |
| | | * 平台远程开阀(强制开阀) |
| | | * @param valve |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "open", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | param.elePrice = 0.0; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | // 获取功能码 |
| | | commandCode = CodeV1.cd_92; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 平台远程关阀(强制关阀) |
| | | * @param dtoBase |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "close_intake", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | VoUnclosedParam voUnclosedParam = null; |
| | | try { |
| | | voUnclosedParam = commandSv.getUncloseParam(intakeId); |
| | | if(voUnclosedParam == null) { |
| | | return BaseResponseUtils.buildErrorMsg("不存在符合条件的未关阀取水口"); |
| | | } |
| | | }catch (Exception e) { |
| | | return BaseResponseUtils.buildErrorMsg("获取未关阀信息错误"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 远程开阀(代农户) |
| | | * @param valve |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "open_client", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | Long operator = valve.getOperator(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if (vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if (vcId == null) { |
| | |
| | | param.elePrice = 0.0; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | param.waterPrice = waterPrice; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 远程关阀(代农户) |
| | | * @param dtoBase |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "close_client", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | param.icCardNo = vcNum; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | param.icCardNo = vcNum; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时关阀式开阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "timed_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | Long operator = automaticClose.getOperator(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setMinutes(minutes); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定量关阀式开阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "quantify_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | Long operator = automaticClose.getOperator(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setWaterAmount(waterAmount); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时关阀式计划开阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "planed_open_timed_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | Integer hour = Integer.parseInt(String.format("%tH", plannedOpenTime)); |
| | | Integer minute = Integer.parseInt(String.format("%tM", plannedOpenTime)); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setMinute(minute); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | Integer hour = Integer.parseInt(String.format("%tH", plannedOpenTime)); |
| | | Integer minute = Integer.parseInt(String.format("%tM", plannedOpenTime)); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setMinute(minute); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据操作员ID获取未关阀记录 |
| | | * @param operator |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/get") |
| | | @SsoAop() |
| | | public BaseResponse<List<VoUnclosedValve>> getUnclosedValves(@RequestParam Long operator){ |
| | |
| | | param.chargeWater = chargeWater; |
| | | param.flowNo = flowNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setCommandCode(commandCode); |
| | |
| | | param.projectNo = projectNo; |
| | | param.icCardAddr = cardAddr; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setCommandCode(commandCode); |
| | |
| | | |
| | | |
| | | /** |
| | | * 得到一个作物一周内的蒸腾量 |
| | | * 得到一个作物一周内的蒸散量 |
| | | * @return 数据集合 |
| | | */ |
| | | @Operation(summary = "一个作物一周内的蒸腾量", description = "一个作物一周内的蒸腾量") |
| | | @Operation(summary = "一个作物一周内的蒸散量", description = "一个作物一周内的蒸散量") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "一个作物一周内的蒸腾量(BaseResponse.content:[VoTopXIntake{}])", |
| | | description = "一个作物一周内的蒸散量(BaseResponse.content:[VoTopXIntake{}])", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = VoEt0Simple.class))} |
| | | ) |
| | |
| | | this.irrigationSv = irrigationSv; |
| | | this.prIntakeControllerMapper = prIntakeControllerMapper; |
| | | } |
| | | /** |
| | | * 虚拟卡ID换虚拟卡对象 |
| | | * @param vcId |
| | | * @return |
| | | */ |
| | | |
| | | public VoVirtualCard getVcById(Long vcId) { |
| | | return seVirtualCardMapper.getVcById(vcId); |
| | | } |
| | | |
| | | /** |
| | | * 获取水价 |
| | | * @return |
| | | */ |
| | | |
| | | public Double getPrice() { |
| | | return prWaterPriceMapper.getPrice(); |
| | | } |
| | | |
| | | /** |
| | | * 根据操作员ID获取未关阀记录(包含在线情况) |
| | | * @param operator |
| | | * @return |
| | | */ |
| | | public List<VoUnclosedValve> getUnclosedValves(Long operator) { |
| | | Command com = new Command() ; |
| | | com.id = Command.defaultId; |
| | |
| | | //System.out.println(jsonArray.toJSONString()); |
| | | } |
| | | |
| | | /** |
| | | * 获取未关阀的RTU地址和虚拟卡编号对数组 |
| | | * 遍历数组获取最后命令日志ID集合 |
| | | */ |
| | | List<VoRtuAndVc> rtus = rmCommandHistoryMapper.getUnclosedRtus(operator); |
| | | String comIds = ""; |
| | | if(rtus != null && rtus.size() > 0) { |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | /** |
| | | * 为指定(阀控器地址、水卡编号、无关阀记录)开关阀最新记录添加关阀时间,使之不在未关阀记录中显示 |
| | | * @param rtuAddr |
| | | * @param icCardNo |
| | | * @return |
| | | */ |
| | | public Integer addClostTime(String rtuAddr, String icCardNo) { |
| | | return rmOpenCloseValveLastMapper.addCloseTime(rtuAddr, icCardNo); |
| | | } |
| | | |
| | | /** |
| | | * 根据取水口ID获取与之绑定虚拟卡ID |
| | | * @param intakeId |
| | | * @return |
| | | */ |
| | | public Long getVcIdByIntakeId(Long intakeId) { |
| | | return prIntakeVcMapper.getVcIdByIntakeId(intakeId); |
| | | } |
| | | |
| | | /** |
| | | * 根据水卡编号获取水卡对象,远程充值使用 |
| | | * @param cardId |
| | | * @return |
| | | */ |
| | | public SeClientCard geClientCardByCardId(Long cardId) { |
| | | return seClientCardMapper.selectByPrimaryKey(cardId); |
| | | } |
| | | |
| | | /** |
| | | * 添加命令日志 |
| | | * @param po 命令日志对象 |
| | | * @return 字符串类型的主键 |
| | | */ |
| | | public Long insert(RmCommandHistory po) { |
| | | rmCommandHistoryMapper.insert(po); |
| | | return po.getComId(); |
| | | } |
| | | |
| | | /** |
| | | * 修改命令日志信息 |
| | | * @param po 命令日志对象 |
| | | * @return 影响记录数量 |
| | | */ |
| | | public Integer update(RmCommandHistory po) { |
| | | return rmCommandHistoryMapper.updateByPrimaryKeySelective(po); |
| | | } |
| | | |
| | | /** |
| | | * 取水口名称换取水口ID,扫码开阀使用 |
| | | * @param intakeName |
| | | * @return |
| | | */ |
| | | public Long getIntakeIdByName(String intakeName) { |
| | | return prIntakeMapper.getIntakeIdByName(intakeName); |
| | | } |
| | | |
| | | /** |
| | | * 根据配置类型获取配置值 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | QueryResultVo<List<VoIrrigaterProfile>> getIrrPro(Integer type) { |
| | | QueryResultVo<List<VoIrrigaterProfile>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.obj = rmIrrigateProfileMapper.getIrrPro(type); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 添加取水口操作记录,轮灌过程命令下发时使用 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Long addIntakeOperate(IrIntakeOperate po) { |
| | | irIntakeOperateMapper.insert(po); |
| | | return po.getId(); |
| | |
| | | // return irIntakeOperateMapper.updateByCommandId(commandId, commandResult); |
| | | //} |
| | | |
| | | /** |
| | | * 定时关阀式计划开阀 |
| | | * @param automaticClose |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map planedOpenTimedClose(AutomaticClose automaticClose, Long planId, Byte operatetype, Date startTime, Integer duration) { |
| | | Long intakeId = automaticClose.getIntakeId(); |
| | |
| | | Integer hour = Integer.parseInt(String.format("%tH", plannedOpenTime)); |
| | | Integer minute = Integer.parseInt(String.format("%tM", plannedOpenTime)); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setMinute(minute); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 小程序远程开阀 |
| | | * @param valve |
| | | * @param planId |
| | | * @param operatetype |
| | | * @return |
| | | */ |
| | | public Map openWx(ValveOpen valve, Long planId, Byte operatetype) { |
| | | Long intakeId = valve.getIntakeId(); |
| | | String intakeName = valve.getIntakeName(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if (vcId == null) { |
| | | vcId = getVcIdByIntakeId(intakeId); |
| | | if (vcId == null) { |
| | |
| | | param.elePrice = 0.0; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | param.waterPrice = waterPrice; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 小程序远程关阀 |
| | | * @param valve |
| | | * @param planId |
| | | * @param operatetype |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map closeWx(ValveClose valve, Long planId, Byte operatetype) { |
| | | String rtuAddr = valve.getRtuAddr(); |
| | |
| | | param.icCardNo = vcNum; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | param.icCardNo = vcNum; |
| | | param.orderNo = orderNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)2); |
| | |
| | | this.env = env; |
| | | } |
| | | |
| | | /** |
| | | * 小程序远程开阀 |
| | | * @param valve |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "open_wx", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> open(@RequestBody @Valid ValveOpen valve, BindingResult bindingResult) { |
| | |
| | | //} |
| | | } |
| | | |
| | | /** |
| | | * 小程序远程关阀 |
| | | * |
| | | * @param valve |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "close_wx", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> close(@RequestBody @Valid ValveClose valve, BindingResult bindingResult) { |
| | |
| | | //} |
| | | } |
| | | |
| | | /** |
| | | * 定时关阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "timed_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> timedClose(@RequestBody @Valid AutomaticClose automaticClose, BindingResult bindingResult) { |
| | |
| | | Long operator = automaticClose.getOperator(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定量关阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "quantify_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> quantifyClose(@RequestBody @Valid AutomaticClose automaticClose, BindingResult bindingResult) { |
| | |
| | | Long operator = automaticClose.getOperator(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setWaterAmount(waterAmount); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计划开阀定时关阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "planed_open_timed_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> planedOpenTimedClose(@RequestBody @Valid AutomaticClose automaticClose, BindingResult bindingResult) { |
| | |
| | | //} |
| | | } |
| | | |
| | | /** |
| | | * 计划开阀定量关阀 |
| | | * @param automaticClose |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "planed_open_quantify_close", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> planedOpenQuantifyClose(@RequestBody @Valid AutomaticClose automaticClose, BindingResult bindingResult) { |
| | |
| | | Integer hour = Integer.parseInt(String.format("%tH", plannedOpenTime)); |
| | | Integer minute = Integer.parseInt(String.format("%tM", plannedOpenTime)); |
| | | |
| | | /** |
| | | * 如果农户选择了虚拟卡,则使用该虚拟卡 |
| | | * 如果农户未选择虚拟卡,则根据取水口ID获取与之绑定的虚拟卡 |
| | | * 如果取水口没有与之绑定的虚拟卡,则提示农户选择一张虚拟卡 |
| | | */ |
| | | if(vcId == null) { |
| | | vcId = commandSv.getVcIdByIntakeId(intakeId); |
| | | if(vcId == null) { |
| | |
| | | param.setMinute(minute); |
| | | param.setOrderNo(orderNo); |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setComType((byte)1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据操作员ID获取未关阀记录 |
| | | * |
| | | * @param operator |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/get") |
| | | public BaseResponse<List<VoUnclosedValve>> getUnclosedValves(@RequestParam Long operator) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 强制隐藏未关阀记录:为指定(阀控器地址、水卡编号、无关阀记录)开关阀最新记录添加关阀时间,使之不在未关阀记录中显示 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "deleteUnclosed", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | public BaseResponse<Boolean> deleteUnclosed(@RequestBody @Valid deleteUnclosedParam po, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | |
| | | return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 小程序远程充值 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "recharge", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> recharge(@RequestBody @Valid Recharge po, BindingResult bindingResult) { |
| | |
| | | param.chargeWater = chargeWater; |
| | | param.flowNo = flowNo; |
| | | |
| | | /** |
| | | * 构造命令、发送命令并处理请求结果及执行结果 |
| | | * 1 准备参数 |
| | | * 2 调用公共方法 |
| | | */ |
| | | Param myParam = new Param(); |
| | | myParam.setComId(comId); |
| | | myParam.setCommandCode(commandCode); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据配置类型获取配置值 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/irrigate_profile") |
| | | public BaseResponse<QueryResultVo<List<VoIrrigaterProfile>>> getIrrPro(Integer type){ |
| | | try { |
| | |
| | | private final IrrigatePlanSv irrigatePlanSv; |
| | | private final CommandSv commandSv; |
| | | |
| | | /** |
| | | * 创建灌溉计划 |
| | | * 1. 添加灌溉计划 |
| | | * 2. 添加灌溉次序 |
| | | * 3. 添加灌溉计划操作记录 |
| | | * @param planAndSchedule |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "createPlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> createPlan(@RequestBody @Valid IrrigatePlan planAndSchedule, BindingResult bindingResult){ |
| | |
| | | return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 删除灌溉计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "deletePlan") |
| | | public BaseResponse<Boolean> deletePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 发布灌溉计划 |
| | | * 1. 修改灌溉计划状态为发布状态 |
| | | * 2. 添加灌溉计划操作记录 |
| | | * 3. 生成开阀计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "publishPlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> publishPlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){ |
| | |
| | | //return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划最新状态 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getPlanLatestState") |
| | | public BaseResponse<Integer> getPlanLatestState(@RequestParam Long planId) { |
| | | if(planId == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 终止灌溉计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "terminatePlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> terminatePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){ |
| | |
| | | return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 获取未完成的计划列表,小程序计划列表页使用 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getNotCompletePlans") |
| | | public BaseResponse<List<VoPlans>> getNotCompletePlans() { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取已完成的计划列表,小程序计划列表页使用 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getCompletedPlans") |
| | | public BaseResponse<QueryResultVo<List<VoPlans>>> getCompletedPlans(QueryConditionVo qo) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划发布结果 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getPublishResults") |
| | | public BaseResponse<VoPlanDetails> getPublishResults(@RequestParam Long planId) { |
| | | if(planId == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划终止操作结果 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getTerminateResults") |
| | | public BaseResponse<VoPlanDetails> getTerminateResults(@RequestParam Long planId) { |
| | | if(planId == null) { |
| | |
| | | @Value("${wechat.irr.plan.planTerminateLimitMinutes:5}") |
| | | private Integer planTerminateLimitMinutes; // 计划终止后限制发布新计划的时间间隔(分钟) |
| | | |
| | | /** |
| | | * 添加灌溉计划 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long addIrrigatePlan(IrIrrigatePlan po) { |
| | | irrigatePlanMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 删除灌溉计划 |
| | | * |
| | | * @param planSimple |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map deletePlan(PlanSimple planSimple) { |
| | | Long planId = planSimple.getPlanId(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发布灌溉计划 |
| | | * |
| | | * @param planSimple |
| | | * @return |
| | | */ |
| | | public Map publishPlan(PlanSimple planSimple) { |
| | | Long planId = planSimple.getPlanId(); |
| | | Long operatorId = planSimple.getOperatorId(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取灌溉计划信息 |
| | | * 更新灌溉计划起止时间及计划状态 |
| | | */ |
| | | VoPlanSimple plan = irrigatePlanMapper.getPlanSimple(planId); |
| | | if (plan == null) { |
| | | Map map = new HashMap<>(); |
| | |
| | | } |
| | | planStartTime = Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | |
| | | // 更新每个灌溉次序的开始时间并计算最后一组关阀时间 |
| | | List<VoIrrigateSchedule> schedules = getSchedulesByPlanId(planId); |
| | | Date scheduleStartTime = null; |
| | | LocalDateTime lastScheduleEndTime = null; |
| | | Integer sort = 0; |
| | | |
| | | // 第一次遍历:更新每个灌溉次序的开始时间 |
| | | for (VoIrrigateSchedule schedule : schedules) { |
| | | if (scheduleStartTime == null) { |
| | | scheduleStartTime = planStartTime; |
| | | } |
| | | this.updateScheduleStartTime(schedule.getScheduleId(), scheduleStartTime); |
| | | |
| | | // 计算当前次序的结束时间 |
| | | LocalDateTime currentScheduleStartTime = scheduleStartTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | LocalDateTime currentScheduleEndTime = currentScheduleStartTime.plusMinutes(schedule.getDuration()); |
| | | |
| | | // 更新最后一组的结束时间 |
| | | lastScheduleEndTime = currentScheduleEndTime; |
| | | |
| | | // 计算下一组的开始时间 |
| | | LocalDateTime LocalscheduleStartTime = scheduleStartTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | LocalscheduleStartTime = LocalscheduleStartTime.plusMinutes(schedule.getDuration()); |
| | | LocalscheduleStartTime = LocalscheduleStartTime.minusMinutes(preOpeningTime); |
| | | scheduleStartTime = Date.from(LocalscheduleStartTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | |
| | | // 确保下一组的开始时间不早于计划开始时间 |
| | | if (scheduleStartTime.before(planStartTime)) { |
| | | scheduleStartTime = planStartTime; |
| | | } |
| | | } |
| | | |
| | | // 根据最后一组关阀时间设置计划结束时间 |
| | | if (lastScheduleEndTime != null) { |
| | | planStopTime = Date.from(lastScheduleEndTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } else { |
| | |
| | | planStopTime = Date.from(stopTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | // 根据计划ID更新计划信息(起止时间、计划状态) |
| | | if (this.updatePlanTimes(planStartTime, planStopTime, planId) == 0) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | |
| | | return map; |
| | | } |
| | | |
| | | // 添加灌溉计划操作记录 |
| | | IrPlanOperate planOperate = new IrPlanOperate(); |
| | | planOperate.setPlanId(planId); |
| | | planOperate.setOperator(operatorId); |
| | |
| | | return irIrrigateUnitMapper.getIntakeIdByUnitId(unitId); |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划发布结果 |
| | | * |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public VoPlanDetails getPublishResults(Long planId) { |
| | | VoPlanDetails planDetails = irrigatePlanMapper.getPlanDetails(planId); |
| | | if (planDetails == null) { |
| | |
| | | |
| | | planDetails.setGroups(groupResults); |
| | | return planDetails; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划终止操作结果 |
| | | * |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public VoPlanDetails getTerminateResults(Long planId) { |
| | | // 获取计划终止时间 |
| | | Date terminateTime = Optional.ofNullable(irPlanOperateMapper.getTerminateTime(planId)).orElse(null); |
| | |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Tag(name = "作物日蒸腾量", description = "作物日蒸腾量查询等操作") |
| | | @Tag(name = "作物日蒸散量", description = "作物日蒸散量查询等操作") |
| | | @RestController |
| | | @RequestMapping(path = "mdVapor") |
| | | public class VaporCtrl { |
| | |
| | | |
| | | |
| | | /** |
| | | * 客户端请求得到所有作物的昨日蒸腾量 |
| | | * @return 所有所有作物的昨日蒸腾量 |
| | | * 客户端请求得到所有作物的昨日蒸散量 |
| | | * @return 所有所有作物的昨日蒸散量 |
| | | */ |
| | | @GetMapping(path = "allCropsWithYesterday") |
| | | public BaseResponse<List<MdEt0>> allYesterday(){ |
| | |
| | | List<MdEt0> res = this.sv.selectEt0(ymd) ; |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询所有作物的昨日蒸腾量异常", e); |
| | | log.error("查询所有作物的昨日蒸散量异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件作物查询一段时间内的蒸腾量 |
| | | * 根据指定条件作物查询一段时间内的蒸散量 |
| | | * @param qo |
| | | * @return |
| | | */ |