diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CheckStaffInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CheckStaffInfoFormDTO.java new file mode 100644 index 0000000000..42e299ae44 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CheckStaffInfoFormDTO.java @@ -0,0 +1,49 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@Data +public class CheckStaffInfoFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + public interface Check extends CustomerClientShowGroup {} + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空", groups = Check.class) + private String mobile; + /** + * 人名姓名 + */ + @NotBlank(message = "姓名不能为空", groups = Check.class) + private String personName; + + + private String customerId; + private String staffId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java new file mode 100644 index 0000000000..0f500a0cab --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java @@ -0,0 +1,50 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +@Data +public class CheckStaffInfoResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 状态,false为有问题 + */ + private Boolean type = false; + + /** + * 提示文案内容 + */ + private String msg = ""; + + /** + * 数据库中工作人员姓名【返参姓名有值的则需要更新工作人员信息】 + */ + private String personName; + + /** + * 类型,后端使用 + */ + private Boolean key = true; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java index 79b1975b9a..fac881ed3e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -161,4 +161,17 @@ public class DepartmentController { List deptList = departmentService.listDepartmentListByStaffId(staffId); return new Result>().ok(deptList); } + + + /** + * @Author sun + * @Description 根据手机号姓名查询人员信息,联建单位、社会自组织新增使用 + */ + @PostMapping("checkstaffinfo") + public Result checkStaffInfo(@LoginUser TokenDto tokenDTO, @RequestBody CheckStaffInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CheckStaffInfoFormDTO.Check.class); + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setStaffId(tokenDTO.getUserId()); + return new Result().ok(departmentService.checkStaffInfo(formDTO)); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java index c97f61e6a1..d1f589b26e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java @@ -20,10 +20,7 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; -import com.epmet.dto.result.AddDepartmentResultDTO; -import com.epmet.dto.result.DepartmentDetailResultDTO; -import com.epmet.dto.result.DepartmentInAgencyResultDTO; -import com.epmet.dto.result.DepartmentListResultDTO; +import com.epmet.dto.result.*; import java.util.List; @@ -104,4 +101,6 @@ public interface DepartmentService { * @return */ List listDepartmentListByStaffId(String staffId); + + CheckStaffInfoResultDTO checkStaffInfo(CheckStaffInfoFormDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java index 0c109e270a..aa8d6c1db8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java @@ -19,7 +19,9 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; 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.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; @@ -30,8 +32,10 @@ import com.epmet.constant.CustomerDepartmentConstant; import com.epmet.dao.CustomerAgencyDao; import com.epmet.dao.CustomerDepartmentDao; import com.epmet.dao.CustomerStaffDepartmentDao; +import com.epmet.dao.StaffOrgRelationDao; import com.epmet.dto.CustomerDepartmentDTO; import com.epmet.dto.CustomerIdDTO; +import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffDepartmentDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -39,6 +43,7 @@ import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerDepartmentEntity; import com.epmet.entity.CustomerStaffDepartmentEntity; import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.CustomerDepartmentService; import com.epmet.service.CustomerStaffDepartmentService; import com.epmet.service.DepartmentService; @@ -49,6 +54,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; @@ -76,6 +82,10 @@ public class DepartmentServiceImpl implements DepartmentService { private EpmetUserFeignClient epmetUserFeignClient; @Autowired private LoginUserUtil loginUserUtil; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private StaffOrgRelationDao staffOrgRelationDao; /** * @param formDTO * @return @@ -280,4 +290,63 @@ public class DepartmentServiceImpl implements DepartmentService { public List listDepartmentListByStaffId(String staffId) { return customerDepartmentDao.listDepartmentListByStaffId(staffId); } + + @Override + public CheckStaffInfoResultDTO checkStaffInfo(CheckStaffInfoFormDTO formDTO) { + CheckStaffInfoResultDTO resultDTO = new CheckStaffInfoResultDTO(); + //1.根据手机号查询客户下工作人员信息 + CustomerStaffFormDTO user = new CustomerStaffFormDTO(); + user.setCustomerId(formDTO.getCustomerId()); + user.setMobile(formDTO.getMobile()); + Result userResult = epmetUserOpenFeignClient.staffDetailInfo(user); + if (!userResult.success()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取工作人员信息失败", "获取工作人员信息失败"); + } + //查不到工作人员就直接返回 + if (null == userResult.getData()) { + return resultDTO; + } + + //2.查询工作人员注册组织关系数据 + List staffIdList = new ArrayList<>(); + staffIdList.add(userResult.getData().getUserId()); + List list = staffOrgRelationDao.selelctStaffOrg(staffIdList); + if (CollectionUtils.isEmpty(list)) { + return resultDTO; + } + + //3.校验工作人员的注册关系【从哪里新增进来的工作人员】 + //获取当前操作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getStaffId())); + } + //所属组织信息不同的给提示【所属组织不同时则不新增部门、不新增工作人员】 + if (!list.get(0).getAgencyId().equals(staffInfo.getAgencyId())) { + resultDTO.setMsg("联系电话已存在其他组织工作账号中,请使用其他手机号,否则将无法获取通知信息"); + resultDTO.setKey(false); + return resultDTO; + } + //从网格下添加的人给提示【网格下加的人时则不新增部门、不新增工作人员】 + if ("gridId".equals(list.get(0).getOrgType())) { + resultDTO.setMsg("联系电话已存在其他部门工作账号中,请先将该工作人员调动至本组织下,再次添加"); + resultDTO.setKey(false); + return resultDTO; + } + //账号被禁用的给提示【人员被禁用的则不新增部门、不新增工作人员】 + if ("disabled".equals(userResult.getData().getEnableFlag())) { + resultDTO.setMsg("该工作人员账号已被禁用,请使用其他联系电话,否则将无法获取通知信息"); + resultDTO.setKey(false); + return resultDTO; + } + //姓名不一样的给反馈 + if (!formDTO.getPersonName().equals(userResult.getData().getRealName())) { + resultDTO.setPersonName(userResult.getData().getRealName()); + } + + resultDTO.setType(true); + return resultDTO; + } + + } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 2dffd84aee..5cd018c37c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -855,4 +855,8 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping("/epmetuser/staffrole/getIsRootManager") Result getIsRootManager(@RequestParam("userId") String userId); + + @PostMapping("/epmetuser/customerstaff/staffdetailinfo") + Result staffDetailInfo(@RequestBody CustomerStaffFormDTO formDTO); + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index bee7102a73..6491dc477d 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -646,4 +646,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getIsRootManager", userId); } + @Override + public Result staffDetailInfo(CustomerStaffFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "staffDetailInfo", formDTO); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 274cb8ed87..f3a5d6bd99 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -493,5 +493,10 @@ public class CustomerStaffController { return new Result>().ok(customerStaffService.gridMobileList(formDTO.getGridId(), tokenDto.getUserId())); } + @PostMapping(value = "staffdetailinfo") + public Result staffDetailInfo(@RequestBody CustomerStaffFormDTO formDTO) { + return new Result().ok(customerStaffService.staffDetailInfo(formDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index e986aa8f07..16d6e83189 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -347,4 +347,6 @@ public interface CustomerStaffService extends BaseService { * @Description 【事件】网格员服务电话 **/ List gridMobileList(String gridId, String userId); + + CustomerStaffDTO staffDetailInfo(CustomerStaffFormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index c9c416d63c..1caf9abf5a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -45,7 +45,6 @@ import com.epmet.dao.StaffRoleDao; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.dto.result.NewUserRoleResultDTO; import com.epmet.entity.CustomerStaffEntity; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.entity.StaffRoleEntity; @@ -870,4 +869,9 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl