From d20d38e22b06559d758c568769017e2acf632583 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期三, 23 四月 2025 14:06:48 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java | 148 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 148 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java new file mode 100644 index 0000000..3cbbdeb --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java @@ -0,0 +1,148 @@ +package com.dy.pipIrrProject.flowMonitoring; + +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 io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +/** + * @author ZhuBaoMin + * @date 2024-01-05 9:21 + * @LastEditTime 2024-01-05 9:21 + * @Description + */ + +@Slf4j +@Tag(name = "娴侀噺鐩戞祴绔欑鐞�", description = "娴侀噺鐩戞祴绔欐搷浣�") +@RestController +@RequestMapping(path = "flowmeter") +@RequiredArgsConstructor +public class FlowmeterCtrl { + private final FlowmeterSv flowmeterSv; + + @Operation(summary = "娣诲姞娴侀噺璁¤褰�", description = "娣诲姞娴侀噺璁¤褰�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + 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); + Integer rec = Optional.ofNullable(flowmeterSv.addFlowmeter(prFlowmeter)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(ProjectResultCode.ADD_FLOWMETER_FAIL.getMessage()); + } + return BaseResponseUtils.buildSuccess(true); + } + + /** + * 鍒犻櫎娴侀噺璁� + * + * @param map + * @return + */ + @Operation(summary = "鍒犻櫎娴侀噺璁¤褰�", description = "鍒犻櫎娴侀噺璁¤褰�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @PostMapping(path = "delete") + @SsoAop() + 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) { + return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_FLOWMETER_FAIL.getMessage()); + } + return BaseResponseUtils.buildSuccess(true); + } + + @Operation(summary = "鑾峰緱涓�椤垫祦閲忚璁板綍", description = "杩斿洖涓�椤垫祦閲忚鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�椤垫祦閲忚鏁版嵁锛圔aseResponse.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()); + } + } +} -- Gitblit v1.8.0