From e2040cd2ca956989c013d362ed4de596108eddc1 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Fri, 11 Feb 2022 16:15:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=BD=91=E6=A0=BC=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/grid/impl/GridServiceImpl.java | 42 +++++++++-- .../mybatis/mapper/grid/grid-mapper.xml | 9 +++ .../templates/grid/grid/default/list.html | 2 +- .../templates/grid/grid/default/save.html | 70 +++++++++++------- .../grid/grid/default/show-grid.html | 3 +- .../templates/grid/grid/default/update.html | 72 +++++++++++++------ 6 files changed, 143 insertions(+), 55 deletions(-) diff --git a/module-map/src/main/java/ink/wgink/module/map/service/grid/impl/GridServiceImpl.java b/module-map/src/main/java/ink/wgink/module/map/service/grid/impl/GridServiceImpl.java index fbc027b5..d38d9c8e 100644 --- a/module-map/src/main/java/ink/wgink/module/map/service/grid/impl/GridServiceImpl.java +++ b/module-map/src/main/java/ink/wgink/module/map/service/grid/impl/GridServiceImpl.java @@ -71,9 +71,8 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService Map params = HashMapUtil.beanToMap(gridVO); params.put("gridSquare", getSquare(pointArray)); params.put("fillColor", gridVO.getGrid().getFillColor()); - GridPO areaLastPO = getAreaLastPO(gridVO.getAreaCode()); - String areaCode = areaLastPO == null ? String.format("%s001", gridVO.getAreaCode().substring(0, 12)) : String.valueOf(Long.valueOf(areaLastPO.getGridCode()) + 1); - params.put("gridCode", areaCode); + String gridCode = getSaveGridCode(gridVO.getAreaCode()); + params.put("gridCode", gridCode); params.put("gridId", gridId); params.remove("relationIdArray"); params.remove("pointArray"); @@ -84,7 +83,7 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService gridRelationService.save(gridId, relationIdArray); gridPointService.save(gridId, pointArray); if (gridSaveAfterHandler != null) { - gridSaveAfterHandler.handle(gridId, areaCode, gridVO.getGridName(), gridVO.getGrid().getFillColor(), gridVO.getAreaCode(), gridVO.getAreaName()); + gridSaveAfterHandler.handle(gridId, gridCode, gridVO.getGridName(), gridVO.getGrid().getFillColor(), gridVO.getAreaCode(), gridVO.getAreaName()); } return gridId; } @@ -164,10 +163,18 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService @Override public void update(String gridId, GridVO gridVO) throws Exception { + GridDTO gridDTO = get(gridId); + if (gridDTO == null) { + throw new SearchException("网格不存在"); + } GridVO.Grid grid = gridVO.getGrid(); Map params = HashMapUtil.beanToMap(gridVO); params.put("fillColor", gridVO.getGrid().getFillColor()); params.put("gridSquare", getSquare(grid.getPointArray())); + if (!StringUtils.equals(gridDTO.getAreaCode(), gridVO.getAreaCode())) { + String gridCode = getUpdateGridCode(gridVO.getAreaCode(), gridDTO.getGridCode()); + params.put("gridCode", gridCode); + } params.put("gridId", gridId); setUpdateInfo(params); gridDao.update(params); @@ -183,7 +190,6 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService @Override public GridDTO get(Map params) { GridDTO gridDTO = gridDao.get(params); - return gridDTO; } @@ -555,4 +561,30 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService return gridDao.getAreaLastPO(params); } + /** + * 获取新增网格编码 + * + * @param areaCode + * @return + */ + private String getSaveGridCode(String areaCode) { + GridPO areaLastPO = getAreaLastPO(areaCode); + return areaLastPO == null ? String.format("%s001", areaLastPO.getAreaCode().substring(0, 12)) : String.valueOf(Long.valueOf(areaLastPO.getGridCode()) + 1); + } + + /** + * 获取修改网格编码 + * + * @param areaCode + * @param gridCode + * @return + */ + private String getUpdateGridCode(String areaCode, String gridCode) { + GridPO areaLastPO = getAreaLastPO(areaCode); + if (areaLastPO == null) { + return String.format("%s001", areaCode); + } + return areaCode + String.format("%03d", Integer.parseInt(gridCode.substring(12, 15)) + 1); + } + } diff --git a/module-map/src/main/resources/mybatis/mapper/grid/grid-mapper.xml b/module-map/src/main/resources/mybatis/mapper/grid/grid-mapper.xml index dec0ba39..06ba278b 100644 --- a/module-map/src/main/resources/mybatis/mapper/grid/grid-mapper.xml +++ b/module-map/src/main/resources/mybatis/mapper/grid/grid-mapper.xml @@ -156,6 +156,15 @@ fill_color = #{fillColor}, + + + grid_code = #{gridCode}, + + + area_code = #{areaCode}, + + + area_name = #{areaName}, gmt_modified = #{gmtModified}, modifier = #{modifier} diff --git a/module-map/src/main/resources/templates/grid/grid/default/list.html b/module-map/src/main/resources/templates/grid/grid/default/list.html index f24aa411..7f8a551f 100644 --- a/module-map/src/main/resources/templates/grid/grid/default/list.html +++ b/module-map/src/main/resources/templates/grid/grid/default/list.html @@ -298,7 +298,7 @@ }); $(document).on('click', '#showGrid', function() { top.dialog.open({ - url: top.restAjax.path('route/grid/show-grid', []), + url: top.restAjax.path('route/grid/show-grid?areaCode={areaCode}', [$('#areaCode').val()]), title: '查看网格', width: '80%', height: '80%', diff --git a/module-map/src/main/resources/templates/grid/grid/default/save.html b/module-map/src/main/resources/templates/grid/grid/default/save.html index 389a9851..532d2da0 100644 --- a/module-map/src/main/resources/templates/grid/grid/default/save.html +++ b/module-map/src/main/resources/templates/grid/grid/default/save.html @@ -13,6 +13,10 @@ .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%;} + .select-area {position: relative;} + .select-area #areaName {width: 64%} + .select-area .select-btn {position: absolute; top: 30px; right: 0px; width: 36%; border-color: #e6e6e6;} + .select-area .select-btn button {height: 38px; width: 50%;} @@ -49,20 +53,28 @@
- +
- +
-
+
- + +
+ + +
@@ -240,31 +252,39 @@ }); } - $('#areaName').on('click', function() { - top.dialog.open({ - title: '选择地区', - url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#areaName').val())]), - width: '600px', - height: '225px', - onClose: function() { - var selectedAreaArray = top.dialog.dialogData.selectedAreaArray; - if(selectedAreaArray.length > 0) { - var areaCode = ''; - var areaName = ''; - areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode; - for(var i = 0, item; item = selectedAreaArray[i++];) { - if(areaName) { - areaName += '/'; + // 区域选择 + (function() { + $('#areaSelectBtn').on('click', function() { + top.dialog.open({ + title: '选择地区', + url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#areaName').val())]), + width: '600px', + height: '225px', + onClose: function() { + var selectedAreaArray = top.dialog.dialogData.selectedAreaArray; + if(selectedAreaArray.length > 0) { + var areaCode = ''; + var areaName = ''; + areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode; + for(var i = 0, item; item = selectedAreaArray[i++];) { + if(areaName) { + areaName += '/'; + } + areaName += item.areaName; } - areaName += item.areaName; + initGridBG(areaCode); + $('#areaCode').val(areaCode); + $('#areaName').val(areaName); } - initGridBG(areaCode); - $('#areaCode').val(areaCode); - $('#areaName').val(areaName); } - } + }) + }); + $('#areaCleanBtn').on('click', function () { + $('#areaCode').val(''); + $('#areaName').val(''); }) - }); + })(); + $('#userNames').on('click', function() { top.dialog.dialogData.selectedUserIds = $('#userIds').val(); diff --git a/module-map/src/main/resources/templates/grid/grid/default/show-grid.html b/module-map/src/main/resources/templates/grid/grid/default/show-grid.html index 6719fea9..5d776b80 100644 --- a/module-map/src/main/resources/templates/grid/grid/default/show-grid.html +++ b/module-map/src/main/resources/templates/grid/grid/default/show-grid.html @@ -41,6 +41,7 @@ var laydate = layui.laydate; var queryParams = top.restAjax.params(window.location.href); var gridId = queryParams.gridId; + var areaCode = queryParams.areaCode; var centerPoint = { lng: [[${baiduMapProperties.centerLng}]], lat: [[${baiduMapProperties.centerLat}]] @@ -59,7 +60,7 @@ // 初始化网格背景 function initGridBG(callback) { var layIndex; - top.restAjax.get(top.restAjax.path('api/grid/list-all-with-point/area-code/{areaCode}', ['1509']), {}, null, function(code, data) { + top.restAjax.get(top.restAjax.path('api/grid/list-all-with-point/area-code/{areaCode}', [areaCode ? areaCode : '1509']), {}, null, function(code, data) { var gridArray = []; for(var i = 0, item; item = data[i++];) { var pointArray = []; diff --git a/module-map/src/main/resources/templates/grid/grid/default/update.html b/module-map/src/main/resources/templates/grid/grid/default/update.html index c1097913..ce48c541 100644 --- a/module-map/src/main/resources/templates/grid/grid/default/update.html +++ b/module-map/src/main/resources/templates/grid/grid/default/update.html @@ -13,6 +13,10 @@ .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%;} + .select-area {position: relative;} + .select-area #areaName {width: 64%} + .select-area .select-btn {position: absolute; top: 30px; right: 0px; width: 36%; border-color: #e6e6e6;} + .select-area .select-btn button {height: 38px; width: 50%;} @@ -49,13 +53,28 @@
- +
- + +
+
+
+ +
+ + +
+ + +
@@ -235,31 +254,38 @@ } initData(); - $('#areaName').on('click', function() { - top.dialog.open({ - title: '选择地区', - url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#areaName').val())]), - width: '600px', - height: '225px', - onClose: function() { - var selectedAreaArray = top.dialog.dialogData.selectedAreaArray; - var areaCode = ''; - var areaName = ''; - if(selectedAreaArray.length > 0) { - areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode; - for(var i = 0, item; item = selectedAreaArray[i++];) { - if(areaName) { - areaName += '/'; + // 区域选择 + (function() { + $('#areaSelectBtn').on('click', function() { + top.dialog.open({ + title: '选择地区', + url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#areaName').val())]), + width: '600px', + height: '225px', + onClose: function() { + var selectedAreaArray = top.dialog.dialogData.selectedAreaArray; + if(selectedAreaArray.length > 0) { + var areaCode = ''; + var areaName = ''; + areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode; + for(var i = 0, item; item = selectedAreaArray[i++];) { + if(areaName) { + areaName += '/'; + } + areaName += item.areaName; } - areaName += item.areaName; + initGridBG(areaCode); + $('#areaCode').val(areaCode); + $('#areaName').val(areaName); } - initGridBG(areaCode); } - $('#areaCode').val(areaCode); - $('#areaName').val(areaName); - } + }) + }); + $('#areaCleanBtn').on('click', function () { + $('#areaCode').val(''); + $('#areaName').val(''); }) - }); + })(); // 提交表单 form.on('submit(submitForm)', function(formData) {