From 346b480ab7848c742065e9bf989abaf43b515613 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 21 四月 2025 15:05:26 +0800 Subject: [PATCH] 获取轮灌组详情 --- pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 206 insertions(+), 15 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java index ddcbe74..30ab742 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java @@ -3,8 +3,15 @@ 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.IrProject; +import com.dy.pipIrrGlobal.voIr.VoProject; +import com.dy.pipIrrGlobal.voIr.VoProjectDetail; +import com.dy.pipIrrGlobal.voIr.VoProjectOne; +import com.dy.pipIrrGlobal.voIr.VoProjectSimple; +import com.dy.pipIrrGlobal.voSe.VoActiveCard; +import com.dy.pipIrrIrrigate.project.dto.IrrigateProject; import com.dy.pipIrrIrrigate.result.IrrigateResultCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -15,17 +22,15 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.annotations.Param; 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.lang.reflect.Array; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; /** * @author :WuZeYu @@ -42,8 +47,7 @@ private final ProjectSv projectSv; /** - * 娣诲姞椤圭洰 - * + * 娣诲姞椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param po 椤圭洰瀹炰綋瀵硅薄 * @param bindingResult * @return 娣诲姞鏄惁鎴愬姛 @@ -77,7 +81,7 @@ } /** - * 閫昏緫鍒犻櫎椤圭洰 + * 閫昏緫鍒犻櫎椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param map * @return */ @@ -118,12 +122,13 @@ @PostMapping(path = "delete_batch", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> delete_batch(@RequestBody List<Long> projectIds) { + public BaseResponse<Boolean> delete_batch(@RequestBody Map<String,List> projectIds) { if (projectIds == null || projectIds.size() <= 0) { BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage()); } - for (int i = 0; i < projectIds.size(); i++) { - Long projectId = projectIds.get(i); + List ids = projectIds.get("projectIds"); + for (int i = 0; i < ids.size(); i++) { + long projectId = Long.parseLong(ids.get(i).toString()); try { Integer rows = projectSv.deleteProject(projectId); if (rows == 0) { @@ -138,7 +143,7 @@ } /** - * 淇敼椤圭洰淇℃伅 + * 淇敼椤圭洰淇℃伅锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param po * @param bindingResult * @return @@ -172,7 +177,7 @@ } /** - * 淇敼椤圭洰鐘舵�� + * 淇敼椤圭洰鐘舵�侊紝鏃犵敤鎺ュ彛锛屽師鍒欎笂搴熷純 * @param po * @param * @return @@ -201,4 +206,190 @@ } 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 = IrProject.class))} + ) + }) + @GetMapping(path = "one") + @SsoAop() + public BaseResponse<VoProjectOne> one(@RequestParam Long id) { + VoProjectOne irProject = this.projectSv.selectById(id); + + return BaseResponseUtils.buildSuccess(irProject); + + } + + /** + * 鍒嗛〉鏌ヨ锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 + * @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<VoProject>>> getProjects(QueryVo vo) { + try { + QueryResultVo<List<VoProject>> res = projectSv.getProjects(vo); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇椤圭洰璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 娣诲姞椤圭洰锛屾柊鐗堟湰锛屼娇鐢ㄨ繖涓� + * @param po 椤圭洰瀹炰綋瀵硅薄 + * @param bindingResult + * @return 娣诲姞鏄惁鎴愬姛 + */ + @PostMapping(path = "addIrrigateProject", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> addIrrigateProject(@RequestBody @Valid IrrigateProject po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Map map_result = projectSv.addIrrigateProject(po); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess() ; + + //String projectName = po.getProjectName(); + //String irrigateGroups = po.getIrrigateGroups(); + //Long operatorId = po.getOperatorId(); + // + //IrProject irProject = new IrProject(); + //irProject.setProjectName(projectName); + //irProject.setProjectState((byte)1); + //irProject.setOperator(operatorId); + //irProject.setOperateTime(new Date()); + //irProject.setDeleted((byte)0); + //Long projectId = projectSv.addIrrigateProject(irProject); + //if(projectId == null) { + // return BaseResponseUtils.buildErrorMsg("鍒涘缓鐏屾簤椤圭洰澶辫触"); + //} + // + //String[] irrigateGroupArr = irrigateGroups.split(","); + //Integer sort = 1; + //for(String irrigateGroupId : irrigateGroupArr) { + // String trimmed = irrigateGroupId.trim(); + // if(trimmed.isEmpty()) { + // continue; + // } + // try { + // Long irrigateGroupIdLong = Long.parseLong(trimmed); + // IrProjectGroup irProjectGroup = new IrProjectGroup(); + // irProjectGroup.setProjectId(projectId); + // irProjectGroup.setGroupId(irrigateGroupIdLong); + // irProjectGroup.setSort(sort++); + // projectSv.projectBindGroup(irProjectGroup); + // + // } catch (NumberFormatException e) { + // return BaseResponseUtils.buildErrorMsg("鐏屾簤缁処D鏍煎紡閿欒"); + // } + //} + + } + + /** + * 鍒犻櫎椤圭洰锛屾柊鐗堟湰锛屼娇鐢ㄨ繖涓� + * @param projectId + * @return + */ + @PostMapping(path = "deleteIrrigateProject") + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> deleteIrrigateProject(@RequestParam(required = false) Long projectId) { + if(projectId == null) { + return BaseResponseUtils.buildErrorMsg("椤圭洰ID涓嶈兘涓虹┖"); + } + + Map map_result = projectSv.deleteIrrigateProject(projectId); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess() ; + } + + /** + * 淇敼椤圭洰锛屾柊鐗堟湰锛屼娇鐢ㄨ繖涓� + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "updateIrrigateProject", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> updateIrrigateProject(@RequestBody @Valid IrrigateProject po, BindingResult bindingResult){ + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + if(po.getProjectId() == null) { + return BaseResponseUtils.buildErrorMsg("椤圭洰ID涓嶈兘涓虹┖"); + } + + Map map_result = projectSv.updateIrrigateProject(po); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess() ; + } + + /** + * 鍒嗛〉鏌ヨ椤圭洰锛屾柊鐗堟湰锛岀洰鍓嶄娇鐢� + * @param qo + * @return + */ + @GetMapping(path = "/getSimpleProjects") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoProjectSimple>>> getSimpleProjects(QueryVo qo) { + try { + QueryResultVo<List<VoProjectSimple>> res = projectSv.getSimpleProjects(qo); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇椤圭洰璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鏍规嵁椤圭洰Id鑾峰彇椤圭洰璇︽儏锛岀紪杈戦」鐩俊鎭娇鐢� + * @param projectId + * @return + */ + @GetMapping(path = "getProject") + @SsoAop() + public BaseResponse<VoProjectDetail> getProject(@RequestParam Long projectId) { + if(projectId == null) { + return BaseResponseUtils.buildErrorMsg("椤圭洰ID涓嶈兘涓虹┖"); + } + + Map map_result = projectSv.getProjectDetail(projectId); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")) ; + } } -- Gitblit v1.8.0