Commit a6ab8d87 by 春觉晓

修改创建策略接口

1 parent bc90a4f4
...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.mindworkplate.model.PadMessageBox; ...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.mindworkplate.model.PadMessageBox;
import cn.com.glsx.dj.mindworkplate.remote.PadMessageBoxRemote; import cn.com.glsx.dj.mindworkplate.remote.PadMessageBoxRemote;
import cn.com.glsx.dj.peanalysis.dto.DataBizQueryParamsDTO; import cn.com.glsx.dj.peanalysis.dto.DataBizQueryParamsDTO;
import cn.com.glsx.dj.peanalysis.dto.DataBusinessDTO; import cn.com.glsx.dj.peanalysis.dto.DataBusinessDTO;
import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import cn.com.glsx.dj.strategy.config.DataStatsConfig; import cn.com.glsx.dj.strategy.config.DataStatsConfig;
import cn.com.glsx.dj.strategy.config.KafkaTopicConfig; import cn.com.glsx.dj.strategy.config.KafkaTopicConfig;
...@@ -130,7 +131,7 @@ public class StrategyInfoService { ...@@ -130,7 +131,7 @@ public class StrategyInfoService {
//批量插入策略基础信息 //批量插入策略基础信息
strategyInfoMapper.insertList(strategyInfoList); strategyInfoMapper.insertList(strategyInfoList);
//批量插入策略人员关联信息 //批量插入策略人员关联信息
strategyStaffRelService.batchInsert(strategyInfoList, batchStrategyInfo.getStaffList()); strategyStaffRelService.batchInsert(strategyInfoList, batchStrategyInfo.getStaffList(), SceneTypeEnum.SCENE1_0.getValue());
//批量插入策略课程关联关系 //批量插入策略课程关联关系
strategyCourseRelService.batchInsert(strategyInfoList, batchStrategyInfo.getCourseList()); strategyCourseRelService.batchInsert(strategyInfoList, batchStrategyInfo.getCourseList());
//批量插入策略-录音关联关系 //批量插入策略-录音关联关系
......
package cn.com.glsx.dj.strategy.service; package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.smartcarlife.dto.StaffInfoDTO;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper; import cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper;
import cn.com.glsx.dj.strategy.model.StrategyInfo; import cn.com.glsx.dj.strategy.model.StrategyInfo;
import cn.com.glsx.dj.strategy.model.StrategyStaffRel; import cn.com.glsx.dj.strategy.model.StrategyStaffRel;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert; import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListRequestDTO; import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListRequestDTO;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListResonseDTO; import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListResonseDTO;
...@@ -30,13 +33,16 @@ public class StrategyStaffRelService { ...@@ -30,13 +33,16 @@ public class StrategyStaffRelService {
@Autowired @Autowired
private MerchantStaffRemote merchantStaffRemote; private MerchantStaffRemote merchantStaffRemote;
@Autowired
private StaffInfoRemote staffInfoRemote;
/** /**
* 批量插入策略人员关联关系 * 批量插入策略人员关联关系
* @param strategyInfoList * @param strategyInfoList
* @param staffList * @param staffList
* @return * @return
*/ */
public int batchInsert(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList) { public int batchInsert(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList, Byte sceneType) {
if (CollectionUtils.isEmpty(staffList)) return 0; if (CollectionUtils.isEmpty(staffList)) return 0;
//根据手机号,查询北森人员userId //根据手机号,查询北森人员userId
List<String> phoneList = staffList.stream().map(StrategyStaffRel::getUserPhone).collect(Collectors.toList()); List<String> phoneList = staffList.stream().map(StrategyStaffRel::getUserPhone).collect(Collectors.toList());
...@@ -46,16 +52,24 @@ public class StrategyStaffRelService { ...@@ -46,16 +52,24 @@ public class StrategyStaffRelService {
//构建map //构建map
phoneUserIdMap = employeeList.stream().collect(Collectors.toMap(BeiSenEmployeeListResonseDTO::getMobilePhone, BeiSenEmployeeListResonseDTO::getUserID)); phoneUserIdMap = employeeList.stream().collect(Collectors.toMap(BeiSenEmployeeListResonseDTO::getMobilePhone, BeiSenEmployeeListResonseDTO::getUserID));
} }
//根据员工id查询 员工信息
Map<String, StaffInfoDTO> userMap = queryUserMap(strategyInfoList, staffList, sceneType);
//构建对象,遍历2个对象创建新StrategyStaffRel //构建对象,遍历2个对象创建新StrategyStaffRel
List<StrategyStaffRel> all = new ArrayList<>(); List<StrategyStaffRel> all = new ArrayList<>();
for (StrategyInfo strategyInfo : strategyInfoList) { for (StrategyInfo strategyInfo : strategyInfoList) {
for (StrategyStaffRel staff : staffList) { for (StrategyStaffRel staff : staffList) {
StrategyStaffRel rel = new StrategyStaffRel(); StrategyStaffRel rel = new StrategyStaffRel();
rel.setUserUuid(staff.getUserUuid()); rel.setUserUuid(staff.getUserUuid());
rel.setUserName(staff.getUserName()); //rel.setUserName(staff.getUserName());
String key = staff.getUserUuid() + staff.getUserPosition();
if (userMap.containsKey(key)) {
StaffInfoDTO user = userMap.get(key);
rel.setUserName(user.getStaffName());
rel.setUserPhone(user.getPhoneNumber());
}
rel.setStrategyId(strategyInfo.getId()); rel.setStrategyId(strategyInfo.getId());
rel.setUserPosition(staff.getUserPosition()); rel.setUserPosition(staff.getUserPosition());
rel.setUserPhone(staff.getUserPhone()); //rel.setUserPhone(staff.getUserPhone());
rel.setCreatedBy(strategyInfo.getCreatedBy()); rel.setCreatedBy(strategyInfo.getCreatedBy());
rel.setCreatedDate(strategyInfo.getCreatedDate()); rel.setCreatedDate(strategyInfo.getCreatedDate());
rel.setDeletedFlag(DeleteFlagEnum.N.getValue()); rel.setDeletedFlag(DeleteFlagEnum.N.getValue());
...@@ -66,6 +80,33 @@ public class StrategyStaffRelService { ...@@ -66,6 +80,33 @@ public class StrategyStaffRelService {
return strategyStaffRelMapper.insertList(all); return strategyStaffRelMapper.insertList(all);
} }
public Map<String, StaffInfoDTO> queryUserMap(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList, Byte sceneType) {
//根据员工id查询 员工信息
List<String> userUuidList = staffList.stream().map(x -> x.getUserUuid()).collect(Collectors.toList());
List<Integer> merchantIdList = strategyInfoList.stream().map(x -> x.getMerchantId()).collect(Collectors.toList());
RpcPagination<StaffInfoDTO> pagination = new RpcPagination<>();
pagination.setPageNum(1);
pagination.setPageSize(staffList.size());
StaffInfoDTO staffInfoDTO = new StaffInfoDTO();
staffInfoDTO.setStaffUuidList(userUuidList);
staffInfoDTO.setMerchantIdList(merchantIdList);
staffInfoDTO.setSceneType(sceneType);
List<Integer> postList = staffList.stream().map(StrategyStaffRel::getUserPosition).distinct().collect(Collectors.toList());
staffInfoDTO.setPositionTypeList(postList);
pagination.setCondition(staffInfoDTO);
RpcResponse<RpcPagination<StaffInfoDTO>> response = staffInfoRemote.listMultipleRolesStaffWithPage(pagination);
if (response.hasError()) {
log.error("创建策略,查询人员失败, response: {}", response);
throw new RpcServiceException(DefaultErrorEnum.RPC_ERROR, response.getMessage());
}
Map<String, StaffInfoDTO> userMap = new HashMap<>();
if (response.getResult() != null && CollectionUtils.isNotEmpty(response.getResult().getList())) {
//以 staff_uuid +positionType 为key 构建map
userMap = response.getResult().getList().stream().collect(Collectors.toMap(x -> x.getStaffUuid() + x.getPositionType(), x -> x, (oldVal, newVal) -> newVal));
}
return userMap;
}
/** /**
* 根据策略id删除关联关系 * 根据策略id删除关联关系
* @param strategyId * @param strategyId
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!