diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 8b9dfc3bc7..99dfb014dd 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -100,6 +100,7 @@ public enum EpmetErrorCode { EXIT_PEND_PROJECT(8408,"该工作人员有项目尚在处理,处理完毕方可操作"), EXIT_PUBLISHED_ACTIVITY(8409,"该工作人员有活动尚在进行,等活动完成方可操作"), CAN_NOT_SELF(8410,"无法对自己进行操作"), + ACCOUNT_USED(8411,"该手机号已注册"), PATROL_IS_NOT_OVER(8520,"巡查尚未结束"), ALREADY_EVALUATE(8501,"您已评价"), diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java index 4f51df6eb4..1afee71a4b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java @@ -212,13 +212,13 @@ public class StaffController { * 【通讯录】人员添加-平阴 * @author zhy */ + @PostMapping("addstaffpy") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE) - public Result addStaffPy(@LoginUser TokenDto tokenDto, @RequestBody AddStaffPyFromDTO fromDTO){ - ValidatorUtils.validateEntity(fromDTO, AddStaffPyFromDTO.AddStaff.class); - fromDTO.setCustomerId(tokenDto.getCustomerId()); - fromDTO.setApp(tokenDto.getApp()); - fromDTO.setClient(tokenDto.getClient()); + public Result addStaffPy(@RequestBody StaffSubmitPyFromDTO fromDTO){ + fromDTO.setApp("gov"); + fromDTO.setClient("wxmp"); + ValidatorUtils.validateEntity(fromDTO); return staffService.addStaffPy(fromDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java index 157e3a3b59..40ea290e27 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java @@ -143,7 +143,7 @@ public interface StaffService { * 【通讯录】人员添加-平阴 * @author zhy */ - Result addStaffPy(AddStaffPyFromDTO fromDTO); + Result addStaffPy(StaffSubmitPyFromDTO fromDTO); /** * @Description 工作人员所属组织 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index ab2fc816e4..5e4af1cfba 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -603,73 +603,37 @@ public class StaffServiceImpl implements StaffService { @Override @Transactional(rollbackFor = Exception.class) - public Result addStaffPy(AddStaffPyFromDTO fromDTO) { - //1.根据新增人员类型判断查询机关信息 - OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType()); - if (null == orgDTO) { - logger.error(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType())); - throw new RenException("根据新增人员组织类型未查询到相关组织信息"); - } + public Result addStaffPy(StaffSubmitPyFromDTO fromDTO) { + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + //fromDTO.setApp(tokenDto.getApp()); + //fromDTO.setClient(tokenDto.getClient()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + Result result = epmetUserFeignClient.addStaffPy(fromDTO); - //2.调用user服务,新增用户信息 - StaffSubmitPyFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitPyFromDTO.class); - submitDTO.setAgencyId(orgDTO.getAgencyId()); - Result result = epmetUserFeignClient.addStaffPy(submitDTO); if (!result.success()) { if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { return new Result().error(result.getCode(), result.getMsg()); } return new Result().error(EpmetErrorCode.STAFF_ADD_FAILED.getCode(), EpmetErrorCode.STAFF_ADD_FAILED.getMsg()); } - - //3.人员机关表总人数加一、关系表新增关系数据 //人员机关关系表 CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity(); - customerStaffAgencyEntity.setCustomerId(fromDTO.getCustomerId()); + customerStaffAgencyEntity.setCustomerId(customerAgencyEntity.getCustomerId()); customerStaffAgencyEntity.setUserId(result.getData().getUserId()); - customerStaffAgencyEntity.setAgencyId(orgDTO.getAgencyId()); + customerStaffAgencyEntity.setAgencyId(customerAgencyEntity.getId()); customerStaffAgencyService.insert(customerStaffAgencyEntity); //机关总人数加一 - CustomerAgencyEntity agencyEntity = new CustomerAgencyEntity(); - agencyEntity.setId(orgDTO.getAgencyId()); - agencyEntity.setTotalUser(orgDTO.getTotalUser() + 1); - customerAgencyService.updateById(agencyEntity); - - //4.部门、网格主表、关系表修改、新增数据 - if ("dept".equals(fromDTO.getOrgType())) { - CustomerStaffDepartmentEntity dept = new CustomerStaffDepartmentEntity(); - dept.setCustomerId(fromDTO.getCustomerId()); - dept.setUserId(result.getData().getUserId()); - dept.setDepartmentId(fromDTO.getOrgId()); - customerStaffDepartmentService.insert(dept); - CustomerDepartmentEntity departmentEntity = new CustomerDepartmentEntity(); - departmentEntity.setId(fromDTO.getOrgId()); - departmentEntity.setTotalUser(orgDTO.getDeptTotalUser() + 1); - customerDepartmentService.updateById(departmentEntity); - } - if ("grid".equals(fromDTO.getOrgType())) { - CustomerStaffGridEntity grid = new CustomerStaffGridEntity(); - grid.setCustomerId(fromDTO.getCustomerId()); - grid.setUserId(result.getData().getUserId()); - grid.setGridId(fromDTO.getOrgId()); - customerStaffGridService.insert(grid); - CustomerGridEntity gridEntity = new CustomerGridEntity(); - gridEntity.setId(fromDTO.getOrgId()); - gridEntity.setTotalUser(orgDTO.getGridTotalUser() + 1); - customerGridService.updateById(gridEntity); - } + customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1); + customerAgencyService.updateById(customerAgencyEntity); - //5.工作人员注册组织关系表新增数据 + //2021.8.25 sun 新增一张工作人员注册组织关系表,所以旧接口新增人员时关系表赋值关系数据 + //工作人员注册组织关系表新增数据 StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId()); - if("agency".equals(fromDTO.getOrgType())){ - staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids())); - }else { - staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids() + ":") + orgDTO.getAgencyId()); - } + staffOrgRelationEntity.setPids(("".equals(customerAgencyEntity.getPids()) ? "" : customerAgencyEntity.getPids())); staffOrgRelationEntity.setStaffId(result.getData().getUserId()); - staffOrgRelationEntity.setOrgId(fromDTO.getOrgId()); - staffOrgRelationEntity.setOrgType(fromDTO.getOrgType()); + staffOrgRelationEntity.setOrgId(customerAgencyEntity.getId()); + staffOrgRelationEntity.setOrgType("agency"); staffOrgRelationService.insert(staffOrgRelationEntity); return new Result(); diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java index 71efe0c029..ca28bb35ab 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java @@ -44,6 +44,11 @@ public class CustomerStaffDTO implements Serializable { */ private String userId; + /** + * 账户 + */ + private String userAccount; + /** * 真实姓名 */ 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 85f770742e..fc0f3e7b58 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 @@ -278,7 +278,11 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg()); } + CustomerStaffByAccountFormDTO customerStaffAccountFormDTO = new CustomerStaffByAccountFormDTO(); + customerStaffAccountFormDTO.setCustomerId(fromDTO.getCustomerId()); + customerStaffAccountFormDTO.setUserAccount(fromDTO.getUserAccount()); + customerStaffDTO = baseDao.selectListCustomerStaffInfoByAccount(customerStaffAccountFormDTO); + if (null != customerStaffDTO) { + return new Result().error(EpmetErrorCode.ACCOUNT_USED.getCode(), EpmetErrorCode.ACCOUNT_USED.getMsg()); + } //USER表插入数据 UserEntity userEntity = new UserEntity(); userEntity.setFromApp(fromDTO.getApp()); @@ -578,6 +589,9 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl