| | |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrGlobal.pojoRm.UgRtuTask; |
| | | import com.dy.pipIrrGlobal.voRm.VoRtuTask; |
| | | 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 org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | } |
| | | UgRtuTask po = new UgRtuTask(); |
| | | vo.toPo(po); |
| | | po.dt = new Date(); |
| | | po.isOver = 0 ; |
| | | po.deleted = 0 ; |
| | | po.init(); |
| | | int count; |
| | | try { |
| | | count = this.sv.save(po); |
| | |
| | | |
| | | |
| | | /** |
| | | * 执行RTU升级任务 |
| | | * @param id RTU升级任务ID |
| | | * @return 是否成功 |
| | | */ |
| | | @Operation(summary = "执行RTU升级任务", description = "提交RTU升级任务ID,进行执行") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "操作结果:true:成功,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.buildFail("id不能为空") ; |
| | | } |
| | | int count; |
| | | try { |
| | | count = this.sv.isOver(id) ; |
| | | if(count > 0){ |
| | | return BaseResponseUtils.buildError("任务已经结束,不能再执行") ; |
| | | } |
| | | count = this.sv.isExecute(id) ; |
| | | if(count > 0){ |
| | | return BaseResponseUtils.buildError("任务已经执行,不能再执行") ; |
| | | } |
| | | count = this.sv.execute(id); |
| | | } catch (Exception e) { |
| | | log.error("结束RTU升级任务异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | if(count <= 0){ |
| | | return BaseResponseUtils.buildFail("数据库操作失败") ; |
| | | }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 = "操作结果:true:成功,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.buildFail("id不能为空") ; |
| | | } |
| | | int count; |
| | | try {count = this.sv.isOver(id) ; |
| | | if(count > 0){ |
| | | return BaseResponseUtils.buildError("任务已经结束,不用再结束") ; |
| | | } |
| | | count = this.sv.over(id); |
| | | } catch (Exception e) { |
| | | log.error("结束RTU升级任务异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | if(count <= 0){ |
| | | return BaseResponseUtils.buildFail("数据库操作失败") ; |
| | | }else{ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除RTU升级任务 |
| | | * @param id RTU升级任务ID |
| | | * @return 是否成功 |
| | |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | if(count <= 0){ |
| | | return BaseResponseUtils.buildFail("数据库存储失败") ; |
| | | return BaseResponseUtils.buildFail("数据库操作失败") ; |
| | | }else{ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |