| | |
| | | package com.dy.pipIrrWechat.irrigatePlan; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.pipIrrGlobal.daoIr.*; |
| | | import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrPlanSchedule; |
| | | import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule; |
| | | import com.dy.pipIrrGlobal.voIr.VoPlanSimple; |
| | | import com.dy.pipIrrGlobal.voIr.VoPlans; |
| | | import com.dy.pipIrrGlobal.voIr.*; |
| | | import com.dy.pipIrrGlobal.voRm.VoIntakeVc; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Autowired |
| | | private IrIntakeOperateMapper irIntakeOperateMapper; |
| | | |
| | | @Autowired |
| | | private RmCommandHistoryMapper rmdCommandHistoryMapper; |
| | | |
| | | /** |
| | | * 添加灌溉计划 |
| | | * @param po |
| | |
| | | */ |
| | | public List<Long> getToTerminateIntakeIds(Long planId) { |
| | | return irIntakeOperateMapper.getToTerminateIntakeIds(planId); |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取待终止的命令ID列表 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public List<Long> getTerminateCommandIds(Long planId) { |
| | | return irIntakeOperateMapper.getTerminateCommandIds(planId); |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取待终止的取水口列表(开阀成功的) |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public List<VoToTerminateIntakes> getToTerminateIntakes(Long planId) { |
| | | return irIntakeOperateMapper.getToTerminateIntakes(planId); |
| | | } |
| | | |
| | | /** |
| | | * 根据命令日志ID获取取水口及虚拟卡信息,终止灌溉计划时使用,用来执行远程关阀 |
| | | * @param commandId |
| | | * @return |
| | | */ |
| | | public VoIntakeVc getValveOpen(Long commandId) { |
| | | return rmdCommandHistoryMapper.getValveOpen(commandId); |
| | | } |
| | | |
| | | /** |
| | |
| | | public Long getIntakeIdByUnitId(Long unitId) { |
| | | return irIrrigateUnitMapper.getIntakeIdByUnitId(unitId); |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划发布结果 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public VoPlanDetails getPublishResults(Long planId) { |
| | | List<VoGroupResult> groupResults = irIrrigateGroupMapper.getGroupResult(planId); |
| | | if(groupResults == null || groupResults.size() == 0){ |
| | | return null; |
| | | } |
| | | |
| | | VoPlanDetails planDetails = irrigatePlanMapper.getPlanDetails(planId); |
| | | |
| | | for (VoGroupResult groupResult : groupResults) { |
| | | List<VoIntakeResult> intakeResults = irIntakeOperateMapper.getIntakeResult(planId, groupResult.getGroupId()); |
| | | if(intakeResults != null) { |
| | | groupResult.setPublishResult(intakeResults); |
| | | } |
| | | } |
| | | |
| | | planDetails.setGroups(groupResults); |
| | | return planDetails; |
| | | |
| | | |
| | | //JSONArray array_groupResult = (JSONArray) JSON.toJSON(groupResults); |
| | | //for(int i = 0; i < array_groupResult.size(); i++){ |
| | | // JSONObject job_groupResult = array_groupResult.getJSONObject(i); |
| | | // Long groupId = job_groupResult.getLong("groupId"); |
| | | // |
| | | // List<VoIntakeResult> intakeResults = irIntakeOperateMapper.getIntakeResult(planId, groupId); |
| | | // if(intakeResults != null) { |
| | | // JSONArray array_intakeResult = (JSONArray) JSON.toJSON(intakeResults); |
| | | // job_groupResult.put("publishResult", array_intakeResult); |
| | | // } |
| | | //} |
| | | // |
| | | //List<VoGroupResult> publishResults = array_groupResult.toJavaList(VoGroupResult.class); |
| | | //return publishResults; |
| | | |
| | | } |
| | | } |