zhongrj
2024-05-17 cd92c8e582d55bdb683be4003a37caa2c6c3ed6c
警务网格查询或新增修改调整处理
11 files modified
223 ■■■■ changed files
src/main/java/org/springblade/modules/police/controller/PoliceAffairsGridController.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/controller/PoliceStationController.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/mapper/PoliceAffairsGridMapper.java 7 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/mapper/PoliceAffairsGridMapper.xml 49 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/mapper/PoliceStationMapper.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/mapper/PoliceStationMapper.xml 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/service/IPoliceAffairsGridService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/service/IPoliceStationService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/service/impl/PoliceAffairsGridServiceImpl.java 47 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/service/impl/PoliceStationServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/vo/PoliceAffairsGridVO.java 30 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/police/controller/PoliceAffairsGridController.java
@@ -1,19 +1,3 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.police.controller;
import io.swagger.annotations.Api;
@@ -22,24 +6,21 @@
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.police.excel.PoliceAffairsGridExcel;
import org.springblade.modules.police.excel.PoliceAffairsGridImporter;
import org.springblade.modules.police.excel.PoliceStationExcel;
import org.springblade.modules.police.excel.PoliceStationImporter;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
import org.springblade.modules.police.vo.PoliceAffairsGridVO;
import org.springblade.modules.police.wrapper.PoliceAffairsGridWrapper;
import org.springblade.modules.police.service.IPoliceAffairsGridService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springframework.web.multipart.MultipartFile;
/**
@@ -55,6 +36,7 @@
public class PoliceAffairsGridController {
    private final IPoliceAffairsGridService policeAffairsGridService;
    private final BladeLogger bladeLogger;
    /**
     * 警务网格(辖区)表 详情
@@ -109,6 +91,17 @@
    }
    /**
     * 警务网格(辖区)表 自定义新增或修改
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "自定义新增或修改", notes = "传入policeAffairsGrid")
    public R saveOrUpdate(@Valid @RequestBody PoliceAffairsGridEntity policeAffairsGrid) {
        bladeLogger.info("警务网格(辖区)表 自定义新增或修改",JsonUtil.toJson(policeAffairsGrid));
        return R.status(policeAffairsGridService.saveOrUpdatePoliceAffairsGrid(policeAffairsGrid));
    }
    /**
     * 警务网格(辖区)表 新增或修改
     */
    @PostMapping("/submit")
src/main/java/org/springblade/modules/police/controller/PoliceStationController.java
@@ -117,5 +117,12 @@
        return R.success("操作成功");
    }
    /**
     * 派出所树查询
     */
    @GetMapping("/tree")
    public R tree(PoliceStationEntity policeStation) {
        return R.data(policeStationService.tree(policeStation));
    }
}
src/main/java/org/springblade/modules/police/mapper/PoliceAffairsGridMapper.java
@@ -38,7 +38,12 @@
     * @param policeAffairsGrid
     * @return
     */
    List<PoliceAffairsGridVO> selectPoliceAffairsGridPage(IPage page, PoliceAffairsGridVO policeAffairsGrid);
    List<PoliceAffairsGridVO> selectPoliceAffairsGridPage(IPage page,
                                                          @Param("policeAffairsGrid") PoliceAffairsGridVO policeAffairsGrid,
                                                          @Param("isAdministrator") Integer isAdministrator,
                                                          @Param("regionChildCodesList") List<String> regionChildCodesList,
                                                          @Param("gridCodeList") List<String> gridCodeList
    );
    /**
     * 空间分析
src/main/java/org/springblade/modules/police/mapper/PoliceAffairsGridMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="org.springblade.modules.police.mapper.PoliceAffairsGridMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="policeAffairsGridResultMap" type="org.springblade.modules.police.entity.PoliceAffairsGridEntity">
    <resultMap id="policeAffairsGridResultMap" type="org.springblade.modules.police.vo.PoliceAffairsGridVO">
        <result column="id" property="id"/>
        <result column="object_id" property="objectId"/>
        <result column="jws_code" property="jwsCode"/>
@@ -24,9 +24,54 @@
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
    <!--自定义分页查询-->
    <select id="selectPoliceAffairsGridPage" resultMap="policeAffairsGridResultMap">
        select * from jczz_police_affairs_grid where is_deleted = 0
        <if test="policeAffairsGrid.communityName!=null and policeAffairsGrid.communityName!=''">
            and community_name like concat('%',#{policeAffairsGrid.communityName},'%')
        </if>
        <if test="policeAffairsGrid.jwGridCode!=null and policeAffairsGrid.jwGridCode!=''">
            and jw_grid_code like concat('%',#{policeAffairsGrid.jwGridCode},'%')
        </if>
        <if test="policeAffairsGrid.pcsCode!=null and policeAffairsGrid.pcsCode!=''">
            and pcs_code like concat('%',#{policeAffairsGrid.pcsCode},'%')
        </if>
        <if test="policeAffairsGrid.pcsName!=null and policeAffairsGrid.pcsName!=''">
            and pcs_name like concat('%',#{policeAffairsGrid.pcsName},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="policeAffairsGrid.roleName != null and policeAffairsGrid.roleName != ''">
                    <if test="policeAffairsGrid.roleName=='mj'">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and community_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </when>
                <otherwise>
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and community_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                        </when>
                        <otherwise>
                            and community_code in ('')
                        </otherwise>
                    </choose>
                </otherwise>
            </choose>
        </if>
        order by id desc,pcs_code desc
    </select>
    <!--判断该点在哪个警务网格-->
src/main/java/org/springblade/modules/police/mapper/PoliceStationMapper.java
@@ -16,11 +16,15 @@
 */
package org.springblade.modules.police.mapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springblade.common.node.TreeStringNode;
import org.springblade.modules.police.entity.PoliceStationEntity;
import org.springblade.modules.police.vo.PoliceStationVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
import java.util.Map;
/**
 * 派出所信息表 Mapper 接口
@@ -39,5 +43,11 @@
     */
    List<PoliceStationVO> selectPoliceStationPage(IPage page, PoliceStationVO policeStation);
    /**
     * 派出所树查询
     * @param policeStation
     * @return
     */
    @MapKey(value = "id")
    Map<String, TreeStringNode> tree(@Param("policeStation") PoliceStationEntity policeStation);
}
src/main/java/org/springblade/modules/police/mapper/PoliceStationMapper.xml
@@ -22,5 +22,14 @@
        select * from jczz_police_station where is_deleted = 0
    </select>
    <!--派出所树查询-->
    <select id="tree" resultType="org.springblade.common.node.TreeStringNode">
        SELECT
        code as id,
        parent_code as parentId,
        name
        FROM jczz_police_station
    </select>
</mapper>
src/main/java/org/springblade/modules/police/service/IPoliceAffairsGridService.java
@@ -46,4 +46,11 @@
     * @return
     */
    List<String> getCommunityCodeListByUserId(Long userId);
    /**
     * 警务网格(辖区)表 自定义新增或修改
     * @param policeAffairsGrid
     * @return
     */
    boolean saveOrUpdatePoliceAffairsGrid(PoliceAffairsGridEntity policeAffairsGrid);
}
src/main/java/org/springblade/modules/police/service/IPoliceStationService.java
@@ -1,6 +1,7 @@
package org.springblade.modules.police.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.common.node.TreeStringNode;
import org.springblade.modules.police.entity.PoliceStationEntity;
import org.springblade.modules.police.excel.PoliceStationExcel;
import org.springblade.modules.police.vo.PoliceStationVO;
@@ -32,4 +33,11 @@
     * @param isCovered
     */
    void importPoliceStation(List<PoliceStationExcel> data, Boolean isCovered);
    /**
     * 派出所树查询
     * @param policeStation
     * @return
     */
    List<TreeStringNode> tree(PoliceStationEntity policeStation);
}
src/main/java/org/springblade/modules/police/service/impl/PoliceAffairsGridServiceImpl.java
@@ -2,9 +2,13 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.community.entity.CommunityEntity;
import org.springblade.modules.community.service.ICommunityService;
import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
import org.springblade.modules.police.entity.PoliceStationEntity;
import org.springblade.modules.police.excel.PoliceAffairsGridExcel;
@@ -32,7 +36,13 @@
    @Override
    public IPage<PoliceAffairsGridVO> selectPoliceAffairsGridPage(IPage<PoliceAffairsGridVO> page, PoliceAffairsGridVO policeAffairsGrid) {
        return page.setRecords(baseMapper.selectPoliceAffairsGridPage(page, policeAffairsGrid));
        CommonParamSet commonParamSet = new CommonParamSet<>().invoke(PoliceAffairsGridVO.class, policeAffairsGrid);
        return page.setRecords(baseMapper.selectPoliceAffairsGridPage(page,
            policeAffairsGrid,
            commonParamSet.getIsAdministrator(),
            commonParamSet.getRegionChildCodesList(),
            commonParamSet.getGridCodeList()
        ));
    }
    /**
@@ -80,4 +90,39 @@
    public List<String> getCommunityCodeListByUserId(Long userId) {
        return baseMapper.getCommunityCodeListByUserId(userId.toString());
    }
    /**
     * 警务网格(辖区)表 自定义新增或修改
     * @param policeAffairsGrid
     * @return
     */
    @Override
    public boolean saveOrUpdatePoliceAffairsGrid(PoliceAffairsGridEntity policeAffairsGrid) {
        boolean flag = false;
        // 查询对应的派出所及社区名称
        IPoliceStationService policeStationService = SpringUtils.getBean(IPoliceStationService.class);
        QueryWrapper<PoliceStationEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("code",policeAffairsGrid.getPcsCode());
        List<PoliceStationEntity> policeStationEntityList = policeStationService.list(queryWrapper);
        if (policeStationEntityList.size()>0){
            policeAffairsGrid.setPcsName(policeStationEntityList.get(0).getName());
        }
        ICommunityService communityService = SpringUtils.getBean(ICommunityService.class);
        QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("code",policeAffairsGrid.getCommunityCode());
        List<CommunityEntity> communityEntityList = communityService.list(wrapper);
        if (communityEntityList.size()>0){
            policeAffairsGrid.setCommunityName(communityEntityList.get(0).getName());
        }
        if (null!=policeAffairsGrid.getId()){
            policeAffairsGrid.setGeom(null);
            // 更新
            flag = updateById(policeAffairsGrid);
        }else {
            policeAffairsGrid.setGeom(null);
            // 新增
            flag = save(policeAffairsGrid);
        }
        return flag;
    }
}
src/main/java/org/springblade/modules/police/service/impl/PoliceStationServiceImpl.java
@@ -2,6 +2,8 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.node.TreeStringNode;
import org.springblade.common.utils.NodeTreeUtil;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.police.entity.PoliceStationEntity;
import org.springblade.modules.police.excel.PoliceStationExcel;
@@ -59,4 +61,14 @@
            }
        }
    }
    /**
     * 派出所树查询
     * @param policeStation
     * @return
     */
    @Override
    public List<TreeStringNode> tree(PoliceStationEntity policeStation) {
        return NodeTreeUtil.getStringNodeTree(baseMapper.tree(policeStation));
    }
}
src/main/java/org/springblade/modules/police/vo/PoliceAffairsGridVO.java
@@ -1,23 +1,7 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.police.vo;
import io.swagger.annotations.ApiModelProperty;
import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
import org.springblade.core.tool.node.INode;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -32,4 +16,16 @@
public class PoliceAffairsGridVO extends PoliceAffairsGridEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 社区编号
     */
    @ApiModelProperty(value = "社区编号")
    private String communityCode;
    /**
     * 角色别名
     */
    @ApiModelProperty(value = "角色别名")
    private String roleName;
}