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 | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 157 insertions(+), 23 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 ee36545..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 @@ -6,10 +6,12 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoIr.IrProject; -import com.dy.pipIrrGlobal.pojoPr.PrIntake; import com.dy.pipIrrGlobal.voIr.VoProject; -import com.dy.pipIrrGlobal.voPr.VoIntake; +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; @@ -20,14 +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.*; -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 @@ -44,8 +47,7 @@ private final ProjectSv projectSv; /** - * 娣诲姞椤圭洰 - * + * 娣诲姞椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param po 椤圭洰瀹炰綋瀵硅薄 * @param bindingResult * @return 娣诲姞鏄惁鎴愬姛 @@ -79,7 +81,7 @@ } /** - * 閫昏緫鍒犻櫎椤圭洰 + * 閫昏緫鍒犻櫎椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param map * @return */ @@ -141,7 +143,7 @@ } /** - * 淇敼椤圭洰淇℃伅 + * 淇敼椤圭洰淇℃伅锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param po * @param bindingResult * @return @@ -175,7 +177,7 @@ } /** - * 淇敼椤圭洰鐘舵�� + * 淇敼椤圭洰鐘舵�侊紝鏃犵敤鎺ュ彛锛屽師鍒欎笂搴熷純 * @param po * @param * @return @@ -206,8 +208,7 @@ } /** - * 鑾峰彇涓�涓」鐩暟鎹� - * + * 鑾峰彇涓�涓」鐩暟鎹紝鏃х増鏈紝鍘熷垯涓婂簾寮� * @return 鑾峰彇涓�涓」鐩暟鎹� */ @Operation(summary = "鑾峰彇涓�涓」鐩暟鎹�", description = "鑾峰彇涓�涓」鐩暟鎹�") @@ -221,17 +222,15 @@ }) @GetMapping(path = "one") @SsoAop() - public BaseResponse<IrProject> one(@RequestParam Long id) { - IrProject irProject = this.projectSv.selectById(id); - if (irProject == null) { - return BaseResponseUtils.buildFail(IrrigateResultCode.NO_PROJECT.getMessage()); - } else { + public BaseResponse<VoProjectOne> one(@RequestParam Long id) { + VoProjectOne irProject = this.projectSv.selectById(id); + return BaseResponseUtils.buildSuccess(irProject); - } + } /** - * 鍒嗛〉鏌ヨ + * 鍒嗛〉鏌ヨ锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純 * @param vo * @return */ @@ -246,16 +245,151 @@ }) @GetMapping(path = "some") @SsoAop() - public BaseResponse<QueryResultVo<List<VoProject>>> getIntakes(QueryVo vo) { + public BaseResponse<QueryResultVo<List<VoProject>>> getProjects(QueryVo vo) { try { QueryResultVo<List<VoProject>> res = projectSv.getProjects(vo); - if (res == null) { - return BaseResponseUtils.buildFail(IrrigateResultCode.NO_PROJECT.getMessage()); - } 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