liurunyu
2024-11-12 046a1118a456bfc9a7eca1bf06b7a6e95c94c120
rtu远程升级任务中,实现删除一个和全部控制器功能
4个文件已修改
100 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerSv.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java
@@ -24,6 +24,13 @@
     * @return deleteCount
     */
    int deleteByPrimaryKey(Long id);
    /**
     * delete by task key
     *
     * @param taskId task id
     * @return deleteCount
     */
    int deleteByTaskId(@Param("taskId")Long taskId);
    /**
     * insert record to table
pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml
@@ -122,6 +122,11 @@
    delete from ug_rtu_controller
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByTaskId" parameterType="java.lang.Long">
    delete from ug_rtu_controller
    where task_id = #{taskId,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.UgRtuController">
    <!--@mbg.generated-->
    insert into ug_rtu_controller (id, task_id, controller_id, 
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java
@@ -74,4 +74,73 @@
        }
    }
    /**
     * 删除升级任务所有控制器
     * @param taskId 任务id
     * @return 是否成功
     */
    @Operation(summary = "删除升级任务所有控制器", description = "删除升级任务所有控制器")
    @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 = "deleteAll")
    @SsoAop()
    public BaseResponse<Boolean> deleteAll(Long taskId){
        if(taskId == null){
            return BaseResponseUtils.buildFail("任务id不能为空") ;
        }
        int count;
        try {
            count = this.sv.deleteAll(taskId);
        } catch (Exception e) {
            log.error("删除升级所有对象控制器异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库操作失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
    /**
     * 升级任务控制器集合中删除一个控制器
     * @param id 数据记录id
     * @return 是否成功
     */
    @Operation(summary = "升级任务控制器集合中删除一个控制器", description = "升级任务控制器集合中删除一个控制器")
    @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 = "deleteOne")
    @SsoAop()
    public BaseResponse<Boolean> deleteOne(Long id){
        if(id == null){
            return BaseResponseUtils.buildFail("id不能为空") ;
        }
        int count;
        try {
            count = this.sv.deleteOne(id);
        } catch (Exception e) {
            log.error("删除升级对象控制器异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库操作失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerSv.java
@@ -76,4 +76,23 @@
    public int save(UgRtuController po){
        return this.dao.insertSelective(po) ;
    }
    /**
     * 删除所有
     * @param taskId 任务主键
     * @return 数量
     */
    @Transactional
    public int deleteAll(Long taskId){
        return this.dao.deleteByTaskId(taskId) ;
    }
    /**
     * 删除
     * @param id 主键
     * @return 数量
     */
    @Transactional
    public int deleteOne(Long id){
        return this.dao.deleteByPrimaryKey(id) ;
    }
}