Files
foton-slrs-system-rest/adc-da-slrs/src/main/java/com/adc/da/search/ResetSearchCenterController.java
T

114 lines
4.9 KiB
Java

package com.adc.da.search;
import com.adc.da.base.web.BaseController;
import com.adc.da.search.bean.SearchCenter;
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 com.adc.da.util.http.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/${restPath}/search/resetSearchCenter")
@Api(tags = "搜索中心重置索引及数据")
public class ResetSearchCenterController extends BaseController<Map<String, Object>> {
private static final Logger logger = LoggerFactory.getLogger(ResetSearchCenterController.class);
@Autowired
private ResetSearchCenterService resetSearchCenterService;
@ApiOperation(value = "|SearchCenter|重新创建ALL标准数据索引")
@PostMapping(value="/resetALLSearchCenter")
public ResponseMessage resetALLSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
return x;
}
return resetSearchCenterService.resetALLSearchCenter(searchCenter);
}
private ResponseMessage verifySearchCenter(SearchCenter searchCenter) {
if(searchCenter.getExecType() == null || "".equals(searchCenter.getExecType())){
return Result.error("执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准, DEL 只删除不存在标准库的数据");
}
return null;
}
@ApiOperation(value = "|SearchCenter|重新创建国内外标准数据索引")
@PostMapping(value="/resetAStandSearchCenter")
public ResponseMessage resetStandSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
return x;
}
SarStandardsInfoEOPage sarStandardsInfoEOPage = new SarStandardsInfoEOPage();
return resetSearchCenterService.resetStandSearchCenter(sarStandardsInfoEOPage,searchCenter);
}
@ApiOperation(value = "|SearchCenter|重新创建国内外政策数据索引")
@PostMapping(value="/resetBLawsSearchCenter")
public ResponseMessage resetLawsSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
return x;
}
SarLawsStandInfoPage sarLawsInfoEOPage = new SarLawsStandInfoPage();
return resetSearchCenterService.resetLawsSearchCenter(sarLawsInfoEOPage,searchCenter);
}
@ApiOperation(value = "|SearchCenter|重新创建企业标准数据索引")
@PostMapping(value="/resetCBussStandSearchCenter")
public ResponseMessage resetBussStandSearchCenter(@RequestBody SearchCenter searchCenter) throws Exception{
ResponseMessage x = verifySearchCenter(searchCenter);
if (x != null){
return x;
}
SarBussionessStandEOPage sarBussionessStandEOPage = new SarBussionessStandEOPage();
return resetSearchCenterService.resetBussStandSearchCenter(sarBussionessStandEOPage,searchCenter);
}
/**
* 根据资源ID对搜索中心数据进行处理
* @param standId
* @param dataType(STAND BUSS)
* @return
*/
@ApiOperation(value = "|SearchCenter|根据资源ID对搜索中心数据进行处理")
@GetMapping(value="/syncSearchCenterData")
public ResponseMessage syncSearchCenterData(@RequestParam("standId") String standId,
@RequestParam("dataType") String dataType){
if(StringUtils.isNotBlank(standId) && StringUtils.isNotBlank(dataType)){
try {
if("STAND".equals(dataType)){
resetSearchCenterService.syncStandSearchCenterData(standId);
}else if("BUSS".equals(dataType)){
resetSearchCenterService.syncBussStandSearchCenterData(standId);
}else{
return Result.error("-1","资源类型错误,请检查",null);
}
return Result.success("200","开始同步",null);
} catch (Exception e) {
logger.error(e.getMessage(),e);
return Result.error("-1","请求错误,请检查",null);
}
}else{
return Result.error("-1","参数有误,请检查",null);
}
}
}