Administrator
2024-01-15 422e68561e15701b3b971db0755623735e7dec42
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowCtrl.java
@@ -4,6 +4,7 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring;
import com.dy.pipIrrGlobal.pojoPr.PrMonitoringFlowmeter;
import com.dy.pipIrrProject.result.ProjectResultCode;
import io.swagger.v3.oas.annotations.Operation;
@@ -18,14 +19,9 @@
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
/**
 * @author ZhuBaoMin
@@ -49,6 +45,7 @@
     * 流量监测站绑定流量计
     *      若流量监测站或流量计不存在需提示用户
     *      若流量监测站已经与流量计绑定需提示用户
     *
     * @param po 绑定关系对象
     * @param bindingResult
     * @return
@@ -71,8 +68,8 @@
        }
        // 根据编号分别获取流量监测站、流量计未删除记录数
        Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoring(po.getMonitoringId())).orElse(0);
        Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeter(po.getFlowmeterId())).orElse(0);
        Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoringByFlowMonitoringId(po.getMonitoringId())).orElse(0);
        Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeterByCode(po.getFlowmeterId())).orElse(0);
        if(recFlowMonitoring == 0 || recFlowmeter == 0) {
            return BaseResponseUtils.buildFail(ProjectResultCode.STATION_OR_FLOWMETER_NO_EXIST.getMessage());
        }
@@ -113,8 +110,8 @@
        }
        // 根据编号分别获取流量监测站、流量计未删除记录数
        Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoring(po.getMonitoringId())).orElse(0);
        Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeter(po.getFlowmeterId())).orElse(0);
        Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoringByFlowMonitoringId(po.getMonitoringId())).orElse(0);
        Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeterByCode(po.getFlowmeterId())).orElse(0);
        if(recFlowMonitoring == 0 || recFlowmeter == 0) {
            return BaseResponseUtils.buildFail(ProjectResultCode.STATION_OR_FLOWMETER_NO_EXIST.getMessage());
        }
@@ -136,4 +133,34 @@
        }
        return BaseResponseUtils.buildSuccess(true) ;
    }
    /**
     * 根据监测站编号获取绑定记录 按操作时间降序
     *
     * @param monitoringId 监测站编号
     * @return 绑定记录
     */
    @Operation(summary = "获取绑定记录", description = "返回获取绑定记录")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回绑定记录(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = PrMonitoringFlowmeter.class))}
            )
    })
    @GetMapping(path = "bingRecords/{monitoringId}")
    @SsoAop()
    public BaseResponse<List<Map<String, Object>>> getBingRecordsByMonitoringId(@PathVariable("monitoringId") Long monitoringId) {
        try {
            List<Map<String, Object>> list = Optional.ofNullable(moniFlowSv.getBingRecordsByMonitoringId(monitoringId)).orElse(new ArrayList<>());
            if (list.size() <= 0) {
                return BaseResponseUtils.buildFail(ProjectResultCode.NO_MONITORING_FLOWMETERS.getMessage());
            }
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("查询绑定记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
}