fix:79084

This commit is contained in:
梁琦涛
2023-12-08 17:17:05 +08:00
parent 8542ec017b
commit 0a4371f663
4 changed files with 50 additions and 8 deletions
@@ -28,9 +28,10 @@ public interface LawsHomeSearchMapper extends BaseMapper<LawsHomeNormalSearchHis
* @date 2023/11/13 11:55 * @date 2023/11/13 11:55
* @param page * @param page
* @param queryWrapper * @param queryWrapper
* @param username
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.jero.modules.laws.home.vo.LawsHomeNormalSearchVO> * @return com.baomidou.mybatisplus.core.metadata.IPage<com.jero.modules.laws.home.vo.LawsHomeNormalSearchVO>
*/ */
IPage<LawsHomeNormalSearchVO> getPage(Page<LawsHomeNormalSearchVO> page,@Param(Constants.WRAPPER) QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper); IPage<LawsHomeNormalSearchVO> getPage(Page<LawsHomeNormalSearchVO> page,@Param(Constants.WRAPPER) QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper,@Param("username") String username);
/** /**
* 首页-一般检索(标题)查询国内标准 * 首页-一般检索(标题)查询国内标准
@@ -42,7 +42,7 @@
select id,'4' as resource_type,dynamic_heading as standard_name,create_time,9 as standard_type_order, select id,'4' as resource_type,dynamic_heading as standard_name,create_time,9 as standard_type_order,
null AS standard_state_order, null AS standard_state_order,
null,null,null,null,null,null,null,null null,null,null,null,null,null,null,null
from laws_news_feed where del_flag = 0 from laws_news_feed where del_flag = 0 and (release_status = 1 or (release_status = 0 and create_by = #{username}))
) as all_data ) as all_data
<where> <where>
${ew.sqlSegment} ${ew.sqlSegment}
@@ -140,7 +140,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = getQueryWrapperNormal(lawsHomeNormalSearchDTO); QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = getQueryWrapperNormal(lawsHomeNormalSearchDTO);
Page<LawsHomeNormalSearchVO> page = new Page<>(pageNo, pageSize); Page<LawsHomeNormalSearchVO> page = new Page<>(pageNo, pageSize);
IPage<LawsHomeNormalSearchVO> pageList = lawsHomeSearchMapper.getPage(page,queryWrapper); IPage<LawsHomeNormalSearchVO> pageList = lawsHomeSearchMapper.getPage(page,queryWrapper,loginUser.getUsername());
addContent(searchContent, pageList); addContent(searchContent, pageList);
return pageList; return pageList;
} }
@@ -655,6 +655,10 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJson); JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJson);
queryMapJsonDict.add(jsonObject); queryMapJsonDict.add(jsonObject);
} }
// 查 (发布状态=1 或者 (发布状态=0 and create_by = 当前登录人))
JSONObject jsonObjectShould = getJsonObject(loginUser);
queryMapJsonDict.add(jsonObjectShould);
if(CollectionUtils.isNotEmpty(queryMapJsonDict)){ if(CollectionUtils.isNotEmpty(queryMapJsonDict)){
jsonAll.put("must",queryMapJsonDict); jsonAll.put("must",queryMapJsonDict);
JSONObject all = new JSONObject(); JSONObject all = new JSONObject();
@@ -917,6 +921,30 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
return objVo; return objVo;
} }
private JSONObject getJsonObject(LoginUser loginUser) {
// 查 (发布状态=1 或者 (发布状态=0 and create_by = 当前登录人))
JSONArray queryMapShould = new JSONArray();
Map<String, Object> status1 = new HashMap<>();
Map<String, Object> status1Val = new HashMap<>();
status1Val.put("release_status", "1");
status1.put("match", status1Val);
queryMapShould.add(status1);
JSONArray queryMapMust = new JSONArray();
Map<String, Object> status2 = new HashMap<>();
Map<String, Object> status2Val = new HashMap<>();
status2Val.put("release_status", "0");
status2.put("match", status2Val);
queryMapMust.add(status2);
Map<String, Object> status3 = new HashMap<>();
Map<String, Object> status3Val = new HashMap<>();
status3Val.put("create_by", loginUser.getUsername());
status3.put("match", status3Val);
queryMapMust.add(status3);
JSONObject jsonObjectMust = jeroElasticsearchTemplate.buildBoolQuery(queryMapMust, null, null);
queryMapShould.add(jsonObjectMust);
return jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapShould);
}
private void addVo(JSONObject search, List<LawsHomeNormalSearchCountVO> list, String aggs, String fieldName) { private void addVo(JSONObject search, List<LawsHomeNormalSearchCountVO> list, String aggs, String fieldName) {
List<Map<String, Object>> list1 = (List<Map<String, Object>>) ((Map) ((Map) search.get("aggregations")).get(aggs)).get("buckets"); List<Map<String, Object>> list1 = (List<Map<String, Object>>) ((Map) ((Map) search.get("aggregations")).get(aggs)).get("buckets");
if (!CollectionUtils.isEmpty(list1)) { if (!CollectionUtils.isEmpty(list1)) {
@@ -1024,6 +1052,8 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
obj.setApplicableVehicle(lawsDomesticStandard.getApplicableVehicle()); obj.setApplicableVehicle(lawsDomesticStandard.getApplicableVehicle());
obj.setStandardProperty(lawsDomesticStandard.getStandardProperty()); obj.setStandardProperty(lawsDomesticStandard.getStandardProperty());
obj.setStandardState(lawsDomesticStandard.getStandardState()); obj.setStandardState(lawsDomesticStandard.getStandardState());
obj.setCreateBy(lawsDomesticStandard.getCreateBy());
obj.setReleaseStatus("1");
List<OSSFile> listFile = getOssFilesLawsDomesticStandard(lawsDomesticStandard); List<OSSFile> listFile = getOssFilesLawsDomesticStandard(lawsDomesticStandard);
updateES(opType, obj, listFile, lawsDomesticStandard.getId()); updateES(opType, obj, listFile, lawsDomesticStandard.getId());
}catch (Exception e){ }catch (Exception e){
@@ -1112,6 +1142,8 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
obj.setStandardClass(lawsOverseasStandard.getStandardClass()); obj.setStandardClass(lawsOverseasStandard.getStandardClass());
obj.setApplicableVehicle(lawsOverseasStandard.getApplicableVehicle()); obj.setApplicableVehicle(lawsOverseasStandard.getApplicableVehicle());
obj.setStandardState(lawsOverseasStandard.getStandardState()); obj.setStandardState(lawsOverseasStandard.getStandardState());
obj.setCreateBy(lawsOverseasStandard.getCreateBy());
obj.setReleaseStatus("1");
List<OSSFile> listFile = getOssFilesLawsOverseasStandard(lawsOverseasStandard); List<OSSFile> listFile = getOssFilesLawsOverseasStandard(lawsOverseasStandard);
updateES(opType, obj, listFile, lawsOverseasStandard.getId()); updateES(opType, obj, listFile, lawsOverseasStandard.getId());
}catch (Exception e){ }catch (Exception e){
@@ -1200,6 +1232,8 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
obj.setStandardCode(lawsEnterpriseStandard.getStandardCode()); obj.setStandardCode(lawsEnterpriseStandard.getStandardCode());
obj.setEnterpriseStandardState(lawsEnterpriseStandard.getStandardState()); obj.setEnterpriseStandardState(lawsEnterpriseStandard.getStandardState());
obj.setGradeClassification(lawsEnterpriseStandard.getGradeClassification()); obj.setGradeClassification(lawsEnterpriseStandard.getGradeClassification());
obj.setCreateBy(lawsEnterpriseStandard.getCreateBy());
obj.setReleaseStatus("1");
List<OSSFile> listFile = getOssFilesLawsEnterpriseStandard(lawsEnterpriseStandard); List<OSSFile> listFile = getOssFilesLawsEnterpriseStandard(lawsEnterpriseStandard);
updateES(opType, obj, listFile, lawsEnterpriseStandard.getId()); updateES(opType, obj, listFile, lawsEnterpriseStandard.getId());
}catch (Exception e){ }catch (Exception e){
@@ -1211,11 +1245,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
} }
} }
@NotNull
private String getImplementationDate(Date implementationDate) {
return Objects.isNull(implementationDate) ? "" : new SimpleDateFormat(YYYY_MM_DD).format(implementationDate);
}
@NotNull @NotNull
private List<OSSFile> getOssFilesLawsEnterpriseStandard(LawsEnterpriseStandard lawsEnterpriseStandard) { private List<OSSFile> getOssFilesLawsEnterpriseStandard(LawsEnterpriseStandard lawsEnterpriseStandard) {
// 从过程稿件从上到下顺序检索;如果文档里有发布稿,只检索发布稿 // 从过程稿件从上到下顺序检索;如果文档里有发布稿,只检索发布稿
@@ -1271,6 +1300,8 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
obj.setStandardState("4"); obj.setStandardState("4");
obj.setReleaseDate(lawsNewsFeed.getReleaseTime()); obj.setReleaseDate(lawsNewsFeed.getReleaseTime());
obj.setCreateTime(lawsNewsFeed.getCreateTime()); obj.setCreateTime(lawsNewsFeed.getCreateTime());
obj.setCreateBy(lawsNewsFeed.getCreateBy());
obj.setReleaseStatus(String.valueOf(lawsNewsFeed.getReleaseStatus()));
updateESLawsNewsFeed(opType, lawsNewsFeed, obj); updateESLawsNewsFeed(opType, lawsNewsFeed, obj);
}catch (Exception e){ }catch (Exception e){
log.error(SYNC_ES_ERR,e.getMessage()); log.error(SYNC_ES_ERR,e.getMessage());
@@ -1358,6 +1389,8 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
log.error("文档库添加es失败",e); log.error("文档库添加es失败",e);
} }
map.put("es_create_time",new Date()); map.put("es_create_time",new Date());
map.put("create_by",obj.getCreateBy());
map.put("release_status",obj.getReleaseStatus());
//添加es //添加es
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(map, SerializerFeature.WriteMapNullValue)); JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(map, SerializerFeature.WriteMapNullValue));
try { try {
@@ -102,4 +102,12 @@ public class LawsHomeNormalSearchVO implements Serializable {
* 入库时间 * 入库时间
*/ */
private Date createTime; private Date createTime;
/**
* 创建人(动态消息使用)
*/
private String createBy;
/**
* 发布状态(0-未发布、1-已发布)(动态消息使用)
*/
private String releaseStatus;
} }