Browse Source

更新小区所属网格时,同时把居民信息里的人给修改到相应的网格

master
jianjun 3 years ago
parent
commit
b2b4c9fb31
  1. 25
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  2. 33
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java
  3. 8
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  4. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  5. 22
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  6. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  7. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  8. 26
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  9. 7
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

25
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java

@ -2,8 +2,10 @@ package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -17,11 +19,13 @@ import com.epmet.dto.IcNeighborHoodPropertyDTO;
import com.epmet.dto.form.IcHouseListFormDTO;
import com.epmet.dto.form.IcNeighborHoodAddFormDTO;
import com.epmet.dto.form.IcNeighborHoodListFormDTO;
import com.epmet.dto.form.IcUserBelongToChangedFormDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.entity.IcHouseEntity;
import com.epmet.entity.IcNeighborHoodEntity;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.excel.IcNeighborHoodExcel;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.IcNeighborHoodPropertyService;
import com.epmet.service.IcNeighborHoodService;
@ -44,7 +48,7 @@ import java.util.Optional;
@Slf4j
@Service
public class NeighborHoodServiceImpl implements NeighborHoodService {
public class NeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao,IcNeighborHoodEntity> implements NeighborHoodService {
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@ -56,6 +60,8 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao;
@Resource
private IcNeighborHoodDao icNeighborHoodDao;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Override
@ -132,11 +138,28 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
if (!customerAgencyResult.success()) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
IcNeighborHoodEntity icNeighborHoodEntity = baseDao.selectById(formDTO.getNeighborHoodId());
if (icNeighborHoodEntity == null){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"小区信息不存在","小区信息不存在");
}
CustomerAgencyDTO customerAgencyDTO = Optional.ofNullable(customerAgencyResult.getData()).orElse(new CustomerAgencyDTO());
icNeighborHoodDTO.setParentAgencyId(customerAgencyDTO.getPid());
icNeighborHoodDTO.setAgencyPids(customerAgencyDTO.getPids());
icNeighborHoodService.update(icNeighborHoodDTO);
//如果更新了网格 则需要更新网格下的居民所属关系
if (icNeighborHoodEntity.getGridId().equals(icNeighborHoodDTO.getGridId())){
IcUserBelongToChangedFormDTO userForm = new IcUserBelongToChangedFormDTO();
userForm.setSourceGridId(icNeighborHoodEntity.getGridId());
userForm.setTargetGridId(icNeighborHoodDTO.getGridId());
Result<Boolean> updateResult = epmetUserOpenFeignClient.changeIcResiUserBelongTo(userForm);
if (updateResult == null || !updateResult.success()){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"更新居民信息失败,请稍后重试!","更新居民信息失败,请稍后重试!");
}
}
//设置物业关联
String propertyId = formDTO.getPropertyId();
String neighborHoodId = icNeighborHoodDTO.getId();

33
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java

@ -0,0 +1,33 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* desc: 居民所属关系调整参数类
*
* @author LiuJanJun
* @date 2022/5/22 9:41 下午
*/
@Data
public class IcUserBelongToChangedFormDTO implements Serializable {
private static final long serialVersionUID = 6572482888379744011L;
/**
* 客户Id
*/
private String customerId;
/**
* 原网格Id
*/
@NotBlank(message = "网格ID不能为空")
private String sourceGridId;
/**
* 新网格Id
*/
@NotBlank(message = "网格ID不能为空")
private String targetGridId;
}

8
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -748,4 +748,12 @@ public interface EpmetUserOpenFeignClient {
*/
@PostMapping("/epmetuser/icresiuser/getResiUserGroupHomeId")
Result<List<HouseIcResiUserResultDTO>> getHouseMemberList(@RequestBody RentTenantDataFormDTO formDTO);
/**
* desc:更新居民所属 eg所属网格等等
* @param formDTO
* @return
*/
@PostMapping("/icresiuser/changeIcResiUserBelongTo")
Result<Boolean> changeIcResiUserBelongTo(@RequestBody IcUserBelongToChangedFormDTO formDTO);
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -548,4 +548,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getHouseMemberList", formDTO);
}
@Override
public Result<Boolean> changeIcResiUserBelongTo(IcUserBelongToChangedFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "changeIcResiUserBelongTo", formDTO);
}
}

22
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -232,6 +232,28 @@ public class IcResiUserController implements ResultDataResolver {
return new Result();
}
/**
* 更新居民的所属网格-来源于小区更改所属网格 目前只有网格,
*
* @param formDTO
* @return
* @remark:后续如果有其他的变动需要调用的话 可以丰富参数 修改方法名
*/
@NoRepeatSubmit
@PostMapping("changeIcResiUserBelongTo")
Result<Boolean> changeIcResiUserBelongTo(@LoginUser TokenDto tokenDto, @RequestBody IcUserBelongToChangedFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO);
List<String> changedUserIds = icResiUserService.changeIcResiUserBelongTo(tokenDto,formDTO);
//推送MQ事件
if (CollectionUtils.isNotEmpty(changedUserIds)){
changedUserIds.forEach(resiUserId->editResiMq(tokenDto.getCustomerId(), resiUserId));
}
return new Result<Boolean>().ok(true);
}
/**
* 租客房东根据身份证更新头像
*

9
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -309,4 +309,13 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
* @return
*/
List<HouseIcResiUserResultDTO> getResiUserGroupHomeId(RentTenantDataFormDTO formDTO);
/**
* desc:条件获取居民Id列表 所有状态的包含死亡等状态
*
* @param customerId
* @param gridId
* @return
*/
List<String> listUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId);
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java

@ -336,4 +336,14 @@ public interface IcResiUserService extends BaseService<IcResiUserEntity> {
* @return
*/
List<HouseIcResiUserResultDTO> getResiUserGroupHomeId(RentTenantDataFormDTO formDTO);
/**
* desc:更新居民信息的所属 eg所属网格等等
*
* @param tokenDto
* @param formDTO
* @return
*/
List<String> changeIcResiUserBelongTo(TokenDto tokenDto, IcUserBelongToChangedFormDTO formDTO);
}

26
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -1920,6 +1920,32 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
return listPage.getResult();
}
@Transactional(rollbackFor = Exception.class)
@Override
public List<String> changeIcResiUserBelongTo(TokenDto tokenDto, IcUserBelongToChangedFormDTO formDTO) {
List<String> resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(),formDTO.getSourceGridId());
if (CollectionUtils.isEmpty(resiUserIdList)){
return null;
}
List<IcResiUserFormDTO> icResiUserFormDTOS = new ArrayList<>();
IcResiUserFormDTO e = new IcResiUserFormDTO();
e.setTableName(IcResiUserConstant.IC_RESI_USER);
LinkedHashMap<String, String> map = new LinkedHashMap();
map.put(FieldConstant.GRID_ID, formDTO.getSourceGridId());
List<LinkedHashMap<String, String>> list = new ArrayList<>();
list.add(map);
e.setList(list);
icResiUserFormDTOS.add(e);
resiUserIdList.forEach(userId->{
map.put(FieldConstant.ID, userId);
this.edit(tokenDto,icResiUserFormDTOS);
});
return resiUserIdList;
}
/**
* desc:根据字段值获取 options
* @param customerId

7
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -971,5 +971,12 @@
and HOME_ID = #{houseId}
</if>
</select>
<select id="listUserIds" resultType="java.lang.String">
SELECT ID from ic_resi_user
WHERE
GRID_ID = #{gridId}
AND DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
</select>
</mapper>

Loading…
Cancel
Save