| | |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoIr.*; |
| | | import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan; |
| | |
| | | import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrPlanSchedule; |
| | | import com.dy.pipIrrGlobal.rtuMw.CodeLocal; |
| | | import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule; |
| | | import com.dy.pipIrrGlobal.voIr.VoPlanSimple; |
| | | import com.dy.pipIrrGlobal.voIr.VoToTerminateIntakes; |
| | | import com.dy.pipIrrGlobal.voIr.*; |
| | | import com.dy.pipIrrGlobal.voRm.VoIntakeVc; |
| | | import com.dy.pipIrrIrrigate.command.CommandSv; |
| | | import com.dy.pipIrrIrrigate.command.dto.AutomaticClose; |
| | |
| | | import com.dy.pipIrrIrrigate.irrigatePlan.dto.PlanSimple; |
| | | import com.dy.pipIrrIrrigate.irrigatePlan.enums.OperateTypeENUM; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.core.env.Environment; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | |
| | | |
| | | @Autowired |
| | | private RmCommandHistoryMapper rmdCommandHistoryMapper; |
| | | |
| | | @Autowired |
| | | private IrIrrigateGroupMapper irIrrigateGroupMapper; |
| | | |
| | | protected String comSendUrl; |
| | | private String key_mw = "comSendUrl"; |
| | |
| | | map.put("msg", "终止灌溉计划成功"); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取未完成的计划列表,灌溉模块计划列表页使用 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<VoPlans> getNotCompletePlans() { |
| | | return irrigatePlanMapper.getNotCompletePlans(); |
| | | } |
| | | |
| | | /** |
| | | * 获取已完成的计划列表,灌溉模块计划列表页使用 |
| | | * |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoPlans>> getCompletedPlans(QueryConditionVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = (long) irrigatePlanMapper.getCompletedPlansCount(params); |
| | | QueryResultVo<List<VoPlans>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = queryVo.pageSize; |
| | | rsVo.pageCurr = queryVo.pageCurr; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = irrigatePlanMapper.getCompletedPlans(params); |
| | | |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划发布结果 |
| | | * |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public VoPlanDetails getPublishResults(Long planId) { |
| | | VoPlanDetails planDetails = irrigatePlanMapper.getPlanDetails(planId); |
| | | if (planDetails == null) { |
| | | return null; |
| | | } |
| | | Integer failureCount = Optional.ofNullable(irIntakeOperateMapper.getFailureCount(planId)).orElse(0); |
| | | planDetails.setFailureCount(failureCount); |
| | | |
| | | Date terminateTime = Optional.ofNullable(irPlanOperateMapper.getTerminateTime(planId)).orElse(null); |
| | | |
| | | List<VoGroupResult> groupResults = irIrrigateGroupMapper.getGroupResult(planId); |
| | | if (groupResults == null || groupResults.size() == 0) { |
| | | return null; |
| | | } |
| | | |
| | | for (VoGroupResult groupResult : groupResults) { |
| | | List<VoIntakeResult> intakeResults = irIntakeOperateMapper.getIntakeResult(planId, groupResult.getGroupId()); |
| | | if (intakeResults != null) { |
| | | groupResult.setPublishResult(intakeResults); |
| | | } |
| | | } |
| | | |
| | | planDetails.setGroups(groupResults); |
| | | return planDetails; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划终止操作结果 |
| | | * |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public VoPlanDetails getTerminateResults(Long planId) { |
| | | // 获取计划终止时间 |
| | | Date terminateTime = Optional.ofNullable(irPlanOperateMapper.getTerminateTime(planId)).orElse(null); |
| | | |
| | | VoPlanDetails planDetails = irrigatePlanMapper.getPlanDetails_terminate(planId, terminateTime); |
| | | if (planDetails == null) { |
| | | return null; |
| | | } |
| | | Integer failureCount = Optional.ofNullable(irIntakeOperateMapper.getFailureCount(planId)).orElse(0); |
| | | planDetails.setFailureCount(failureCount); |
| | | |
| | | List<VoGroupResult> groupResults = irIrrigateGroupMapper.getGroupResult_terminate(planId, terminateTime); |
| | | if (groupResults == null || groupResults.size() == 0) { |
| | | return null; |
| | | } |
| | | |
| | | for (VoGroupResult groupResult : groupResults) { |
| | | List<VoIntakeResult> intakeResults = irIntakeOperateMapper.getIntakeResult(planId, groupResult.getGroupId()); |
| | | if (intakeResults != null) { |
| | | groupResult.setPublishResult(intakeResults); |
| | | } |
| | | } |
| | | |
| | | planDetails.setGroups(groupResults); |
| | | return planDetails; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划最新状态 |
| | | * |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | public Integer getPlanLatestState(Long planId) { |
| | | return irrigatePlanMapper.getPlanLatestState(planId); |
| | | } |
| | | } |