mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 03:16:48 +08:00
Merge branch 'master' of https://codeup.aliyun.com/648097ddb583fece2f059e59/boe/java-servers
This commit is contained in:
@@ -177,6 +177,8 @@ public class CasesApi extends ApiBaseController {
|
||||
try {
|
||||
OutputStream = response.getOutputStream();
|
||||
LinkedHashMap<String,String> map = new LinkedHashMap<>();
|
||||
map.put("标题","title");
|
||||
map.put("密级","confidentialityLevel");
|
||||
map.put("浏览量","views");
|
||||
map.put("推荐量","recommends");
|
||||
map.put("引用量","cites");
|
||||
@@ -191,6 +193,8 @@ public class CasesApi extends ApiBaseController {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (Cases c:list){
|
||||
CaseExportVo caseExportVo = new CaseExportVo();
|
||||
caseExportVo.setTitle(c.getTitle());
|
||||
caseExportVo.setConfidentialityLevel(c.getConfidentialityLevel());
|
||||
caseExportVo.setViews(c.getViews());
|
||||
caseExportVo.setRecommends(c.getRecommends());
|
||||
caseExportVo.setCites(c.getCites());
|
||||
|
||||
@@ -18,43 +18,37 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
public interface CasesRecordDao extends JpaRepository<Cases, String>, JpaSpecificationExecutor<Cases> {
|
||||
|
||||
@Query(nativeQuery = true, value = "select b.id,b.sys_create_aid,b.sys_create_by,b.sys_create_time,b.deleted,b.sys_update_by,b.sys_update_time,b.sys_version," +
|
||||
"b.excellent_time,b.excellent,b.case_value,b.readers,b.keyword5,b.keyword4,b.keyword3,b.keyword2,b.keyword1,b.case_theme_description,b.case_theme" +
|
||||
",b.case_type2,b.case_type1,b.case_type,b.case_owner_org,b.case_specialty_sequence,b.case_other_contributor,b.case_owner_phone,b.case_owner_department" +
|
||||
",b.case_owner,b.case_flow,b.case_scope,b.is_leadership_plan,b.case_channel,b.email,b.contact_number,b.department,b.drafter,b.end_time,b.drafting_time," +
|
||||
"b.confidentiality_level,b.approval_number,b.major_type,b.org_domain_parent3,b.org_domain_parent2,b.org_domain_parent,b.org_domain,b.summary,b.cites,b.recommends," +
|
||||
"b.favorites,b.shares,b.praises,b.comments,b.views,b.status,b.top_time,b.is_top,b.recommend_time,b.bre_commend,b.cover_url,b.author_name,b.author_id,b.file_name" +
|
||||
",b.file_path,b.content,b.company_id,b.title" +
|
||||
" from boe_cases_recommend_push_record a LEFT JOIN boe_cases b on a.case_id = b.id and b.deleted=0 " +
|
||||
" where a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(:#{#condition.keyWord} is not null,b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
@Query(nativeQuery = true, value = "select b.*" +
|
||||
" from boe_cases_recommend_push_record a INNER JOIN boe_cases b on a.case_id = b.id" +
|
||||
" where b.deleted=0 and a.push_status = 3 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
|
||||
" and if(:#{#condition.years} is not null ,YEAR(b.sys_create_time) in (:#{#condition.years}),1=1 )" +
|
||||
" and if(:#{#condition.majorType} is not null ,b.major_type = :#{#condition.majorType},1=1) " +
|
||||
" and if(:#{#condition.org1} is not null,b.org_domain_parent in (:#{#condition.org1}),1=1)" +
|
||||
" and if(:#{#condition.org2} is not null,b.org_domain_parent2 in (:#{#condition.org2}),1=1)" +
|
||||
" and if(:#{#condition.org3} is not null,b.org_domain_parent3 in (:#{#condition.org3}),1=1)" +
|
||||
" and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
|
||||
" and if(IFNULL(:#{#condition.majorType},'') !='',b.major_type = :#{#condition.majorType},1=1) " +
|
||||
" and if(:#{#condition.org1Empty}, 1=1, b.org_domain_parent in (:#{#condition.org1}))" +
|
||||
" and if(:#{#condition.org2Empty}, 1=1, b.org_domain_parent2 in (:#{#condition.org2}))" +
|
||||
" and if(:#{#condition.org3Empty}, 1=1, b.org_domain_parent3 in (:#{#condition.org3}))" +
|
||||
" group by b.id order by a.sys_create_time DESC",
|
||||
countQuery = "select count(*)" +
|
||||
" from boe_cases_recommend_push_record a LEFT JOIN boe_cases b on a.case_id = b.id and b.deleted=0 " +
|
||||
" where a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(:#{#condition.keyWord} is not null,b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
countQuery = "select count(*) FROM (select b.*" +
|
||||
" from boe_cases_recommend_push_record a INNER JOIN boe_cases b on a.case_id = b.id " +
|
||||
" where b.deleted=0 and a.push_status = 3 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
|
||||
" and if(:#{#condition.years} is not null ,YEAR(b.sys_create_time) in (:#{#condition.years}),1=1 )" +
|
||||
" and if(:#{#condition.majorType} is not null ,b.major_type = :#{#condition.majorType},1=1) " +
|
||||
" and if(:#{#condition.org1} is not null,b.org_domain_parent in (:#{#condition.org1}),1=1)" +
|
||||
" and if(:#{#condition.org2} is not null,b.org_domain_parent2 in (:#{#condition.org2}),1=1)" +
|
||||
" and if(:#{#condition.org3} is not null,b.org_domain_parent3 in (:#{#condition.org3}),1=1)" +
|
||||
" group by b.id")
|
||||
" and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
|
||||
" and if(IFNULL(:#{#condition.majorType},'') !='' ,b.major_type = :#{#condition.majorType},1=1) " +
|
||||
" and if(:#{#condition.org1Empty}, 1=1, b.org_domain_parent in (:#{#condition.org1}))" +
|
||||
" and if(:#{#condition.org2Empty}, 1=1, b.org_domain_parent2 in (:#{#condition.org2}))" +
|
||||
" and if(:#{#condition.org3Empty}, 1=1, b.org_domain_parent3 in (:#{#condition.org3}))" +
|
||||
" group by b.id) as b")
|
||||
Page<Cases> queryList(Pageable pageable, @Param("condition") CasePageVo casePage);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.boecase.dto;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -61,6 +62,9 @@ public class CasePageVo extends PageDto {
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
public boolean isYearsEmpty() {
|
||||
return CollUtil.isEmpty(this.years);
|
||||
}
|
||||
|
||||
public List<String> getOrg1() {
|
||||
if (CollectionUtils.isNotEmpty(this.orgDomainDtos)) {
|
||||
@@ -69,6 +73,18 @@ public class CasePageVo extends PageDto {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOrg1Empty() {
|
||||
return CollUtil.isEmpty(this.getOrg1());
|
||||
}
|
||||
|
||||
public boolean isOrg2Empty() {
|
||||
return CollUtil.isEmpty(this.getOrg2());
|
||||
}
|
||||
|
||||
public boolean isOrg3Empty() {
|
||||
return CollUtil.isEmpty(this.getOrg3());
|
||||
}
|
||||
|
||||
public List<String> getOrg2() {
|
||||
if (CollectionUtils.isNotEmpty(this.orgDomainDtos)) {
|
||||
return orgDomainDtos.stream().flatMap(it->it.getChildren().stream()).map(OrgDomainDto::getParent).filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
|
||||
@@ -28,4 +28,5 @@ public class CaseVo {
|
||||
private String authorName;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -267,6 +267,32 @@ public class Cases extends BaseEntity {
|
||||
@Transient
|
||||
private String recommendOrgName;
|
||||
|
||||
@Transient
|
||||
private Long recommendId;
|
||||
|
||||
public Long getRecommendId() {
|
||||
return recommendId;
|
||||
}
|
||||
|
||||
public void setRecommendId(Long recommendId) {
|
||||
this.recommendId = recommendId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Cases() {
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ public class CasesServiceImpl implements ICasesService {
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.eq("pushUserId", caseVo.getUserId()));
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 4));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
@@ -331,15 +331,62 @@ public class CasesServiceImpl implements ICasesService {
|
||||
|
||||
@Override
|
||||
public PageList<Cases> queryRecommendPageCasesV2(CasePageVo caseVo) {
|
||||
PageRequest pageRequest = PageRequest.of(caseVo.getPageIndex(), caseVo.getPageSize());
|
||||
Page<Cases> cases = casesRecordDao.queryList(pageRequest, caseVo);
|
||||
|
||||
PageRequest pageRequest = PageRequest.of(caseVo.getPageIndex() - 1, caseVo.getPageSize());
|
||||
Page<Cases> cases = casesRecordDao.queryList(pageRequest,caseVo);
|
||||
PageList<Cases> pageList = new PageList<>();
|
||||
pageList.setCount((int) cases.getTotalElements());
|
||||
pageList.setPageSize(cases.getSize());
|
||||
pageList.setList(cases.getContent());
|
||||
List<Cases> content = cases.getContent();
|
||||
List<String> caseIds = content.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
String userId = caseVo.getUserId();
|
||||
if (CollUtil.isNotEmpty(caseIds)) {
|
||||
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
|
||||
recommendCasesQuery.addField("new CasesRecommendPushRecord(recommendId,caseId)");
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.eq("pushUserId", userId));
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
.addOrder("sysCreateTime", OrderDirection.DESC)
|
||||
.addGroupBy("recommendId");
|
||||
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
|
||||
if (CollUtil.isNotEmpty(pushRecords)) {
|
||||
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).collect(Collectors.toList());
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
|
||||
builder.addField("new CasesRecommend(id,recommendOrgName)");
|
||||
List<IFieldFilter> recommendFilters = new ArrayList<>();
|
||||
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
recommendFilters.add(FieldFilters.in("id", rIds));
|
||||
builder.addFilters(recommendFilters);
|
||||
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
|
||||
if (CollUtil.isNotEmpty(recommands)) {
|
||||
Map<String, String> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), v -> v.getRecommendOrgName()));
|
||||
content.forEach(it -> {
|
||||
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
|
||||
if (Objects.nonNull(one)) {
|
||||
String recommendOrgName = collect.get(one.getRecommendId());
|
||||
it.setBreCommend(1);
|
||||
it.setRecommendOrgName(recommendOrgName);
|
||||
} else {
|
||||
it.setBreCommend(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
pageList.setList(content);
|
||||
return pageList;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String rename = "a.name".replaceAll("\\.", "");
|
||||
System.out.println(rename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -840,12 +887,12 @@ public class CasesServiceImpl implements ICasesService {
|
||||
String accountId = current.getAccountId();
|
||||
List<Cases> result = new ArrayList<>();
|
||||
try {
|
||||
String hql = "select a.caseId FROM CasesRecommendPushRecord a left join Cases b ON a.caseId = b.id WHERE a.pushUserId=?1 and b.deleted = false group by a.caseId ORDER By a.pushTime DESC";
|
||||
List<Object[]> listFields = casesRecommendDao.findListFields(hql, CASE_LEN, accountId);
|
||||
List<Long> caseIds = new ArrayList<>();
|
||||
String hql = "select a.caseId FROM CasesRecommendPushRecord a left join Cases b ON a.caseId = b.id WHERE a.pushUserId=?1 and a.pushStatus=4 and b.deleted = false group by a.caseId ORDER By a.pushTime DESC";
|
||||
List<String> listFields = casesRecommendDao.findListFields(hql, CASE_LEN, ListUtil.toList(accountId));
|
||||
List<String> caseIds = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(listFields)) {
|
||||
for (Object[] objs : listFields) {
|
||||
caseIds.add(resultToVo(objs));
|
||||
for (String objs : listFields) {
|
||||
caseIds.add(objs);
|
||||
}
|
||||
}
|
||||
int caseIdLen = caseIds.size();
|
||||
@@ -890,11 +937,6 @@ public class CasesServiceImpl implements ICasesService {
|
||||
return casesVos;
|
||||
}
|
||||
|
||||
private Long resultToVo(Object[] objs) {
|
||||
Long caseId = (Long) objs[0];
|
||||
return caseId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excellent(String id, Boolean excellent) {
|
||||
//取消时,把时间清空
|
||||
|
||||
@@ -34,4 +34,6 @@ public class CaseExportVo {
|
||||
private String caseScope;
|
||||
|
||||
private LocalDateTime endTime;
|
||||
|
||||
private String confidentialityLevel;
|
||||
}
|
||||
|
||||
@@ -11,20 +11,12 @@ import com.xboe.module.dict.service.ISysDictionaryService;
|
||||
import com.xboe.module.dict.vo.DictionaryVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.xboe.module.boecase.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.module.boecase.dto.CasePageVo;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -7,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
@@ -18,4 +22,15 @@ class CasesRecordDaoTest {
|
||||
@Autowired
|
||||
private CasesRecordDao casesRecordDao;
|
||||
|
||||
@Test
|
||||
void queryList() throws JsonProcessingException {
|
||||
PageRequest of = PageRequest.of(0, 10);
|
||||
String jsonStr = "{\"pageIndex\":1,\"pageSize\":10,\"orderField\":\"excellent\",\"majorType\":\"\",\"orgDomainDtos\":[],\"orderAsc\":false,\"excellent\":true,\"breCommend\":true,\"caseType\":\"\",\"authorName\":\"\",\"notInIds\":[],\"type\":\"recommend\",\"userId\":\"\",\"parent\":\"\",\"children\":[],\"name\":\"\",\"years\":[2023,2022,2020,2021]}";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
|
||||
CasePageVo pageVo = mapper.readValue(jsonStr, CasePageVo.class);
|
||||
pageVo.setUserId("965341999643234304");
|
||||
Page<Cases> cases = casesRecordDao.queryList(of, pageVo);
|
||||
System.out.println(cases);
|
||||
}
|
||||
}
|
||||
@@ -39,10 +39,21 @@ class CasesServiceImplTest {
|
||||
System.out.println(casesV2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryRecommendPageCasesV2() throws JsonProcessingException {
|
||||
String jsonStr = "{\"pageIndex\":1,\"pageSize\":10,\"orderField\":\"excellent\",\"majorType\":\"\",\"orgDomainDtos\":[],\"orderAsc\":false,\"excellent\":true,\"breCommend\":true,\"caseType\":\"\",\"authorName\":\"\",\"notInIds\":[],\"type\":\"recommend\",\"userId\":\"\",\"parent\":\"\",\"children\":[],\"name\":\"\",\"years\":[2023,2022,2020,2021]}";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
|
||||
CasePageVo pageVo = mapper.readValue(jsonStr, CasePageVo.class);
|
||||
pageVo.setUserId("965342027497607168");
|
||||
PageList<Cases> casesV2 = casesService.queryRecommendPageCasesV2(pageVo);
|
||||
System.out.println(casesV2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryCaseV2() {
|
||||
CurrentUser currentUser = new CurrentUser();
|
||||
currentUser.setAccountId("12323");
|
||||
currentUser.setAccountId("965342027497607168");
|
||||
List<CasesVo> list = casesService.caseIndexV2(currentUser);
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user