| | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrFlowmeter; |
| | | import com.dy.pipIrrGlobal.voPr.VoFlowMeter; |
| | | import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; |
| | | import com.dy.pipIrrProject.result.ProjectResultCode; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | 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.Map; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | |
| | | @Slf4j |
| | | @Tag(name = "流量监测站管理", description = "流量监测站操作") |
| | | @RestController |
| | | @RequestMapping(path="flowmeter") |
| | | @RequestMapping(path = "flowmeter") |
| | | @RequiredArgsConstructor |
| | | public class FlowmeterCtrl { |
| | | private final FlowmeterSv flowmeterSv; |
| | |
| | | }) |
| | | @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> add(@RequestBody @Valid DtoFlowmeter po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | public BaseResponse<Boolean> add(@RequestBody @Valid DtoFlowmeter po, BindingResult bindingResult) { |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | PrFlowmeter prFlowmeter = DtoToFlowmeterPojo.INSTANCT.po2vo(po); |
| | | Date operateTime = new Date(); |
| | | prFlowmeter.setOperatedt(operateTime); |
| | | prFlowmeter.setDeleted((byte)0); |
| | | prFlowmeter.setReporttime(operateTime); |
| | | prFlowmeter.setOperateDt(operateTime); |
| | | prFlowmeter.setDeleted((byte) 0); |
| | | prFlowmeter.setReportTime(operateTime); |
| | | Integer rec = Optional.ofNullable(flowmeterSv.addFlowmeter(prFlowmeter)).orElse(0); |
| | | if(rec == 0) { |
| | | if (rec == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.ADD_FLOWMETER_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | | /** |
| | | * 删除流量计 |
| | | * |
| | | * @param map |
| | | * @return |
| | | */ |
| | |
| | | }) |
| | | @PostMapping(path = "delete") |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> delete(@RequestBody Map map){ |
| | | if(map == null || map.size() <=0) { |
| | | public BaseResponse<Boolean> delete(@RequestBody Map map) { |
| | | if (map == null || map.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_FLOW_MONITORING_ID.getMessage()); |
| | | } |
| | | |
| | | Long flowmeterId = Long.parseLong(map.get("flowmeterId").toString()); |
| | | Integer recordCount = Optional.ofNullable(flowmeterSv.deleteFlowmeter(flowmeterId)).orElse(0); |
| | | if(recordCount == 0) { |
| | | if (recordCount == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_FLOWMETER_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | | @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 = PrFlowmeter.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "getFlowMeters") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoFlowMeter>>> getFlowMeters(QueryVoFlowMeter vo) { |
| | | try { |
| | | QueryResultVo<List<VoFlowMeter>> res = flowmeterSv.getFlowMeters(vo); |
| | | if (res.itemTotal != null && res.itemTotal > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_FLOWMETERS.getMessage()); |
| | | } catch (Exception e) { |
| | | log.error("获取流量计记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | @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 = PrFlowmeter.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "all") |
| | | @SsoAop() |
| | | public BaseResponse<List<PrFlowmeter>> getFlowMeterAll() { |
| | | try { |
| | | List<PrFlowmeter> res = flowmeterSv.getFlowMeterAll(); |
| | | if (res != null && res.size() > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_DATA.getMessage()); |
| | | } catch (Exception e) { |
| | | log.error("获取流量计数据异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | } |