wuzeyu
2024-05-15 2938172b377e5ed7a55e5dde4a218244445e8a6e
田间灌溉项目管理 修改项目信息接口 修改项目状态接口
5个文件已修改
227 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java
@@ -3,7 +3,9 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoIr.IrProject;
import com.dy.pipIrrGlobal.pojoPr.PrController;
import com.dy.pipIrrGlobal.pojoPr.PrIntake;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * @author :WuZeYu
@@ -13,10 +15,19 @@
 */
@Mapper
public interface IrProjectMapper extends BaseMapper<IrProject> {
//增
    int insertSelective(IrProject record);
//删
    int deleteLogicById(Long id);
//改
    int updateByPrimaryKeySelective(IrProject record);
    /**
     * 修改项目状态
     * @param id
     * @return
     */
    int updateProjectState(IrProject record);
    /**
     * 根据下级Id获取上一级地址Id
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
@@ -17,7 +17,7 @@
        <result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" />
        <result column="deleted" jdbcType="TINYINT" property="deleted" />
    </resultMap>
    <!--添加-->
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrProject">
        <!--@mbg.generated-->
        insert into ir_project
@@ -108,11 +108,59 @@
        on dis_vil.supperId = dis_tow.id
        where dis_vil.id = #{vaId,jdbcType=BIGINT}
    </select>
    <!--逻辑删除-->
    <delete id="deleteLogicById" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        update ir_project
        set deleted = 1
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrProject">
        update ir_project
        <set>
            <if test="projectName != null">
                project_name = #{projectName,jdbcType=VARCHAR},
            </if>
            <if test="provinceId != null">
                province_id = #{provinceId,jdbcType=BIGINT},
            </if>
            <if test="cityId != null">
                city_id = #{cityId,jdbcType=BIGINT},
            </if>
            <if test="countyId != null">
                county_id = #{countyId,jdbcType=BIGINT},
            </if>
            <if test="townId != null">
                town_id = #{townId,jdbcType=BIGINT},
            </if>
            <if test="villageId != null">
                village_id = #{villageId,jdbcType=BIGINT},
            </if>
            <if test="projectState != null">
                project_state = #{projectState,jdbcType=TINYINT},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="operator != null">
                operator = #{operator,jdbcType=BIGINT},
            </if>
            <if test="operateDt != null">
                operate_time = #{operateDt,jdbcType=TIMESTAMP},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=TINYINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateProjectState">
        update ir_project
        set project_state = #{projectState,jdbcType=TINYINT},
            operator = #{operator,jdbcType=BIGINT},
            operate_time = #{operateDt,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java
@@ -24,9 +24,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.lang.reflect.Array;
import java.util.*;
/**
 * @author :WuZeYu
@@ -77,6 +76,20 @@
        return BaseResponseUtils.buildSuccess(true);
    }
    /**
     * 逻辑删除项目
     * @param map
     * @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))}
            )
    })
    @PostMapping(path = "delete", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
@@ -84,7 +97,7 @@
        if (map == null || map.size() <= 0) {
            BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
        }
        Long projectId = Long.parseLong(map.get("projectId").toString());
        Long projectId = Long.parseLong(map.get("id").toString());
        try {
            Integer rows = projectSv.deleteProject(projectId);
            if (rows == 0) {
@@ -96,4 +109,96 @@
        }
        return BaseResponseUtils.buildSuccess(true);
    }
    /**
     * 批量删除
     * @param projectIds
     * @return
     */
    @PostMapping(path = "delete_batch", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> delete_batch(@RequestBody List<Long> projectIds) {
        if (projectIds == null || projectIds.size() <= 0) {
            BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
        }
        for (int i = 0; i < projectIds.size(); i++) {
            Long projectId = projectIds.get(i);
            try {
                Integer rows = projectSv.deleteProject(projectId);
                if (rows == 0) {
                    return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage());
                }
            } catch (Exception e) {
                log.error("删除项目异常", e);
                return BaseResponseUtils.buildException(e.getMessage());
            }
        }
        return BaseResponseUtils.buildSuccess(true);
    }
    /**
     * 修改项目信息
     * @param po
     * @param bindingResult
     * @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))}
            )
    })
    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> update(@RequestBody @Valid IrProject po, BindingResult bindingResult){
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        try {
            Integer rec = Optional.ofNullable(projectSv.updateProject(po)).orElse(0);
            if (rec == 0) {
                return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage());
            }
        } catch (Exception e) {
            log.error("修改项目异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
    /**
     * 修改项目状态
     * @param po
     * @param
     * @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))}
            )
    })
    @PostMapping(path = "update_state", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> update_state(@RequestBody IrProject po){
        try {
            Integer rec = Optional.ofNullable(projectSv.updateProjectState(po)).orElse(0);
            if (rec == 0) {
                return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage());
            }
        } catch (Exception e) {
            log.error("修改项目异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
@@ -67,4 +67,50 @@
        }
            return 1;
    }
    /**
     * 修改项目信息
     * @param po
     * @return
     */
    public Integer updateProject(IrProject po){
        po.setOperateDt(new Date());
        if (po.getVillageId() != null) {
            po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
            po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getTownId() != null) {
            po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getCountyId() != null) {
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getCityId() != null) {
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        int rows = irProjectMapper.updateByPrimaryKeySelective(po);
        if (rows == 0){
            return 0;
        }
        return 1;
    }
    /**
     * 修改项目状态
     * @param po
     * @return
     */
    public Integer updateProjectState(IrProject po){
        po.setOperateDt(new Date());
        int rows = irProjectMapper.updateProjectState(po);
        if (rows == 0){
            return 0;
        }
        return 1;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java
@@ -19,6 +19,7 @@
    ADD_PROJECT_FAIL(10001, "项目添加失败"),
    PLEASE_INPUT_PROJECT_ID(10002, "请输入项目ID"),
    DELETE_PROJECT_FAIL(10003, "项目删除失败"),
    UPDATE_PROJECT_FAIL(10004, "项目修改失败"),
    NO_DIVIDES(10001, "无符合条件的分水房记录");