Merge branch 'develop_migration' into 'develop_master'

Develop migration

See merge request LiuChao/foton-slrs-system-rest!411
This commit is contained in:
super_liu
2022-03-07 17:34:18 +08:00
8 changed files with 277 additions and 7 deletions
@@ -0,0 +1,52 @@
package com.adc.da.search;
import com.adc.da.base.web.BaseController;
import com.adc.da.search.server.ResetSearchCenterService;
import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage;
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfoPage;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage;
import com.adc.da.util.http.ResponseMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/${restPath}/search/resetSearchCenter")
@Api(description = "搜索中心重置索引及数据+实施预警触发")
public class ResetSearchCenterController extends BaseController<Map<String, Object>> {
@Autowired
private ResetSearchCenterService resetSearchCenterService;
@ApiOperation(value = "|SearchCenter|重新创建ALL标准数据索引")
@PostMapping(value="/resetALLSearchCenter")
public ResponseMessage resetALLSearchCenter() throws Exception{
return resetSearchCenterService.resetALLSearchCenter();
}
@ApiOperation(value = "|SearchCenter|重新创建国内外标准数据索引")
@PostMapping(value="/resetAStandSearchCenter")
public ResponseMessage resetStandSearchCenter() throws Exception{
SarStandardsInfoEOPage sarStandardsInfoEOPage = new SarStandardsInfoEOPage();
return resetSearchCenterService.resetStandSearchCenter(sarStandardsInfoEOPage);
}
@ApiOperation(value = "|SearchCenter|重新创建国内外政策数据索引")
@PostMapping(value="/resetBLawsSearchCenter")
public ResponseMessage resetLawsSearchCenter() throws Exception{
SarLawsStandInfoPage sarLawsInfoEOPage = new SarLawsStandInfoPage();
return resetSearchCenterService.resetLawsSearchCenter(sarLawsInfoEOPage);
}
@ApiOperation(value = "|SearchCenter|重新创建企业标准数据索引")
@PostMapping(value="/resetCBussStandSearchCenter")
public ResponseMessage resetBussStandSearchCenter() throws Exception{
SarBussionessStandEOPage sarBussionessStandEOPage = new SarBussionessStandEOPage();
return resetSearchCenterService.resetBussStandSearchCenter(sarBussionessStandEOPage);
}
}
@@ -0,0 +1,184 @@
package com.adc.da.search.server;
import com.adc.da.mq.CreateStandMQService;
import com.adc.da.search.service.ElasticsearchService;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo;
import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage;
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.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.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.transport.TransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("resetSearchCenterService")
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class ResetSearchCenterService {
private static final Logger logger = LoggerFactory.getLogger(ResetSearchCenterService.class);
@Autowired
private ElasticsearchService elasticsearchService;
@Autowired
private TransportClient transportClient;
@Autowired
private TransportClient client;
@Autowired
private ISarStandardsInfoService iSarStandardsInfoService;
@Autowired
private ISarLawsStandInfoService iSarLawsStandInfoService;
@Autowired
private ISarBussionessStandService iSarBussionessStandService;
@Autowired
private CreateStandMQService createStandMQService;
@PostConstruct
public void init() {
client = this.transportClient;
}
@Async
public ResponseMessage resetALLSearchCenter() throws Exception{
ResponseMessage stand = resetStandSearchCenter(new SarStandardsInfoEOPage());
List<String> r = new ArrayList<>();
if(stand.isOk() && StringUtils.isNotBlank(stand.getData().toString())){
r.add(stand.getData().toString());
}
ResponseMessage laws = resetLawsSearchCenter(new SarLawsStandInfoPage());
if(laws.isOk() && StringUtils.isNotBlank(laws.getData().toString())){
r.add(laws.getData().toString());
}
ResponseMessage buss = resetBussStandSearchCenter(new SarBussionessStandEOPage());
if(buss.isOk() && StringUtils.isNotBlank(buss.getData().toString())){
r.add(buss.getData().toString());
}
String res = String.join(", ", r);
return Result.success(res);
}
//重建国内外标准
@Async
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page) throws Exception{
Boolean getStandIndex = elasticsearchService.isIndexExist("stand");
if(getStandIndex){
Boolean deleteStandIndex = elasticsearchService.deleteIndex("stand");
}
page.setValidFlag("0");
// int countStand = sarStandardsInfoEODao.getSarStandardsInfoCount(page);
int countStand = 10000;
int countSuccess = 0;
if(countStand>0){
page.setPageSize(countStand);
page.setMenuId("nomenu");
page.setStandType("ALL");
List<SarStandardsInfo> rowsStand = iSarStandardsInfoService.getSarStandardsInfoPage(page);
for(SarStandardsInfo sarStandardsInfoEO : rowsStand){
countSuccess++;
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap()));
}
createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
}
}
return Result.success("重置国内外:"+ countSuccess + "");
}
@Async
public ResponseMessage resetLawsSearchCenter(SarLawsStandInfoPage sarLawsInfoEOPage) throws Exception{
Boolean getLawsIndex = elasticsearchService.isIndexExist("laws");
if(getLawsIndex){
Boolean deleteLawsIndex = elasticsearchService.deleteIndex("laws");
}
sarLawsInfoEOPage.setLawsType("FOREIGN");
// sarLawsInfoEOPage.setMenuId("6bc1632eb6354d4fb725");
// int countLaws = sarLawsInfoEODao.queryByCount(sarLawsInfoEOPage);
int countLaws = 10000;
int countSuccess = 0;
if (countLaws>0) {
sarLawsInfoEOPage.setPageSize(countLaws);
List<SarLawsStandInfo> rowsLaws = iSarLawsStandInfoService.getSarStandardsInfoPage(sarLawsInfoEOPage);
for(SarLawsStandInfo sarLawsInfoEO : rowsLaws){
countSuccess++;
if (sarLawsInfoEO.getAttrInfoMap() != null) {
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
}
createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
}
}
return Result.success("重置国内外政策:"+ countSuccess + "");
}
@Async
public ResponseMessage resetBussStandSearchCenter(SarBussionessStandEOPage sarBussionessStandEOPage) throws Exception{
Boolean getbussstandIndex = elasticsearchService.isIndexExist("bussstand");
int number = 0;
if(getbussstandIndex){
Boolean deletebussstandIndex = elasticsearchService.deleteIndex("bussstand");
}
List<SarBussionessStand> getAllList = new ArrayList<>();
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);
sarBussionessStandEOPage.setMenuId("nomenu");
int countBuss = 10000;
int countSuccess = 0;
if(countBuss>0){
sarBussionessStandEOPage.setMenuId("0");
sarBussionessStandEOPage.setPageSize(countBuss);
getAllList = iSarBussionessStandService.getSarBussionStandPage(sarBussionessStandEOPage);
number = getAllList.size();
}
if (getAllList != null && !getAllList.isEmpty()) {
sendESForBussStand(getAllList,countSuccess);
}
return Result.success("重置企标:"+ number + "");
}
@Async
public void sendESForBussStand(List<SarBussionessStand> getAllList,int countSuccess) throws Exception {
for(SarBussionessStand sarBussionessStandEO : getAllList){
countSuccess++;
Map<String,Object> attrInfoMap = sarBussionessStandEO.getAttrInfoMap();
if (null != attrInfoMap && attrInfoMap.containsKey("QBMJ") && null != attrInfoMap.get("QBMJ") && String.valueOf(attrInfoMap.get("QBMJ")).contains("ACF675Z88W")){
countSuccess--;
}
if (sarBussionessStandEO.getAttrInfoMap() != null) {
sarBussionessStandEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarBussionessStandEO.getAttrInfoMap()));
}
createStandMQService.sendBussStandMQ(sarBussionessStandEO,"add");
}
}
}
@@ -98,7 +98,12 @@ public class SysInfoEOService {
String names = "";
if (StringUtils.isNotBlank(codes)) {
String[] idArr = codes.split(",");
names = dicTypeEODao.getDicNamesByCodes(Arrays.asList(idArr));
String names1 = dicTypeEODao.getDicNamesByCodes(Arrays.asList(idArr));
if(StringUtils.isNotBlank(names1) && names1.contains(",")){
List<String> list1 = Arrays.asList(names1.split(","));
List<String> list = list1.stream().distinct().collect(Collectors.toList());
names = String.join(",",list);
}
}
return names;
}