Browse Source

no message

master
zhangyuan 3 years ago
parent
commit
aac7da2598
  1. 80
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffV3FromDTO.java
  2. 74
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitV3FromDTO.java
  3. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  4. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  5. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
  6. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java
  7. 78
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  8. 49
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  9. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerStaffEntity.java
  10. 17
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  11. 132
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

80
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffV3FromDTO.java

@ -0,0 +1,80 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.List;
/**
* @author sun
* @dscription
*/
@NoArgsConstructor
@Data
public class AddStaffV3FromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 新增人员所属类型Id
*/
private String orgId;
/**
* 客户ID
*/
private String customerId;
/**
* 新增人员所属类型组织:agency;部门:dept;网格:grid
*/
private String orgType;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空", groups = AddStaffV3FromDTO.AddStaff.class)
@Length(max = 15, message = "姓名仅允许输入15个字符", groups = AddStaffV3FromDTO.AddStaff.class)
private String name;
/**
* 人员ID
*/
private String staffId;
/**
* 手机
*/
@NotBlank(message = "手机号不能为空", groups = AddStaffV3FromDTO.AddStaff.class)
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号", groups = AddStaffV3FromDTO.AddStaff.class)
private String mobile;
/**
* 性别
*/
@NotNull(message = "性别不能为空", groups = AddStaffV3FromDTO.AddStaff.class)
private Integer gender;
/**
* 专兼职
*/
@NotBlank(message = "专兼职不能为空", groups = AddStaffV3FromDTO.AddStaff.class)
private String workType;
/**
* 账户
*/
@NotBlank(message = "账户不能为空", groups = AddStaffV3FromDTO.AddStaff.class)
private String userAccount;
/**
* 角色id列表
*/
@NotNull(message = "角色不能为空", groups = AddStaffV3FromDTO.AddStaff.class)
private List<String> roles;
public interface AddStaff extends CustomerClientShowGroup {}
/**
* 来源app(政府端:gov居民端:resi运营端:oper)
*/
private String app;
/**
* 来源client(PC端:web微信小程序:wxmp)
*/
private String client;
}

74
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitV3FromDTO.java

@ -0,0 +1,74 @@
package com.epmet.dto.form;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/24 10:43
*/
@NoArgsConstructor
@Data
public class StaffSubmitV3FromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/
private String agencyId;
/**
* 人员ID
*/
private String staffId;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空")
@Length(max = 15, message = "姓名仅允许输入15个字符")
private String name;
/**
* 手机
*/
@NotBlank(message = "手机号不能为空")
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号")
private String mobile;
/**
* 性别
*/
@NotNull(message = "性别不能为空")
private Integer gender;
/**
* 性别
*/
@NotNull(message = "账户不能为空")
private String userAccount;
/**
* 专兼职
*/
@NotBlank(message = "专兼职不能为空")
private String workType;
/**
* 角色id列表
*/
@NotNull(message = "角色不能为空")
private List<String> roles;
/**
* 来源app(政府端:gov居民端:resi运营端:oper)
*/
private String app;
/**
* 来源client(PC端:web微信小程序:wxmp)
*/
private String client;
}

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java

@ -195,6 +195,20 @@ public class StaffController {
return staffService.addStaffV2(fromDTO);
}
/**
* 通讯录人员添加v2
* @author sun
*/
@PostMapping("addstaffv3")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE)
public Result addStaffV2(@LoginUser TokenDto tokenDto, @RequestBody AddStaffV3FromDTO fromDTO){
ValidatorUtils.validateEntity(fromDTO, AddStaffV3FromDTO.AddStaff.class);
fromDTO.setCustomerId(tokenDto.getCustomerId());
fromDTO.setApp(tokenDto.getApp());
fromDTO.setClient(tokenDto.getClient());
return staffService.addStaffV3(fromDTO);
}
/**
* @Description 用户所属组织
* @Param tokenDto

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -91,6 +91,16 @@ public interface EpmetUserFeignClient {
@PostMapping("/epmetuser/customerstaff/addstaff")
Result<CustomerStaffDTO> addStaff(@RequestBody StaffSubmitFromDTO fromDTO);
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("/epmetuser/customerstaff/addstaffv3")
Result<CustomerStaffDTO> addStaffV3(@RequestBody StaffSubmitV3FromDTO fromDTO);
/**
* 人员编辑
*

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java

@ -62,6 +62,11 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaff", fromDTO);
}
@Override
public Result<CustomerStaffDTO> addStaffV3(StaffSubmitV3FromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaffv3", fromDTO);
}
@Override
public Result editStaff(StaffSubmitFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaff", fromDTO);

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java

@ -130,6 +130,13 @@ public interface StaffService {
*/
Result addStaffV2(AddStaffV2FromDTO fromDTO);
/**
* 通讯录人员添加v3
* @author zhy
*/
Result addStaffV3(AddStaffV3FromDTO fromDTO);
/**
* @Description 工作人员所属组织
* @Param tokenDto

78
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java

@ -581,6 +581,84 @@ public class StaffServiceImpl implements StaffService {
return new Result();
}
/**
* 通讯录人员添加v3
* @author zhy
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result addStaffV3(AddStaffV3FromDTO 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("根据新增人员组织类型未查询到相关组织信息");
}
//2.调用user服务,新增用户信息
StaffSubmitV3FromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitV3FromDTO.class);
submitDTO.setAgencyId(orgDTO.getAgencyId());
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaffV3(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.setUserId(result.getData().getUserId());
customerStaffAgencyEntity.setAgencyId(orgDTO.getAgencyId());
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);
}
//5.工作人员注册组织关系表新增数据
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.setStaffId(result.getData().getUserId());
staffOrgRelationEntity.setOrgId(fromDTO.getOrgId());
staffOrgRelationEntity.setOrgType(fromDTO.getOrgType());
staffOrgRelationService.insert(staffOrgRelationEntity);
return new Result();
}
/**
* @param tokenDto
* @Description 工作人员所属组织

49
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -231,6 +231,31 @@ public class CustomerStaffController {
return result;
}
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("addstaffv3")
public Result<CustomerStaffDTO> addStaffV3(@RequestBody StaffSubmitV3FromDTO fromDTO){
Result<CustomerStaffDTO> result = customerStaffService.addStaffV3(fromDTO);
//2021-10-18 推送mq,数据同步到中介库 start
if (result.success()) {
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
mq.setCustomerId(fromDTO.getCustomerId());
mq.setOrgId(result.getData().getUserId());
mq.setOrgType("staff");
mq.setType("staff_create");
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq);
}
//2021-10-18 end
return result;
}
/**
* 人员编辑
*
@ -255,6 +280,30 @@ public class CustomerStaffController {
return result;
}
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("editstaffv3")
public Result editStaffV3(@RequestBody StaffSubmitV3FromDTO fromDTO){
Result result = customerStaffService.editStaffV3(fromDTO);
//2021-10-18 推送mq,数据同步到中介库 start
if (result.success()) {
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
mq.setCustomerId(fromDTO.getCustomerId());
mq.setOrgId(fromDTO.getStaffId());
mq.setOrgType("staff");
mq.setType("staff_change");
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq);
}
//2021-10-18 end
return result;
}
/**
* 人员详情
*

5
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerStaffEntity.java

@ -42,6 +42,11 @@ public class CustomerStaffEntity extends BaseEpmetEntity {
*/
private String userId;
/**
* 账户
*/
private String userAccount;
/**
* 真实姓名
*/

17
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java

@ -169,6 +169,15 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
*/
Result<CustomerStaffDTO> addStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
Result<CustomerStaffDTO> addStaffV3(StaffSubmitV3FromDTO fromDTO);
/**
* 人员编辑
*
@ -177,6 +186,14 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
*/
Result editStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
Result editStaffV3(StaffSubmitV3FromDTO fromDTO);
/**
* 人员详情
*

132
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -342,6 +342,63 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result<CustomerStaffDTO> addStaffV3(StaffSubmitV3FromDTO fromDTO) {
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO();
customerStaffFormDTO.setCustomerId(fromDTO.getCustomerId());
customerStaffFormDTO.setMobile(fromDTO.getMobile());
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO);
if (null != customerStaffDTO) {
return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg());
}
//USER表插入数据
UserEntity userEntity = new UserEntity();
userEntity.setFromApp(fromDTO.getApp());
userEntity.setFromClient(fromDTO.getClient());
userEntity.setCustomerId(fromDTO.getCustomerId());
userService.insert(userEntity);
//Customer_Staff表插入数据
CustomerStaffEntity staffEntity = new CustomerStaffEntity();
staffEntity.setCustomerId(fromDTO.getCustomerId());
staffEntity.setUserId(userEntity.getId());
staffEntity.setUserAccount(fromDTO.getUserAccount());
staffEntity.setRealName(fromDTO.getName());
staffEntity.setMobile(fromDTO.getMobile());
staffEntity.setActiveFlag(CustomerStaffConstant.INACTIVE);
staffEntity.setGender(fromDTO.getGender());
staffEntity.setWorkType(fromDTO.getWorkType());
staffEntity.setEnableFlag(CustomerStaffConstant.ENABLE);
staffEntity.setPassword(PasswordUtils.encode("12345678"));
baseDao.insert(staffEntity);
//工作人员角色关联表
fromDTO.getRoles().forEach(role -> {
StaffRoleEntity staffRoleEntity = new StaffRoleEntity();
staffRoleEntity.setStaffId(userEntity.getId());
staffRoleEntity.setRoleId(role);
staffRoleEntity.setOrgId(fromDTO.getAgencyId());
staffRoleEntity.setCustomerId(fromDTO.getCustomerId());
staffRoleService.insert(staffRoleEntity);
});
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(userEntity.getId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(), r.getRoleName());
});
dto.setRoles(m);
CustomerStaffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId());
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result editStaff(StaffSubmitFromDTO fromDTO) {
@ -416,6 +473,81 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return new Result();
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result editStaffV3(StaffSubmitV3FromDTO fromDTO) {
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO();
customerStaffFormDTO.setCustomerId(fromDTO.getCustomerId());
customerStaffFormDTO.setMobile(fromDTO.getMobile());
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO);
if (null != customerStaffDTO && !fromDTO.getStaffId().equals(customerStaffDTO.getUserId())) {
return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg());
}
CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId());
//Customer_Staff表插入数据
CustomerStaffEntity staffEntity = new CustomerStaffEntity();
staffEntity.setId(customerStaffEntity.getId());
staffEntity.setRealName(fromDTO.getName());
staffEntity.setMobile(fromDTO.getMobile());
staffEntity.setGender(fromDTO.getGender());
staffEntity.setUserAccount(fromDTO.getUserAccount());
staffEntity.setWorkType(fromDTO.getWorkType());
baseDao.updateById(staffEntity);
//清空权限关联
StaffRoleDTO staffRoleDTO = new StaffRoleDTO();
staffRoleDTO.setStaffId(fromDTO.getStaffId());
staffRoleDTO.setOrgId(fromDTO.getAgencyId());
staffRoleService.clearStaffRoles(staffRoleDTO);
//重新添加角色关联
fromDTO.getRoles().forEach(role -> {
StaffRoleEntity staffRoleEntity = new StaffRoleEntity();
staffRoleEntity.setStaffId(fromDTO.getStaffId());
staffRoleEntity.setRoleId(role);
staffRoleEntity.setOrgId(fromDTO.getAgencyId());
staffRoleService.insert(staffRoleEntity);
});
// 重新查询用户的角色列表(可以取到前端没有传过来的角色,例如根管理员)
List<StaffRoleEntity> staffRoleEntytiesByStaffIdAndOrgId = staffRoleService.getStaffRoleEntytiesByStaffIdAndOrgId(fromDTO.getAgencyId(), fromDTO.getStaffId());
List<String> roleIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(staffRoleEntytiesByStaffIdAndOrgId)) {
roleIds = staffRoleEntytiesByStaffIdAndOrgId.stream().map(sr -> sr.getRoleId()).collect(Collectors.toList());
}
// redis缓存角色修改
UpdateCachedRolesFormDTO updateRolesForm = new UpdateCachedRolesFormDTO();
updateRolesForm.setOrgId(fromDTO.getAgencyId());
updateRolesForm.setStaffId(fromDTO.getStaffId());
updateRolesForm.setRoleIds(roleIds);
try {
Result result = authFeignClient.updateCachedRoles(updateRolesForm);
if (!result.success()) {
logger.error("修改用户信息:修改用户已缓存的角色列表失败:{}", result.getInternalMsg());
}
logger.info("修改用户信息:修改用户已缓存的角色列表成功");
} catch (Exception e) {
log.error("method exception", e);
logger.error("修改用户信息:修改用户已缓存的角色列表异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
// 角色放缓存
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO();
List<RoleKeyValueResultDTO> roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles());
dto.setCustomerId(fromDTO.getCustomerId());
dto.setStaffId(fromDTO.getStaffId());
dto.setAgencyId(fromDTO.getAgencyId());
Map m = new HashMap(16);
roleKeyValue.forEach(r -> {
m.put(r.getRoleKey(), r.getRoleName());
});
dto.setRoles(m);
CustomerStaffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId());
return new Result();
}
@Override
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) {
StaffDetailResultDTO resultDTO = new StaffDetailResultDTO();

Loading…
Cancel
Save