fix:79161

This commit is contained in:
梁琦涛
2023-12-08 19:49:20 +08:00
parent 8451fe4456
commit 4092c6125a
3 changed files with 60 additions and 38 deletions
@@ -1,5 +1,6 @@
package com.jero.modules.laws.home.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -20,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -47,7 +49,7 @@ public class LawsHomeNormalSearchHistoryController extends JeroController<LawsHo
/**
* 分页列表查询
*/
// @RequiresPermissions("sys:innerWorkingGroup:search")
@RequiresPermissions("dashboard:generalSearch:searchHistory")
@AutoLog(value = "检索历史-分页列表查询", operateType = 1)
@ApiOperation(value = "检索历史-分页列表查询", notes = "检索历史-分页列表查询")
@GetMapping(value = "/page")
@@ -70,7 +72,7 @@ public class LawsHomeNormalSearchHistoryController extends JeroController<LawsHo
/**
* 通过id删除
*/
// @RequiresPermissions("sys:innerWorkingGroup:delete")
@RequiresPermissions("dashboard:generalSearch:searchHistory")
@AutoLog(value = "检索历史-通过id删除", operateType = 4)
@ApiOperation(value = "检索历史-通过id删除", notes = "检索历史-通过id删除")
@PostMapping(value = "/delete")
@@ -78,7 +80,14 @@ public class LawsHomeNormalSearchHistoryController extends JeroController<LawsHo
if (!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))) {
throw new JeroBootException(ResultCommon.PLEASE_SELECT_DATA);
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LambdaQueryWrapper<LawsHomeNormalSearchHistory> query = new LambdaQueryWrapper<>();
query.eq(LawsHomeNormalSearchHistory::getId,map.get("id"));
query.ne(LawsHomeNormalSearchHistory::getUserId,sysUser.getId());
long l = lawsHomeNormalSearchHistoryService.count(query);
if(l > 0){
return Result.error(MessageUtils.getMessage(ResultCommon.HORIZONTAL_TRANSGRESSION));
}
lawsHomeNormalSearchHistoryService.removeById(map.get("id"));
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
@@ -86,7 +95,7 @@ public class LawsHomeNormalSearchHistoryController extends JeroController<LawsHo
/**
* 批量删除
*/
// @RequiresPermissions("sys:innerWorkingGroup:delete")
@RequiresPermissions("dashboard:generalSearch:searchHistory")
@AutoLog(value = "检索历史-批量删除", operateType = 4)
@ApiOperation(value = "检索历史-批量删除", notes = "检索历史-批量删除")
@PostMapping(value = "/deleteBatch")
@@ -94,6 +103,14 @@ public class LawsHomeNormalSearchHistoryController extends JeroController<LawsHo
if (!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))) {
throw new JeroBootException(ResultCommon.PLEASE_SELECT_DATA);
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
LambdaQueryWrapper<LawsHomeNormalSearchHistory> query = new LambdaQueryWrapper<>();
query.in(LawsHomeNormalSearchHistory::getId,Arrays.asList(map.get("id").split(",")));
query.ne(LawsHomeNormalSearchHistory::getUserId,sysUser.getId());
long l = lawsHomeNormalSearchHistoryService.count(query);
if(l > 0){
return Result.error(MessageUtils.getMessage(ResultCommon.HORIZONTAL_TRANSGRESSION));
}
lawsHomeNormalSearchHistoryService.removeByIds(Arrays.asList(map.get("id").split(",")));
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
}
@@ -10,10 +10,13 @@ import com.jero.modules.laws.home.vo.LawsHomeNormalSearchVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Map;
/**
* @author lqt
@@ -34,6 +37,7 @@ public class LawsHomeSearchController {
@AutoLog(value = "首页-一般检索(标题)查询",operateType = 1)
@ApiOperation(value="首页-一般检索(标题)查询", notes="首页-一般检索(标题)查询")
@GetMapping(value = "/getNormalSearchTitlePage")
@RequiresPermissions("dashboard:generalSearch:search")
public Result<IPage<LawsHomeNormalSearchVO>> getNormalSearchTitlePage(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
@@ -43,6 +47,7 @@ public class LawsHomeSearchController {
@AutoLog(value = "首页-一般检索(标题)(数据统计)",operateType = 1)
@ApiOperation(value="首页-一般检索(标题)(数据统计)", notes="首页-一般检索(标题)(数据统计)")
@GetMapping(value = "/getNormalSearchTitleCount")
@RequiresPermissions("dashboard:generalSearch:search")
public Result<LawsHomeNormalSearchStatisticsVO> getNormalSearchTitleCount(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO) {
return Result.OK(lawsHomeSearchService.getNormalSearchTitleCount(lawsHomeNormalSearchDTO));
}
@@ -50,6 +55,7 @@ public class LawsHomeSearchController {
@AutoLog(value = "首页-一般检索(全文)查询",operateType = 1)
@ApiOperation(value="首页-一般检索(全文)查询", notes="首页-一般检索(全文)查询")
@GetMapping(value = "/getNormalSearchAllPage")
@RequiresPermissions("dashboard:generalSearch:search")
public Result<IPage<LawsHomeNormalSearchVO>> getNormalSearchAllPage(LawsHomeNormalSearchDTO homeNormalSearchDTO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
@@ -59,15 +65,8 @@ public class LawsHomeSearchController {
@AutoLog(value = "首页-一般检索(全文)(数据统计)",operateType = 1)
@ApiOperation(value="首页-一般检索(全文)(数据统计)", notes="首页-一般检索(全文)(数据统计)")
@GetMapping(value = "/getNormalSearchAllCount")
@RequiresPermissions("dashboard:generalSearch:search")
public Result<LawsHomeNormalSearchStatisticsVO> getNormalSearchAllCount(LawsHomeNormalSearchDTO homeNormalSearchDTO) {
return Result.OK(lawsHomeSearchService.getNormalSearchAllCount(homeNormalSearchDTO));
}
@AutoLog(value = "首页-一般检索(全文)测试",operateType = 1)
@ApiOperation(value="首页-一般检索(全文)测试", notes="首页-一般检索(全文)测试")
@PostMapping(value = "/getNormalSearchAllUpdate")
public Result<String> getNormalSearchAllUpdate(@RequestBody Map<String,String> map) {
lawsHomeSearchService.updateEsData(map.get("resourceType"),map.get("ids") ,map.get("opType"));
return Result.OK("操作成功");
}
}
@@ -121,6 +121,14 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
public static final String BLANK_SPACE = "\\s+";
public static final String FILE_TYPE = "pdf,PDF,doc,DOC,docx,DOCX";
public static final String RELEASE_STATUS = "release_status";
public static final String QUERY = "query";
public static final String MATCH = "match";
@Override
@@ -793,7 +801,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
// 前缀匹配 缺点是前缀一定不能断开
//情况举例:用户只记得前面那段字
String boost = "boost";
String query = "query";
Map<String, Object> map21 = new HashMap<>();
Map<String, Object> map31 = new HashMap<>();
Map<String, Object> map41 = new HashMap<>();
@@ -812,7 +819,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
if(CONTENT.equals(field)){
map32.put(boost,0.01);
}
map32.put(query, selectValue);
map32.put(QUERY, selectValue);
map22.put(field, map32);
map42.put("match_phrase_prefix", map22);
queryMapJson.add(map42);
@@ -825,9 +832,9 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
if(CONTENT.equals(field)){
map33.put(boost,0.01);
}
map33.put(query, selectValue);
map33.put(QUERY, selectValue);
map23.put(field, map33);
map43.put("match", map23);
map43.put(MATCH, map23);
queryMapJson.add(map43);
// wildcard模糊查询
@@ -885,11 +892,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
}
if(CollectionUtils.isNotEmpty(queryMapJson)){
JSONObject object = jeroElasticsearchTemplate.buildBoolQuery(null,null,queryMapJson);
jsonObject.put("query",object);
jsonObject.put(QUERY,object);
}
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
JSONObject jsonObjectShould = getJsonObject(loginUser);
jsonObject.put("query",jsonObjectShould);
jsonObject.put(QUERY,jsonObjectShould);
//2. 数据查询
JSONObject search = jeroElasticsearchTemplate.search(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), jsonObject);
@@ -929,19 +936,19 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
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);
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);
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);
status3.put(MATCH, status3Val);
queryMapMust.add(status3);
JSONObject jsonObjectMust = jeroElasticsearchTemplate.buildBoolQuery(queryMapMust, null, null);
queryMapShould.add(jsonObjectMust);
@@ -1067,10 +1074,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
@NotNull
private List<OSSFile> getOssFilesLawsDomesticStandard(LawsDomesticStandard lawsDomesticStandard) {
// 从过程稿件从上到下顺序检索;如果文档里有发布稿,只检索发布稿
LambdaQueryWrapper<OSSFile> ossFile = new LambdaQueryWrapper<>();
ossFile.eq(OSSFile::getStandardId,lawsDomesticStandard.getId());
ossFile.orderByAsc(OSSFile::getCreateTime);
List<OSSFile> list = oSSFileService.list(ossFile);
List<OSSFile> list = getOssFiles(lawsDomesticStandard.getId());
List<OSSFile> listFile = new ArrayList<>();
if(!CollectionUtils.isEmpty(list)){
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
@@ -1093,6 +1097,14 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
return listFile;
}
private List<OSSFile> getOssFiles(String id) {
QueryWrapper<OSSFile> ossFile = new QueryWrapper<>();
ossFile.eq("standard_id", id);
ossFile.in("substring_index(file_name,'.',-1)", Arrays.asList(FILE_TYPE.split(",")));
ossFile.orderByAsc(CREATE_TIME);
return oSSFileService.list(ossFile);
}
private int getEndIndex(int startIndex, int batchCount, List<String> listIds) {
int endIndex = 0;
if (listIds.size() - batchCount < startIndex) {
@@ -1161,10 +1173,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
@NotNull
private List<OSSFile> getOssFilesLawsOverseasStandard(LawsOverseasStandard lawsOverseasStandard) {
// 从过程稿件从上到下顺序检索;如果文档里有发布稿,只检索发布稿
LambdaQueryWrapper<OSSFile> ossFile = new LambdaQueryWrapper<>();
ossFile.eq(OSSFile::getStandardId,lawsOverseasStandard.getId());
ossFile.orderByAsc(OSSFile::getCreateTime);
List<OSSFile> list = oSSFileService.list(ossFile);
List<OSSFile> list = getOssFiles(lawsOverseasStandard.getId());
List<OSSFile> listFile = new ArrayList<>();
if(CollectionUtils.isEmpty(list)){
return listFile;
@@ -1251,10 +1260,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
@NotNull
private List<OSSFile> getOssFilesLawsEnterpriseStandard(LawsEnterpriseStandard lawsEnterpriseStandard) {
// 从过程稿件从上到下顺序检索;如果文档里有发布稿,只检索发布稿
LambdaQueryWrapper<OSSFile> ossFile = new LambdaQueryWrapper<>();
ossFile.eq(OSSFile::getStandardId,lawsEnterpriseStandard.getId());
ossFile.orderByAsc(OSSFile::getCreateTime);
List<OSSFile> list = oSSFileService.list(ossFile);
List<OSSFile> list = getOssFiles(lawsEnterpriseStandard.getId());
List<OSSFile> listFile = new ArrayList<>();
if(!CollectionUtils.isEmpty(list)){
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
@@ -1393,7 +1399,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
}
map.put("es_create_time",new Date());
map.put("create_by",obj.getCreateBy());
map.put("release_status",obj.getReleaseStatus());
map.put(RELEASE_STATUS,obj.getReleaseStatus());
//添加es
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(map, SerializerFeature.WriteMapNullValue));
try {