From db49c37fba7dead9396be43300f492ed5c75f1c2 Mon Sep 17 00:00:00 2001 From: yujintao Date: Mon, 17 Feb 2020 10:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=9A=E8=BF=87=E5=93=A8?= =?UTF-8?q?=E5=8D=A1=E7=99=BB=E8=AE=B0=E4=BF=A1=E6=81=AF=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SentryPostUserInfoRedisListener.java | 8 +-- .../epdc/service/impl/UserServiceImpl.java | 49 ++++++++++--------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/listener/SentryPostUserInfoRedisListener.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/listener/SentryPostUserInfoRedisListener.java index 5bee613ed..ad0998407 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/listener/SentryPostUserInfoRedisListener.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/listener/SentryPostUserInfoRedisListener.java @@ -1,7 +1,6 @@ package com.elink.esua.epdc.listener; import com.alibaba.fastjson.JSONObject; -import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.EpidemicSentryPostDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcAppPidemicCompleteInfoFromDTO; @@ -40,7 +39,9 @@ public class SentryPostUserInfoRedisListener implements MessageListener { EpdcAppPidemicCompleteInfoFromDTO completeInfoDto = JSONObject.parseObject(message.toString(), EpdcAppPidemicCompleteInfoFromDTO.class); EpidemicSentryPostDTO sentryPostInfoByThirdId = getEpidemicSentryPostInfoByThirdId(completeInfoDto.getPostId()); - completeInfoDto.setGridId(sentryPostInfoByThirdId.getGridId()); + if (null != sentryPostInfoByThirdId) { + completeInfoDto.setGridId(sentryPostInfoByThirdId.getGridId()); + } userFeignClient.createPidemicInfo(completeInfoDto); } catch (Exception e) { @@ -59,7 +60,8 @@ public class SentryPostUserInfoRedisListener implements MessageListener { private EpidemicSentryPostDTO getEpidemicSentryPostInfoByThirdId(String thirdId) { Result epidemicSentryResult = customFeignClient.getEpidemicSentryByThirdSentryPostid(thirdId); if (!epidemicSentryResult.success() || null == epidemicSentryResult.getData()) { - throw new RenException("查询哨卡信息失败"); + log.error("根据第三方哨卡id:{}查询哨卡信息失败", thirdId); + return null; } return epidemicSentryResult.getData(); } diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java index 9a2a723f7..b752edc65 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java @@ -897,33 +897,38 @@ public class UserServiceImpl extends BaseServiceImpl implem @Override public Result createPidemicInfo(EpdcAppPidemicCompleteInfoFromDTO completeInfoFromDto) { + String userId = completeInfoFromDto.getUserId(); + // 更新用户信息 - UserEntity userEntity = selectById(completeInfoFromDto.getUserId()); + UserEntity userEntity = selectById(userId); if (null == userEntity) { return new Result().error("查询用户信息失败"); } - Result parentAndAllDeptDTOResult = adminFeignClient.getParentAndAllDept(String.valueOf(completeInfoFromDto.getGridId())); - if (!parentAndAllDeptDTOResult.success()) { - return new Result().error("查询机构信息失败"); + UserEntity updateUser = new UserEntity(); + updateUser.setId(userId); + updateUser.setRealName(completeInfoFromDto.getName()); + updateUser.setIdentityNo(completeInfoFromDto.getIdcard()); + updateUser.setMobile(completeInfoFromDto.getPhone()); + updateUser.setAddress(completeInfoFromDto.getHabitationDetail()); + updateUser.setRentFlag(completeInfoFromDto.getIsRent()); + updateUser.setDriverFlag(completeInfoFromDto.getIsDriver()); + + Long gridId = completeInfoFromDto.getGridId(); + if (null != gridId) { + Result parentAndAllDeptDTOResult = adminFeignClient.getParentAndAllDept(String.valueOf(gridId)); + if (!parentAndAllDeptDTOResult.success()) { + return new Result().error("查询机构信息失败"); + } + ParentAndAllDeptDTO deptInfo = parentAndAllDeptDTOResult.getData(); + updateUser.setDeptId(gridId); + updateUser.setAllDeptIds(deptInfo.getAllDeptIds()); + updateUser.setAllDeptNames(deptInfo.getAllDeptNames()); + updateUser.setParentDeptIds(deptInfo.getParentDeptIds()); + updateUser.setParentDeptNames(deptInfo.getParentDeptNames()); } - ParentAndAllDeptDTO deptInfo = parentAndAllDeptDTOResult.getData(); - - - UserEntity userDTO = new UserEntity(); - userDTO.setId(completeInfoFromDto.getUserId()); - userDTO.setRealName(completeInfoFromDto.getName()); - userDTO.setIdentityNo(completeInfoFromDto.getIdcard()); - userDTO.setMobile(completeInfoFromDto.getPhone()); - userDTO.setAddress(completeInfoFromDto.getHabitationDetail()); - userDTO.setRentFlag(completeInfoFromDto.getIsRent()); - userDTO.setDriverFlag(completeInfoFromDto.getIsDriver()); - userDTO.setAllDeptIds(deptInfo.getAllDeptIds()); - userDTO.setAllDeptNames(deptInfo.getAllDeptNames()); - userDTO.setParentDeptIds(deptInfo.getParentDeptIds()); - userDTO.setParentDeptNames(deptInfo.getParentDeptNames()); - this.updateById(userDTO); + this.updateById(updateUser); String carNum = completeInfoFromDto.getCarNum(); @@ -933,12 +938,12 @@ public class UserServiceImpl extends BaseServiceImpl implem UserCarInfoDTO userCarInfoDTO = userCarInfoService.selectOneByCarNumber(carNum); if (userCarInfoDTO == null) { UserCarInfoDTO dto = new UserCarInfoDTO(); - dto.setUserId(userDTO.getId()); + dto.setUserId(userId); dto.setCarNumber(carNum); userCarInfoService.save(dto); } else { // 库里存的车牌号与该用户不相符 - if (!userCarInfoDTO.getUserId().equals(userDTO.getId())) { + if (!userCarInfoDTO.getUserId().equals(userId)) { throw new RenException("保存失败,此车牌已被注册"); } }