11 files modified
2 files added
| | |
| | | import lombok.AllArgsConstructor; |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.secure.BladeUser; |
| | | 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.utils.Func; |
| | | import org.springblade.modules.community.excel.CommunityExcel; |
| | | import org.springblade.modules.community.excel.CommunityImporter; |
| | | import org.springblade.modules.grid.excel.GridExcel; |
| | | import org.springblade.modules.grid.excel.GridImporter; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | |
| | | import org.springblade.modules.community.wrapper.CommunityWrapper; |
| | | import org.springblade.modules.community.service.ICommunityService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * 社区表 控制器 |
| | |
| | | CommunityEntity detail = communityService.getOne(Condition.getQueryWrapper(community)); |
| | | return R.data(CommunityWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 社区表 自定义详情 |
| | | */ |
| | | @GetMapping("/getDetail") |
| | | public R<CommunityVO> getDetail(CommunityEntity community) { |
| | | return R.data(communityService.getDetail(community)); |
| | | } |
| | | |
| | | /** |
| | | * 社区表 分页 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 社区表 自定义新增或修改 |
| | | */ |
| | | @PostMapping("/saveOrUpdate") |
| | | public R saveOrUpdate(@Valid @RequestBody CommunityEntity community) { |
| | | return R.status(communityService.saveOrUpdateCommunityEntity(community)); |
| | | } |
| | | |
| | | /** |
| | | * 社区表 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | |
| | | return R.status(communityService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 导入社区数据 |
| | | */ |
| | | @PostMapping("/import-community") |
| | | public R importCommunity(MultipartFile file, Integer isCovered) { |
| | | CommunityImporter communityImporter = new CommunityImporter(communityService, isCovered == 1); |
| | | ExcelUtil.save(file, communityImporter, CommunityExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import java.util.Date; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | import org.springblade.modules.grid.handle.GeometryTypeHandler; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | |
| | | @ApiModelProperty(value = "中心坐标-纬度") |
| | | private String lat; |
| | | /** |
| | | * 社区面数据 |
| | | * @TableField(typeHandler = GeometryTypeHandler.class) 操作面的时候用,平时注释掉 |
| | | */ |
| | | @ApiModelProperty(value = "社区面数据") |
| | | // @TableField(typeHandler = GeometryTypeHandler.class) |
| | | private String geom; |
| | | /** |
| | | * 简介 |
| | | */ |
| | | @ApiModelProperty(value = "简介") |
| New file |
| | |
| | | package org.springblade.modules.community.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * GridExcel |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ColumnWidth(25) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | public class CommunityExcel implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("社区名称") |
| | | private String communityName; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("社区编号") |
| | | private String communityCode; |
| | | |
| | | @ColumnWidth(100) |
| | | @ExcelProperty("区域") |
| | | private String geom; |
| | | |
| | | } |
| New file |
| | |
| | | package org.springblade.modules.community.excel; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.excel.support.ExcelImporter; |
| | | import org.springblade.modules.community.service.ICommunityService; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 社区数据导入类 |
| | | * |
| | | * @author zhongrj |
| | | */ |
| | | @RequiredArgsConstructor |
| | | public class CommunityImporter implements ExcelImporter<CommunityExcel> { |
| | | |
| | | private final ICommunityService communityService; |
| | | private final Boolean isCovered; |
| | | |
| | | @Override |
| | | public void save(List<CommunityExcel> data) { |
| | | communityService.importCommunity(data, isCovered); |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | List<String> getCommunityCodeListByUserId(@Param("userId") Long userId); |
| | | |
| | | /** |
| | | * 社区表 自定义详情 |
| | | */ |
| | | CommunityVO getDetail(@Param("community") CommunityEntity community); |
| | | } |
| | |
| | | <!--自定义分页列表查询--> |
| | | <select id="selectCommunityPage" resultType="org.springblade.modules.community.vo.CommunityVO"> |
| | | select |
| | | jc.*, |
| | | jc.id, |
| | | jc.street_code, |
| | | jc.code, |
| | | jc.name, |
| | | jc.pic_url, |
| | | jc.address, |
| | | jc.res_police_user_id, |
| | | jc.lng, |
| | | jc.lat, |
| | | jc.remark, |
| | | br.town_name townName |
| | | from jczz_community jc |
| | | left join blade_region br on br.code = jc.code |
| | |
| | | where is_deleted = 0 and res_police_user_id like concat('%',#{userId},'%') |
| | | </select> |
| | | |
| | | <!--自定义分页列表查询--> |
| | | <select id="getDetail" resultType="org.springblade.modules.community.vo.CommunityVO"> |
| | | select |
| | | jc.id, |
| | | jc.street_code, |
| | | jc.code, |
| | | jc.name, |
| | | jc.pic_url, |
| | | jc.address, |
| | | jc.res_police_user_id, |
| | | jc.lng, |
| | | jc.lat, |
| | | jc.remark, |
| | | br.town_name townName |
| | | from jczz_community jc |
| | | left join blade_region br on br.code = jc.code |
| | | where jc.is_deleted = 0 |
| | | and jc.id = #{community.id} |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | | import org.springblade.modules.community.excel.CommunityExcel; |
| | | import org.springblade.modules.community.vo.CommunityVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | List<String> getCommunityCodeListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 导入社区数据 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | void importCommunity(List<CommunityExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 社区表 自定义新增或修改 |
| | | */ |
| | | boolean saveOrUpdateCommunityEntity(CommunityEntity community); |
| | | |
| | | /** |
| | | * 社区表 自定义详情 |
| | | */ |
| | | CommunityVO getDetail(CommunityEntity community); |
| | | } |
| | |
| | | */ |
| | | package org.springblade.modules.community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | | import org.springblade.modules.community.excel.CommunityExcel; |
| | | import org.springblade.modules.community.vo.CommunityVO; |
| | | import org.springblade.modules.community.mapper.CommunityMapper; |
| | | import org.springblade.modules.community.service.ICommunityService; |
| | |
| | | public List<String> getCommunityCodeListByUserId(Long userId) { |
| | | return baseMapper.getCommunityCodeListByUserId(userId); |
| | | } |
| | | |
| | | /** |
| | | * 导入社区数据 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importCommunity(List<CommunityExcel> data, Boolean isCovered) { |
| | | for (CommunityExcel communityExcel : data) { |
| | | // 查询是否存在,存在即更新,否则新增 |
| | | QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("code",communityExcel.getCommunityCode()); |
| | | CommunityEntity one = getOne(wrapper); |
| | | if (null!=one){ |
| | | // 更新 |
| | | one.setGeom(communityExcel.getGeom()); |
| | | // 更新 |
| | | updateById(one); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 社区表 自定义新增或修改 |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateCommunityEntity(CommunityEntity community) { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 社区表 自定义详情 |
| | | */ |
| | | @Override |
| | | public CommunityVO getDetail(CommunityEntity community) { |
| | | return baseMapper.getDetail(community); |
| | | } |
| | | } |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("社区网格名称") |
| | | @ExcelProperty("社区名称") |
| | | private String communityName; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("社区编号") |
| | | private String communityCode; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("网格名称") |
| | | private String gridName; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("网格编号") |
| | | private String gridCode; |
| | | |
| | | /** |
| | | * 网格员名称 |
| | | */ |
| | | @ApiModelProperty(value = "网格员姓名") |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("网格员姓名") |
| | | private String gridmanName; |
| | | |
| | | /** |
| | | * 网格员电话 |
| | | */ |
| | | @ApiModelProperty(value = "网格员电话") |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("网格员电话") |
| | | private String mobile; |
| | | |
| | | } |
| | |
| | | <if test="grid.townName != null and grid.townName !='' "> |
| | | and br.town_name like concat('%',#{grid.townName},'%') |
| | | </if> |
| | | order by community_code asc,grid_code asc |
| | | </select> |
| | | |
| | | <!--根据地址编号查询网格数据--> |
| | |
| | | |
| | | <!--查询全部--> |
| | | <select id="selectGridAll" resultType="org.springblade.modules.grid.entity.GridEntity"> |
| | | select id,community_code,grid_name,principal,principal_phone,remark,sort from jczz_grid |
| | | select id,grid_code,community_code,grid_name,principal,principal_phone,remark,sort from jczz_grid |
| | | where is_deleted = 0 |
| | | </select> |
| | | |
| | |
| | | QueryWrapper<Region> regionWrapper = new QueryWrapper<>(); |
| | | regionWrapper.eq("code",grid.getCommunityCode()); |
| | | Region region = regionService.getOne(regionWrapper); |
| | | // 查询父机构 |
| | | // 查询父机构(社区机构) |
| | | System.out.println("社区名称 = " + region.getName()); |
| | | QueryWrapper<Dept> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("dept_name",region.getName()) |
| | | .eq("is_deleted",0); |
| | |
| | | QueryWrapper<Dept> wrapperChild = new QueryWrapper<>(); |
| | | wrapperChild.eq("dept_name",grid.getGridName()) |
| | | .eq("is_deleted",0) |
| | | .eq("id",dept.getId()); |
| | | Dept deptChild = deptService.getOne(wrapperChild); |
| | | if (null==deptChild){ |
| | | .eq("parent_id",dept.getId()); |
| | | List<Dept> deptChild = deptService.list(wrapperChild); |
| | | if (deptChild.size()==0){ |
| | | Dept deptInfo = new Dept(); |
| | | deptInfo.setParentId(dept.getId()); |
| | | deptInfo.setFullName(grid.getGridName()); |
| | | deptInfo.setDeptName(grid.getGridName()); |
| | | deptInfo.setDeptCategory(1); |
| | | deptInfo.setTenantId("000000"); |
| | | deptInfo.setRegionCode(grid.getGridCode()); |
| | | deptInfo.setAncestors(dept.getAncestors() + "," +dept.getId()); |
| | | // 新增 |
| | | deptService.save(deptInfo); |
| | | // 查询网格是否已存在(社区编号-网格名称),已存在更新,不存在插入新的 |
| | | QueryWrapper<GridEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("grid_name",grid.getGridName()) |
| | | .eq("is_deleted",0) |
| | | .eq("community_code",grid.getCommunityCode()); |
| | | queryWrapper.eq("grid_code",grid.getGridCode()) |
| | | .eq("is_deleted",0); |
| | | System.out.println("网格编号 = " + grid.getGridCode()); |
| | | GridEntity one = getOne(queryWrapper); |
| | | if (null!=one){ |
| | | grid.setId(one.getId()); |
| | |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.grid.vo.GridmanVO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public void importGridman(List<GridmanExcel> data, Boolean isCovered) { |
| | | // 遍历 |
| | | for (GridmanExcel gridmanExcel : data) { |
| | | // 先查询是否有对应的用户 |
| | | List<User> userList = userService.getUserListByPhoneOrAccount(gridmanExcel.getMobile()); |
| | | if (userList.size()>0){ |
| | | User user = userList.get(0); |
| | | // 判断角色是否包好网格员的角色,如果没有则加入网格员的角色,有则不更改 |
| | | if (!user.getRoleId().contains("1717429261910528001")) { |
| | | // 更新角色 |
| | | user.setRoleId(user.getRoleId() + "," + "1717429261910528001"); |
| | | // 更新机构 |
| | | setDeptId(gridmanExcel,user); |
| | | // 更新用户信息 |
| | | userService.updateById(user); |
| | | // 更新网格员绑定 |
| | | updateGridmanBind(gridmanExcel,user); |
| | | } |
| | | }else { |
| | | // 创建用户 |
| | | User user = new User(); |
| | | user.setTenantId("000000"); |
| | | user.setUserType(1); |
| | | user.setRoleId("1717429261910528001"); |
| | | user.setName(gridmanExcel.getGridmanName()); |
| | | user.setRealName(gridmanExcel.getGridmanName()); |
| | | user.setPhone(gridmanExcel.getMobile()); |
| | | user.setAccount(gridmanExcel.getMobile()); |
| | | // 更新机构 |
| | | setDeptId(gridmanExcel,user); |
| | | // 设置默认密码 |
| | | user.setPassword("123456"); |
| | | // 保存 |
| | | userService.submit(user); |
| | | // 更新网格员绑定 |
| | | updateGridmanBind(gridmanExcel,user); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新网格员绑定 |
| | | * @param gridmanExcel |
| | | * @param user |
| | | */ |
| | | public void updateGridmanBind(GridmanExcel gridmanExcel, User user) { |
| | | // 保存更新网格员信息 |
| | | GridmanEntity gridmanEntity = Objects.requireNonNull(BeanUtil.copy(gridmanExcel, GridmanEntity.class)); |
| | | // 通过社区名称和网格名称获取网格id |
| | | QueryWrapper<GridEntity> queryWrapper = new QueryWrapper<>(); |
| | |
| | | GridEntity gridEntity = gridService.getOne(queryWrapper); |
| | | // 设置网格id |
| | | gridmanEntity.setGridId(gridEntity.getId()); |
| | | gridmanEntity.setUserId(user.getId()); |
| | | // 插入网格员 |
| | | if (!Strings.isBlank(gridmanExcel.getMobile())) { |
| | | saveOrUpdateGridman(gridmanEntity); |
| | | // 判断是否已存,已存在则更新,否则插入 |
| | | QueryWrapper<GridmanEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("user_id",user.getId()).eq("grid_code",gridmanExcel.getGridCode()); |
| | | GridmanEntity entity = getOne(wrapper); |
| | | if (null!=entity){ |
| | | gridmanEntity.setId(entity.getId()); |
| | | updateById(gridmanEntity); |
| | | }else { |
| | | save(gridmanEntity); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新机构 |
| | | * @param gridmanExcel |
| | | * @param user |
| | | */ |
| | | public void setDeptId(GridmanExcel gridmanExcel, User user) { |
| | | // 通过社区编号查询对应的机构id |
| | | Region region = SpringUtil.getBean(IRegionService.class).getById(gridmanExcel.getCommunityCode()); |
| | | // 查询社区对应的机构 |
| | | QueryWrapper<Dept> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("dept_name",region.getName()); |
| | | Dept dept = SpringUtil.getBean(IDeptService.class).getOne(wrapper); |
| | | // 查询网格对应的机构 |
| | | QueryWrapper<Dept> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0). |
| | | eq("parent_id",dept.getId()). |
| | | eq("dept_name",gridmanExcel.getGridName()); |
| | | System.out.println("网格名称 = " + gridmanExcel.getGridName()); |
| | | Dept deptGrid = SpringUtil.getBean(IDeptService.class).getOne(queryWrapper); |
| | | // 设置机构 |
| | | user.setDeptId(deptGrid.getId().toString()); |
| | | } |
| | | |
| | | /** |
| | |
| | | - /blade-userPublicEnroll/userPublicEnroll/page |
| | | - /blade-topics/topics/lists |
| | | - /blade-household/household/getHouseholdOtherInfo |
| | | - /blade-resource/oss/endpoint/put-file |
| | | - /blade-hiddenDangerRecord/** |
| | | # - /blade-doorplateAddress/doorplateAddress/** |
| | | # - /blade-house/house/** |
| | | # - /blade-household/household/** |
| | | # - /blade-label/label/** |
| | | # - /blade-houseRental/houseRental/** |
| | | # - /blade-resource/oss/** |
| | | - /blade-resource/oss/endpoint/put-file |
| | | - /blade-hiddenDangerRecord/** |
| | | # - /blade-place/** |
| | | # - /blade-taskReportForRepairs/** |
| | | # - /blade-placeExt/** |