Browse Source

Merge branch 'dev_data_sync_user_org_for_yt' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_data_sync_user_org_for_yt

master
jianjun 3 years ago
parent
commit
8ec327e7ea
  1. 1
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java
  2. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  3. 49
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java
  4. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncOrgDataDao.java
  5. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/yantai/DataSyncOrgDataDao.xml
  6. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffOrgRelationDTO.java
  7. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffV2FromDTO.java
  8. 3
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java
  9. 1
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java
  10. 24
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  11. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/StaffOrgRelationEntity.java
  12. 17
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  13. 19
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

1
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java

@ -46,5 +46,6 @@ public class StaffDetailV2FormDTO implements Serializable {
* 数字社区里的角色名称 * 数字社区里的角色名称
*/ */
private List<String> szsqRoles; private List<String> szsqRoles;
private String customerId;
} }

5
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -7,6 +7,8 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.form.IdAndNameDTO; import com.epmet.commons.tools.dto.form.IdAndNameDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.OrgTypeEnum; 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.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
@ -720,7 +722,8 @@ public class EpmetUserServiceImpl implements EpmetUserService {
//基本信息 //基本信息
CustomerStaffDTO dto = customerStaffDao.selectByStaffId(staffId); CustomerStaffDTO dto = customerStaffDao.selectByStaffId(staffId);
if (null == dto) { if (null == dto) {
return result; // return result;
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"customer_staff is null staffId:"+staffId,"未查询到工作人员基础信息");
} }
//角色信息 //角色信息
List<String> list = staffRoleDao.selectByStaffId(staffId); List<String> list = staffRoleDao.selectByStaffId(staffId);

49
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java

@ -1,16 +1,22 @@
package com.epmet.controller.yantai; package com.epmet.controller.yantai;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoDTOCache;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.api.yt.OrgData; import com.epmet.commons.tools.utils.api.yt.OrgData;
import com.epmet.commons.tools.utils.api.yt.UserData;
import com.epmet.commons.tools.utils.api.yt.YantaiApi; import com.epmet.commons.tools.utils.api.yt.YantaiApi;
import com.epmet.dao.yantai.DataSyncOrgDataDao; import com.epmet.dao.yantai.DataSyncOrgDataDao;
import com.epmet.dao.yantai.DataSyncUserDataDao; import com.epmet.dao.yantai.DataSyncUserDataDao;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.form.yantai.YtUserPageFormDTO; import com.epmet.dto.form.yantai.YtUserPageFormDTO;
import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; import com.epmet.dto.result.yantai.DataSyncOrgDataDTO;
import com.epmet.dto.result.yantai.YtUserPageResDTO; import com.epmet.dto.result.yantai.YtUserPageResDTO;
import com.epmet.entity.yantai.DataSyncOrgDataEntity; import com.epmet.entity.yantai.DataSyncOrgDataEntity;
import com.epmet.entity.yantai.DataSyncUserDataEntity;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.DataSyncOrgDataService; import com.epmet.service.DataSyncOrgDataService;
import com.epmet.service.DataSyncUserDataService; import com.epmet.service.DataSyncUserDataService;
@ -56,9 +62,46 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService
*/ */
@Override @Override
public Boolean yanTaiSyncUser(String organizationId) { public Boolean yanTaiSyncUser(String organizationId) {
String customerId = "45687aa479955f9d06204d415238f7cc";
// List<UserData> data = YantaiApi.getUserByOuGuid(organizationId); // 缓存初始化staffs
//todo 更新或插入数据 epmetUserOpenFeignClient.allCustomerStaffInCache(customerId);
Integer no = NumConstant.ONE;
Integer size;
do {
// 分批获取org
PageInfo<com.epmet.dto.DataSyncOrgDataDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_HUNDRED).doSelectPageInfo(() -> dataSyncOrgDataDao.getAllList(customerId));
size = pageInfo.getList().size();
if (CollectionUtils.isNotEmpty(pageInfo.getList())){
List<DataSyncUserDataEntity> needInsert = new ArrayList<>();
pageInfo.getList().forEach(org -> {
// 根据org查用户
List<UserData> data = YantaiApi.getUserByOuGuid(org.getOrganizationId());
if (CollectionUtils.isNotEmpty(data)){
for (UserData u : data) {
CustomerStaffInfoDTOCache staffInfo = CustomerStaffRedis.getStaffInfoByMobile(customerId, u.getMobileTelephoneNumber());
DataSyncUserDataEntity entity = ConvertUtils.sourceToTarget(u, DataSyncUserDataEntity.class);
entity.setCustomerId(customerId);
entity.setRemark("");
if (null == staffInfo){
entity.setStatus(NumConstant.ZERO_STR);
entity.setOrganizationId("");
entity.setStaffId("");
}else {
CustomerStaffInfoCacheResult staffInfo1 = CustomerStaffRedis.getStaffInfo(customerId, staffInfo.getUserId());
entity.setStatus(NumConstant.ONE_STR);
entity.setOrganizationId(null == staffInfo1 ? "" : staffInfo1.getAgencyId());
entity.setStaffId(staffInfo.getUserId());
}
needInsert.add(entity);
}
}
});
dataSyncUserDataService.insertBatch(needInsert,NumConstant.FIVE_HUNDRED);
}
no++;
}while (size == NumConstant.ONE_HUNDRED);
// 删除staffs缓存
CustomerStaffRedis.delAllCustomerStaff(customerId);
return false; return false;
} }

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncOrgDataDao.java

@ -22,4 +22,6 @@ public interface DataSyncOrgDataDao extends BaseDao<DataSyncOrgDataEntity> {
* @return * @return
*/ */
List<DataSyncOrgDataDTO> queryList(@Param("pid") String pid); List<DataSyncOrgDataDTO> queryList(@Param("pid") String pid);
List<com.epmet.dto.DataSyncOrgDataDTO> getAllList(@Param("customerId") String customerId);
} }

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/yantai/DataSyncOrgDataDao.xml

@ -46,4 +46,10 @@
</if> </if>
order by d.ORDER_NUMBER asc order by d.ORDER_NUMBER asc
</select> </select>
<select id="getAllList" resultType="com.epmet.dto.DataSyncOrgDataDTO">
select * from data_sync_org_data
where del_flag = '0'
and CUSTOMER_ID = #{customerId}
order by ORDER_NUMBER asc
</select>
</mapper> </mapper>

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffOrgRelationDTO.java

@ -60,7 +60,7 @@ public class StaffOrgRelationDTO implements Serializable {
private String orgId; private String orgId;
/** /**
* 工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) * 工作人员添加入口类型(组织:agency;部门:dept;网格:grid)
*/ */
private String orgType; private String orgType;

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffV2FromDTO.java

@ -74,5 +74,8 @@ public class AddStaffV2FromDTO implements Serializable {
private List<String> newRoles; private List<String> newRoles;
private String currentStaffId; /**
* 烟台用当前登录用户
*/
private String currentUserId;
} }

3
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto.form; package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -14,7 +15,7 @@ import java.io.Serializable;
@Data @Data
public class StaffInfoFromDTO implements Serializable { public class StaffInfoFromDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public interface EditStaffInitGroup {} public interface EditStaffInitGroup extends CustomerClientShowGroup {}
/** /**
* 客户ID * 客户ID
*/ */

1
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java

@ -13,6 +13,7 @@ import java.util.List;
@Data @Data
public class StaffInitResultDTO implements Serializable { public class StaffInitResultDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String customerId;
/** /**
* 人员ID * 人员ID
*/ */

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

@ -4,13 +4,17 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.service.StaffService; import com.epmet.service.StaffService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -97,7 +101,7 @@ public class StaffController {
*/ */
@PostMapping("editstaff") @PostMapping("editstaff")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_UPDATE) @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_UPDATE)
public Result editStaff(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitFromDTO fromDTO){ public Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO){
ValidatorUtils.validateEntity(fromDTO); ValidatorUtils.validateEntity(fromDTO);
return staffService.editStaff(fromDTO); return staffService.editStaff(fromDTO);
} }
@ -204,10 +208,20 @@ public class StaffController {
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE) @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE)
public Result<StaffDetailResultDTO> addStaffV2(@LoginUser TokenDto tokenDto, @RequestBody AddStaffV2FromDTO fromDTO){ public Result<StaffDetailResultDTO> addStaffV2(@LoginUser TokenDto tokenDto, @RequestBody AddStaffV2FromDTO fromDTO){
ValidatorUtils.validateEntity(fromDTO, AddStaffV2FromDTO.AddStaff.class); ValidatorUtils.validateEntity(fromDTO, AddStaffV2FromDTO.AddStaff.class);
fromDTO.setCustomerId(tokenDto.getCustomerId()); if(AppClientConstant.APP_OPER.equals(tokenDto.getApp())){
fromDTO.setApp(tokenDto.getApp()); if(StringUtils.isBlank(fromDTO.getCustomerId())){
fromDTO.setClient(tokenDto.getClient()); // 该接口烟台运营端-统一认证也在用,所以客户id,运营端必传。
fromDTO.setCurrentStaffId(tokenDto.getUserId()); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"运营端操作,customerId不能为空","运营端操作,customerId不能为空");
}
}else{
//小程序端或者数字社区从token里面取
fromDTO.setCustomerId(tokenDto.getCustomerId());
}
//因为添加的是工作人员,这里写死吧!
fromDTO.setApp("gov");
fromDTO.setClient("wxmp");
//当前登录用户
fromDTO.setCurrentUserId(tokenDto.getUserId());
return staffService.addStaffV2(fromDTO); return staffService.addStaffV2(fromDTO);
} }

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/StaffOrgRelationEntity.java

@ -56,7 +56,7 @@ public class StaffOrgRelationEntity extends BaseEpmetEntity {
private String orgId; private String orgId;
/** /**
* 工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) * 工作人员添加入口类型(组织:agency;部门:dept;网格:grid)
*/ */
private String orgType; private String orgType;

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

@ -216,14 +216,12 @@ public class StaffServiceImpl implements StaffService {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
} }
// epmetUserFeignClient.editStaff没有用到这俩参数,就注释了。
// fromDTO.setApp(tokenDto.getApp()); // fromDTO.setApp(tokenDto.getApp());
// fromDTO.setClient(tokenDto.getClient()); // fromDTO.setClient(tokenDto.getClient());
Result result = epmetUserFeignClient.editStaff(fromDTO); Result result = epmetUserFeignClient.editStaff(fromDTO);
if (!result.success()) { if (!result.success()) {
if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),result.getInternalMsg(),result.getMsg());
return new Result().error(result.getCode(), result.getMsg());
}
return new Result().error(EpmetErrorCode.STAFF_EDIT_FAILED.getCode(), EpmetErrorCode.STAFF_EDIT_FAILED.getMsg());
} }
// if (tokenDto.getClient().equals("web")){ // if (tokenDto.getClient().equals("web")){
if(CollectionUtils.isNotEmpty(fromDTO.getNewRoles())){ if(CollectionUtils.isNotEmpty(fromDTO.getNewRoles())){
@ -575,8 +573,8 @@ public class StaffServiceImpl implements StaffService {
//1.根据新增人员类型判断查询机关信息 //1.根据新增人员类型判断查询机关信息
OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType()); OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType());
if (null == orgDTO) { if (null == orgDTO) {
logger.error(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType())); logger.warn(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType()));
throw new RenException("根据新增人员组织类型未查询到相关组织信息"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"根据新增人员组织类型未查询到相关组织信息","组织不存在");
} }
//2.调用user服务,新增用户信息 //2.调用user服务,新增用户信息
@ -584,10 +582,7 @@ public class StaffServiceImpl implements StaffService {
submitDTO.setAgencyId(orgDTO.getAgencyId()); submitDTO.setAgencyId(orgDTO.getAgencyId());
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaff(submitDTO); Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaff(submitDTO);
if (!result.success()) { if (!result.success()) {
if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),result.getInternalMsg(),result.getMsg());
return new Result().error(result.getCode(), result.getMsg());
}
return new Result().error(EpmetErrorCode.STAFF_ADD_FAILED.getCode(), EpmetErrorCode.STAFF_ADD_FAILED.getMsg());
} }
//3.人员机关表总人数加一、关系表新增关系数据 //3.人员机关表总人数加一、关系表新增关系数据
@ -655,7 +650,7 @@ public class StaffServiceImpl implements StaffService {
|| "0c41b272ee9ee95ac6f184ad548a30eb".equals(fromDTO.getCustomerId())) { || "0c41b272ee9ee95ac6f184ad548a30eb".equals(fromDTO.getCustomerId())) {
YtSyncStaffIdFormDTO ytSyncStaffIdFormDTO = ConvertUtils.sourceToTarget(fromDTO,YtSyncStaffIdFormDTO.class); YtSyncStaffIdFormDTO ytSyncStaffIdFormDTO = ConvertUtils.sourceToTarget(fromDTO,YtSyncStaffIdFormDTO.class);
ytSyncStaffIdFormDTO.setStaffId(result.getData().getUserId()); ytSyncStaffIdFormDTO.setStaffId(result.getData().getUserId());
ytSyncStaffIdFormDTO.setOperUserId(fromDTO.getCurrentStaffId()); ytSyncStaffIdFormDTO.setOperUserId(fromDTO.getCurrentUserId());
epmetThirdOpenFeignClient.dataSyncUpdateStaff(ytSyncStaffIdFormDTO); epmetThirdOpenFeignClient.dataSyncUpdateStaff(ytSyncStaffIdFormDTO);
} }
//2022.10.18加个返参,借用下StaffDetailResultDTO不再新建dto了 //2022.10.18加个返参,借用下StaffDetailResultDTO不再新建dto了

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

@ -61,6 +61,8 @@ import com.epmet.service.GovStaffRoleService;
import com.epmet.service.StaffRoleService; import com.epmet.service.StaffRoleService;
import com.epmet.service.UserService; import com.epmet.service.UserService;
import com.epmet.util.ModuleConstant; import com.epmet.util.ModuleConstant;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -301,6 +303,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
resultDTO.setMobile(customerStaffDTO.getMobile()); resultDTO.setMobile(customerStaffDTO.getMobile());
resultDTO.setWorkType(customerStaffDTO.getWorkType()); resultDTO.setWorkType(customerStaffDTO.getWorkType());
resultDTO.setIdCard(customerStaffDTO.getIdCard()); resultDTO.setIdCard(customerStaffDTO.getIdCard());
resultDTO.setCustomerId(customerStaffDTO.getCustomerId());
//获取角色列表 //获取角色列表
GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO(); GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO();
govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId()); govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId());
@ -347,7 +350,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
customerStaffFormDTO.setMobile(fromDTO.getMobile()); customerStaffFormDTO.setMobile(fromDTO.getMobile());
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO); CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO);
if (null != customerStaffDTO) { if (null != customerStaffDTO) {
return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg()); // return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"手机号已存在","手机号已存在");
} }
//USER表插入数据 //USER表插入数据
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
@ -467,12 +471,14 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
customerStaffFormDTO.setMobile(fromDTO.getMobile()); customerStaffFormDTO.setMobile(fromDTO.getMobile());
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO); CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO);
if (null != customerStaffDTO && !fromDTO.getStaffId().equals(customerStaffDTO.getUserId())) { if (null != customerStaffDTO && !fromDTO.getStaffId().equals(customerStaffDTO.getUserId())) {
return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg()); // return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"手机号已存在","手机号已存在");
} }
CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId());
//Customer_Staff表插入数据 //Customer_Staff表插入数据
CustomerStaffEntity staffEntity = new CustomerStaffEntity(); CustomerStaffEntity staffEntity = new CustomerStaffEntity();
staffEntity.setCustomerId(customerStaffEntity.getCustomerId());
staffEntity.setId(customerStaffEntity.getId()); staffEntity.setId(customerStaffEntity.getId());
staffEntity.setRealName(fromDTO.getName()); staffEntity.setRealName(fromDTO.getName());
staffEntity.setMobile(fromDTO.getMobile()); staffEntity.setMobile(fromDTO.getMobile());
@ -491,6 +497,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
staffRoleEntity.setStaffId(fromDTO.getStaffId()); staffRoleEntity.setStaffId(fromDTO.getStaffId());
staffRoleEntity.setRoleId(role); staffRoleEntity.setRoleId(role);
staffRoleEntity.setOrgId(fromDTO.getAgencyId()); staffRoleEntity.setOrgId(fromDTO.getAgencyId());
staffRoleEntity.setCustomerId(customerStaffEntity.getCustomerId());
staffRoleService.insert(staffRoleEntity); staffRoleService.insert(staffRoleEntity);
}); });
@ -1159,10 +1166,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
Integer no = NumConstant.ONE; Integer no = NumConstant.ONE;
Integer size; Integer size;
do { do {
List<CustomerStaffDTO> customerStaffs = baseDao.getAllStaffByCustomerId(customerId); PageInfo<CustomerStaffDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_HUNDRED).doSelectPageInfo(() -> baseDao.getAllStaffByCustomerId(customerId));
size = customerStaffs.size(); size = pageInfo.getList().size();
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(customerStaffs)){ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(pageInfo.getList())){
customerStaffs.forEach(c -> { pageInfo.getList().forEach(c -> {
String key = RedisKeys.getCustomerStaffInfoKeyByMobile(customerId, c.getMobile()); String key = RedisKeys.getCustomerStaffInfoKeyByMobile(customerId, c.getMobile());
Map<String, Object> map = BeanUtil.beanToMap(c, false, true); Map<String, Object> map = BeanUtil.beanToMap(c, false, true);
redisUtils.hMSet(key,map); redisUtils.hMSet(key,map);

Loading…
Cancel
Save