diff --git a/src/main/java/cn/com/tenlion/systemhouse/controller/api/community/CommunityController.java b/src/main/java/cn/com/tenlion/systemhouse/controller/api/community/CommunityController.java index 6199850..7fba030 100644 --- a/src/main/java/cn/com/tenlion/systemhouse/controller/api/community/CommunityController.java +++ b/src/main/java/cn/com/tenlion/systemhouse/controller/api/community/CommunityController.java @@ -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.vos.community.CommunityVO; import cn.com.tenlion.systemhouse.service.community.ICommunityService; +import cn.com.tenlion.systemhouse.service.grid.IGridService; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; @@ -33,6 +34,8 @@ public class CommunityController extends DefaultBaseController { @Autowired private ICommunityService communityService; + @Autowired + private IGridService gridService; @ApiOperation(value = "新增社区管理", notes = "新增社区管理接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @@ -108,4 +111,12 @@ public class CommunityController extends DefaultBaseController { return new SuccessResultData<>(communityService.count(params)); } + @ApiOperation(value = "社区管理统计", notes = "社区管理统计接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("setdata") + SuccessResultData setData() { + Map params = requestParams(); + return new SuccessResultData<>(communityService.setdata(params)); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemhouse/service/community/ICommunityService.java b/src/main/java/cn/com/tenlion/systemhouse/service/community/ICommunityService.java index bc1ce08..85a493e 100644 --- a/src/main/java/cn/com/tenlion/systemhouse/service/community/ICommunityService.java +++ b/src/main/java/cn/com/tenlion/systemhouse/service/community/ICommunityService.java @@ -191,4 +191,10 @@ public interface ICommunityService { void deleteKafka(String uid); + /** + * 将区域表中的社区数据转存到社区表中 + * @param params + * @return + */ + String setdata(Map params); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemhouse/service/community/impl/CommunityServiceImpl.java b/src/main/java/cn/com/tenlion/systemhouse/service/community/impl/CommunityServiceImpl.java index 5150e36..c3afe6a 100644 --- a/src/main/java/cn/com/tenlion/systemhouse/service/community/impl/CommunityServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemhouse/service/community/impl/CommunityServiceImpl.java @@ -11,6 +11,8 @@ import cn.com.tenlion.systemhouse.service.community.ICommunityService; import cn.com.tenlion.systemhouse.service.grid.IGridService; import com.alibaba.fastjson.JSONObject; 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.result.SuccessResultList; import ink.wgink.util.map.HashMapUtil; @@ -40,6 +42,8 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni private IGridService gridService; @Autowired private KafkaTemplate kafkaTemplate; + @Autowired + private IMongoAreaService mongoAreaService; @Override public void save(CommunityVO communityVO) { @@ -68,7 +72,9 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni } communityDao.save(params); - saveKafka(communityId, communityVO); + if(!StringUtils.isEmpty(communityVO.getGrid())) { + saveKafka(communityId, communityVO); + } return communityId; } @@ -121,9 +127,11 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni public CommunityDTO get(Map params) { CommunityDTO communityDTO = communityDao.get(params); if(null != communityDTO) { - GridDTO gridDTO = gridService.get(communityDTO.getGrid()); - if(null != gridDTO) { - communityDTO.setGridName(gridDTO.getGridName()); + if(!StringUtils.isEmpty(communityDTO.getGrid())) { + GridDTO gridDTO = gridService.get(communityDTO.getGrid()); + if(null != gridDTO) { + communityDTO.setGridName(gridDTO.getGridName()); + } } } return communityDTO; @@ -162,7 +170,58 @@ public class CommunityServiceImpl extends DefaultBaseService implements ICommuni @Override public List list(Map params) { - return communityDao.list(params); + Map newParams = params; + List list = communityDao.list(params); + return list; + } + + @Override + public String setdata(Map params) { + List communityVOList = new ArrayList<>(); + List 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 getArea(String id, List areaDTOList1) { + List 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 subList = areaDTO.getSubArea(); + for(AreaDTO areaDTO1: subList) { + if(null != areaDTO1.getSubArea() && areaDTO1.getSubArea().size() > 0) { + if ("4".equals(areaDTO1.getSubArea().get(0).getAreaLevel())) { + List subList1 = areaDTO.getSubArea(); + for(AreaDTO areaDTO2: subList1) { + areaDTOList1.addAll(areaDTO2.getSubArea()); + } + } + } + } + } + } + } + areaDTOList1.addAll(areaDTOList); + return areaDTOList1; } @Override diff --git a/src/main/java/cn/com/tenlion/systemhouse/service/grid/impl/GridServiceImpl.java b/src/main/java/cn/com/tenlion/systemhouse/service/grid/impl/GridServiceImpl.java index 18180c2..a6888ca 100644 --- a/src/main/java/cn/com/tenlion/systemhouse/service/grid/impl/GridServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemhouse/service/grid/impl/GridServiceImpl.java @@ -38,9 +38,7 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService @Override public String getLocationAll(String locationCode) { String locationAll = ""; - System.out.println("locationCode = " + locationCode); AreaDTO areaDTO = mongoAreaService.getByCode(locationCode); - System.out.println("areaDTO.toString() = " + areaDTO.toString()); Integer parentId = Integer.valueOf(areaDTO.getAreaParentId()); String areaName = areaDTO.getAreaName(); locationAll += areaName; @@ -66,7 +64,7 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService Integer parentId = Integer.valueOf(areaDTO.getAreaParentId()); String areaName = areaDTO.getAreaName(); locationArea = areaName; - if(0 != level && 2 != level) { + if(0 != level && 2 != level && level > 1) { for(int i=1;i<=5;i++) { areaDTO = mongoAreaService.get(parentId.toString()); level = Integer.valueOf(areaDTO.getAreaLevel()); diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a411440..8eef401 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,7 +1,7 @@ server: port: 7012 - ip: 1.24.238.149 - url: http://${server.ip}:37210/house + ip: www.wlcbsyzl.cn + url: http://${server.ip}/house system-title: 房屋管理系统 system-sub-title: 智慧城市 nav-page: ${api-path.user-center-2} @@ -117,8 +117,8 @@ file: api-path: #103 155 - user-center: http://10.25.242.190:37210/usercenter - user-center-2: http://1.24.238.149:37210/usercenter + user-center: http://10.25.242.183:80/usercenter + user-center-2: http://www.wlcbsyzl.cn/usercenter security: oauth2: diff --git a/src/main/resources/templates/community/list.html b/src/main/resources/templates/community/list.html index 90163e3..6f474ef 100644 --- a/src/main/resources/templates/community/list.html +++ b/src/main/resources/templates/community/list.html @@ -34,15 +34,9 @@ @@ -67,6 +61,23 @@ var resizeTimeout = null; 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() { table.render({ @@ -180,6 +191,9 @@ ], page: true, parseData: function(data) { + if(data.rows <= 0) { + setData(); + } return { 'code': 0, 'msg': '', diff --git a/src/main/resources/templates/community/update.html b/src/main/resources/templates/community/update.html index 530a407..a1b7c2c 100644 --- a/src/main/resources/templates/community/update.html +++ b/src/main/resources/templates/community/update.html @@ -32,14 +32,7 @@
- - -
- -
-
- -
+
-
-
- -
- +
+ +
+ +
+
@@ -266,8 +260,15 @@ } form.val('dataForm', dataFormData); form.render(null, 'dataForm'); + $('#locationCode').val(data['locationCode']); 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']); }, function(code, data) { top.dialog.msg(data.msg);