liurunyu
2024-11-08 e3aae0ec49b7423d4e8a9c903fe0b9852c89d6b6
RTU升级任务增加两个属性,及线束、执行一些逻辑
7个文件已修改
239 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuTaskMapper.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/UgRtuTask.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuTaskMapper.xml 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskSv.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuTaskMapper.java
@@ -83,4 +83,33 @@
     * @return update count
     */
    int updateByPrimaryKey(UgRtuTask record);
    /**
     * execute by primary key
     * @param id primaryKey
     * @return deleteCount
     */
    int executeById(Long id);
    /**
     * over by primary key
     * @param id primaryKey
     * @return deleteCount
     */
    int overById(Long id);
    /**
     * is execute by primary key
     * @param id primaryKey
     * @return deleteCount
     */
    int isExecuteById(Long id);
    /**
     * is over by primary key
     * @param id primaryKey
     * @return deleteCount
     */
    int isOverById(Long id);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/UgRtuTask.java
@@ -65,10 +65,28 @@
    public Date dt;
    /**
    * 是否执行(1是,0否)
    */
    @Schema(description = "是否执行(1是,0否)", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public Byte isExecute;
    /**
    * 是否执行
    */
    @Schema(description = "是否执行", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public String isExecuteStr;
    /**
    * 是否结束(1是,0否)
    */
    @Schema(description = "是否结束(1是,0否)", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public Byte isOver;
    /**
    * 是否结束
    */
    @Schema(description = "是否结束", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public String isOverStr;
    /**
     * 删除标识
@@ -77,4 +95,11 @@
    @JSONField(serialize=false)
    public Byte deleted;
    public void init(){
        this.dt = new Date();
        this.isExecute = 0 ;
        this.isOver = 0 ;
        this.deleted = 0 ;
    }
}
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -5,9 +5,9 @@
            #name: ym
            type: com.alibaba.druid.pool.DruidDataSource
            driverClassName: com.mysql.cj.jdbc.Driver
#            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://8.130.130.233:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            username: root
            password: dysql,;.abc!@#
            druid:
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -77,7 +77,7 @@
pipIrr:
    global:
        dev: false  #是否开发阶段,true或false
        dev: true  #是否开发阶段,true或false
        dsName: ym  #开发阶段,设置临时的数据库名称
    nginx:
        webPort: 54321
pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuTaskMapper.xml
@@ -9,17 +9,20 @@
    <result column="creator" jdbcType="VARCHAR" property="creator" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="dt" jdbcType="TIMESTAMP" property="dt" />
    <result column="is_execute" jdbcType="TINYINT" property="isExecute" />
    <result column="is_over" jdbcType="TINYINT" property="isOver" />
    <result column="deleted" jdbcType="TINYINT" property="deleted" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, program_id, creator, remark, dt, is_over, deleted
    id, program_id, creator, remark, dt, is_execute, is_over, deleted
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    <include refid="Base_Column_List" />,
    (CASE WHEN is_execute = 1 THEN '是' ELSE '否' END) AS isExecuteStr,
    (CASE WHEN is_over = 1 THEN '是' ELSE '否' END) AS isOverStr
    from ug_rtu_task
    where id = #{id,jdbcType=BIGINT}
  </select>
@@ -55,7 +58,9 @@
    select
    <include refid="Base_Column_List" >
      <property name="alias" value="bd"/>
    </include>
    </include>,
    (CASE WHEN bd.is_execute = 1 THEN '是' ELSE '否' END) AS isExecuteStr,
    (CASE WHEN bd.is_over = 1 THEN '是' ELSE '否' END) AS isOverStr
    from ug_rtu_task bd
    where bd.deleted != 1
    <trim prefix="and" suffixOverrides="and">
@@ -86,10 +91,11 @@
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.UgRtuTask">
    <!--@mbg.generated-->
    insert into ug_rtu_task (id, program_id, creator, 
      remark, dt, is_over, deleted
      remark, dt, is_execute, is_over, deleted
      )
    values (#{id,jdbcType=BIGINT}, #{programId,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, 
      #{remark,jdbcType=VARCHAR}, #{dt,jdbcType=TIMESTAMP}, #{isOver,jdbcType=TINYINT}, #{deleted,jdbcType=TINYINT}
      #{remark,jdbcType=VARCHAR}, #{dt,jdbcType=TIMESTAMP}, #{isExecute,jdbcType=TINYINT},
      #{isOver,jdbcType=TINYINT}, #{deleted,jdbcType=TINYINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.UgRtuTask">
@@ -110,6 +116,9 @@
      </if>
      <if test="dt != null">
        dt,
      </if>
      <if test="isExecute != null">
        is_execute,
      </if>
      <if test="isOver != null">
        is_over,
@@ -133,6 +142,9 @@
      </if>
      <if test="dt != null">
        #{dt,jdbcType=TIMESTAMP},
      </if>
      <if test="isExecute != null">
        #{isExecute,jdbcType=TINYINT},
      </if>
      <if test="isOver != null">
        #{isOver,jdbcType=TINYINT},
@@ -158,7 +170,10 @@
      <if test="dt != null">
        dt = #{dt,jdbcType=TIMESTAMP},
      </if>
      <if test="isOver != null">
      <if test="isExecute != null">
        is_execute = #{isExecute,jdbcType=TINYINT},
      </if>
     <if test="isOver != null">
        is_over = #{isOver,jdbcType=TINYINT},
      </if>
      <if test="deleted != null">
@@ -174,8 +189,34 @@
      creator = #{creator,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      dt = #{dt,jdbcType=TIMESTAMP},
      is_execute = #{isExecute,jdbcType=TINYINT},
      is_over = #{isOver,jdbcType=TINYINT},
      deleted = #{deleted,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="executeById" parameterType="java.lang.Long">
    update ug_rtu_task set is_execute = 1
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="overById" parameterType="java.lang.Long">
    update ug_rtu_task set is_over = 1
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="isExecuteById" parameterType="java.lang.Long" resultType="java.lang.Integer">
    select
    is_execute
    from ug_rtu_task
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="isOverById" parameterType="java.lang.Long" resultType="java.lang.Integer">
    select
    is_over
    from ug_rtu_task
    where id = #{id,jdbcType=BIGINT}
  </select>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java
@@ -25,7 +25,6 @@
import org.springframework.web.bind.annotation.RestController;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -137,9 +136,7 @@
        }
        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);
@@ -192,6 +189,85 @@
    /**
     * 执行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 是否成功
@@ -219,7 +295,7 @@
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库存储失败") ;
            return BaseResponseUtils.buildFail("数据库操作失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskSv.java
@@ -80,6 +80,46 @@
    }
    /**
     * 执行任务
     * @param id 实体ID
     * @return 数量
     */
    @Transactional
    public int execute(Long id){
        return this.dao.executeById(id) ;
    }
    /**
     * 结束任务
     * @param id 实体ID
     * @return 数量
     */
    @Transactional
    public int over(Long id){
        return this.dao.overById(id) ;
    }
    /**
     * 执行任务
     * @param id 实体ID
     * @return 数量
     */
    @Transactional
    public int isExecute(Long id){
        return this.dao.isExecuteById(id) ;
    }
    /**
     * 结束任务
     * @param id 实体ID
     * @return 数量
     */
    @Transactional
    public int isOver(Long id){
        return this.dao.isOverById(id) ;
    }
    /**
     * 逻辑删除实体
     * @param id 实体ID
     * @return 数量