From 86bba1b6323d5ae0340371ebfb0bc91271068c7e Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 12 十一月 2024 15:37:07 +0800
Subject: [PATCH] 获取巡检员问题上报记录接口
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitCtrl.java | 262 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 259 insertions(+), 3 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitCtrl.java
index f2b0bf9..80700e6 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitCtrl.java
@@ -1,12 +1,34 @@
package com.dy.pipIrrIrrigate.irrigateUnit;
+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.pojoIr.IrIrrigateUnit;
+import com.dy.pipIrrGlobal.pojoIr.IrUnitClient;
+import com.dy.pipIrrGlobal.voIr.VoUnit;
+import com.dy.pipIrrGlobal.voIr.VoUnitOne;
+import com.dy.pipIrrGlobal.voSe.VoActiveCard;
+import com.dy.pipIrrIrrigate.irrigateUnit.dto.UnitClient;
+import com.dy.pipIrrIrrigate.result.IrrigateResultCode;
+import io.swagger.v3.oas.annotations.Operation;
+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.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.MediaType;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
/**
* @author :WuZeYu
@@ -17,9 +39,243 @@
@Slf4j
@Tag(name = "鐏屾簤鍗曞厓", description = "鐏屾簤鍗曞厓")
@RestController
-@RequestMapping(path = "irrigate/unit")
+@RequestMapping(path = "unit")
@RequiredArgsConstructor
public class IrrigateUnitCtrl {
@Autowired
private IrrigateUnitSv irrigateUnitSv;
+
+ /**
+ * 鍒涘缓鐏屾簤鍗曞厓
+ *
+ * @param po 鐏屾簤鍗曞厓瀹炰綋瀵硅薄
+ * @param bindingResult
+ * @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 = "add", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> add(@RequestBody @Valid IrIrrigateUnit po, BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ try {
+ Integer rec = Optional.ofNullable(irrigateUnitSv.addIrrigateUnit(po)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_UNIT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("鍒涘缓鐏屾簤鍗曞厓寮傚父", e);
+ return BaseResponseUtils.buildException(e.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", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> delete(@RequestBody Map map) {
+ if (map == null || map.size() <= 0) {
+ BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_UNIT_ID.getMessage());
+ }
+ Long unitId = Long.parseLong(map.get("id").toString());
+ try {
+ Integer rows = irrigateUnitSv.deleteUnit(unitId);
+ if (rows == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_UNIT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("鍒犻櫎鐏屾簤鍗曞厓寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ /**
+ * 鎵归噺鍒犻櫎
+ * @param unitIds
+ * @return
+ */
+ @PostMapping(path = "delete_batch", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> delete_batch(@RequestBody Map<String, List> unitIds) {
+ if (unitIds == null || unitIds.size() <= 0) {
+ BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
+ }
+ List ids = unitIds.get("unitIds");
+ for (int i = 0; i < ids.size(); i++) {
+ long unitId = Long.parseLong(ids.get(i).toString());
+ try {
+ Integer rows = irrigateUnitSv.deleteUnit(unitId);
+ if (rows == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_UNIT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("鍒犻櫎鐏屾簤鍗曞厓寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ /**
+ * 淇敼鐏屾簤鍗曞厓
+ * @param po
+ * @param bindingResult
+ * @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 = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateUnit po, BindingResult bindingResult){
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ try {
+ Integer rec = Optional.ofNullable(irrigateUnitSv.updateUnit(po)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_UNIT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("淇敼鐏屾簤鍗曞厓寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ /**
+ * 鑾峰彇涓�涓亴婧夊崟鍏�
+ *
+ * @return 鑾峰彇涓�涓亴婧夊崟鍏�
+ */
+ @Operation(summary = "鑾峰彇涓�涓亴婧夊崟鍏�", description = "鑾峰彇涓�涓亴婧夊崟鍏�")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鑾峰彇涓�涓亴婧夊崟鍏冿紙BaseResponse.content:{}锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = IrIrrigateUnit.class))}
+ )
+ })
+ @GetMapping(path = "one")
+ @SsoAop()
+ public BaseResponse<VoUnitOne> one(@RequestParam Long id) {
+ VoUnitOne irIrrigateUnit = this.irrigateUnitSv.selectById(id);
+
+ return BaseResponseUtils.buildSuccess(irIrrigateUnit);
+
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param vo
+ * @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 = VoActiveCard.class))}
+ )
+ })
+ @GetMapping(path = "some")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoUnit>>> getUnits(QueryVo vo) {
+ try {
+ QueryResultVo<List<VoUnit>> res = irrigateUnitSv.getUnits(vo);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鑾峰彇鐏屾簤鍗曞厓璁板綍寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鐏屾簤鍗曞厓鍒嗛厤锛堝啘鎴风鍦帮級
+ * @param po
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path = "add_unit_client", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> addUnitClient(@RequestBody @Valid UnitClient po, BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ IrUnitClient irUnitClient = new IrUnitClient();
+ irUnitClient.setUnitId(po.getUnitId());
+ irUnitClient.setClientId(po.getClientId());
+ irUnitClient.setOperator(po.getOperator());
+ irUnitClient.setOperateTime(new Date());
+
+ try {
+ Long rec = Optional.ofNullable(irrigateUnitSv.addUnitClient(irUnitClient)).orElse(0L);
+ if (rec == 0) {
+ return BaseResponseUtils.buildErrorMsg(IrrigateResultCode.UNIT_ASSOCIATE_CLIENT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ @PostMapping(path = "delete_unit_client", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> deleteUnitClient(@RequestBody @Valid UnitClient po, BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ IrUnitClient irUnitClient = new IrUnitClient();
+ irUnitClient.setUnitId(po.getUnitId());
+ irUnitClient.setClientId(po.getClientId());
+ irUnitClient.setOperator(po.getOperator());
+ irUnitClient.setOperateTime(new Date());
+
+ try {
+ Long rec = Optional.ofNullable(irrigateUnitSv.addUnitClient(irUnitClient)).orElse(0L);
+ if (rec == 0) {
+ return BaseResponseUtils.buildErrorMsg(IrrigateResultCode.UNIT_ASSOCIATE_CLIENT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
}
--
Gitblit v1.8.0