Merge branch 'master' into feature/REQ-2539
This commit is contained in:
commit
f7ebc2524b
@ -19,7 +19,7 @@ import java.util.Map;
|
||||
public class JoinedWorkspaceOuJob {
|
||||
|
||||
/**
|
||||
* 加入的项目部及在该项目部下担任的所有岗位
|
||||
* 加入的项目及在该项目下担任的所有岗位
|
||||
*/
|
||||
private Map<Long, List<String>> workspaceJobMap = Collections.emptyMap();
|
||||
|
||||
@ -29,12 +29,12 @@ public class JoinedWorkspaceOuJob {
|
||||
private Map<Long, List<String>> ouJobMap = Collections.emptyMap();
|
||||
|
||||
/**
|
||||
* 加入的单位及在该单位加入的项目部
|
||||
* 加入的单位及在该单位加入的项目
|
||||
*/
|
||||
private Map<Long, List<Long>> ouWorkspaceMap = Collections.emptyMap();
|
||||
|
||||
/**
|
||||
* 加入的项目部及在该项目部加入的单位
|
||||
* 加入的项目及在该项目加入的单位
|
||||
*/
|
||||
private Map<Long, List<Long>> workspaceOuMap = Collections.emptyMap();
|
||||
|
||||
|
||||
@ -33,23 +33,23 @@ public enum MaterialTargetUserTypeEnum {
|
||||
}
|
||||
},
|
||||
|
||||
PROJECT("PROJECT", "按照项目部") {
|
||||
PROJECT("PROJECT", "按照项目") {
|
||||
@Override
|
||||
public boolean isDeliverRequired(List<Long> workspaceIds, List<Long> ouIds, List<String> jobCodes,
|
||||
Long loginWorkspaceId, Long loginOuid,
|
||||
JoinedWorkspaceOuJob workspaceOuJob) {
|
||||
|
||||
Map<Long, List<String>> workspaceJobMap = workspaceOuJob.getWorkspaceJobMap();
|
||||
log.info("投放项目部:{},投放岗位岗位:{},当前登录单位:{},用户加入项目部及担任岗位:{},单位加入的项目部:{},项目部下的单位:{}",
|
||||
log.info("投放项目:{},投放岗位:{},当前登录单位:{},用户加入项目及担任岗位:{},单位加入的项目:{},项目下的单位:{}",
|
||||
JSONUtil.toJsonStr(workspaceIds), JSONUtil.toJsonStr(jobCodes),
|
||||
loginOuid,
|
||||
JSONUtil.toJsonStr(workspaceJobMap),
|
||||
JSONUtil.toJsonStr(workspaceOuJob.getOuWorkspaceMap()),
|
||||
JSONUtil.toJsonStr(workspaceOuJob.getWorkspaceOuMap()));
|
||||
|
||||
// 配置全部项目部
|
||||
// 配置全部项目
|
||||
if (CollectionUtils.isEmpty(workspaceIds)) {
|
||||
// 未加入任何项目部
|
||||
// 未加入任何项目
|
||||
if (Objects.isNull(workspaceJobMap) || workspaceJobMap.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@ -65,13 +65,13 @@ public enum MaterialTargetUserTypeEnum {
|
||||
}
|
||||
}
|
||||
|
||||
// 若配置了具体项目部
|
||||
// 若配置了具体项目
|
||||
if (Objects.isNull(loginOuid) || loginOuid == 0L) {
|
||||
// 未加入任何项目部
|
||||
// 未加入任何项目
|
||||
if (CollectionUtils.isEmpty(workspaceJobMap)){
|
||||
return false;
|
||||
}
|
||||
// 加入的全部项目部与配置的项目部有交集
|
||||
// 加入的全部项目与配置的项目有交集
|
||||
if (workspaceIds.stream().anyMatch(workspaceJobMap::containsKey)) {
|
||||
if (CollectionUtils.isEmpty(jobCodes)) {
|
||||
return true;
|
||||
@ -85,8 +85,8 @@ public enum MaterialTargetUserTypeEnum {
|
||||
if (CollectionUtils.isEmpty(workspaceOuJob.getOuWorkspaceMap().get(loginOuid))) {
|
||||
return false;
|
||||
}
|
||||
// 以项目部下单位登录
|
||||
// 加入的全部项目部与配置的项目部有交集
|
||||
// 以项目下单位登录
|
||||
// 加入的全部项目与配置的项目有交集
|
||||
if (workspaceIds.stream().anyMatch(w -> workspaceOuJob.getOuWorkspaceMap().get(loginOuid).stream().anyMatch(w::equals))) {
|
||||
if (CollectionUtils.isEmpty(jobCodes)) {
|
||||
return true;
|
||||
@ -105,7 +105,7 @@ public enum MaterialTargetUserTypeEnum {
|
||||
JoinedWorkspaceOuJob workspaceOuJob) {
|
||||
|
||||
Map<Long, List<String>> ouJobMap = workspaceOuJob.getOuJobMap();
|
||||
log.info("投放单位:{},投放岗位岗位:{},当前登录单位:{},用户加入单位及担任岗位:{}",
|
||||
log.info("投放单位:{},投放岗位:{},当前登录单位:{},用户加入单位及担任岗位:{}",
|
||||
JSONUtil.toJsonStr(ouIds), JSONUtil.toJsonStr(jobCodes),
|
||||
loginOuid,
|
||||
JSONUtil.toJsonStr(ouJobMap));
|
||||
@ -170,12 +170,12 @@ public enum MaterialTargetUserTypeEnum {
|
||||
/**
|
||||
* 根据目标人权类型确认是否需要投放
|
||||
*
|
||||
* @param workspaceIds 配置的投放项目部
|
||||
* @param workspaceIds 配置的投放项目
|
||||
* @param ouIds 配置的投放单位
|
||||
* @param jobCodes 配置的投放岗位
|
||||
* @param loginWorkspaceId 当前登录的项目部
|
||||
* @param loginWorkspaceId 当前登录的项目
|
||||
* @param loginOuid 当前登录的单位
|
||||
* @param workspaceOuJob 用户参与的项目部和单位及其岗位
|
||||
* @param workspaceOuJob 用户参与的项目和单位及其岗位
|
||||
* @return 是否需要投放
|
||||
*/
|
||||
public abstract boolean isDeliverRequired(List<Long> workspaceIds, List<Long> ouIds, List<String> jobCodes,
|
||||
|
||||
@ -128,7 +128,7 @@ public class CreateMaterialReq {
|
||||
private List<String> jobCodes;
|
||||
|
||||
/**
|
||||
* 项目部id
|
||||
* 项目id
|
||||
*/
|
||||
private List<Long> workspaceIds;
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ public class ListMaterialByBannerCodeReq {
|
||||
private Long personId;
|
||||
|
||||
/**
|
||||
* 当前登录项目部id,用于筛选相关运营素材是否配置给了该项目部人员
|
||||
* 当前登录项目id,用于筛选相关运营素材是否配置给了该项目人员
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
@ -43,7 +43,7 @@ public class ListMaterialByBannerCodeReq {
|
||||
|
||||
/**
|
||||
* 岗位编码,搭配{@code workspaceIds}或{@code unitIds}使用
|
||||
* 用于筛选相关运营素材是否配置给了指定项目部下指定岗位人员
|
||||
* 用于筛选相关运营素材是否配置给了指定项目下指定岗位人员
|
||||
* 或指定单位下指定岗位人员
|
||||
*/
|
||||
private String jobCode;
|
||||
|
||||
@ -83,7 +83,7 @@ public class MaterialResp extends PageMaterialResp {
|
||||
private List<String> jobCodes;
|
||||
|
||||
/**
|
||||
* 项目部id
|
||||
* 项目id
|
||||
*/
|
||||
private List<Long> workspaceIds;
|
||||
|
||||
@ -138,7 +138,7 @@ public class MaterialResp extends PageMaterialResp {
|
||||
private Date createAt;
|
||||
|
||||
/**
|
||||
* 目标投放项目部或企业
|
||||
* 目标投放项目或企业
|
||||
*/
|
||||
private String targetWorkspaceOrUnit;
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ public class Material extends BaseEntity<Material> {
|
||||
private List<String> jobCodes;
|
||||
|
||||
/**
|
||||
* 项目部id,0表示所有项目部
|
||||
* 项目id,0表示所有项目
|
||||
*/
|
||||
@TableField(value = "workspace_ids", typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> workspaceIds;
|
||||
|
||||
@ -104,20 +104,29 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public List<MaterialResp> listMaterialByBannerCode(ListMaterialByBannerCodeReq req, String traceId) {
|
||||
long methodStartTime = System.currentTimeMillis();
|
||||
log.info("enter method {} : {}", "listMaterialByBannerCode", methodStartTime);
|
||||
// 获取广告位并校验(是否存在,是否启用,是否在有效期)
|
||||
if (Objects.isNull(validateBanner(req.getBannerCode()))) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
log.info("step 1 banner check finished: {}, duration: {}", System.currentTimeMillis(), System.currentTimeMillis() - methodStartTime);
|
||||
|
||||
// 获取该广告位下已上架且在有效期内的所有素材
|
||||
List<Material> materialList = list(buildListByBannerCodeQueryWrapper(req));
|
||||
if (CollectionUtils.isEmpty(materialList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
log.info("上架且有效广告位:{}", JSONUtil.toJsonStr(materialList));
|
||||
log.info("上架且有效素材:{}", JSONUtil.toJsonStr(materialList));
|
||||
|
||||
// 获取当前登录用户加入的所有项目部,单位及其在项目部或在单位下担任的岗位
|
||||
log.info("step 2 get valid materials finished: {}, duration: {}", System.currentTimeMillis(), System.currentTimeMillis() - methodStartTime);
|
||||
|
||||
// 获取当前登录用户加入的所有项目,单位及其在项目或在单位下担任的岗位
|
||||
JoinedWorkspaceOuJob personJoinedWorkspaceOuJob = getPersonJoinedWorkspaceOuJob(req.getPersonId());
|
||||
log.info("当前登录用户加入的所有项目,单位及其在项目或在单位下担任的岗位:{}", JSONUtil.toJsonStr(personJoinedWorkspaceOuJob));
|
||||
|
||||
log.info("step 3 get joined jobs finished: {}, duration: {}", System.currentTimeMillis(), System.currentTimeMillis() - methodStartTime);
|
||||
|
||||
// 根据素材投放规则进行过滤
|
||||
List<Material> list = materialList.stream()
|
||||
@ -135,6 +144,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
log.info("step 4 filter by rules finished: {}, duration: {}", System.currentTimeMillis(), System.currentTimeMillis() - methodStartTime);
|
||||
|
||||
// 记录素材投放日志
|
||||
CreateMaterialPutLogReq materialPutLogReq = new CreateMaterialPutLogReq();
|
||||
@ -144,6 +154,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
.setMaterialIds(list.stream().map(Material::getId).collect(Collectors.toList()));
|
||||
materialPutLogService.create(materialPutLogReq);
|
||||
|
||||
log.info("step 5 record log finished: {}, duration: {}", System.currentTimeMillis(), System.currentTimeMillis() - methodStartTime);
|
||||
|
||||
return BeanUtil.copyToList(list, MaterialResp.class);
|
||||
}
|
||||
|
||||
@ -379,7 +391,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取人员参与的项目部(单位)及其在该项目部(单位)下担任的岗位
|
||||
* 获取人员参与的项目(单位)及其在该项目(单位)下担任的岗位
|
||||
*
|
||||
* @param personId 人员的personId
|
||||
* @return {@link JoinedWorkspaceOuJob}
|
||||
@ -418,7 +430,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
// 获取相关的项目部和单位
|
||||
// 获取相关的项目和单位
|
||||
List<CooperateShipResp> genericQuery = cooperateShipGateway.genericQuery(CooperateShipQueryReq.builder()
|
||||
.organizationNodeIds(topNodeToJobIdMap.keySet())
|
||||
.workspaceTypes(Arrays.asList(1, 2, 4, 6))
|
||||
@ -436,13 +448,13 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
.collect(Collectors.groupingBy(CooperateShipResp::getOrganizationalUnitId,
|
||||
Collectors.mapping(CooperateShipResp::getOrganizationalNodeId, Collectors.toList())));
|
||||
|
||||
// 单位加入的项目部,Map<ouId,List<workspace>>
|
||||
// 单位加入的项目,Map<ouId,List<workspace>>
|
||||
Map<Long, List<Long>> ouIdToWorkspaceMap = genericQuery.stream()
|
||||
.filter(c -> c.getWorkspaceType() == 2)
|
||||
.collect(Collectors.groupingBy(CooperateShipResp::getOrganizationalUnitId,
|
||||
Collectors.mapping(CooperateShipResp::getWorkspaceId, Collectors.toList())));
|
||||
|
||||
// 项目部下的单位 Map<workspaceId, List<ouId>
|
||||
// 项目下的单位 Map<workspaceId, List<ouId>
|
||||
Map<Long, List<Long>> workspaceToOuIdMap = genericQuery.stream()
|
||||
.filter(c -> c.getWorkspaceType() == 2)
|
||||
.collect(Collectors.groupingBy(CooperateShipResp::getWorkspaceId,
|
||||
@ -468,7 +480,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialDao, Material> impl
|
||||
.distinct()
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
return new JoinedWorkspaceOuJob(workspaceToJobCodeMap, ouIdToJobCodeMap,ouIdToWorkspaceMap,workspaceToOuIdMap);
|
||||
return new JoinedWorkspaceOuJob(workspaceToJobCodeMap, ouIdToJobCodeMap, ouIdToWorkspaceMap, workspaceToOuIdMap);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cn.axzo.nanopart.api;
|
||||
|
||||
import cn.axzo.framework.web.http.ApiResponse;
|
||||
import cn.axzo.nanopart.api.constant.enums.BizTypeEnum;
|
||||
import cn.axzo.nanopart.api.request.CreateConfigReq;
|
||||
import cn.axzo.nanopart.api.response.ConfigResp;
|
||||
|
||||
@ -15,7 +15,8 @@ public enum BizTypeEnum {
|
||||
* 前端
|
||||
*/
|
||||
|
||||
FRONT(0, "前端");
|
||||
FRONT(0, "前端"),
|
||||
BACKEND(1, "后端");
|
||||
|
||||
@EnumValue
|
||||
private final Integer value;
|
||||
|
||||
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@ -32,7 +33,7 @@ public class CreateConfigReq {
|
||||
/**
|
||||
* 配置内容
|
||||
*/
|
||||
@NotNull(message = "配置内容不能为空")
|
||||
@NotEmpty(message = "配置内容不能为空")
|
||||
private Map<String, Object> content;
|
||||
|
||||
/**
|
||||
|
||||
@ -15,6 +15,11 @@
|
||||
<name>config-server</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.pokonyan</groupId>
|
||||
<artifactId>pokonyan</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-web-spring-boot-starter</artifactId>
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
package cn.axzo.nanopart.server.dao.entity;
|
||||
|
||||
import cn.axzo.nanopart.api.constant.enums.BizTypeEnum;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -19,7 +17,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "nanopart_config", autoResultMap = true)
|
||||
public class Config {
|
||||
public class Config extends BaseEntity<Config> {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ -29,10 +27,6 @@ public class Config {
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
private Map<String, Object> content;
|
||||
|
||||
private Boolean isDelete;
|
||||
private Date createAt;
|
||||
private Date updateAt;
|
||||
|
||||
private Long createBy;
|
||||
private Long updateBy;
|
||||
}
|
||||
|
||||
@ -8,15 +8,12 @@ import cn.axzo.nanopart.api.dto.CreateConfigDto;
|
||||
import cn.axzo.nanopart.server.dao.entity.Config;
|
||||
import cn.axzo.nanopart.server.dao.mapper.ConfigMapper;
|
||||
import cn.axzo.nanopart.server.service.ConfigService;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author wangsiqian
|
||||
@ -26,27 +23,24 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {
|
||||
private final ConfigMapper configMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createOrUpdateConfig(CreateConfigDto dto) {
|
||||
Config config = configMapper.selectOne(
|
||||
Wrappers.<Config>lambdaQuery()
|
||||
.eq(Config::getBizCode, dto.getBizCode())
|
||||
.eq(Config::getBizType, dto.getBizType())
|
||||
);
|
||||
Config config = lambdaQuery().eq(Config::getBizCode, dto.getBizCode())
|
||||
.eq(Config::getBizType, dto.getBizType())
|
||||
// 写入时可能存在的并发问题,取最新的一个
|
||||
.orderByDesc(BaseEntity::getUpdateAt)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
|
||||
if (config == null) {
|
||||
config = BeanMapper.copyBean(dto, Config::new);
|
||||
config.setCreateAt(new Date());
|
||||
config.setUpdateAt(new Date());
|
||||
} else {
|
||||
config.setBizCode(dto.getBizCode());
|
||||
config.setBizType(dto.getBizType());
|
||||
config.setContent(dto.getContent());
|
||||
config.setUpdateBy(dto.getCreateBy());
|
||||
config.setIsDelete(false);
|
||||
config.setUpdateAt(new Date());
|
||||
}
|
||||
|
||||
saveOrUpdate(config);
|
||||
@ -54,12 +48,11 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
|
||||
|
||||
@Override
|
||||
public ConfigDto getConfigByBizCode(String bizCode, BizTypeEnum bizType) {
|
||||
Config config = configMapper.selectOne(
|
||||
Wrappers.<Config>lambdaQuery()
|
||||
.eq(Config::getBizCode, bizCode)
|
||||
.eq(Config::getBizType, bizType)
|
||||
.eq(Config::getIsDelete, false)
|
||||
);
|
||||
Config config = lambdaQuery().eq(Config::getBizCode, bizCode)
|
||||
.eq(Config::getBizType, bizType)
|
||||
.orderByDesc(BaseEntity::getUpdateAt)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
if (config == null) {
|
||||
throw new ServiceException("未找到该配置");
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
||||
@ -6,7 +6,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -13,3 +13,8 @@ spring:
|
||||
include: swagger
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
arthas:
|
||||
app-name: ${spring.application.name}
|
||||
agent-id: ${ARTHAS_AGENT_ID:${spring.profiles.active}-${spring.application.name}}
|
||||
tunnel-server: ${ARTHAS_TUNNEL_SERVER:ws://localhost:7777/ws}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user