Commit 445774e3 authored by 曹盼盼's avatar 曹盼盼

代码格式化

parent c514dc89
......@@ -99,7 +99,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
IdxFeignService idxFeignService;
@Autowired
private static final String TABLENAME="tableName";
private static final String TABLENAME = "tableName";
@Value("${regulator.unit.code}")
private String code;
......@@ -133,6 +133,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Value("${elasticsearch.password}")
private String esPwd;
/**
* 分页查询
*/
......@@ -177,7 +178,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<Map<String, Object>> mapList = resourceJson.get(EquipmentClassifityEnum.BDLS.getCode());
List<Map<String, Object>> list = new ArrayList<>();
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if(ObjectUtils.isEmpty(reginParams)){
if (ObjectUtils.isEmpty(reginParams)) {
return null;
}
String level = reginParams.getUserModel().getCompanys().get(0).getLevel();
......@@ -285,6 +286,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 将管辖机构树中children为[]的修改为null
*
* @param result
* @return
*/
......@@ -293,9 +295,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//将管辖机构树中children为[]的修改为null
if(e.get("children") != null){
if(((List<LinkedHashMap>) e.get("children")).size() == 0){
e.put("children",null);
if (e.get("children") != null) {
if (((List<LinkedHashMap>) e.get("children")).size() == 0) {
e.put("children", null);
}
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
......@@ -319,7 +321,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if ("company".equals(e.get("level"))) {
it.remove();
}
if(e.get("companyName").toString().contains("行政审批局")){
if (e.get("companyName").toString().contains("行政审批局")) {
it.remove();
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
......@@ -397,12 +399,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public List<CategoryOtherInfo> checkCode(Map<String, Object> obj) {
List<CategoryOtherInfo> codeList;
if("save".equals(obj.get("type"))){
if ("save".equals(obj.get("type"))) {
codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("CODE96333", obj.get("CODE96333")));
} else {
codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().ne("RECORD",obj.get("id")).eq("CODE96333", obj.get("CODE96333")));
codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().ne("RECORD", obj.get("id")).eq("CODE96333", obj.get("CODE96333")));
}
return codeList;
return codeList;
}
@Override
......@@ -497,7 +499,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
resultMap.put("superviseCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
resultMap.put("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString());
resultMap.put("qrCode",ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
resultMap.put("qrCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
return resultMap;
}
......@@ -698,7 +700,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
map.remove("ORG_BRANCH_CODE");
}
total += m.getTotal();
if (!ValidationUtil.isEmpty(m) && !ValidationUtil.isEmpty(m.getRecords())) {
if (!ValidationUtil.isEmpty(m) && !ValidationUtil.isEmpty(m.getRecords())) {
res.addAll(m.getRecords());
}
}
......@@ -726,7 +728,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
public List<Map<String, Object>> scalp(Map<String, Object> map) {
List<Map<String, Object>> list = new ArrayList<>();
if (!ValidationUtil.isEmpty(map.get("orgBranchName"))) {
......@@ -775,7 +776,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(id);
}
if (!ObjectUtils.isEmpty(dto)){
if (!ObjectUtils.isEmpty(dto)) {
esEquipmentCategory.save(dto);
}
}
......@@ -844,13 +845,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public Page<Map<String, Object>> getAll(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
String selectSql = " SELECT * FROM " + tableName ;
String selectSql = " SELECT * FROM " + tableName;
Integer number = ValidationUtil.isEmpty(map.get("number")) ? 0 : Integer.valueOf(map.get("number").toString());
Integer size = ValidationUtil.isEmpty(map.get("size")) ? 0 : Integer.valueOf(map.get("size").toString());
Page<Map<String, Object>> page = new Page<>(number, size);
int begin = (number - 1) * size;
if (size > 0) {
selectSql = selectSql+" LIMIT " + begin + "," + size;
selectSql = selectSql + " LIMIT " + begin + "," + size;
}
List<Map<String, Object>> mapList = bizJdbcTemplate.queryForList(selectSql);
page.setRecords(mapList);
......@@ -858,39 +859,43 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
//查询总条数
public Long counts(Map<String, Object> map){
public Long counts(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
String countSql = " SELECT COUNT(SEQUENCE_NBR) count FROM " + tableName;
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
return count;
}
/**
* es数据同步
*
* @return
*/
public void saveEs() {
Map<String, Object> map = new HashMap<>();
map.put(TABLENAME,"idx_biz_view_jg_all");
map.put(TABLENAME, "idx_biz_view_jg_all");
Long counts = counts(map);
Long times = counts / 1000;
Long yushu = counts % 1000;
if (yushu > 0) {
times++;
}
for (int i = 1; i <=times; i++) {
map.put("number",i);
map.put("size",1000);
for (int i = 1; i <= times; i++) {
map.put("number", i);
map.put("size", 1000);
Page<Map<String, Object>> page = getAll(map);
for (Map<String, Object> record : page.getRecords()) {
if (ValidationUtil.isEmpty(record.get("IS_NOT_ES")) ) {
if (ValidationUtil.isEmpty(record.get("IS_NOT_ES"))) {
saveESEquipmentCategory(record);
}
}
}
}
/**es保存设备数据*/
/**
* es保存设备数据
*/
public ESEquipmentCategoryDto saveESEquipmentCategory(Map<String, Object> map) {
ESEquipmentCategoryDto dto = JSONObject.parseObject(JSONObject.toJSONString(map), ESEquipmentCategoryDto.class);
ESEquipmentCategoryDto save = esEquipmentCategory.save(dto);
......@@ -903,10 +908,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
......@@ -921,7 +922,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (LEVEL.equals(level)) {
//企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else {
//监管单位
map.put("ORG_BRANCH_CODE", code);
......@@ -930,125 +930,54 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//通用匹配规则,条件构建
//SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("SEQUENCE_NBR", map.getString("SEQUENCE_NBR")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("ORG_BRANCH_NAME", "*" + map.getString("ORG_BRANCH_NAME") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("ORG_BRANCH_CODE", "*" + map.getString("ORG_BRANCH_CODE") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("USE_UNIT_NAME", "*" + map.getString("USE_UNIT_NAME") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", map.getString("USE_UNIT_CREDIT_CODE")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_LIST_CODE", "*"+map.getString("EQU_LIST_CODE")+"*"));
meBuilder.must(QueryBuilders.matchQuery("EQU_LIST_CODE", "*" + map.getString("EQU_LIST_CODE") + "*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_LIST", map.getString("EQU_LIST")));
......@@ -1064,18 +993,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("USE_ORG_CODE", map.getString("USE_ORG_CODE")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("CODE96333", map.getString("CODE96333")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_CODE", "*"+map.getString("EQU_CODE")+"*"));
meBuilder.must(QueryBuilders.matchQuery("EQU_CODE", "*" + map.getString("EQU_CODE") + "*"));
boolMust.must(meBuilder);
}
......@@ -1116,59 +1042,41 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
if (!ValidationUtil.isEmpty(dto2.get(EQUSTATE))) {
Integer integer = Integer.valueOf(dto2.get(EQUSTATE).toString());
String status = EquimentEnum.getName.get(integer);
dto2.put(EQUSTATE, status);
}
list.add(dto2);
}
totle = getCount("idx_biz_view_jg_all",esClient);
totle = getCount("idx_biz_view_jg_all", esClient);
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}finally {
} finally {
try {
esClient.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
}
//es统计总记录数
public Long getCount(String indexs ,RestHighLevelClient esClient){
Long totle=0L;
public Long getCount(String indexs, RestHighLevelClient esClient) {
Long totle = 0L;
SearchRequest searchRequest = new SearchRequest(indexs);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchSourceBuilder.trackTotalHits(true);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = esClient.search(searchRequest, RequestOptions.DEFAULT);
totle=searchResponse.getInternalResponse().hits().getTotalHits().value;
totle = searchResponse.getInternalResponse().hits().getTotalHits().value;
} catch (IOException e) {
throw new RuntimeException(e);
}
return totle;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment