diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/feign/AdminFeignClient.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/feign/AdminFeignClient.java index 4734141..8488ee8 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/feign/AdminFeignClient.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/feign/AdminFeignClient.java @@ -50,6 +50,6 @@ public interface AdminFeignClient { * @author work@yujt.net.cn * @date 2020/5/22 08:57 */ - @GetMapping("optimize/deptlevel/listByParent/{typeKey}/{deptId}") + @GetMapping("sys/optimize/deptlevel/listByParent/{typeKey}/{deptId}") Result> listChildDeptLevelById(@PathVariable("typeKey") String typeKey, @PathVariable("deptId") Long deptId); } diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/group/dao/GroupDao.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/group/dao/GroupDao.java index 7b3d68e..5e4e390 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/group/dao/GroupDao.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/group/dao/GroupDao.java @@ -18,6 +18,7 @@ package com.elink.esua.epdc.modules.group.dao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; import com.elink.esua.epdc.dto.group.*; import com.elink.esua.epdc.dto.group.form.GroupDetailForMobileEndFormDTO; import com.elink.esua.epdc.dto.group.form.GroupsOfMineFormDTO; @@ -123,12 +124,22 @@ public interface GroupDao extends BaseDao { /** * 获取警群社区下所有社群 * - * @return java.util.List + * @return java.util.List * @params [deptId] - * @author liuchuang + * @author zhangyuan + * @since 2019/11/12 9:35 + */ + List selectListOfGroupByDeptIds(List list); + + /** + * 获取社区下所有社群 + * + * @return java.util.List + * @params [deptId] + * @author zhangyuan * @since 2019/11/12 9:35 */ - List selectListOfGroupByDeptId(Long deptId); + List selectListOfGroupByDeptId(@Param("deptId") String deptId); /** * 排行榜-活跃度 diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/controller/PoliceController.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/controller/PoliceController.java index 64ada19..de9bfd8 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/controller/PoliceController.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/controller/PoliceController.java @@ -45,24 +45,24 @@ import java.util.Map; @RestController @RequestMapping("police") public class PoliceController { - + @Autowired private PoliceService policeService; @GetMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = policeService.page(params); return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ + public Result get(@PathVariable("id") String id) { PoliceDTO data = policeService.get(id); return new Result().ok(data); } @PostMapping - public Result save(@RequestBody PoliceDTO dto){ + public Result save(@RequestBody PoliceDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); policeService.save(dto); @@ -70,15 +70,23 @@ public class PoliceController { } @PutMapping - public Result update(@RequestBody PoliceDTO dto){ + public Result update(@RequestBody PoliceDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); policeService.update(dto); return new Result(); } + @PutMapping("supplement") + public Result supplement(@RequestBody PoliceDTO[] dtos) { + //效验数据 + AssertUtils.isArrayEmpty(dtos, "dto"); + policeService.supplement(dtos); + return new Result(); + } + @DeleteMapping - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); policeService.delete(ids); diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/PoliceService.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/PoliceService.java index 4d5bd1d..4166594 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/PoliceService.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/PoliceService.java @@ -19,6 +19,7 @@ package com.elink.esua.epdc.modules.police.service; import com.elink.esua.epdc.commons.mybatis.service.BaseService; import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.police.PoliceDTO; import com.elink.esua.epdc.modules.police.entity.PoliceEntity; @@ -71,7 +72,7 @@ public interface PoliceService extends BaseService { * @author generator * @date 2020-05-21 */ - void save(PoliceDTO dto); + Result save(PoliceDTO dto); /** * 默认更新 @@ -92,4 +93,14 @@ public interface PoliceService extends BaseService { * @date 2020-05-21 */ void delete(String[] ids); + + /** + * 群补建 + * + * @param ids + * @return void + * @author zhangyuan + * @date 2020-05-21 + */ + void supplement(PoliceDTO[] ids); } \ No newline at end of file diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java index 821e5fd..a3f1be6 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java @@ -21,11 +21,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.utils.DeptEntityUtils; +import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; import com.elink.esua.epdc.dto.constant.GroupConstant; import com.elink.esua.epdc.dto.enums.GroupStateEnum; @@ -48,6 +50,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import static java.util.stream.Collectors.toList; + /** * 民警表 * @@ -98,35 +102,42 @@ public class PoliceServiceImpl extends BaseServiceImpl @Override @Transactional(rollbackFor = Exception.class) - public void save(PoliceDTO dto) { + public Result save(PoliceDTO dto) { PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); - - ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(dto.getDeptId() + ""); - - // 保存机构,及其他冗余字段。 - DeptEntityUtils.loadDeptInfo( - ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), - entity - ); - entity.setDeptName(parentAndAllDeptDTO.getGrid()); - insert(entity); - - List groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId()); + // 先查询该社区下有没有网格群,没有就同时创建民警和群,有就表示已经创建过。 + List deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()).getData(); + List groupList = groupDao.selectListOfGroupByDeptIds(deptList); if (groupList.size() == 0) { - // 创民警的同时创建群 - GroupEntity groupEntity = new GroupEntity(); + ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(dto.getDeptId() + ""); + + // 保存机构,及其他冗余字段。 DeptEntityUtils.loadDeptInfo( ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), - groupEntity + entity ); - groupEntity.setReferenceBusinessId(entity.getId()); - groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); - groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); - groupEntity.setGroupName(entity.getDeptName() + "警民群"); - groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); - groupEntity.setGrid(entity.getDeptName()); - groupEntity.setGridId(entity.getDeptId()); - groupDao.insert(groupEntity); + entity.setDeptName(parentAndAllDeptDTO.getGrid()); + insert(entity); + + // 创民警的同时创建群 + deptList.forEach(dept -> { + ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); + GroupEntity groupEntity = new GroupEntity(); + DeptEntityUtils.loadDeptInfo( + ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), + groupEntity + ); + groupEntity.setReferenceBusinessId(entity.getId()); + groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); + groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); + groupEntity.setGroupName(entity.getDeptName() + "警民群"); + groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); + groupEntity.setGrid(dept.getDeptName()); + groupEntity.setGridId(dept.getDeptId()); + groupDao.insert(groupEntity); + }); + return new Result(); + } else { + return new Result().error(); } } @@ -134,34 +145,7 @@ public class PoliceServiceImpl extends BaseServiceImpl @Transactional(rollbackFor = Exception.class) public void update(PoliceDTO dto) { PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); - - ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(dto.getDeptId()+""); - // 保存机构,及其他冗余字段。 - DeptEntityUtils.loadDeptInfo( - ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), - entity - ); - entity.setDeptName(parentAndAllDeptDTO.getGrid()); updateById(entity); - - List groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId()); - if (groupList.size() == 0) { - // 创民警的同时创建群 - GroupEntity groupEntity = new GroupEntity(); - //保存用户居住地所在网格,及其他冗余字段。 - DeptEntityUtils.loadDeptInfo( - ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), - groupEntity - ); - groupEntity.setReferenceBusinessId(entity.getId()); - groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); - groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); - groupEntity.setGroupName(entity.getDeptName() + "警民群"); - groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); - groupEntity.setGrid(entity.getDeptName()); - groupEntity.setGridId(entity.getDeptId()); - groupDao.insert(groupEntity); - } } @Override @@ -171,6 +155,39 @@ public class PoliceServiceImpl extends BaseServiceImpl baseDao.deleteBatchIds(Arrays.asList(ids)); } + @Override + @Transactional(rollbackFor = Exception.class) + public void supplement(PoliceDTO[] ids) { + + for (PoliceDTO dto : ids) { + // 社区ID下有多少个网格信息 + List deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); + // 现有的群的网格信息 + List existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); + // 求差集,即为还没有创建过群的网格ID + List reduce = deptList.stream().filter(item -> !existedDeptList.contains(item)).collect(toList()); + + // 补建群 + reduce.forEach(dept -> { + ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); + GroupEntity groupEntity = new GroupEntity(); + DeptEntityUtils.loadDeptInfo( + ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), + groupEntity + ); + groupEntity.setReferenceBusinessId(dto.getId()); + groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); + groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); + groupEntity.setGroupName(dto.getDeptName() + "警民群"); + groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); + groupEntity.setGrid(dept.getDeptName()); + groupEntity.setGridId(dept.getDeptId()); + groupDao.insert(groupEntity); + }); + } + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + /** * 根据网格ID获取冗余的组织机构信息 * diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/project/entity/PropertyProjectScoreEntity.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/project/entity/PropertyProjectScoreEntity.java index e5bd7b3..041f491 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/project/entity/PropertyProjectScoreEntity.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/project/entity/PropertyProjectScoreEntity.java @@ -57,6 +57,6 @@ public class PropertyProjectScoreEntity extends BaseEpdcEntity { /** * 得分 */ - private BigDecimal score; + private Integer score; } \ No newline at end of file diff --git a/epdc-cloud-property/src/main/resources/mapper/group/GroupDao.xml b/epdc-cloud-property/src/main/resources/mapper/group/GroupDao.xml index 92abb7c..a780d15 100644 --- a/epdc-cloud-property/src/main/resources/mapper/group/GroupDao.xml +++ b/epdc-cloud-property/src/main/resources/mapper/group/GroupDao.xml @@ -315,16 +315,29 @@ ORDER BY AND GRID_ID = #{deptId} - SELECT - ID AS groupId, - GROUP_NAME AS groupName + ID AS groupId, + GROUP_NAME AS groupName FROM - epdc_group + epdc_group WHERE - DEL_FLAG = '0' - AND STATE IN ( 10, 15 ) - AND GRID_ID = #{deptId} + DEL_FLAG = '0' + AND STATE IN ( 10, 15 ) + AND GRID_ID IN + #{dept.groupId} + + +