public List<Map> activityList(Map bean) {
MetaDBTemplate template = new MetaDBTemplate();
List<Map> resultList = new ArrayList<>();
IBusinessTrip trip = template.get(IBusinessTrip.class, MapUtil.getInt(bean, "objid"));
if (Objects.isNull(trip)) {
throw new CrmException("公出信息不存在");
}
if(StrUtil.isNotEmpty(trip.getActivity_id())) {
resultList = Stream.of(trip.getActivity_id().split(","))
.filter(StrUtil::isNotEmpty)
.filter(activityId -> {
IActivity activity = template.get(IActivity.class, Integer.parseInt(activityId));
return Objects.nonNull(activity);
}).map(activityId -> {
IActivity activity = template.get(IActivity.class, Integer.parseInt(activityId));
Map map = new HashMap();
map.put("subject", activity.getSubject());
map.put("start_time", activity.getStart_time());
map.put("end_time", activity.getEnd_time());
map.put("accountname", activity.getAccountname());
map.put("createtimestamp", activity.getCreateTimestamp());
map.put("objid", activity.getId());
if (Objects.nonNull(activity.getAccount_id())) {
IAccount account = template.get(IAccount.class, activity.getAccount_id());
if (Objects.nonNull(account)) {
map.put("accountname", account.getName());
}
}
if (StrUtil.isNotEmpty(activity.getCreatedby())) {
try {
IEcUserInfo userInfo = userInfoService.queryUserByUserId(activity.getCreatedby());
if (Objects.nonNull(userInfo)) {
map.put("createdby_value", userInfo.getEmpname());
}
} catch (Exception e) {
LOGGER.error("查询创建用户异常", e);
}
}
map.put("state_value", ActivityStateEnums.getDesc(activity.getState()));
map.put("type_value", ActivityTypeEnum.getDesc(activity.getType()));
return map;
}).collect(Collectors.toList());
}
return resultList;
}
使用Stream.of方法遍历对象或者集合
最新推荐文章于 2024-01-22 12:00:00 发布