社区修改。

This commit is contained in:
Renpc-kilig 2022-02-28 14:40:15 +08:00
parent e94b8994f5
commit 0b1724c77d
7 changed files with 121 additions and 32 deletions

View File

@ -3,6 +3,7 @@ package cn.com.tenlion.systemhouse.controller.api.community;
import cn.com.tenlion.systemhouse.pojo.dtos.community.CommunityDTO; import cn.com.tenlion.systemhouse.pojo.dtos.community.CommunityDTO;
import cn.com.tenlion.systemhouse.pojo.vos.community.CommunityVO; import cn.com.tenlion.systemhouse.pojo.vos.community.CommunityVO;
import cn.com.tenlion.systemhouse.service.community.ICommunityService; import cn.com.tenlion.systemhouse.service.community.ICommunityService;
import cn.com.tenlion.systemhouse.service.grid.IGridService;
import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController; import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.interfaces.consts.ISystemConstant;
@ -33,6 +34,8 @@ public class CommunityController extends DefaultBaseController {
@Autowired @Autowired
private ICommunityService communityService; private ICommunityService communityService;
@Autowired
private IGridService gridService;
@ApiOperation(value = "新增社区管理", notes = "新增社区管理接口") @ApiOperation(value = "新增社区管理", notes = "新增社区管理接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@ -108,4 +111,12 @@ public class CommunityController extends DefaultBaseController {
return new SuccessResultData<>(communityService.count(params)); return new SuccessResultData<>(communityService.count(params));
} }
@ApiOperation(value = "社区管理统计", notes = "社区管理统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("setdata")
SuccessResultData<String> setData() {
Map<String, Object> params = requestParams();
return new SuccessResultData<>(communityService.setdata(params));
}
} }

View File

@ -191,4 +191,10 @@ public interface ICommunityService {
void deleteKafka(String uid); void deleteKafka(String uid);
/**
* 将区域表中的社区数据转存到社区表中
* @param params
* @return
*/
String setdata(Map<String, Object> params);
} }

View File

@ -11,6 +11,8 @@ import cn.com.tenlion.systemhouse.service.community.ICommunityService;
import cn.com.tenlion.systemhouse.service.grid.IGridService; import cn.com.tenlion.systemhouse.service.grid.IGridService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.common.base.DefaultBaseService; import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoAreaService;
import ink.wgink.pojo.ListPage; import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.map.HashMapUtil;
@ -40,6 +42,8 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni
private IGridService gridService; private IGridService gridService;
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private IMongoAreaService mongoAreaService;
@Override @Override
public void save(CommunityVO communityVO) { public void save(CommunityVO communityVO) {
@ -68,7 +72,9 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni
} }
communityDao.save(params); communityDao.save(params);
saveKafka(communityId, communityVO); if(!StringUtils.isEmpty(communityVO.getGrid())) {
saveKafka(communityId, communityVO);
}
return communityId; return communityId;
} }
@ -121,9 +127,11 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni
public CommunityDTO get(Map<String, Object> params) { public CommunityDTO get(Map<String, Object> params) {
CommunityDTO communityDTO = communityDao.get(params); CommunityDTO communityDTO = communityDao.get(params);
if(null != communityDTO) { if(null != communityDTO) {
GridDTO gridDTO = gridService.get(communityDTO.getGrid()); if(!StringUtils.isEmpty(communityDTO.getGrid())) {
if(null != gridDTO) { GridDTO gridDTO = gridService.get(communityDTO.getGrid());
communityDTO.setGridName(gridDTO.getGridName()); if(null != gridDTO) {
communityDTO.setGridName(gridDTO.getGridName());
}
} }
} }
return communityDTO; return communityDTO;
@ -162,7 +170,58 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni
@Override @Override
public List<CommunityDTO> list(Map<String, Object> params) { public List<CommunityDTO> list(Map<String, Object> params) {
return communityDao.list(params); Map<String, Object> newParams = params;
List<CommunityDTO> list = communityDao.list(params);
return list;
}
@Override
public String setdata(Map<String, Object> params) {
List<CommunityVO> communityVOList = new ArrayList<>();
List<AreaDTO> areaDTOList = new ArrayList<>();
areaDTOList = getArea("110889", areaDTOList);
if(null != areaDTOList && areaDTOList.size() > 0) {
for(AreaDTO areaDTO: areaDTOList) {
if("4".equals(areaDTO.getAreaLevel())) {
System.out.println("areaDTO.toString() = " + areaDTO.toString());
CommunityVO communityVO = new CommunityVO();
communityVO.setCommunityName(areaDTO.getAreaName());
communityVO.setLocationCode(areaDTO.getAreaCode());
communityVO.setLocation(areaDTO.getAreaMergerName());
communityVOList.add(communityVO);
save(communityVO);
}
}
}
if(null != communityVOList && communityVOList.size() > 0) {
return "success";
}
return "error";
}
private List<AreaDTO> getArea(String id, List<AreaDTO> areaDTOList1) {
List<AreaDTO> areaDTOList = mongoAreaService.listAllByParentId(id);
for(AreaDTO areaDTO: areaDTOList) {
if(null != areaDTO.getSubArea() && areaDTO.getSubArea().size() > 0) {
if("4".equals(areaDTO.getSubArea().get(0).getAreaLevel())) {
areaDTOList1.addAll(areaDTO.getSubArea());
}else {
List<AreaDTO> subList = areaDTO.getSubArea();
for(AreaDTO areaDTO1: subList) {
if(null != areaDTO1.getSubArea() && areaDTO1.getSubArea().size() > 0) {
if ("4".equals(areaDTO1.getSubArea().get(0).getAreaLevel())) {
List<AreaDTO> subList1 = areaDTO.getSubArea();
for(AreaDTO areaDTO2: subList1) {
areaDTOList1.addAll(areaDTO2.getSubArea());
}
}
}
}
}
}
}
areaDTOList1.addAll(areaDTOList);
return areaDTOList1;
} }
@Override @Override

View File

@ -38,9 +38,7 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
@Override @Override
public String getLocationAll(String locationCode) { public String getLocationAll(String locationCode) {
String locationAll = ""; String locationAll = "";
System.out.println("locationCode = " + locationCode);
AreaDTO areaDTO = mongoAreaService.getByCode(locationCode); AreaDTO areaDTO = mongoAreaService.getByCode(locationCode);
System.out.println("areaDTO.toString() = " + areaDTO.toString());
Integer parentId = Integer.valueOf(areaDTO.getAreaParentId()); Integer parentId = Integer.valueOf(areaDTO.getAreaParentId());
String areaName = areaDTO.getAreaName(); String areaName = areaDTO.getAreaName();
locationAll += areaName; locationAll += areaName;
@ -66,7 +64,7 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
Integer parentId = Integer.valueOf(areaDTO.getAreaParentId()); Integer parentId = Integer.valueOf(areaDTO.getAreaParentId());
String areaName = areaDTO.getAreaName(); String areaName = areaDTO.getAreaName();
locationArea = areaName; locationArea = areaName;
if(0 != level && 2 != level) { if(0 != level && 2 != level && level > 1) {
for(int i=1;i<=5;i++) { for(int i=1;i<=5;i++) {
areaDTO = mongoAreaService.get(parentId.toString()); areaDTO = mongoAreaService.get(parentId.toString());
level = Integer.valueOf(areaDTO.getAreaLevel()); level = Integer.valueOf(areaDTO.getAreaLevel());

View File

@ -1,7 +1,7 @@
server: server:
port: 7012 port: 7012
ip: 1.24.238.149 ip: www.wlcbsyzl.cn
url: http://${server.ip}:37210/house url: http://${server.ip}/house
system-title: 房屋管理系统 system-title: 房屋管理系统
system-sub-title: 智慧城市 system-sub-title: 智慧城市
nav-page: ${api-path.user-center-2} nav-page: ${api-path.user-center-2}
@ -117,8 +117,8 @@ file:
api-path: api-path:
#103 155 #103 155
user-center: http://10.25.242.190:37210/usercenter user-center: http://10.25.242.183:80/usercenter
user-center-2: http://1.24.238.149:37210/usercenter user-center-2: http://www.wlcbsyzl.cn/usercenter
security: security:
oauth2: oauth2:

View File

@ -34,15 +34,9 @@
<!-- 表头按钮组 --> <!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar"> <script type="text/html" id="headerToolBar">
<div class="layui-btn-group"> <div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent"> <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑 <i class="fa fa-lg fa-edit"></i> 编辑
</button> </button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div> </div>
</script> </script>
</div> </div>
@ -67,6 +61,23 @@
var resizeTimeout = null; var resizeTimeout = null;
var tableUrl = 'api/community/listpage'; var tableUrl = 'api/community/listpage';
function setData() {
var layIndex;
top.restAjax.get(top.restAjax.path("api/community/setdata", []), {}, null, function (code, data) {
if('success' == data.data) {
reloadTable();
}else {
top.dialog.msg('数据更新失败,请联系管理人员');
}
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg('第一次同步数据,耗时较长,请稍等', {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
// 初始化表格 // 初始化表格
function initTable() { function initTable() {
table.render({ table.render({
@ -180,6 +191,9 @@
], ],
page: true, page: true,
parseData: function(data) { parseData: function(data) {
if(data.rows <= 0) {
setData();
}
return { return {
'code': 0, 'code': 0,
'msg': '', 'msg': '',

View File

@ -32,14 +32,7 @@
</div> </div>
<div class="layui-form-item layui-row"> <div class="layui-form-item layui-row">
<div class="layui-col-lg6"> <div class="layui-col-lg6">
<label class="layui-form-label">所在地<span style="color: red;vertical-align: middle;">*</span></label> <input type="hidden" id="locationCode" name="locationCode">
<input type="hidden" id="locationCode" name="locationCode" class="layui-input" value="" placeholder="请输入一级区域名称" maxlength="255">
<div class="layui-input-block">
<input type="text" id="location" name="location" class="layui-input" value="" placeholder="点击选择所在地" lay-verify="required" maxlength="11">
</div>
</div>
<div class="layui-col-lg6">
<label class="layui-form-label">所属网格<span style="color: red;vertical-align: middle;">*</span></label> <label class="layui-form-label">所属网格<span style="color: red;vertical-align: middle;">*</span></label>
<div class="layui-input-block layui-form" id="gridSelectTemplateBox" lay-filter="gridSelectTemplateBox"></div> <div class="layui-input-block layui-form" id="gridSelectTemplateBox" lay-filter="gridSelectTemplateBox"></div>
<script id="gridSelectTemplate" type="text/html"> <script id="gridSelectTemplate" type="text/html">
@ -51,14 +44,15 @@
</select> </select>
</script> </script>
</div> </div>
</div>
<div class="layui-form-item"> <div class="layui-col-lg6">
<label class="layui-form-label">详细地址<span style="color: red;vertical-align: middle;">*</span></label> <label class="layui-form-label">详细地址<span style="color: red;vertical-align: middle;">*</span></label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="text" id="address" name="address" class="layui-input" value="" placeholder="请输入详细地址" lay-verify="required" maxlength="255"> <input type="text" id="address" name="address" class="layui-input" value="" placeholder="请输入详细地址" lay-verify="required" maxlength="255">
</div>
</div> </div>
</div> </div>
<div class="layui-form-item layui-row"> <div class="layui-form-item layui-row">
<div class="layui-col-lg4"> <div class="layui-col-lg4">
<label class="layui-form-label">社区联系人</label> <label class="layui-form-label">社区联系人</label>
@ -266,8 +260,15 @@
} }
form.val('dataForm', dataFormData); form.val('dataForm', dataFormData);
form.render(null, 'dataForm'); form.render(null, 'dataForm');
$('#locationCode').val(data['locationCode']);
initRemakeRichText(data['remake']); initRemakeRichText(data['remake']);
initGridSelect(data['locationCode'], data['grid']); if(data['grid']) {
console.log('grid存在')
initGridSelect(data['locationCode'], data['grid']);
}else {
console.log('grid不存在')
initGridSelect(data['locationCode']);
}
initMap(data['longitude'], data['latitude']); initMap(data['longitude'], data['latitude']);
}, function(code, data) { }, function(code, data) {
top.dialog.msg(data.msg); top.dialog.msg(data.msg);