Commit 957b8c0d by 春觉晓

添加策略,新增北森员工id保存逻辑

1 parent 6216eb87
......@@ -9,13 +9,13 @@ import java.math.BigDecimal;
@Data
public class StaffSummaryDTO implements Serializable {
@ApiModelProperty(value = "驻店时长")
@ApiModelProperty(notes = "驻店时长")
private Integer stayDuration;
@ApiModelProperty(value = "学习时长")
@ApiModelProperty(notes = "学习时长")
private BigDecimal studyDuration;
@ApiModelProperty(value = "学习率")
@ApiModelProperty(notes = "学习率")
private BigDecimal studyRate;
}
......@@ -49,6 +49,15 @@ public class StrategyStaffRel implements Serializable {
private Integer userPosition;
/**
* 北森人员id
*/
@ApiModelProperty(notes = "北森人员id")
@Column(name = "beisen_userid")
private Integer beisenUserId;
/**
* 创建人
*/
@Column(name = "created_by")
......
......@@ -64,6 +64,11 @@
<artifactId>rpc-dj-pe-analysis-api</artifactId>
<version>5.6.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.merchants</groupId>
<artifactId>platform-merchants-api</artifactId>
<version>5.6.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -13,17 +13,22 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration
@RequiredArgsConstructor
public class MerchantDubboConfig {
public class MerchantDubboConfig extends DubboConfig {
private final ReferenceBuilderFactory factory;
// @Bean
// public MerchantStaffRemote merchantStaffRemote() {
// return factory
// .builder(MerchantStaffRemote.class)
// .check(false)
// .timeout(30000)
// .build();
// }
@Bean
public MerchantStaffRemote merchantStaffRemote() {
return factory
.builder(MerchantStaffRemote.class)
.check(false)
.timeout(30000)
.build();
return factory.builder(MerchantStaffRemote.class).version("2.0.0").check(check).timeout(timeout).build();
}
}
......@@ -112,7 +112,13 @@ public class StrategyInfoService {
strategyRecordingRelService.batchInsert(strategyInfoList, batchStrategyInfo.getRecordingList());
//判断是否需要立即推送消息
if (StrategyPushType.IMMEDIATE_PUSH.getValue().equals(baseStrategyInfo.getPushType())) {
//立即推送消息
// 异步线程推送消息
new Thread(() -> {
strategyInfoList.forEach(x -> {
sendStrategyPushMessage(x.getId());
});
}).start();
}
return Boolean.TRUE;
}
......
......@@ -3,6 +3,13 @@ package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper;
import cn.com.glsx.dj.strategy.model.StrategyInfo;
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.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListRequestDTO;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListResonseDTO;
import cn.com.glsx.merchants.remote.MerchantStaffRemote;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -11,9 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
......@@ -21,6 +27,9 @@ public class StrategyStaffRelService {
@Autowired
private StrategyStaffRelMapper strategyStaffRelMapper;
@Autowired
private MerchantStaffRemote merchantStaffRemote;
/**
* 批量插入策略人员关联关系
* @param strategyInfoList
......@@ -29,6 +38,14 @@ public class StrategyStaffRelService {
*/
public int batchInsert(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList) {
if (CollectionUtils.isEmpty(staffList)) return 0;
//根据手机号,查询北森人员userId
List<String> phoneList = staffList.stream().map(StrategyStaffRel::getUserPhone).collect(Collectors.toList());
List<BeiSenEmployeeListResonseDTO> employeeList = listEmployeeInfoByStaffPhone(phoneList);
Map<String, Integer> phoneUserIdMap = Collections.EMPTY_MAP;
if (CollectionUtils.isNotEmpty(employeeList)) {
//构建map
phoneUserIdMap = employeeList.stream().collect(Collectors.toMap(BeiSenEmployeeListResonseDTO::getMobilePhone, BeiSenEmployeeListResonseDTO::getUserID));
}
//构建对象,遍历2个对象创建新StrategyStaffRel
List<StrategyStaffRel> all = new ArrayList<>();
for (StrategyInfo strategyInfo : strategyInfoList) {
......@@ -42,6 +59,7 @@ public class StrategyStaffRelService {
rel.setCreatedBy(strategyInfo.getCreatedBy());
rel.setCreatedDate(strategyInfo.getCreatedDate());
rel.setDeletedFlag(DeleteFlagEnum.N.getValue());
rel.setBeisenUserId(phoneUserIdMap.get(staff.getUserPhone()));
all.add(rel);
}
}
......@@ -79,4 +97,21 @@ public class StrategyStaffRelService {
public StrategyStaffRel selectByPrimaryKey(Integer strategyStaffId) {
return strategyStaffRelMapper.selectByPrimaryKey(strategyStaffId);
}
public List<BeiSenEmployeeListResonseDTO> listEmployeeInfoByStaffPhone(List<String> phoneList) {
RpcAssert.assertNotEmpty(phoneList, DefaultErrorEnum.PARAMETER_NULL, "员工手机号不能为空");
RpcPagination<BeiSenEmployeeListRequestDTO> pagination = new RpcPagination<>();
BeiSenEmployeeListRequestDTO condition = new BeiSenEmployeeListRequestDTO();
pagination.setCondition(condition);
pagination.setPageNum(1);
pagination.setPageSize(phoneList.size());
condition.setMobilePhoneList(phoneList);
RpcResponse<RpcPagination<BeiSenEmployeeListResonseDTO>> rpcRes = merchantStaffRemote.getBeisenUserWithConditions(pagination);
RpcPagination<BeiSenEmployeeListResonseDTO> result = rpcRes.getResult();
if (result == null || CollectionUtils.isEmpty(result.getList())) {
return null;
}
return result.getList();
}
}
......@@ -60,9 +60,9 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
batchInsertStrategyInfo.setStrategyInfo(strategyInfo);
List<StrategyStaffRel> staffList = new ArrayList<>();
StrategyStaffRel strategyStaffRel = new StrategyStaffRel();
strategyStaffRel.setUserUuid("c359e4838e2547aaa140d9a67ec0b165");
strategyStaffRel.setUserName("狗蛋");
strategyStaffRel.setUserPhone("13568974654");
strategyStaffRel.setUserUuid("45b08bd283f441bcb3ebbf5048eab1a0");
strategyStaffRel.setUserName("测试小胡");
strategyStaffRel.setUserPhone("15946151312");
strategyStaffRel.setUserPosition(9);
staffList.add(strategyStaffRel);
batchInsertStrategyInfo.setStaffList(staffList);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!