Merge remote-tracking branch 'origin/develop_master_new' into FOTON

This commit is contained in:
高嵩
2022-12-08 17:12:35 +08:00
2 changed files with 850 additions and 43 deletions
@@ -4,6 +4,7 @@ import com.adc.da.base.web.BaseController;
import com.adc.da.search.bean.SearchCenter;
import com.adc.da.search.bean.SearchFields;
import com.adc.da.search.server.ResetSearchCenterService;
import com.adc.da.search.server.ResetSearchCenterServiceTemp;
import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage;
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfoPage;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
@@ -41,20 +42,20 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
}
@ApiOperation(value = "|Search|文本条件搜索更新标准数据索引")
@PostMapping(value="/resetALLSearchCenterToSearch")
public ResponseMessage resetALLSearchCenterToSearch(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/resetALLSearchCenterToSearch")
public ResponseMessage resetALLSearchCenterToSearch(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
return resetSearchCenterService.resetALLSearchCenterToSearch(searchCenter);
}
@ApiOperation(value = "|SearchCenter|重新创建ALL标准数据索引")
@PostMapping(value="/resetALLSearchCenter")
public ResponseMessage resetALLSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/resetALLSearchCenter")
public ResponseMessage resetALLSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
return resetSearchCenterService.resetALLSearchCenter(searchCenter);
@@ -62,10 +63,10 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
@ApiOperation(value = "|SearchCenter|重新创建ALL标准数据索引")
@PostMapping(value="/resetALLSearchCenterForExits")
public ResponseMessage resetALLSearchCenterForExits(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/resetALLSearchCenterForExits")
public ResponseMessage resetALLSearchCenterForExits(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
return resetSearchCenterService.resetALLSearchCenterForExits(searchCenter);
@@ -73,27 +74,27 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
@ApiOperation(value = "|SearchCenter|手动重新创建(---7天内---)ALL标准数据索引(凌晨有自动程序会跑)")
@PostMapping(value="/manualResetALLSearchCenter")
public ResponseMessage manualResetALLSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/manualResetALLSearchCenter")
public ResponseMessage manualResetALLSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
return resetSearchCenterService.syncResetALLSearchCenter(searchCenter);
}
@ApiOperation(value = "|SearchCenter|手动重新创建 ALL标准数据索引(凌晨有自动程序会跑)")
@PostMapping(value="/manualResetALLSearchCenter1")
public ResponseMessage manualResetALLSearchCenter1(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/manualResetALLSearchCenter1")
public ResponseMessage manualResetALLSearchCenter1(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
return resetSearchCenterService.syncResetALLSearchCenter1(searchCenter);
}
private ResponseMessage verifySearchCenter(SearchCenter searchCenter) {
if(searchCenter.getExecType() == null || "".equals(searchCenter.getExecType())){
if (searchCenter.getExecType() == null || "".equals(searchCenter.getExecType())) {
return Result.error("执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准, DEL 只删除不存在标准库的数据");
}
@@ -101,66 +102,77 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
}
@ApiOperation(value = "|SearchCenter|重新创建国内外标准数据索引")
@PostMapping(value="/resetAStandSearchCenter")
public ResponseMessage resetStandSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/resetAStandSearchCenter")
public ResponseMessage resetStandSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
SarStandardsInfoEOPage sarStandardsInfoEOPage = new SarStandardsInfoEOPage();
return resetSearchCenterService.resetStandSearchCenter(sarStandardsInfoEOPage,searchCenter);
return resetSearchCenterService.resetStandSearchCenter(sarStandardsInfoEOPage, searchCenter);
}
@ApiOperation(value = "|SearchCenter|重新创建国内外政策数据索引")
@PostMapping(value="/resetBLawsSearchCenter")
public ResponseMessage resetLawsSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/resetBLawsSearchCenter")
public ResponseMessage resetLawsSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
SarLawsStandInfoPage sarLawsInfoEOPage = new SarLawsStandInfoPage();
return resetSearchCenterService.resetLawsSearchCenter(sarLawsInfoEOPage,searchCenter);
SarLawsStandInfoPage sarLawsInfoEOPage = new SarLawsStandInfoPage();
return resetSearchCenterService.resetLawsSearchCenter(sarLawsInfoEOPage, searchCenter);
}
@ApiOperation(value = "|SearchCenter|重新创建企业标准数据索引")
@PostMapping(value="/resetCBussStandSearchCenter")
public ResponseMessage resetBussStandSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
@PostMapping(value = "/resetCBussStandSearchCenter")
public ResponseMessage resetBussStandSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
if (x != null) {
return x;
}
SarBussionessStandEOPage sarBussionessStandEOPage = new SarBussionessStandEOPage();
return resetSearchCenterService.resetBussStandSearchCenter(sarBussionessStandEOPage,searchCenter);
SarBussionessStandEOPage sarBussionessStandEOPage = new SarBussionessStandEOPage();
return resetSearchCenterService.resetBussStandSearchCenter(sarBussionessStandEOPage, searchCenter);
}
/**
* 根据资源ID对搜索中心数据进行处理
* @param standId
* @param dataType(STAND BUSS)
* @param dataType(STAND BUSS)
* @return
*/
@ApiOperation(value = "|SearchCenter|根据资源ID对搜索中心数据进行处理")
@GetMapping(value="/syncSearchCenterData")
@GetMapping(value = "/syncSearchCenterData")
public ResponseMessage syncSearchCenterData(@RequestParam("standId") String standId,
@RequestParam("dataType") String dataType){
if(StringUtils.isNotBlank(standId) && StringUtils.isNotBlank(dataType)){
@RequestParam("dataType") String dataType) {
if (StringUtils.isNotBlank(standId) && StringUtils.isNotBlank(dataType)) {
try {
if("STAND".equals(dataType)){
if ("STAND".equals(dataType)) {
resetSearchCenterService.syncStandSearchCenterData(standId);
}else if("BUSS".equals(dataType)){
} else if ("BUSS".equals(dataType)) {
resetSearchCenterService.syncBussStandSearchCenterData(standId);
}else{
return Result.error("-1","资源类型错误,请检查",null);
} else {
return Result.error("-1", "资源类型错误,请检查", null);
}
return Result.success("200","开始同步",null);
return Result.success("200", "开始同步", null);
} catch (Exception e) {
logger.error(e.getMessage(),e);
return Result.error("-1","请求错误,请检查",null);
logger.error(e.getMessage(), e);
return Result.error("-1", "请求错误,请检查", null);
}
}else{
return Result.error("-1","参数有误,请检查",null);
} else {
return Result.error("-1", "参数有误,请检查", null);
}
}
@Autowired
private ResetSearchCenterServiceTemp resetSearchCenterServiceTemp;
@ApiOperation(value = "|SearchCenter|临时手动更新ALL标准数据索引")
@PostMapping(value = "/manualResetALLSearchCenterTemp")
public ResponseMessage manualResetALLSearchCenterTemp(@RequestBody SearchCenter searchCenter) throws Exception {
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null) {
return x;
}
return resetSearchCenterServiceTemp.syncResetALLSearchCenter(searchCenter);
}
}
@@ -0,0 +1,795 @@
package com.adc.da.search.server;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.mq.CreateEsMQService;
import com.adc.da.mq.CreateStandMQService;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.search.bean.SearchCenter;
import com.adc.da.search.service.ElasticsearchService;
import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarLawsAttrInfo.dao.SarLawsAttrInfoDao;
import com.adc.da.slrs.sarLawsItems.dao.SarLawsItemsDao;
import com.adc.da.slrs.sarLawsItems.entity.SarLawsItems;
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfo;
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfoPage;
import com.adc.da.slrs.sarLawsStandInfo.service.ISarLawsStandInfoService;
import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao;
import com.adc.da.slrs.sarStandItems.dao.SarStandItemsDao;
import com.adc.da.slrs.sarStandItems.entity.FindSarItemsPageReqDTO;
import com.adc.da.slrs.sarStandItems.entity.SarStandItems;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage;
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.Utils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.transport.TransportClient;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Clob;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class ResetSearchCenterServiceTemp {
private static final Logger logger = LoggerFactory.getLogger(ResetSearchCenterServiceTemp.class);
@Autowired
private ElasticsearchService elasticsearchService;
@Autowired
private DicTypeEODao dicTypeEODao;
@Autowired
private SarStandItemsDao standItemsDao;
@Autowired
private SarLawsItemsDao sarLawsItemsDao;
@Autowired
private IAttFileEOService attFileEOService;
@Autowired
private SarLawsAttrInfoDao sarLawsAttrInfoDao;
@Autowired
private ISarStandardsInfoService iSarStandardsInfoService;
@Autowired
private ISarLawsStandInfoService iSarLawsStandInfoService;
@Autowired
private ISarBussionessStandService iSarBussionessStandService;
@Autowired
private CreateStandMQService createStandMQService;
@Autowired
private CreateEsMQService createEsMQService;
@Autowired
private IPersonCollectEOService personCollectEOService;
@Autowired
private SarStandAttrInfoDao sarStandAttrInfoEODao;
@Autowired
private SarBussStandAttrInfoDao sarBussStandAttrInfoEODao;
@Autowired
private ISarStandardsInfoService sarStandardsInfoEOService;
// 全部
@Async
public ResponseMessage syncResetALLSearchCenter(SearchCenter searchCenter) throws Exception{
Boolean getFulltextserchIndex = elasticsearchService.isIndexExist("fulltextserch");
SearchCenter standSearch = new SearchCenter();
standSearch.setExecType(searchCenter.getExecType());
SarStandardsInfoEOPage page = new SarStandardsInfoEOPage();
// page.setSyncParam("sync");
ResponseMessage stand = resetStandSearchCenter(page,standSearch);
List<String> r = new ArrayList<>();
if(stand.isOk() && StringUtils.isNotBlank(stand.getData().toString())){
r.add(stand.getData().toString());
}
// SearchCenter lawsSearch = new SearchCenter();
// lawsSearch.setExecType(searchCenter.getExecType());
// SarLawsStandInfoPage lawsPage = new SarLawsStandInfoPage();
// lawsPage.setSyncParam("sync");
// ResponseMessage laws = resetLawsSearchCenter(lawsPage,lawsSearch);
// if(laws.isOk() && StringUtils.isNotBlank(laws.getData().toString())){
// r.add(laws.getData().toString());
// }
SearchCenter bussSearch = new SearchCenter();
bussSearch.setExecType(searchCenter.getExecType());
SarBussionessStandEOPage bussPage = new SarBussionessStandEOPage();
// bussPage.setSyncParam("sync");
ResponseMessage buss = resetBussStandSearchCenter(bussPage,bussSearch);
if(buss.isOk() && StringUtils.isNotBlank(buss.getData().toString())){
r.add(buss.getData().toString());
}
String res = String.join(", ", r);
logger.info(res);
return Result.success(res);
}
//重建国内外标准
@Async
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page,SearchCenter searchCenter) throws Exception{
int countUpdateSuccess = 0;
int countAddSuccess = 0;
Boolean getStandIndex = elasticsearchService.isIndexExist("stand");
if(!getStandIndex){
logger.info("ES 不存在索引:stand");
return Result.error("ES 不存在索引:stand");
}
String search = getSearch(searchCenter);
List<Map<String, Object>> searchListData = elasticsearchService.searchAll("stand",search);
List<String> esIdList = searchListData.stream().map(stringObjectMap -> stringObjectMap.get("id").toString()).collect(Collectors.toList());
page.setValidFlag("0");
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty()){
String[] result = searchCenter.getIdList().toArray(new String[0]);
page.setIdlist(result);
}
QueryWrapper qw = new QueryWrapper();
qw.eq("VALID_FLAG","0");
int count = iSarStandardsInfoService.count(qw);
if(count > 0){
page.setPageSize(count);
page.setMenuId("nomenu");
page.setStandType("ALL");
List<SarStandardsInfo> rowsStand = iSarStandardsInfoService.getSarStandardsInfoPage(page);
//如果时自动触发,删除需要根据全部的结果进行数据处理
SarStandardsInfoEOPage infoEOPage = new SarStandardsInfoEOPage();
List<SarStandardsInfo> allStand = null;
if (StringUtils.isNotBlank(page.getSyncParam())) {
BeanUtils.copyProperties(page, infoEOPage);
infoEOPage.setSyncParam(null);
allStand = iSarStandardsInfoService.getSarStandardsInfoPage(infoEOPage);
}
String isAll = null == allStand ? "" : "";
logger.info("是否查询了全部数据信息:" + isAll);
List<SarStandardsInfo> insList = new ArrayList<>();
List<SarStandardsInfo> updList = new ArrayList<>();
List<String> delList = new ArrayList<>();
List<String> standIdList = rowsStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
if(!esIdList.isEmpty()){
// 差集 (list1 - list2) 新增
List<SarStandardsInfo> distinctByUniqueList = rowsStand.stream()
.filter(item -> !new ArrayList<>(esIdList)
.contains(item.getId()))
.collect(Collectors.toList());
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && !distinctByUniqueList.isEmpty()){
List<SarStandardsInfo> collect = distinctByUniqueList.stream()
.filter(item -> searchCenter.getIdList().contains(item.getId())).collect(Collectors.toList());
insList.addAll(collect);
}else{
insList.addAll(distinctByUniqueList);
}
// 交集 更新
List<SarStandardsInfo> intersection = rowsStand.stream()
.filter(item -> new ArrayList<>(esIdList)
.contains(item.getId()))
.collect(Collectors.toList());
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && !intersection.isEmpty()){
List<SarStandardsInfo> collect = intersection.stream()
.filter(item -> searchCenter.getIdList().contains(item.getId())).collect(Collectors.toList());
updList.addAll(collect);
}else{
updList.addAll(intersection);
}
List<String> finalStandIdList = null;
// 差集 (list2 - list1) 删除
if (allStand != null && !allStand.isEmpty()) {
finalStandIdList = allStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
}else{
finalStandIdList = rowsStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
}
List<String> finalStandIdList1 = finalStandIdList;
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
.collect(Collectors.toList());
// 可以更新IDLIST 删除 ES
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
delList.addAll(searchCenter.getIdList());
}else{
delList.addAll(delDataList);
}
}else {
// 新增
insList.addAll(rowsStand);
}
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){
for(SarStandardsInfo sarStandardsInfoEO : updList){
countUpdateSuccess++;
standFunc(sarStandardsInfoEO);
// createStandMQService.sendStandMQ(sarStandardsInfoEO,"update");
}
}
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){
for(SarStandardsInfo sarStandardsInfoEO : insList){
countAddSuccess++;
standFunc(sarStandardsInfoEO);
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap()));
}
// createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
}
}
if(!delList.isEmpty() && !"sync".equals(page.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
// elasticsearchService.deleteBatchId(delList,"stand");
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
logger.info("重置国内外标准:删除-共"+delList.size()+"条数据");
}else{
logger.info("重置国内外标准:没有删除数据,但应该删除"+delList.size()+"条数据");
}
logger.info("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
return Result.success("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
}else {
logger.info("未查询到标准数据");
return Result.error("未查询到标准数据");
}
}
// 国内外政策
@Async
public ResponseMessage resetLawsSearchCenter(SarLawsStandInfoPage sarLawsInfoEOPage,SearchCenter searchCenter) throws Exception{
Boolean getLawsIndex = elasticsearchService.isIndexExist("laws");
if(!getLawsIndex){
logger.info("ES 不存在索引:laws");
return Result.error("ES 不存在索引:laws");
}
String search = getSearch(searchCenter);
List<Map<String, Object>> searchListData = elasticsearchService.searchAll("laws",search);
List<String> esIdList = searchListData.stream().map(stringObjectMap -> stringObjectMap.get("id").toString()).collect(Collectors.toList());
sarLawsInfoEOPage.setLawsType("FOREIGN");
// page idlist 赋值
idListFunc(sarLawsInfoEOPage, searchCenter);
int countUpdateSuccess = 0;
int countAddSuccess = 0;
QueryWrapper qw2 = new QueryWrapper();
qw2.eq("VALID_FLAG","0");
int count2 = iSarLawsStandInfoService.count(qw2);
if(count2 > 0){
sarLawsInfoEOPage.setPageSize(count2);
List<SarLawsStandInfo> rowsStand = iSarLawsStandInfoService.getSarStandardsInfoPage(sarLawsInfoEOPage);
//如果时自动触发,删除需要根据全部的结果进行数据处理
SarLawsStandInfoPage infoEOPage = new SarLawsStandInfoPage();
List<SarLawsStandInfo> allStand = null;
if (StringUtils.isNotBlank(sarLawsInfoEOPage.getSyncParam())) {
BeanUtils.copyProperties(sarLawsInfoEOPage, infoEOPage);
infoEOPage.setSyncParam(null);
allStand = iSarLawsStandInfoService.getSarStandardsInfoPage(infoEOPage);
}
String isAll = null == allStand ? "" : "";
logger.info("是否查询了全部数据信息:" + isAll);
List<SarLawsStandInfo> insList = new ArrayList<>();
List<SarLawsStandInfo> updList = new ArrayList<>();
List<String> delList = new ArrayList<>();
List<String> standIdList = rowsStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
if(!esIdList.isEmpty()){
// 差集 (list1 - list2) 新增
List<SarLawsStandInfo> distinctByUniqueList = rowsStand.stream()
.filter(item -> !new ArrayList<>(esIdList)
.contains(item.getId()))
.collect(Collectors.toList());
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && !distinctByUniqueList.isEmpty()){
List<SarLawsStandInfo> collect = distinctByUniqueList.stream()
.filter(item -> searchCenter.getIdList().contains(item.getId())).collect(Collectors.toList());
insList.addAll(collect);
}else{
insList.addAll(distinctByUniqueList);
}
// 交集 更新
List<SarLawsStandInfo> intersection = rowsStand.stream()
.filter(item -> new ArrayList<>(esIdList)
.contains(item.getId()))
.collect(Collectors.toList());
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && !intersection.isEmpty()){
List<SarLawsStandInfo> collect = intersection.stream()
.filter(item -> searchCenter.getIdList().contains(item.getId())).collect(Collectors.toList());
updList.addAll(collect);
}else{
updList.addAll(intersection);
}
// 差集 (list2 - list1) 删除
List<String> finalStandIdList = null;
// 差集 (list2 - list1) 删除
if (allStand != null && !allStand.isEmpty()) {
finalStandIdList = allStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
}else{
finalStandIdList = rowsStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
}
List<String> finalStandIdList1 = finalStandIdList;
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
.collect(Collectors.toList());
// 可以更新IDLIST 删除 ES
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
delList.addAll(searchCenter.getIdList());
}else{
delList.addAll(delDataList);
}
}else {
// 新增
insList.addAll(rowsStand);
}
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){
for(SarLawsStandInfo sarLawsInfoEO : updList){
countUpdateSuccess++;
lawsAttrInfoShowSearchDetails(sarLawsInfoEO);
FindSarItemsPageReqDTO pageInfo = new FindSarItemsPageReqDTO();
pageInfo.setStandId(sarLawsInfoEO.getId());
pageInfo.setFileType("FBGBJBD");
/**
* SarItemVO换为sarItemVOS
* List<SarItemVO> sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo);
* .collect(Collectors.toMap(SarItemVO::getItemsNum, SarItemVO::getItemsName));
*/
List<SarLawsItems> sarItemVOS = sarLawsItemsDao.querySarItemAndInterpretation(pageInfo);
if(!sarItemVOS.isEmpty()){
Map<String,String> collectMap = sarItemVOS.stream().filter((e) -> e.getItemsNum() != null && e.getItemsName() != null)
.collect(Collectors.toMap(SarLawsItems::getItemsNum, SarLawsItems::getTermsConditions));
sarLawsInfoEO.setMapItems(collectMap);
}
if (sarLawsInfoEO.getAttrInfoMap() != null) {
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
}
// createStandMQService.sendLawsMQ(sarLawsInfoEO,"update");
}
}
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){
for(SarLawsStandInfo sarLawsInfoEO : insList){
countAddSuccess++;
lawsAttrInfoShowSearchDetails(sarLawsInfoEO);
FindSarItemsPageReqDTO pageInfo = new FindSarItemsPageReqDTO();
pageInfo.setStandId(sarLawsInfoEO.getId());
pageInfo.setFileType("FBGBJBD");
/**
* SarItemVO换为sarItemVOS
* List<SarItemVO> sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo);
* .collect(Collectors.toMap(SarItemVO::getItemsNum, SarItemVO::getItemsName));
*/
List<SarLawsItems> sarItemVOS = sarLawsItemsDao.querySarItemAndInterpretation(pageInfo);
if(!sarItemVOS.isEmpty()){
Map<String,String> collectMap = sarItemVOS.stream().filter((e) -> e.getItemsNum() != null && e.getItemsName() != null)
.collect(Collectors.toMap(SarLawsItems::getItemsNum, SarLawsItems::getTermsConditions));
sarLawsInfoEO.setMapItems(collectMap);
}
if (sarLawsInfoEO.getAttrInfoMap() != null) {
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
}
if (sarLawsInfoEO.getAttrInfoMap() != null) {
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
}
// createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
}
}
if(!delList.isEmpty() && !"sync".equals(sarLawsInfoEOPage.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
// elasticsearchService.deleteBatchId(delList,"laws");
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
logger.info("重置国内外政策:删除-共"+delList.size()+"条数据");
}else{
logger.info("重置国内外政策:没有删除数据,但应该删除"+delList.size()+"条数据");
}
logger.info("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)数据");
return Result.success("");
}else {
logger.info("未查询到国内外政策数据");
return Result.error("未查询到国内外政策数据");
}
}
// 企业标准
@Async
public ResponseMessage resetBussStandSearchCenter(SarBussionessStandEOPage sarBussionessStandEOPage,SearchCenter searchCenter) throws Exception{
Boolean getbussstandIndex = elasticsearchService.isIndexExist("bussstand");
if(!getbussstandIndex){
logger.info("ES 不存在索引:bussstand");
return Result.error("ES 不存在索引:bussstand");
}
String search = getSearch(searchCenter);
List<Map<String, Object>> searchListData = elasticsearchService.searchAll("bussstand",search);
List<String> esIdList = searchListData.stream().map(stringObjectMap -> stringObjectMap.get("id").toString()).collect(Collectors.toList());
sarBussionessStandEOPage.setValidFlag("0");
sarBussionessStandEOPage.setOrderBy("SAR_BUSSIONESS_STAND.issue_time is null,SAR_BUSSIONESS_STAND.issue_time desc,SAR_BUSSIONESS_STAND.id");
sarBussionessStandEOPage.setMenuRoleList(null);
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty()){
String[] result = searchCenter.getIdList().toArray(new String[0]);
sarBussionessStandEOPage.setIdlist(result);
}
int countUpdateSuccess = 0;
int countAddSuccess = 0;
sarBussionessStandEOPage.setMenuId("0");
QueryWrapper qw3 = new QueryWrapper();
qw3.eq("VALID_FLAG","0");
int count3 = iSarBussionessStandService.count(qw3);
if(count3 > 0){
sarBussionessStandEOPage.setPageSize(count3);
List<SarBussionessStand> rowsStand = iSarBussionessStandService.getSarBussionStandPage(sarBussionessStandEOPage);
//如果时自动触发,删除需要根据全部的结果进行数据处理
SarBussionessStandEOPage infoEOPage = new SarBussionessStandEOPage();
List<SarBussionessStand> allStand = null;
if (StringUtils.isNotBlank(sarBussionessStandEOPage.getSyncParam())) {
BeanUtils.copyProperties(sarBussionessStandEOPage, infoEOPage);
infoEOPage.setSyncParam(null);
allStand = iSarBussionessStandService.getSarBussionStandPage(infoEOPage);
}
String isAll = null == allStand ? "" : "";
logger.info("是否查询了全部数据信息:" + isAll);
List<SarBussionessStand> insList = new ArrayList<>();
List<SarBussionessStand> updList = new ArrayList<>();
List<String> delList = new ArrayList<>();
List<String> standIdList = rowsStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
if(!esIdList.isEmpty()){
// 差集 (list1 - list2) 新增
List<SarBussionessStand> distinctByUniqueList = rowsStand.stream()
.filter(item -> !new ArrayList<>(esIdList)
.contains(item.getId()))
.collect(Collectors.toList());
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && !distinctByUniqueList.isEmpty()){
List<SarBussionessStand> collect = distinctByUniqueList.stream()
.filter(item -> searchCenter.getIdList().contains(item.getId())).collect(Collectors.toList());
insList.addAll(collect);
}else{
insList.addAll(distinctByUniqueList);
}
// 交集 更新
List<SarBussionessStand> intersection = rowsStand.stream()
.filter(item -> new ArrayList<>(esIdList)
.contains(item.getId()))
.collect(Collectors.toList());
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && !intersection.isEmpty()){
List<SarBussionessStand> collect = intersection.stream()
.filter(item -> searchCenter.getIdList().contains(item.getId())).collect(Collectors.toList());
updList.addAll(collect);
}else{
updList.addAll(intersection);
}
List<String> finalStandIdList = null;
// 差集 (list2 - list1) 删除
if (allStand != null && !allStand.isEmpty()) {
finalStandIdList = allStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
}else{
finalStandIdList = rowsStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
}
List<String> finalStandIdList1 = finalStandIdList;
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
.collect(Collectors.toList());
// 可以更新IDLIST 删除 ES
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
delList.addAll(searchCenter.getIdList());
}else{
delList.addAll(delDataList);
}
}else {
// 新增
insList.addAll(rowsStand);
}
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){
for(SarBussionessStand sarBussionessStandEO : updList){
countUpdateSuccess++;
bussAttrInfoShowSearchDetails(sarBussionessStandEO);
if (sarBussionessStandEO.getAttrInfoMap() != null) {
sarBussionessStandEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarBussionessStandEO.getAttrInfoMap()));
}
// createStandMQService.sendBussStandMQ(sarBussionessStandEO,"update");
}
}
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){
for(SarBussionessStand sarBussionessStandEO : insList){
countAddSuccess++;
bussAttrInfoShowSearchDetails(sarBussionessStandEO);
if (sarBussionessStandEO.getAttrInfoMap() != null) {
sarBussionessStandEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarBussionessStandEO.getAttrInfoMap()));
}
// createStandMQService.sendBussStandMQ(sarBussionessStandEO,"add");
}
}
if(!delList.isEmpty() && !"sync".equals(sarBussionessStandEOPage.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
// elasticsearchService.deleteBatchId(delList,"bussstand");
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
logger.info("重置企标:删除-共"+delList.size()+"条数据");
}else{
logger.info("重置企标:没有删除数据,但应该删除"+delList.size()+"条数据");
}
logger.info("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)数据");
return Result.success("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)数据");
}else {
logger.info("未查询到企标数据");
return Result.error("未查询到企标数据");
}
}
private String getSearch(SearchCenter searchCenter) {
String search = "";
if(StringUtils.isNotBlank(searchCenter.getSearch())) {
search = searchCenter.getSearch();
}
return search;
}
private void standFunc(SarStandardsInfo sarStandardsInfoEO) throws Exception {
attrInfoSearchDetails(sarStandardsInfoEO);
FindSarItemsPageReqDTO pageInfo = new FindSarItemsPageReqDTO();
pageInfo.setStandId(sarStandardsInfoEO.getId());
pageInfo.setFileType("FBGBJBD");
/**
* SarItemVO换为sarItemVOS
* List<SarItemVO> sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo);
* .collect(Collectors.toMap(SarItemVO::getItemsNum, SarItemVO::getItemsName));
*/
List<SarStandItems> sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo);
if (!sarItemVOS.isEmpty()) {
Map<String, String> collectMap = sarItemVOS.stream().filter((e) -> e.getItemsNum() != null && e.getItemsName() != null)
.collect(Collectors.toMap(SarStandItems::getItemsNum, SarStandItems::getTermsConditions));
sarStandardsInfoEO.setMapItems(collectMap);
}
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap()));
}
}
public void attrInfoSearchDetails(SarStandardsInfo row) throws Exception {
if (row != null) {
String fieldInfo = InitStandAttrUtil.queryField;
String collectId = personCollectEOService.queryCollectByUserAndId(row.getId());
row.setCollectId(collectId);
// 查询属性表数据
if (StringUtils.isNotBlank(fieldInfo)) {
Map<String, Object> getAttrMap = sarStandAttrInfoEODao.selectStandFieldAndData(fieldInfo, row.getId());
// if (CollectionUtil.isNotEmpty(getAttrMap)) {
if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) {
// 遍历修改所有clob类型的值
for (String clobField : InitStandAttrUtil.clobFieldList) {
Clob clobValue = (Clob) getAttrMap.get(clobField);
String fieldValue = FieldConvertUtil.ClobToString(clobValue);
getAttrMap.put(clobField, fieldValue);
}
}
getAttrMap.put("updateAuth", "1");
row.setAttrInfoMap(getAttrMap);
// }
}
// Map<String, Object> getAttrMap = row.getAttrInfoMap();
// if (getAttrMap != null && getAttrMap.size() > 0) {
// for (Map.Entry<String, Object> entry : getAttrMap.entrySet()) {
// String name = entry.getKey();
// String value = "";
// List<String> valArr = new ArrayList<>();
// if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
// if (StringUtils.isNotBlank(entry.getValue().toString())) {
// Object json = null;
// if(Utils.isJson(entry.getValue().toString())){
// json = new JSONTokener(entry.getValue().toString()).nextValue();
// }
// if (json instanceof org.json.JSONArray) {
// valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class);
// } else {
// value = entry.getValue().toString();
// valArr = Arrays.asList(value.split(","));
// }
// if (!valArr.isEmpty()) {
// value = dicTypeEODao.getDicNamesByCodes(valArr, "");
// }
// }
// entry.setValue(value);
// }
// }
// }
// if (getAttrMap != null) {
// row.setSarStandAttrEOStr(JSONObject.toJSONString(getAttrMap));
// }
}
}
public void bussAttrInfoShowSearchDetails(SarBussionessStand row) throws Exception {
if (row != null) {
bussAttrInfoSearchDetails(row);
Map<String, Object> getAttrMap = row.getAttrInfoCaseMap();
if (getAttrMap != null && getAttrMap.size() > 0) {
for (Map.Entry<String, Object> entry : getAttrMap.entrySet()) {
String name = entry.getKey().toUpperCase();
String value = "";
List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){
Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else {
value = entry.getValue().toString();
valArr = Arrays.asList(value.split(","));
}
if(!valArr.isEmpty()){
value = dicTypeEODao.getDicNamesByCodes(valArr,"");
}
}
entry.setValue(value);
}
}
}
}
}
public void bussAttrInfoSearchDetails(SarBussionessStand row) throws Exception {
String fieldInfo = InitStandAttrUtil.queryFieldBuss;
String collectId = personCollectEOService.queryCollectByUserAndId(row.getId());
row.setCollectId(collectId);
// 查询属性表数据
if (org.apache.commons.lang.StringUtils.isNotBlank(fieldInfo)) {
Map<String, Object> getAttrMap = sarBussStandAttrInfoEODao.selectStandFieldAndData(fieldInfo, row.getId());
if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) {
// 遍历修改所有clob类型的值
for (String clobField : InitStandAttrUtil.clobFieldList) {
Clob clobValue = (Clob) getAttrMap.get(clobField);
String fieldValue = FieldConvertUtil.ClobToString(clobValue);
getAttrMap.put(clobField, fieldValue);
}
}
row.setAttrInfoMap(getAttrMap);
}
}
private void idListFunc(SarLawsStandInfoPage sarLawsInfoEOPage, SearchCenter searchCenter) {
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty()){
String[] result = searchCenter.getIdList().toArray(new String[0]);
sarLawsInfoEOPage.setIdlist(result);
}
}
public void lawsAttrInfoShowSearchDetails(SarLawsStandInfo row) throws Exception {
if (row != null) {
lawsAttrInfoSearchDetails(row);
Map<String, Object> getAttrMap = row.getAttrInfoCaseMap();
if (getAttrMap != null && getAttrMap.size() > 0) {
for (Map.Entry<String, Object> entry : getAttrMap.entrySet()) {
String name = entry.getKey().toUpperCase();
String value = "";
List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListLaws != null && InitStandAttrUtil.selectionFieldListLaws.size() > 0 && InitStandAttrUtil.selectionFieldListLaws.contains(name)) {
if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){
Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else {
value = entry.getValue().toString();
valArr = Arrays.asList(value.split(","));
}
if(!valArr.isEmpty()){
value = dicTypeEODao.getDicNamesByCodes(valArr,"");
}
}
entry.setValue(value);
}
}
}
}
}
public void lawsAttrInfoSearchDetails(SarLawsStandInfo row) throws Exception {
String fieldInfo = InitStandAttrUtil.queryFieldLaws;
String collectId = personCollectEOService.queryCollectByUserAndId(row.getId());
row.setCollectId(collectId);
// 查询属性表数据
if (org.apache.commons.lang.StringUtils.isNotBlank(fieldInfo)) {
Map<String, Object> getAttrMap = sarLawsAttrInfoDao.selectLawsFieldAndData(fieldInfo, row.getId());
if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) {
// 遍历修改所有clob类型的值
for (String clobField : InitStandAttrUtil.clobFieldList) {
Clob clobValue = (Clob) getAttrMap.get(clobField);
String fieldValue = FieldConvertUtil.ClobToString(clobValue);
getAttrMap.put(clobField, fieldValue);
}
}
if (getAttrMap != null && !getAttrMap.isEmpty()) {
row.setAttrInfoCaseMap(transformUpperCase(getAttrMap));
}
// row.setAttrInfoMap(getAttrMap);
}
}
private Map<String, Object> transformUpperCase(Map<String, Object> orgMap) {
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<String, Object> entry : orgMap.entrySet()) {
String newKey = entry.getKey().toLowerCase();
resultMap.put(newKey, orgMap.get(entry.getKey()));
if (entry.getValue() != null && InitStandAttrUtil.fileFieldListLaws != null && !InitStandAttrUtil.fileFieldListLaws.isEmpty() && InitStandAttrUtil.fileFieldListLaws.contains(entry.getKey())) {
String value = entry.getValue().toString();
if (org.apache.commons.lang.StringUtils.isNotBlank(value)) {
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value);
if(!fileObj.isEmpty()){
resultMap.put(newKey + "Name", fileObj.get(0).getOldFileName());
}
}
}
}
return resultMap;
}
}