Merge remote-tracking branch 'origin/develop_master' into develop_master

This commit is contained in:
yuezhihang
2022-03-08 15:48:55 +08:00
8 changed files with 281 additions and 7 deletions
@@ -4,6 +4,7 @@ import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
@@ -65,8 +66,12 @@ public class JwtSysUtils {
String user = "";
if(attributes != null){
HttpServletRequest request = attributes.getRequest();
Claims claim = getClaimsByToken(request.getHeader("token"));
user = claim.getSubject();
if(StringUtils.isNotBlank(request.getHeader("token"))){
Claims claim = getClaimsByToken(request.getHeader("token"));
user = claim.getSubject();
}else {
user = "chenchunmei";
}
}
return user;
}
@@ -109,6 +109,12 @@ public class WebMvcConfig implements WebMvcConfigurer {
addInterceptor.excludePathPatterns("/api/lawss/activiti/loginMobile");
// 重置ES
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetALLSearchCenter");
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetAStandSearchCenter");
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetBLawsSearchCenter");
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetCBussStandSearchCenter");
//// //测试接口使用
// addInterceptor.excludePathPatterns("/api/**");
@@ -236,7 +236,7 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
fullTextSearchEO.put("textItems",textItemContent.toString());
if (null != attrInfoMap.get("issueTime") && !"".equals(attrInfoMap.get("issueTime")) && !"null".equals(attrInfoMap.get("issueTime"))) {
fullTextSearchEO.put("issue_time", attrInfoMap.get("issueTime"));
fullTextSearchEO.put("issue_time", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))));
}else {
fullTextSearchEO.put("issue_time", "--");
}
@@ -298,7 +298,7 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
fullTextSearchEO.put("textContent",textContent.toString());
if (null != attrInfoMap.get("issueTime") && !"".equals(attrInfoMap.get("issueTime")) && !"null".equals(attrInfoMap.get("issueTime"))) {
fullTextSearchEO.put("issue_time", attrInfoMap.get("issueTime"));
fullTextSearchEO.put("issue_time", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))));
}else {
fullTextSearchEO.put("issue_time", "--");
}
@@ -349,14 +349,28 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
StringBuilder textContent = replaceAll(contentBuilder, "null", "--");
fullTextSearchEO.put("textContent",textContent.toString());
if (null != attrInfoMap.get("issueTime") && !"".equals(attrInfoMap.get("issueTime")) && !"null".equals(attrInfoMap.get("issueTime"))) {
fullTextSearchEO.put("issue_time", attrInfoMap.get("issueTime"));
fullTextSearchEO.put("issue_time", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))));
}else {
fullTextSearchEO.put("issue_time", "");
fullTextSearchEO.put("issue_time", "--");
}
}
return fullTextSearchEO;
}
private String dateFormatToStr(String dateStr){
if(dateStr == null || dateStr.equals("")){
return "";
}
String dateToStr = "";
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateToStr = dateFormat.format(dateFormat.parse(dateStr.trim().substring(0,10)));
}catch (Exception e){
e.getMessage();
}
return dateToStr;
}
FullTextSearchEO getFullTextSearch(StandLawsEO standLawsEO){
FullTextSearchEO fullTextSearchEO = new FullTextSearchEO();
fullTextSearchEO.setId(standLawsEO.getId());
@@ -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,188 @@
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{
Boolean getFulltextserchIndex = elasticsearchService.isIndexExist("fulltextserch");
if(getFulltextserchIndex){
Boolean deleteFulltextserchIndex = elasticsearchService.deleteIndex("fulltextserch");
}
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)){
List<String> list1 = Arrays.asList(names1.split(","));
List<String> list = list1.stream().distinct().collect(Collectors.toList());
names = String.join(",",list);
}
}
return names;
}
@@ -863,6 +863,9 @@
END,
sar_standards_info.stand_sort ASC,CAST(sar_standards_info.STAND_NUMBER AS decimal(9,2)) ASC,sar_standards_info.STAND_YEAR DESC,sar_standards_info.id
</if>
<if test='page.standType != null and page.standType == "ALL"'>
sar_standards_info.stand_sort ASC
</if>
</sql>
<sql id="standSort_out">
<if test='standType != null and standType == "INLAND"'>
@@ -0,0 +1 @@
ALTER TABLE sar_buss_stand_val MODIFY COLUMN stand_id varchar(64)