From 1a2b07f01ba4616fd9e894dddf474b56d020158c Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 07 四月 2025 15:18:51 +0800 Subject: [PATCH] 整理版本 --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 304 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java new file mode 100644 index 0000000..3e6cc53 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java @@ -0,0 +1,304 @@ +package com.dy.pipIrrBase.rtuUpgrade.task; + +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.pojoUg.UgRtuTask; +import com.dy.pipIrrGlobal.voUg.VoRtuTask; +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.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.UnsupportedEncodingException; +import java.util.List; +import java.util.Objects; + +/** + * @Author: liurunyu + * @Date: 2024/11/7 11:33 + * @Description + */ +@Slf4j +@Tag(name = "RTU鍗囩骇浠诲姟绠$悊", description = "RTU鍗囩骇浠诲姟澧炲垹鏀规煡绛夋搷浣�") +@RestController +@RequestMapping(path = "ugRtuTask") +@SuppressWarnings("unchecked") +//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class UgRtuTaskCtrl { + + private UgRtuTaskSv sv; + + @Autowired + private void setSv(UgRtuTaskSv sv) { this.sv = sv; } + + /** + * 寰楀埌涓�涓猂TU鍗囩骇浠诲姟鏁版嵁 + * @return 涓�涓猂TU鍗囩骇浠诲姟鏁版嵁 + */ + @Operation(summary = "涓�涓猂TU鍗囩骇浠诲姟", description = "寰楀埌涓�涓猂TU鍗囩骇浠诲姟鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�涓猂TU鍗囩骇浠诲姟鏁版嵁锛圔aseResponse.content:{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = UgRtuTask.class))} + ) + }) + @GetMapping(path = "one") + @SsoAop() + public BaseResponse<UgRtuTask> one(Long id) throws UnsupportedEncodingException { + return BaseResponseUtils.buildSuccess(this.sv.selectById(id) ); + } + /** + * 瀹㈡埛绔姹傚緱鍒颁竴浜汻TU鍗囩骇浠诲姟鏁版嵁 + * @return 涓�浜汻TU鍗囩骇浠诲姟鏁版嵁 + */ + @Operation(summary = "鑾峰緱涓�浜汻TU鍗囩骇浠诲姟", description = "杩斿洖涓�浜涘垎椤礡TU鍗囩骇浠诲姟鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�浜汻TU鍗囩骇浠诲姟鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = UgRtuTask.class))} + ) + }) + @GetMapping(path = "/some") + @SsoAop() + public BaseResponse<QueryResultVo<List<UgRtuTask>>> some(QueryTaskVo vo){ + try { + QueryResultVo<List<UgRtuTask>> res = this.sv.selectSome(vo) ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + } + + /** + * 瀹㈡埛绔姹傚緱鍒版墍鏈夊崌绾т换鍔¤褰旾D鍜屾枃浠跺悕绉� 锛屼互渚涘叾浠栧簲鐢ㄤ笅鎷夐�夋嫨 + * @return 鎵�RTU鍗囩骇浠诲姟鏂囦欢鍚嶆暟鎹� + */ + @Operation(summary = "鑾峰緱涓�浜汻TU鍗囩骇浠诲姟", description = "杩斿洖涓�浜涘垎椤礡TU鍗囩骇浠诲姟鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�浜汻TU鍗囩骇浠诲姟鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = UgRtuTask.class))} + ) + }) + @GetMapping(path = "/all") + @SsoAop() + public BaseResponse<QueryResultVo<List<UgRtuTask>>> all(){ + try { + QueryResultVo<List<UgRtuTask>> res = this.sv.selectAll() ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + } + + /** + * 鏂板淇濆瓨RTU鍗囩骇浠诲姟 + * @param vo 鏂板淇濆瓨RTU鍗囩骇浠诲姟form琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "淇濆瓨RTU鍗囩骇浠诲姟", description = "鎻愪氦RTU鍗囩骇浠诲姟鏁版嵁锛坒orm琛ㄥ崟锛夛紝杩涜淇濆瓨") + @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 = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @SsoAop() + public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid VoRtuTask vo, @Parameter(hidden = true) BindingResult bindingResult){ + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + UgRtuTask po = new UgRtuTask(); + vo.toPo(po); + po.init(); + int count; + try { + count = this.sv.save(po); + } catch (Exception e) { + log.error("淇濆瓨RTU鍗囩骇浠诲姟寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + /** + * 涓轰簡淇濊瘉鍗囩骇浠诲姟鐨勬纭紝涓嶆彁渚涗慨鏀瑰姛鑳斤紝濡傛灉涓婁紶閿欎簡锛屽彧鑳藉垹闄ゅ悗閲嶆柊涓婁紶 + * @param po 淇濆瓨RTU鍗囩骇浠诲姟form琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + * */ + @Operation(summary = "缂栬緫淇敼鐗囧尯", description = "鎻愪氦鐗囧尯鏁版嵁锛坒orm琛ㄥ崟锛夛紝杩涜淇敼") + @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.MULTIPART_FORM_DATA_VALUE) + @SsoAop() + public BaseResponse<Boolean> update(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid UgRtuTask po, @Parameter(hidden = true) BindingResult bindingResult){ + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + if(po.id == null){ + return BaseResponseUtils.buildErrorMsg("鏃犳暟鎹疄浣揑D") ; + } + int count; + try { + count = this.sv.update(po); + } catch (Exception e) { + log.error("淇濆瓨瀹炰綋鏁版嵁寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + + /** + * 鎵цRTU鍗囩骇浠诲姟 + * @param id RTU鍗囩骇浠诲姟ID + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "鎵цRTU鍗囩骇浠诲姟", description = "鎻愪氦RTU鍗囩骇浠诲姟ID锛岃繘琛屾墽琛�") + @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))} + ) + }) + @GetMapping(path = "execute") + @SsoAop() + public BaseResponse<Boolean> execute(Long id){ + if(id == null){ + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; + } + int count; + try { + count = this.sv.isOver(id) ; + if(count > 0){ + return BaseResponseUtils.buildErrorMsg("浠诲姟宸茬粡缁撴潫锛屼笉鑳藉啀鎵ц") ; + } + count = this.sv.isExecute(id) ; + if(count > 0){ + return BaseResponseUtils.buildErrorMsg("浠诲姟宸茬粡鎵ц锛屼笉鑳藉啀鎵ц") ; + } + count = this.sv.execute(id); + } catch (Exception e) { + log.error("鎵цRTU鍗囩骇浠诲姟寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + /** + * 缁撴潫RTU鍗囩骇浠诲姟 + * @param id RTU鍗囩骇浠诲姟ID + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "缁撴潫RTU鍗囩骇浠诲姟", description = "鎻愪氦RTU鍗囩骇浠诲姟ID锛岃繘琛岀粨鏉�") + @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))} + ) + }) + @GetMapping(path = "over") + @SsoAop() + public BaseResponse<Boolean> over(Long id){ + if(id == null){ + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; + } + int count; + try {count = this.sv.isOver(id) ; + if(count > 0){ + return BaseResponseUtils.buildErrorMsg("浠诲姟宸茬粡缁撴潫锛屼笉鐢ㄥ啀缁撴潫") ; + } + count = this.sv.over(id); + } catch (Exception e) { + log.error("缁撴潫RTU鍗囩骇浠诲姟寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + /** + * 鍒犻櫎RTU鍗囩骇浠诲姟 + * @param id RTU鍗囩骇浠诲姟ID + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "鍒犻櫎RTU鍗囩骇浠诲姟", description = "鎻愪氦RTU鍗囩骇浠诲姟ID锛岃繘琛岄�昏緫鍒犻櫎") + @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))} + ) + }) + @GetMapping(path = "delete") + @SsoAop() + public BaseResponse<Boolean> delete(Long id){ + if(id == null){ + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; + } + int count; + try { + count = this.sv.delete(id); + } catch (Exception e) { + log.error("鍒犻櫎RTU鍗囩骇浠诲姟寮傚父", e); + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + +} -- Gitblit v1.8.0