增加网格地图功能

This commit is contained in:
TS-QD1 2023-08-26 15:59:47 +08:00
parent d688b8338e
commit be3fa53cb6
6 changed files with 451 additions and 1 deletions

View File

@ -0,0 +1,31 @@
package cn.com.tenlion.usercenter.controller.api.map.count;
import cn.com.tenlion.usercenter.service.map.count.MapCountService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.common.manager.env.EnvManager;
import ink.wgink.interfaces.consts.ISystemConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/map/count")
public class MapCountController {
@Autowired
private MapCountService mapCountService;
@GetMapping("get-grid-person/{gridCode}")
JSONObject getGridPerson(@PathVariable("gridCode") String gridCode) {
return mapCountService.getGridPerson(gridCode);
}
@GetMapping("list-grid-info/{gridCode}")
JSONArray listGridInfo(@PathVariable("gridCode") String gridCode) {
return mapCountService.listGridInfo(gridCode);
}
}

View File

@ -0,0 +1,37 @@
package cn.com.tenlion.usercenter.controller.route.map.count;
import ink.wgink.common.manager.env.EnvManager;
import ink.wgink.interfaces.consts.IGisConstant;
import ink.wgink.interfaces.consts.ISystemConstant;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/map/count")
public class MapCountRouteController {
@GetMapping("map-count")
public ModelAndView mapCount() {
ModelAndView mv = new ModelAndView("map/count/map-count");
setConfig(mv);
return mv;
}
private void setConfig(ModelAndView modelAndView) {
EnvManager envManager = EnvManager.getInstance();
Map<String, Object> baiduMapProperties = new HashMap<>(5);
baiduMapProperties.put("centerLng", envManager.getValue(IGisConstant.GIS_MAP_CENTER_LNG));
baiduMapProperties.put("centerLat", envManager.getValue(IGisConstant.GIS_MAP_CENTER_LAT));
baiduMapProperties.put("zoom", envManager.getValue(IGisConstant.GIS_MAP_CENTER_ZOOM));
baiduMapProperties.put("boundary", envManager.getValue(IGisConstant.GIS_MAP_BAIDU_BOUNDARY));
baiduMapProperties.put("ak", envManager.getValue(IGisConstant.GIS_MAP_BAIDU_AK));
modelAndView.addObject("baiduMapProperties", baiduMapProperties);
}
}

View File

@ -0,0 +1,19 @@
package cn.com.tenlion.usercenter.remote.client;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.annotation.rpc.rest.RemoteService;
import ink.wgink.annotation.rpc.rest.method.RemoteGetMethod;
import ink.wgink.annotation.rpc.rest.params.RemotePathParams;
import ink.wgink.annotation.rpc.rest.params.RemoteServerParams;
@RemoteService
public interface ICaseRemoteService {
@RemoteGetMethod("/app/populationreport/get-bygridcode/{gridCode}/release")
JSONObject getGridPerson(@RemoteServerParams String server, @RemotePathParams("gridCode") String gridCode);
@RemoteGetMethod("app/placereport/listgridplacetype/{gridCode}/release")
JSONArray listGridInfo(@RemoteServerParams String server, @RemotePathParams("gridCode") String gridCode);
}

View File

@ -12,10 +12,14 @@ import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler;
import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.service.role.service.IRoleUserService; import ink.wgink.service.role.service.IRoleUserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.Years;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -78,6 +82,9 @@ public class RoleUserSaveAfterHandlerImpl implements IRoleUserSaveAfterHandler {
dataMap.put("user_avatar", userExpandDTO.getUserAvatar()); dataMap.put("user_avatar", userExpandDTO.getUserAvatar());
dataMap.put("area_name", userExpandDTO.getAreaName()); dataMap.put("area_name", userExpandDTO.getAreaName());
dataMap.put("area_code", userExpandDTO.getAreaCode()); dataMap.put("area_code", userExpandDTO.getAreaCode());
dataMap.put("user_sex", userExpandDTO.getUserSexName());
dataMap.put("user_birth", userExpandDTO.getUserBirth());
dataMap.put("user_education", userExpandDTO.getUserEducationName());
syncDataDTO.setData(dataMap); syncDataDTO.setData(dataMap);
kafkaTemplate.send(ISmartCityUserCenterConsts.KAFKA_TOPIC_TABLE_SYNC, JSONObject.toJSONString(syncDataDTO)); kafkaTemplate.send(ISmartCityUserCenterConsts.KAFKA_TOPIC_TABLE_SYNC, JSONObject.toJSONString(syncDataDTO));
} }
@ -111,9 +118,11 @@ public class RoleUserSaveAfterHandlerImpl implements IRoleUserSaveAfterHandler {
if (userExpandPO != null) { if (userExpandPO != null) {
dataMap.put("area_name", userExpandPO.getAreaName()); dataMap.put("area_name", userExpandPO.getAreaName());
dataMap.put("area_code", userExpandPO.getAreaCode()); dataMap.put("area_code", userExpandPO.getAreaCode());
dataMap.put("user_sex", userExpandPO.getUserSexName());
dataMap.put("user_birth", userExpandPO.getUserBirth());
dataMap.put("user_education", userExpandPO.getUserEducationName());
} }
syncDataDTO.setData(dataMap); syncDataDTO.setData(dataMap);
kafkaTemplate.send(ISmartCityUserCenterConsts.KAFKA_TOPIC_TABLE_SYNC, JSONObject.toJSONString(syncDataDTO)); kafkaTemplate.send(ISmartCityUserCenterConsts.KAFKA_TOPIC_TABLE_SYNC, JSONObject.toJSONString(syncDataDTO));
} }
} }

View File

@ -0,0 +1,26 @@
package cn.com.tenlion.usercenter.service.map.count;
import cn.com.tenlion.usercenter.remote.client.ICaseRemoteService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.common.manager.env.EnvManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class MapCountService {
@Autowired
private ICaseRemoteService caseRemoteService;
public JSONObject getGridPerson(String gridCode) {
String server = EnvManager.getInstance().getValue("clientCaseServer");
return caseRemoteService.getGridPerson(server, gridCode);
}
public JSONArray listGridInfo(String gridCode) {
String server = EnvManager.getInstance().getValue("clientCaseServer");
return caseRemoteService.listGridInfo(server, gridCode);
}
}

View File

@ -0,0 +1,328 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>网格地图</title>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
.layui-form-label-up {width: 100% !important; height: 30px !important; line-height: 30px !important; border: none !important; padding: 0px !important; font-size: 15px; background-color: transparent !important; text-align: left !important;}
.layui-input-block-down {margin: 0px !important; left: 0px !important;}
.layui-input-block-down .layui-form-select .layui-edge {top: 74%;}
.table-select-area {position: relative; width: 400px;}
.table-select-area #areaName {width: 82%}
.table-select-area .select-btn {position: absolute; top: 0px; right: 0px; width: 18%; border-color: #e6e6e6;}
</style>
</head>
<body>
<div class="layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-body" style="padding: 15px;">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline table-select-area">
<input type="hidden" id="areaCode" value="150902000000">
<input type="text" id="areaName" class="layui-input search-item search-item-width-300" placeholder="选择地区" value="乌兰察布市 / 集宁区" readonly>
<div class="layui-btn-group select-btn">
<button type="button" id="areaSelectBtn" class="layui-btn layui-btn-sm layui-btn-primary" title="选择区域">
<i class="fa fa-circle-thin"></i>
</button>
<button type="button" id="areaCleanBtn" class="layui-btn layui-btn-sm layui-btn-primary" title="删除区域">
<i class="fa fa-times-circle"></i>
</button>
</div>
</div>
<div class="layui-btn-group">
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
<button type="button" id="goback" class="layui-btn layui-btn-sm layui-btn-normal" onclick="window.location.href = '/usercenter'">
<i class="fa fa-lg fa-backward"></i> 返回首页
</button>
</div>
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div id="baiduMapContainer"></div>
</form>
</div>
</div>
</div>
<script type="text/javascript" th:src="'http://api.map.baidu.com/api?v=3.0&ak='+ ${baiduMapProperties.ak}"></script>
<script type="text/javascript" src="static/baidu-map/baidu-map-1.0.0.min.js?v=2"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script th:inline="javascript">
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl', 'restajax', 'dialog', 'datamessage'], function(){
var $ = layui.$;
var $win = $(window);
var form = layui.form;
var layer = layui.layer;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var ajax = layui.restajax;
var dialog = layui.dialog;
var dataMessage = layui.datamessage;
window['restAjax'] = ajax;
window['dialog'] = dialog;
window['dataMessage'] = dataMessage;
var mapAreaCode = null;
var layerBtnGroupIndex = null;
var centerPoint = {
lng: [[${baiduMapProperties.centerLng}]],
lat: [[${baiduMapProperties.centerLat}]]
}
var baiduMap = null;
var gridMember = {
users: [],
gridArray: []
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化网格背景
function initGridBG(callback) {
baiduMap.clearMap();
var layIndex;
ajax.get(ajax.path('api/grid/list-all-with-point/area-code/{areaCode}', [mapAreaCode ? mapAreaCode : '150902000000']), {}, null, function(code, data) {
var gridArray = [];
for(var i = 0, item; item = data[i++];) {
var pointArray = [];
for(var j = 0, jItem; jItem = item.pointArray[j++];) {
pointArray.push(new BaiduMap.Point(jItem.lng, jItem.lat));
}
gridArray.push({
id: item.gridId,
label: item.gridName,
code: item.gridCode,
fillColor: item.fillColor,
pointArray: pointArray
})
}
baiduMap.initBackgroundGrid({
gridArray: gridArray,
onClick: function(grid) {
layerBtnGroupIndex = layer.open({
type: 1,
title: `${grid.label}[${grid.code}]`,
closeBtn: false,
shadeClose: true,
content: `
<div style="padding: 15px;">
<div class="layui-btn-group">
<button type="button" class="layui-btn" id="gridPersonBtn" data-code="${grid.code}" data-name="${grid.label}">网格基本信息</button>
<button type="button" class="layui-btn layui-btn-primary" id="gridInfoBtn" data-code="${grid.code}" data-name="${grid.label}">网格场所情况</button>
</div>
</div>
`
});
},
});
callback ? callback() : '';
}, function(code, data) {
dialog.msg(data.msg);
}, function () {
layIndex = dialog.msg(dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function () {
dialog.close(layIndex);
});
}
function initMap(callback) {
$('#baiduMapContainer').css({
width: '100%',
height: ($win.height() - 70) +'px'
});
baiduMap = new BaiduMap('baiduMapContainer', {
single: true,
});
baiduMap.setCenterAndZoom(centerPoint, 14);
var mapTypeControl = new BMap.MapTypeControl({
mapTypes: [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP],
});
baiduMap.getMap().addControl(mapTypeControl);
baiduMap.setDefaultConfig();
baiduMap.initGridOptionEvent();
baiduMap.initColorOption();
callback ? callback() : '';
}
// 初始化内容
function initData() {
initMap(function() {
initGridBG();
});
}
initData();
// 地区选择事件
(function() {
$(document).on('click', '#areaSelectBtn', function() {
dialog.open({
title: '选择地区',
url: ajax.path('route/area/get-select', []),
width: '600px',
height: '225px',
onClose: function() {
var selectedAreaArray = dialog.dialogData.selectedAreaArray;
var areaCode = '';
var areaName = '';
if(selectedAreaArray.length > 1) {
areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
for(var i = 0, item; item = selectedAreaArray[i++];) {
if(areaName) {
areaName += ' / ';
}
areaName += item.areaName;
}
$('#areaCode').val(areaCode);
$('#areaName').val(areaName);
mapAreaCode = areaCode;
} else {
dialog.msg('至少选择旗县区一级');
}
}
})
});
$(document).on('click', '#areaCleanBtn', function () {
$('#areaCode').val('150902000000');
$('#areaName').val('乌兰察布市 / 集宁区');
mapAreaCode = '150902000000';
})
})()
// 事件 - 搜索
$(document).on('click', '#search', function() {
initGridBG();
});
$(document).on('click', '#gridPersonBtn', function() {
layer.close(layerBtnGroupIndex);
let gridCode = this.dataset.code;
let gridName = this.dataset.name;
let layIndex = null;
ajax.get(ajax.path('api/map/count/get-grid-person/{gridCode}', [gridCode]), {}, null, function(code, data) {
layer.open({
type: 1,
title: `网格基本情况:${gridName}`,
shadeClose: true,
area: ['320px', 'audo'],
content: `
<div style="padding: 0 15px;">
<table class="layui-table">
<colgroup>
<col width="200">
<col>
</colgroup>
<tbody>
<tr>
<td>总人口数</td>
<td>${data.populationTotalNum}人</td>
</tr>
<tr>
<td>常住人口数</td>
<td>${data.populationResidentNum}人</td>
</tr>
<tr>
<td colspan="2">其中</td>
</tr>
<tr>
<td>重点信访人</td>
<td>${data.petitionNum}人</td>
</tr>
<tr>
<td>社区矫正人员</td>
<td>${data.communityCorrectionNum}人</td>
</tr>
<tr>
<td>易肇事肇祸精神障碍患者</td>
<td>${data.mentallyDisabledNum}人</td>
</tr>
<tr>
<td>刑满释放人员</td>
<td>${data.crimeReleaseNum}人</td>
</tr>
<tr>
<td>邪教人员</td>
<td>${data.cultistNum}人</td>
</tr>
<tr>
<td>吸毒人员</td>
<td>${data.drugAddictNum}人</td>
</tr>
</tbody>
</table>
</div>
`
});
}, function(code, data) {
dialog.msg(data.msg);
}, function () {
layIndex = dialog.msg(dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function () {
dialog.close(layIndex);
});
})
$(document).on('click', '#gridInfoBtn', function() {
layer.close(layerBtnGroupIndex);
let gridCode = this.dataset.code;
let gridName = this.dataset.name;
ajax.get(ajax.path('api/map/count/list-grid-info/{gridCode}', [gridCode]), {}, null, function(code, data) {
if(data.length == 0) {
dialog.msg('暂无数据');
return;
}
let trs = '';
$.each(data, function(index, item) {
trs += `
<tr>
<td>${item.placeTypeName}</td>
<td>${item.placeName}</td>
</tr>
`;
})
layer.open({
type: 1,
title: `网格场所情况:${gridName}`,
shadeClose: true,
area: ['800px', 'auto'],
maxHeight: '500px',
content: `
<div style="padding: 0 15px;">
<table class="layui-table">
<colgroup>
<col width="100">
<col>
</colgroup>
<tbody>${trs}</tbody>
</table>
</div>
`
});
}, function(code, data) {
dialog.msg(data.msg);
}, function () {
layIndex = dialog.msg(dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function () {
dialog.close(layIndex);
});
})
// 校验
form.verify({});
});
</script>
</body>
</html>