10 files modified
12 files added
| | |
| | | <artifactId>lombok</artifactId> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.vividsolutions</groupId> |
| | | <artifactId>jts</artifactId> |
| | | <version>1.13</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <!--自定义分页--> |
| | | <!--小区树查询--> |
| | | <select id="getDistrictTree" resultType="org.springblade.common.node.TreeStringNode"> |
| | | SELECT |
| | | code as id, |
| | |
| | | GridEntity detail = gridService.getOne(Condition.getQueryWrapper(grid)); |
| | | return R.data(GridWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 网格表 自定义详情 |
| | | */ |
| | | @GetMapping("/getGridDetail") |
| | | public R getGridDetail(GridVO grid) { |
| | | return R.data(gridService.getGridDetail(grid)); |
| | | } |
| | | /** |
| | | * 网格表 分页 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 网格表 自定义新增或修改 |
| | | */ |
| | | @PostMapping("/saveOrUpdate") |
| | | public R saveOrUpdate(@Valid @RequestBody GridEntity grid) { |
| | | return R.status(gridService.saveOrUpdateGrid(grid)); |
| | | } |
| | | |
| | | /** |
| | | * 网格表 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(gridService.removeByIds(Func.toLongList(ids))); |
| | | return R.status(gridService.removeByIds(Func.toIntList(ids))); |
| | | } |
| | | |
| | | /** |
| | |
| | | return R.data(gridService.spatialAnalysis()); |
| | | } |
| | | |
| | | /** |
| | | * 网格数据同步处理 |
| | | */ |
| | | @GetMapping("/asyncGridDept") |
| | | public R asyncGridDept() { |
| | | return R.data(gridService.asyncGridDept()); |
| | | } |
| | | |
| | | /** |
| | | * 网格树 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | @GetMapping("/getGridTree") |
| | | public R getGridTree(GridVO grid) { |
| | | return R.data(gridService.getGridTree(grid)); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.grid.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | 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.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.grid.excel.GridExcel; |
| | | import org.springblade.modules.grid.excel.GridImporter; |
| | | import org.springblade.modules.grid.excel.GridmanExcel; |
| | | import org.springblade.modules.grid.excel.GridmanImporter; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.vo.GridmanVO; |
| | | import org.springblade.modules.grid.wrapper.GridmanWrapper; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * 网格员表 控制器 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("blade-gridman/gridman") |
| | | @Api(value = "网格员表", tags = "网格员表接口") |
| | | public class GridmanController { |
| | | |
| | | private final IGridmanService gridmanService; |
| | | |
| | | /** |
| | | * 网格员表 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入gridman") |
| | | public R<GridmanVO> detail(GridmanEntity gridman) { |
| | | GridmanEntity detail = gridmanService.getOne(Condition.getQueryWrapper(gridman)); |
| | | return R.data(GridmanWrapper.build().entityVO(detail)); |
| | | } |
| | | /** |
| | | * 网格员表 分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入gridman") |
| | | public R<IPage<GridmanVO>> list(GridmanEntity gridman, Query query) { |
| | | IPage<GridmanEntity> pages = gridmanService.page(Condition.getPage(query), Condition.getQueryWrapper(gridman)); |
| | | return R.data(GridmanWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 自定义分页 |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入gridman") |
| | | public R<IPage<GridmanVO>> page(GridmanVO gridman, Query query) { |
| | | IPage<GridmanVO> pages = gridmanService.selectGridmanPage(Condition.getPage(query), gridman); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入gridman") |
| | | public R save(@Valid @RequestBody GridmanEntity gridman) { |
| | | return R.status(gridmanService.save(gridman)); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入gridman") |
| | | public R update(@Valid @RequestBody GridmanEntity gridman) { |
| | | return R.status(gridmanService.updateById(gridman)); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入gridman") |
| | | public R submit(@Valid @RequestBody GridmanEntity gridman) { |
| | | return R.status(gridmanService.saveOrUpdate(gridman)); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 自定义新增或修改 |
| | | * @param gridman |
| | | * @return |
| | | */ |
| | | @PostMapping("/saveOrUpdate") |
| | | public R saveOrUpdate(@Valid @RequestBody GridmanEntity gridman) { |
| | | return R.status(gridmanService.saveOrUpdateGridman(gridman)); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(gridmanService.removeByIds(Func.toIntList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 导入网格员数据 |
| | | */ |
| | | @PostMapping("/import-gridman") |
| | | public R importGrid(MultipartFile file, Integer isCovered) { |
| | | GridmanImporter gridmanImporter = new GridmanImporter(gridmanService, isCovered == 1); |
| | | ExcelUtil.save(file, gridmanImporter, GridmanExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.grid.dto; |
| | | |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 网格员表 数据传输对象实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class GridmanDTO extends GridmanEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.springblade.modules.grid.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.alibaba.fastjson.support.geo.Geometry; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | |
| | | |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | import org.springblade.modules.grid.handle.GeometryTypeHandler; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | |
| | | @ApiModelProperty("主键id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | /** |
| | | * 机构id |
| | | */ |
| | | @ApiModelProperty(value = "机构id") |
| | | private Long deptId; |
| | | /** |
| | | * 社区编号 |
| | | */ |
| | | @ApiModelProperty(value = "社区编号") |
| | | private String communityCode; |
| | | /** |
| | | * 社区名称 |
| | | */ |
| | |
| | | * 网格面数据 |
| | | */ |
| | | @ApiModelProperty(value = "网格面数据") |
| | | // @TableField(typeHandler = GeometryTypeHandler.class) |
| | | private String geom; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value = "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("创建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long createUser; |
| | | |
| | | /** |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("创建时间") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("更新人") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updateUser; |
| | | |
| | | /** |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("更新时间") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 备注 |
| | | * 备注/简介 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | @ApiModelProperty(value = "备注/简介") |
| | | private String remark; |
| | | |
| | | /** |
| New file |
| | |
| | | /* |
| | | * 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.grid.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import lombok.Data; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * 网格员表 实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | @Data |
| | | @TableName("jczz_gridman") |
| | | @ApiModel(value = "Gridman对象", description = "网格员表") |
| | | public class GridmanEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("主键id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | /** |
| | | * 网格id |
| | | */ |
| | | @ApiModelProperty(value = "网格id") |
| | | private Integer gridId; |
| | | /** |
| | | * 关联用户表id |
| | | */ |
| | | @ApiModelProperty(value = "关联用户表id") |
| | | private Long userId; |
| | | /** |
| | | * 网格员名称 |
| | | */ |
| | | @ApiModelProperty(value = "网格员名称") |
| | | private String gridmanName; |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @ApiModelProperty(value = "手机号") |
| | | private String mobile; |
| | | |
| | | /** |
| | | * 形象照 |
| | | */ |
| | | @ApiModelProperty(value = "形象照") |
| | | private String picUrl; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("创建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long createUser; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("创建时间") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新人 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty("更新人") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Long updateUser; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("更新时间") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | | */ |
| | | @TableLogic |
| | | @ApiModelProperty("是否已删除 0:否 1:是") |
| | | private Integer isDeleted; |
| | | |
| | | } |
| New file |
| | |
| | | |
| | | package org.springblade.modules.grid.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 io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * GridExcel |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ColumnWidth(25) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | public class GridmanExcel implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("社区名称") |
| | | private String communityName; |
| | | |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("网格名称") |
| | | private String gridName; |
| | | |
| | | /** |
| | | * 网格员名称 |
| | | */ |
| | | @ApiModelProperty(value = "网格员姓名") |
| | | private String gridmanName; |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String mobile; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ColumnWidth(50) |
| | | @ExcelProperty("备注") |
| | | private String remark; |
| | | |
| | | } |
| New file |
| | |
| | | package org.springblade.modules.grid.excel; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.excel.support.ExcelImporter; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 网格员数据导入类 |
| | | * |
| | | * @author zhongrj |
| | | */ |
| | | @RequiredArgsConstructor |
| | | public class GridmanImporter implements ExcelImporter<GridmanExcel> { |
| | | |
| | | private final IGridmanService gridmanService; |
| | | private final Boolean isCovered; |
| | | |
| | | @Override |
| | | public void save(List<GridmanExcel> data) { |
| | | gridmanService.importGridman(data, isCovered); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.springblade.modules.grid.handle; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.PrecisionModel; |
| | | import com.vividsolutions.jts.io.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.type.BaseTypeHandler; |
| | | import org.apache.ibatis.type.JdbcType; |
| | | import org.apache.ibatis.type.MappedJdbcTypes; |
| | | import org.apache.ibatis.type.MappedTypes; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.sql.CallableStatement; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | |
| | | @MappedTypes({String.class}) |
| | | @MappedJdbcTypes({JdbcType.OTHER}) |
| | | @Slf4j |
| | | public class GeometryTypeHandler extends BaseTypeHandler<String> { |
| | | |
| | | |
| | | /** |
| | | * 设置转换 |
| | | * @param preparedStatement |
| | | * @param i |
| | | * @param s |
| | | * @param jdbcType |
| | | * @throws SQLException |
| | | */ |
| | | @Override |
| | | public void setNonNullParameter(PreparedStatement preparedStatement, int i, String s, JdbcType jdbcType) throws SQLException { |
| | | try{ |
| | | //String转Geometry |
| | | Geometry geo = new WKTReader(new GeometryFactory(new PrecisionModel())).read(s); |
| | | // Geometry转WKB |
| | | byte[] geometryBytes = new WKBWriter(2, ByteOrderValues.LITTLE_ENDIAN, false).write(geo); |
| | | // 设置SRID为mysql默认的 0 |
| | | byte[] wkb = new byte[geometryBytes.length+4]; |
| | | wkb[0] = wkb[1] = wkb[2] = wkb[3] = 0; |
| | | System.arraycopy(geometryBytes, 0, wkb, 4, geometryBytes.length); |
| | | preparedStatement.setBytes(i,wkb); |
| | | }catch (ParseException e){ |
| | | log.error("坐标转换异常:【{}】",e.getMessage(),e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getNullableResult(ResultSet resultSet, String s){ |
| | | try( |
| | | InputStream inputStream = resultSet.getBinaryStream(s)){ |
| | | Geometry geo = getGeometryFromInputStream(inputStream); |
| | | if(geo != null){ |
| | | return geo.toString(); |
| | | } |
| | | }catch(Exception e){ |
| | | log.error("坐标转换异常:【{}】",e.getMessage(),e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getNullableResult(ResultSet resultSet, int i){ |
| | | try(InputStream inputStream = resultSet.getBinaryStream(i)){ |
| | | Geometry geo = getGeometryFromInputStream(inputStream); |
| | | if(geo != null){ |
| | | return geo.toString(); |
| | | } |
| | | }catch(Exception e){ |
| | | log.error("坐标转换异常:【{}】",e.getMessage(),e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getNullableResult(CallableStatement callableStatement, int i) throws SQLException { |
| | | System.out.println("i = " + i); |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 流 转 geometry |
| | | * */ |
| | | private Geometry getGeometryFromInputStream(InputStream inputStream) throws Exception { |
| | | |
| | | Geometry dbGeometry = null; |
| | | |
| | | if (inputStream != null) { |
| | | // 二进制流转成字节数组 |
| | | byte[] buffer = new byte[255]; |
| | | |
| | | int bytesRead; |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | baos.write(buffer, 0, bytesRead); |
| | | } |
| | | // 得到字节数组 |
| | | byte[] geometryAsBytes = baos.toByteArray(); |
| | | // 字节数组小于5 异常 |
| | | if (geometryAsBytes.length < 5) { |
| | | throw new RuntimeException("坐标异常"); |
| | | } |
| | | |
| | | //字节数组前4个字节表示srid 去掉 |
| | | byte[] sridBytes = new byte[4]; |
| | | System.arraycopy(geometryAsBytes, 0, sridBytes, 0, 4); |
| | | boolean bigEndian = (geometryAsBytes[4] == 0x00); |
| | | // 解析srid |
| | | int srid = 0; |
| | | if (bigEndian) { |
| | | for (byte sridByte : sridBytes) { |
| | | srid = (srid << 8) + (sridByte & 0xff); |
| | | } |
| | | } else { |
| | | for (int i = 0; i < sridBytes.length; i++) { |
| | | srid += (sridBytes[i] & 0xff) << (8 * i); |
| | | } |
| | | } |
| | | |
| | | WKBReader wkbReader = new WKBReader(); |
| | | // WKBReader 把字节数组转成geometry对象。 |
| | | byte[] wkb = new byte[geometryAsBytes.length - 4]; |
| | | System.arraycopy(geometryAsBytes, 4, wkb, 0, wkb.length); |
| | | dbGeometry = wkbReader.read(wkb); |
| | | dbGeometry.setSRID(srid); |
| | | } |
| | | return dbGeometry; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.springblade.modules.grid.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.MapKey; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 网格表 Mapper 接口 |
| | |
| | | * @return |
| | | */ |
| | | GridVO getGridDetailByParam(@Param("place") PlaceVO place); |
| | | |
| | | /** |
| | | * 网格表 自定义详情 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | GridVO getGridDetail(@Param("grid") GridVO grid); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * @return |
| | | */ |
| | | List<GridEntity> selectGridAll(); |
| | | |
| | | /** |
| | | * 网格树 |
| | | * @return |
| | | */ |
| | | @MapKey(value = "id") |
| | | Map<String, TreeStringNode> getGridTree(); |
| | | } |
| | |
| | | |
| | | <!--自定义分页查询--> |
| | | <select id="selectGridPage" resultType="org.springblade.modules.grid.vo.GridVO"> |
| | | select * from jczz_grid where is_deleted = 0 |
| | | select |
| | | id,community_code,grid_name,principal,principal_phone,remark |
| | | from jczz_grid |
| | | where is_deleted = 0 |
| | | <if test="grid.communityCode!=null and grid.communityCode!=''"> |
| | | and community_code = #{grid.communityCode} |
| | | </if> |
| | | <if test="grid.gridName!=null and grid.gridName!=''"> |
| | | and grid_name like concat('%',#{grid.gridName},'%') |
| | | </if> |
| | | <if test="grid.principal!=null and grid.principal!=''"> |
| | | and principal like concat('%',#{grid.principal},'%') |
| | | </if> |
| | | <if test="grid.principalPhone!=null and grid.principalPhone!=''"> |
| | | and principal_phone like concat('%',#{grid.principalPhone},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | <!--根据地址编号查询网格数据--> |
| | |
| | | <!--根据用户id(网格员)查询对应的房屋地址code--> |
| | | <select id="getAddressCodeListByUserId" resultType="java.lang.String"> |
| | | select jgr.house_code from jczz_grid_range jgr |
| | | left join jczz_grid jg on jg.id = jgr.grid_id |
| | | where jg.is_deleted = 0 |
| | | and jg.user_id = #{userId} |
| | | left join jczz_grid jg on jg.id = jgr.grid_id and jg.is_deleted = 0 |
| | | left join jczz_gridman jgm on jgm.grid_id = jg.id and jgm.is_deleted = 0 |
| | | where 1=1 |
| | | and jgm.user_id = #{userId} |
| | | </select> |
| | | |
| | | <!--判断该小区点在哪个派出所--> |
| | |
| | | |
| | | <!--根据地址编号查询网格数据--> |
| | | <select id="getGridDetailByParam" resultType="org.springblade.modules.grid.vo.GridVO"> |
| | | select jg.id,jg.grid_name,jg.community_name, |
| | | select jg.id,jg.grid_name,jg.community_name,sort, |
| | | bu.real_name as realName,bu.phone as gridPhone |
| | | from jczz_grid jg |
| | | left join jczz_grid_range jgr on jg.id = jgr.grid_id |
| | |
| | | limit 1 |
| | | </select> |
| | | |
| | | <!--自定义详情查询--> |
| | | <select id="getGridDetail" resultType="org.springblade.modules.grid.vo.GridVO"> |
| | | select id,community_code,grid_name,principal,principal_phone,remark,sort from jczz_grid |
| | | where is_deleted = 0 and id = #{grid.id} |
| | | </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 |
| | | where is_deleted = 0 |
| | | </select> |
| | | |
| | | <!--网格树--> |
| | | <select id="getGridTree" resultType="org.springblade.common.node.TreeStringNode"> |
| | | SELECT |
| | | code as id, |
| | | parent_code as parentId, |
| | | name |
| | | FROM blade_region where district_code = '361102' |
| | | union all |
| | | ( |
| | | select |
| | | id, |
| | | community_code as parentId, |
| | | grid_name as name |
| | | from jczz_grid |
| | | where is_deleted = 0 |
| | | ) |
| | | </select> |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * 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.grid.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.vo.GridmanVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 网格员表 Mapper 接口 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | public interface GridmanMapper extends BaseMapper<GridmanEntity> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param gridman |
| | | * @return |
| | | */ |
| | | List<GridmanVO> selectGridmanPage(IPage page,@Param("gridman") GridmanVO gridman); |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.modules.grid.mapper.GridmanMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="gridmanResultMap" type="org.springblade.modules.grid.entity.GridmanEntity"> |
| | | <result column="id" property="id"/> |
| | | <result column="grid_id" property="gridId"/> |
| | | <result column="user_id" property="userId"/> |
| | | <result column="gridman_name" property="gridmanName"/> |
| | | <result column="mobile" property="mobile"/> |
| | | <result column="remark" property="remark"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <!--自定义分页查询--> |
| | | <select id="selectGridmanPage" resultType="org.springblade.modules.grid.vo.GridmanVO"> |
| | | select |
| | | jgm.*,jg.community_code communityCode |
| | | from jczz_gridman jgm |
| | | left join jczz_grid jg on jg.id = jgm.grid_id and jg.is_deleted = 0 |
| | | where jgm.is_deleted = 0 |
| | | <if test="gridman.gridmanName!=null and gridman.gridmanName!=''"> |
| | | and jgm.gridman_name like concat('%',#{gridman.gridmanName},'%') |
| | | </if> |
| | | <if test="gridman.mobile!=null and gridman.mobile!=''"> |
| | | and jgm.mobile like concat('%',#{gridman.mobile},'%') |
| | | </if> |
| | | <if test="gridman.gridId!=null"> |
| | | and jg.id = #{gridman.gridId} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.excel.GridExcel; |
| | | import org.springblade.modules.grid.excel.GridmanExcel; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | * @return |
| | | */ |
| | | GridVO getGridDetailByParam(PlaceVO place); |
| | | |
| | | /** |
| | | * 网格表 自定义详情 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | GridVO getGridDetail(GridVO grid); |
| | | |
| | | /** |
| | | * 网格表 自定义新增或修改 |
| | | */ |
| | | boolean saveOrUpdateGrid(GridEntity grid); |
| | | |
| | | /** |
| | | * 网格数据同步处理 |
| | | */ |
| | | Object asyncGridDept(); |
| | | |
| | | /** |
| | | * 网格树 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | Object getGridTree(GridVO grid); |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.grid.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.excel.GridmanExcel; |
| | | import org.springblade.modules.grid.vo.GridmanVO; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 网格员表 服务类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | public interface IGridmanService extends IService<GridmanEntity> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param gridman |
| | | * @return |
| | | */ |
| | | IPage<GridmanVO> selectGridmanPage(IPage<GridmanVO> page, GridmanVO gridman); |
| | | |
| | | /** |
| | | * 网格员表 自定义新增或修改 |
| | | * @param gridman |
| | | * @return |
| | | */ |
| | | boolean saveOrUpdateGridman(GridmanEntity gridman); |
| | | |
| | | /** |
| | | * 网格员导入 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | void importGridman(List<GridmanExcel> data, Boolean isCovered); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity; |
| | |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | public class GridServiceImpl extends ServiceImpl<GridMapper, GridEntity> implements IGridService { |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | @Autowired |
| | | private IDoorplateAddressService doorplateAddressService; |
| | | |
| | | @Autowired |
| | | private IGridRangeService gridRangeService; |
| | | |
| | | @Autowired |
| | | private IDeptService deptService; |
| | | |
| | | @Override |
| | | public IPage<GridVO> selectGridPage(IPage<GridVO> page, GridVO grid) { |
| | |
| | | // 取出名称分隔 |
| | | String[] split = gridExcel.getGridName().split("居民委员会"); |
| | | GridEntity gridEntity = new GridEntity(); |
| | | gridEntity.setCommunityName(split[0] + "居民委员会"); |
| | | String communityName = split[0] + "居民委员会"; |
| | | gridEntity.setCommunityName(communityName); |
| | | // 通过社区名称查询对应的社区编号 |
| | | QueryWrapper<Region> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("name",split[0]); |
| | | Region region = regionService.getOne(wrapper); |
| | | if (null!=region){ |
| | | gridEntity.setCommunityCode(region.getCode()); |
| | | } |
| | | gridEntity.setGridName(split[1]); |
| | | gridEntity.setGeom(gridExcel.getGeom()); |
| | | gridEntity.setCreateUser(AuthUtil.getUserId()); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object spatialAnalysis() { |
| | | // 按社区 |
| | | // String name = "万达社区居民委员会"; |
| | | String name = "茶山路社区居民委员会"; |
| | | String name = "万达社区居民委员会"; |
| | | // String name = "茶山路社区居民委员会"; |
| | | //查询社区信息 |
| | | List<DoorplateAddressEntity> doorplateAddressEntities = doorplateAddressService.getAllDoorplateAddress(name); |
| | | //遍历 |
| | |
| | | public GridVO getGridDetailByParam(PlaceVO place) { |
| | | return baseMapper.getGridDetailByParam(place); |
| | | } |
| | | |
| | | /** |
| | | * 网格表 自定义详情 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public GridVO getGridDetail(GridVO grid) { |
| | | return baseMapper.getGridDetail(grid); |
| | | } |
| | | |
| | | /** |
| | | * 网格表 自定义新增或修改 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrUpdateGrid(GridEntity grid) { |
| | | boolean flag = false; |
| | | // 先查询当前网格社区对应的机构id |
| | | QueryWrapper<Region> regionWrapper = new QueryWrapper<>(); |
| | | regionWrapper.eq("code",grid.getCommunityCode()); |
| | | Region region = regionService.getOne(regionWrapper); |
| | | // 查询父机构 |
| | | QueryWrapper<Dept> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("dept_name",region.getName()) |
| | | .eq("is_deleted",0); |
| | | Dept dept = deptService.getOne(wrapper); |
| | | // 查询当前网格在机构中是否存在,存在不做操作,否则则新增 |
| | | 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){ |
| | | Dept deptInfo = new Dept(); |
| | | deptInfo.setParentId(dept.getId()); |
| | | deptInfo.setFullName(grid.getGridName()); |
| | | deptInfo.setDeptName(grid.getGridName()); |
| | | deptInfo.setDeptCategory(1); |
| | | deptInfo.setTenantId("000000"); |
| | | // 新增 |
| | | deptService.save(deptInfo); |
| | | // 查询网格是否已存在(社区编号-网格名称),已存在更新,不存在插入新的 |
| | | QueryWrapper<GridEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("grid_name",grid.getGridName()) |
| | | .eq("is_deleted",0) |
| | | .eq("community_code",grid.getCommunityCode()); |
| | | GridEntity one = getOne(queryWrapper); |
| | | if (null!=one){ |
| | | grid.setId(one.getId()); |
| | | grid.setDeptId(deptInfo.getId()); |
| | | if (null!= grid.getGeom() && grid.getGeom().equals("")){ |
| | | grid.setGeom(null); |
| | | } |
| | | // 更新 |
| | | flag = updateById(grid); |
| | | }else { |
| | | grid.setDeptId(deptInfo.getId()); |
| | | grid.setGeom(null); |
| | | // 插入 |
| | | flag = save(grid); |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 网格数据同步处理 |
| | | */ |
| | | @Override |
| | | public Object asyncGridDept() { |
| | | List<GridEntity> list = baseMapper.selectGridAll(); |
| | | for (GridEntity gridEntity : list) { |
| | | saveOrUpdateGrid(gridEntity); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 网格树 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getGridTree(GridVO grid) { |
| | | return NodeTreeUtil.getStringNodeTree(baseMapper.getGridTree()); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.grid.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.excel.GridmanExcel; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.vo.GridmanVO; |
| | | import org.springblade.modules.grid.mapper.GridmanMapper; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | 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.IRegionService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 网格员表 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | @Service |
| | | public class GridmanServiceImpl extends ServiceImpl<GridmanMapper, GridmanEntity> implements IGridmanService { |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private IGridService gridService; |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | @Override |
| | | public IPage<GridmanVO> selectGridmanPage(IPage<GridmanVO> page, GridmanVO gridman) { |
| | | return page.setRecords(baseMapper.selectGridmanPage(page, gridman)); |
| | | } |
| | | |
| | | /** |
| | | * 网格员表 自定义新增或修改 |
| | | * @param gridman |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrUpdateGridman(GridmanEntity gridman) { |
| | | boolean flag = false; |
| | | // 修改 |
| | | if (null!=gridman.getId()) { |
| | | // 更新网格员信息 |
| | | flag = updateById(gridman); |
| | | }else { |
| | | // 新增 |
| | | // 先判断用户表中是否已存在该用户,如果已存在则不新增,需要更新角色 |
| | | QueryWrapper<User> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0).eq("account", gridman.getMobile()); |
| | | List<User> list = userService.list(wrapper); |
| | | // 更新用户,查询是否需要更新角色 |
| | | if (list.size() > 0) { |
| | | // 默认取出第一个 |
| | | User user = list.get(0); |
| | | // 判断角色是否包好网格员的角色,如果没有则加入网格员的角色,有则不更改 |
| | | if (!user.getRoleId().contains("1717429261910528001")) { |
| | | user.setRoleId(user.getRoleId() + "," + "1717429261910528001"); |
| | | // 更新用户信息 |
| | | userService.updateById(user); |
| | | } |
| | | //插入网格员信息 |
| | | gridman.setUserId(user.getId()); |
| | | flag = save(gridman); |
| | | } else { |
| | | saveUser(gridman); |
| | | // 插入网格员信息 |
| | | flag = save(gridman); |
| | | } |
| | | } |
| | | // 返回 |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 用户新增 |
| | | * @param gridman |
| | | */ |
| | | public void saveUser(GridmanEntity gridman) { |
| | | // 新增用户 |
| | | User userInfo = new User(); |
| | | // 设置机构 |
| | | GridEntity gridEntity = gridService.getById(gridman.getGridId()); |
| | | if (null != gridEntity) { |
| | | userInfo.setDeptId(gridEntity.getDeptId().toString()); |
| | | } |
| | | // 设置账号信息 |
| | | userInfo.setAccount(gridman.getMobile()); |
| | | userInfo.setPhone(gridman.getMobile()); |
| | | userInfo.setName(gridman.getGridmanName()); |
| | | userInfo.setRealName(gridman.getGridmanName()); |
| | | // 设置网格员角色 |
| | | userInfo.setRoleId("1717429261910528001"); |
| | | // 设置密码,默认密码为 123456 |
| | | userInfo.setPassword("123456"); |
| | | // 插入用户 |
| | | userService.submit(userInfo); |
| | | // 设置网格信息 |
| | | gridman.setUserId(userInfo.getId()); |
| | | } |
| | | |
| | | /** |
| | | * 网格员导入 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importGridman(List<GridmanExcel> data, Boolean isCovered) { |
| | | // 遍历 |
| | | for (GridmanExcel gridmanExcel : data) { |
| | | GridmanEntity gridmanEntity = Objects.requireNonNull(BeanUtil.copy(gridmanExcel, GridmanEntity.class)); |
| | | // 先查询当前网格社区对应的机构id |
| | | QueryWrapper<Region> regionWrapper = new QueryWrapper<>(); |
| | | regionWrapper.eq("name",gridmanExcel.getCommunityName()); |
| | | Region region = regionService.getOne(regionWrapper); |
| | | // 通过社区名称和网格名称获取网格id |
| | | QueryWrapper<GridEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0) |
| | | .eq("community_code",region.getCode()) |
| | | .eq("grid_name",gridmanExcel.getGridName()); |
| | | GridEntity gridEntity = gridService.getOne(queryWrapper); |
| | | // 设置网格id |
| | | gridmanEntity.setGridId(gridEntity.getId()); |
| | | // 通过手机号查询网格员id |
| | | QueryWrapper<GridmanEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("mobile",gridmanEntity.getMobile()); |
| | | GridmanEntity one = getOne(wrapper); |
| | | if (one!=null){ |
| | | gridmanEntity.setId(one.getId()); |
| | | } |
| | | // 插入网格员 |
| | | saveOrUpdateGridman(gridmanEntity); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.grid.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.core.tool.node.INode; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 网格员表 视图实体类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class GridmanVO extends GridmanEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 社区编号 |
| | | */ |
| | | @ApiModelProperty(value = "社区编号") |
| | | private String communityCode; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.grid.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.vo.GridmanVO; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 网格员表 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author BladeX |
| | | * @since 2023-11-27 |
| | | */ |
| | | public class GridmanWrapper extends BaseEntityWrapper<GridmanEntity, GridmanVO> { |
| | | |
| | | public static GridmanWrapper build() { |
| | | return new GridmanWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public GridmanVO entityVO(GridmanEntity gridman) { |
| | | GridmanVO gridmanVO = Objects.requireNonNull(BeanUtil.copy(gridman, GridmanVO.class)); |
| | | |
| | | //User createUser = UserCache.getUser(gridman.getCreateUser()); |
| | | //User updateUser = UserCache.getUser(gridman.getUpdateUser()); |
| | | //gridmanVO.setCreateUserName(createUser.getName()); |
| | | //gridmanVO.setUpdateUserName(updateUser.getName()); |
| | | |
| | | return gridmanVO; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package org.springblade.modules.house.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | |
| | | // 更新 |
| | | flag = updateById(household); |
| | | }else { |
| | | // 往用户表中插入数据 |
| | | // 通过手机号判断 |
| | | if (!Strings.isBlank(household.getPhoneNumber())){ |
| | | //判断用户是否存在 |
| | | |
| | | } |
| | | // 新增 |
| | | household.setCreateTime(new Date()); |
| | | household.setCreateUser(AuthUtil.getUserId()); |
| | |
| | | userParams.setPhone(placeVO.getPhone()); |
| | | User user = userService.getOne(Condition.getQueryWrapper(userParams)); |
| | | |
| | | if (user != null) { |
| | | if (null!=user) { |
| | | //如果用户存在,则该用户id绑定场所 |
| | | placeVO.setPrincipalUserId(user.getId()); |
| | | newUser = user; |
| | | // 判断用户是否包含了居民角色,不包含则需更新 |
| | | if (!user.getRoleId().contains("1717429059648606209")){ |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | //更新 |
| | | userService.updateById(user); |
| | | } |
| | | } else { |
| | | //如果用户不存在,则新增一个用户 |
| | | newUser.setAccount(placeVO.getPhone()); |
| | | newUser.setPhone(placeVO.getPhone()); |
| | | newUser.setName(placeVO.getUsername()); |
| | | newUser.setRealName(placeVO.getUsername()); |
| | | // 目前暂定居民角色,默认密码为 123456 |
| | | // 社区群众部门 |
| | | newUser.setDeptId("1727979636479037441"); |
| | | // 目前暂定居民角色, |
| | | newUser.setRoleId("1717429059648606209"); |
| | | //默认密码为 123456 |
| | | newUser.setPassword("123456"); |
| | | // 设置机构 |
| | | // 用户新增 |
| | | boolean submit = userService.submit(newUser); |
| | | //绑定id |