Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
a4e4798a
Commit
a4e4798a
authored
Jul 21, 2025
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(amos-boot): 优化统计模块代码结构和功能
- 调整气瓶分类统计逻辑,优化数据完整性统计 - 修复部分统计模板解析错误,增加模板覆盖逻辑 - 优化 JSON 字段处理,添加新字段方法 - 调整隐患模板结构,增加关联设备和企业信息展示
parent
680950b3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
259 additions
and
40 deletions
+259
-40
JsonValueUtils.java
...om/yeejoin/amos/boot/biz/common/utils/JsonValueUtils.java
+59
-0
DPSubController.java
...boot/module/statistcs/biz/controller/DPSubController.java
+1
-0
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+71
-38
DPSubServiceImpl.java
...t/module/statistcs/biz/service/impl/DPSubServiceImpl.java
+19
-1
problem.json
...odule-statistics-biz/src/main/resources/json/problem.json
+1
-1
problem_9.json
...ule-statistics-biz/src/main/resources/json/problem_9.json
+108
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/JsonValueUtils.java
View file @
a4e4798a
...
...
@@ -2,6 +2,11 @@ package com.yeejoin.amos.boot.biz.common.utils;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.google.common.base.Strings
;
/**
...
...
@@ -11,6 +16,8 @@ import com.google.common.base.Strings;
*/
public
class
JsonValueUtils
{
private
static
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
public
static
Object
getValueByKey
(
Object
originObject
,
String
startKey
,
String
targetKeyExpression
)
{
if
(
Strings
.
isNullOrEmpty
(
startKey
))
{
...
...
@@ -71,4 +78,56 @@ public class JsonValueUtils {
String
a
=
"{\"agencyCode\":\"jcs\",\"agencyUserType\":\"NORMAL\",\"appCodes\":[\"AMOS_ADMIN\",\"studio_normalapp_3144441\",\"studio_normalapp_3157169\",\"studio_normalapp_3168830\",\"studio_normalapp_3206513\",\"studio_normalapp_3230377\"],\"companyDepartments\":{},\"companys\":[{\"agencyCode\":\"jcs\",\"companyName\":\"咸阳机场\",\"companyOrgCode\":49,\"level\":\"headquarter\",\"orgCode\":\"49\",\"parentId\":0,\"sequenceNbr\":1397143494413381633}],\"createTime\":1625058001000,\"lockStatus\":\"UNLOCK\",\"orgNames\":\"咸阳机场(admin\\\\idx_report_data\\\\idx_report_audit\\\\Safety_Supervision_Instruct_Report\\\\Safety_Supervision_Rectify_Report\\\\Safety_Supervision_Rectify_Affirm)\",\"orgRoleName\":{1397143494413381633:\"咸阳机场(admin\\\\idx_report_data\\\\idx_report_audit\\\\Safety_Supervision_Instruct_Report\\\\Safety_Supervision_Rectify_Report\\\\Safety_Supervision_Rectify_Affirm)\"},\"orgRoleSeqs\":{1397143494413381633:[1397143493910065153,1484425579646689281,1484425839416713217,1536242867071119362,1536243072738816002,1536243348623355905]},\"orgRoles\":{1397143494413381633:[{\"agencyCode\":\"jcs\",\"roleDesc\":\"admin\",\"roleName\":\"admin\",\"roleType\":\"admin\",\"sequenceNbr\":1397143493910065153},{\"agencyCode\":\"jcs\",\"roleDesc\":\"指标系统-数据填报\",\"roleName\":\"idx_report_data\",\"roleType\":\"admin\",\"sequenceNbr\":1484425579646689281},{\"agencyCode\":\"jcs\",\"roleDesc\":\"指标系统-数据审核\",\"roleName\":\"idx_report_audit\",\"roleType\":\"admin\",\"sequenceNbr\":1484425839416713217},{\"agencyCode\":\"jcs\",\"roleDesc\":\"安全监察-填报指令书\",\"roleName\":\"Safety_Supervision_Instruct_Report\",\"roleType\":\"admin\",\"sequenceNbr\":1536242867071119362},{\"agencyCode\":\"jcs\",\"roleDesc\":\"安全监察-企业整改\",\"roleName\":\"Safety_Supervision_Rectify_Report\",\"roleType\":\"admin\",\"sequenceNbr\":1536243072738816002},{\"agencyCode\":\"jcs\",\"roleDesc\":\"安全监察-整改确认\",\"roleName\":\"Safety_Supervision_Rectify_Affirm\",\"roleType\":\"admin\",\"sequenceNbr\":1536243348623355905}]},\"password\":\"1CABE8C68B956573D0709013FD61CA5F\",\"passwordReset\":false,\"realName\":\"邢磊\",\"sequenceNbr\":1410417876975759361,\"userId\":\"3187681\",\"userName\":\"jcs_xl\"}"
;
System
.
out
.
println
(
getValueByKey
(
JSONObject
.
parse
(
a
),
"companys"
,
"companys.0.sequenceNbr"
));
}
/**
* JSON字段添加
*
* @param jsonString JSON字符串 示例 {"a":{"b":{"c":1}}}
* @param keyPath 字段路径 示例 "a.b.c"
* @param field 字段名 示例 "name"
* @param value 字段值 示例 "张三"
* @return 修改后的JSON字符串 {"a":{"b":{"c":1,"name":"张三"}}}
*/
public
String
jsonFieldAdd
(
String
jsonString
,
String
keyPath
,
String
field
,
String
value
)
throws
JsonProcessingException
{
JsonNode
rootNode
=
objectMapper
.
readTree
(
jsonString
);
// 修复路径格式(添加前导/)
JsonNode
targetNode
=
rootNode
.
at
(
'/'
+
keyPath
.
replace
(
"."
,
"/"
));
if
(
targetNode
.
isArray
())
{
ArrayNode
arrayNode
=
(
ArrayNode
)
targetNode
;
// 替换现有字段或添加新字段
boolean
replaced
=
false
;
for
(
JsonNode
node
:
arrayNode
)
{
if
(
node
.
has
(
"key"
)
&&
node
.
get
(
"key"
).
asText
().
equals
(
field
))
{
((
ObjectNode
)
node
).
put
(
"label"
,
value
);
replaced
=
true
;
break
;
}
}
if
(!
replaced
)
{
addNewArrayField
(
arrayNode
,
field
,
value
);
}
}
else
if
(
targetNode
.
isObject
())
{
boolean
replaced
=
false
;
if
(
targetNode
.
has
(
"key"
)
&&
targetNode
.
get
(
"key"
).
asText
().
equals
(
field
))
{
((
ObjectNode
)
targetNode
).
put
(
"label"
,
value
);
replaced
=
true
;
}
if
(!
replaced
)
{
((
ObjectNode
)
targetNode
).
put
(
field
,
value
);
}
}
// 修复返回值:序列化修改后的rootNode
return
objectMapper
.
writeValueAsString
(
rootNode
);
}
// 添加新的 key-value 字段
private
static
void
addNewArrayField
(
ArrayNode
arrayNode
,
String
newKey
,
String
newLabel
)
{
ObjectNode
newField
=
objectMapper
.
createObjectNode
();
newField
.
put
(
"key"
,
newKey
);
newField
.
put
(
"label"
,
newLabel
);
arrayNode
.
add
(
newField
);
}
}
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/controller/DPSubController.java
View file @
a4e4798a
...
...
@@ -72,6 +72,7 @@ public class DPSubController {
param
.
put
(
"sequenceNbr"
,
param
.
get
(
"alertId"
));
}
Assert
.
notNull
(
param
.
get
(
"sequenceNbr"
),
"sequenceNbr不能为空"
);
template
=
subService
.
getOverrideTemplateName
(
template
,
(
String
)
param
.
get
(
"problemTypeCode"
));
}
else
if
(
template
.
equals
(
"registration"
))
{
// 登记证
Assert
.
notNull
(
param
.
get
(
"sequenceNbr"
),
"sequenceNbr不能为空"
);
}
else
if
(
template
.
equals
(
"inspection"
))
{
// 报检
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/service/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
View file @
a4e4798a
...
...
@@ -46,9 +46,7 @@ import org.elasticsearch.client.core.CountResponse;
import
org.elasticsearch.index.query.*
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.nested.ParsedNested
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.ParsedSum
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.FieldSortBuilder
;
import
org.elasticsearch.search.sort.SortBuilders
;
...
...
@@ -711,6 +709,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
dto
.
get
(
"unitType"
).
toString
().
contains
(
"安装改造维修单位"
)))
{
permissionStatus
=
noneStr
;
}
if
(
dto
.
get
(
"unitType"
).
equals
(
"使用单位"
)
||
dto
.
get
(
"unitType"
).
equals
(
"个人主体"
)){
permissionStatus
=
null
;
}
dto
.
put
(
"permissionStatus"
,
permissionStatus
);
list
.
add
(
dto
);
}
...
...
@@ -735,7 +736,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(!
""
.
equals
(
permitStatusStr
))
{
getFilterCompanyOrPersonPermitStatusStatic
(
staticMap
,
StatisticalAnalysisEnum
.
company
.
getKey
(),
permitStatusStr
,
totle
);
}
else
{
getCompanyOrPersonPermitStatusStatic
(
boolMust
,
staticMap
,
StatisticalAnalysisEnum
.
person
.
getKey
());
getCompanyOrPersonPermitStatusStatic
(
boolMust
,
staticMap
,
StatisticalAnalysisEnum
.
company
.
getKey
());
}
result
.
put
(
"keyIndicator"
,
staticMap
);
...
...
@@ -820,7 +821,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
else
if
(
item
.
equals
(
none
))
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
nestedField
)),
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
enhancedDynamicQueryBuilder
.
add
(
nestedQuery
,
or
);
...
...
@@ -1020,7 +1021,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
DynamicQueryBuilder
dynamicQueryBuilder
=
new
DynamicQueryBuilder
();
dynamicQueryBuilder
.
or
(
QueryBuilders
.
prefixQuery
(
"ORG_BRANCH_CODE"
,
orgCode
));
dynamicQueryBuilder
.
or
(
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termQuery
(
"ORG_BRANCH_CODE"
,
""
)));
dynamicQueryBuilder
.
or
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
"ORG_BRANCH_CODE"
)));
dynamicQueryBuilder
.
or
(
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
"ORG_BRANCH_CODE"
)));
boolMust
.
must
(
dynamicQueryBuilder
.
build
());
}
else
{
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"ORG_BRANCH_CODE"
,
orgCode
));
...
...
@@ -1064,7 +1065,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 正常:大于当前日期加上30天
queryBuilder
.
add
(
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
))),
or
);
}
else
{
queryBuilder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
finalField
)),
or
);
queryBuilder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
finalField
)),
or
);
}
});
boolMust
.
must
(
queryBuilder
.
build
());
...
...
@@ -1074,11 +1075,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
();
if
(
"1"
.
equals
(
item
))
{
queryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"IS_INTO_MANAGEMENT"
,
Boolean
.
TRUE
))
.
must
(
QueryBuilders
.
existsQuery
(
"USE_ORG_CODE"
));
.
must
(
existsQuery
(
"USE_ORG_CODE"
));
}
else
{
queryBuilder
.
should
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
"IS_INTO_MANAGEMENT"
)))
queryBuilder
.
should
(
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
"IS_INTO_MANAGEMENT"
)))
.
should
(
QueryBuilders
.
matchQuery
(
"IS_INTO_MANAGEMENT"
,
Boolean
.
FALSE
))
.
should
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
"USE_ORG_CODE"
)))
.
should
(
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
"USE_ORG_CODE"
)))
.
minimumShouldMatch
(
1
);
}
enhancedDynamicQueryBuilder
.
add
(
queryBuilder
,
or
);
...
...
@@ -1110,7 +1111,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(!
item
.
equals
(
"99"
))
{
queryBuilder
.
add
(
QueryBuilders
.
matchQuery
(
k
,
item
.
toString
()),
or
);
}
else
{
queryBuilder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
k
)),
or
);
queryBuilder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
k
)),
or
);
}
});
boolMust
.
must
(
queryBuilder
.
build
());
...
...
@@ -1289,24 +1290,53 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private
BigDecimal
getPipeLength
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
,
String
countField
)
{
SearchRequest
request
=
new
SearchRequest
();
request
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
BigDecimal
pipeLong
;
NestedQueryBuilder
nestedQueryBuilder
=
QueryBuilders
.
nestedQuery
(
"techParams"
,
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termsQuery
(
"techParams.paramKey"
,
"pipeLength"
)),
ScoreMode
.
None
);
boolMust
.
must
(
nestedQueryBuilder
);
builder
.
query
(
boolMust
).
aggregation
(
AggregationBuilders
.
nested
(
countField
,
"techParams"
).
subAggregation
(
AggregationBuilders
.
sum
(
"pipeLength"
).
field
(
"techParams.doubleValue"
)
)
);
BigDecimal
pipeLong
=
new
BigDecimal
(
0
);
// String painlessScript =
// "double total = 0.0; " +
// "for (int i = 0; i < doc['techParams.doubleValue'].length; i++) { " +
// " if (doc['techParams.paramKey'][i] == 'pipeLength') { " +
// " try { " +
// " total += Double.parseDouble(doc['techParams.doubleValue'][i].toString()); " +
// " } catch (Exception e) {} " +
// " } " +
// "} " +
// "return total;";
// NestedAggregationBuilder nestedAgg = AggregationBuilders.nested(countField, "techParams");
// SumAggregationBuilder sumAgg = AggregationBuilders.sum("pipeLength")
// .script(new Script(ScriptType.INLINE, "painless", painlessScript, Collections.emptyMap()));
// nestedAgg.subAggregation(sumAgg);
builder
.
query
(
boolMust
).
size
(
10000000
);
request
.
source
(
builder
);
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
ParsedSum
sumAgg
=
((
ParsedNested
)
response
.
getAggregations
()
.
get
(
countField
))
.
getAggregations
()
.
get
(
"pipeLength"
);
double
value
=
sumAgg
.
getValue
();
pipeLong
=
new
BigDecimal
(
value
);
JSONArray
resultList
=
new
JSONArray
();
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
hit
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
resultList
.
add
(
dto
.
get
(
"techParams"
));
}
for
(
Object
object
:
resultList
)
{
JSONArray
jsonArray
=
(
JSONArray
)
object
;
for
(
Object
o
:
jsonArray
)
{
JSONObject
jsonObject
=
(
JSONObject
)
o
;
if
(
jsonObject
.
getString
(
"paramKey"
).
equals
(
"pipeLength"
)
&&
jsonObject
.
containsKey
(
"doubleValue"
)){
BigDecimal
value
=
new
BigDecimal
(
jsonObject
.
get
(
"doubleValue"
).
toString
());
pipeLong
=
pipeLong
.
add
(
value
);
}
}
}
// // 获取最外层聚合结果
// Aggregations aggregations = response.getAggregations();
// // 1. 获取嵌套聚合结果
// ParsedNested nestedItems = aggregations.get(countField);
// 2. 从嵌套聚合中获取过滤聚合结果
// ParsedFilter filteredItems = nestedItems.getAggregations().get("filtered_items");
// 3. 从过滤聚合中获取指标聚合结果
// ParsedSum totalValue = nestedItems.getAggregations().get("pipeLength");
// double value = 0;
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
@@ -1801,13 +1831,13 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 无许可到期日期
NestedQueryBuilder
noneQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
nestedField
)),
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
// 有效许可到期日期
NestedQueryBuilder
existsQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
existsQuery
(
nestedField
)),
QueryBuilders
.
boolQuery
().
must
(
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
// 正常许可到期日期
...
...
@@ -3043,7 +3073,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(
groupField
.
equals
(
"EQU_LIST_CODE"
))
{
gasBoolQueryBuilder
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
}
boolMust
.
mustNot
(
QueryBuilders
.
matchQuery
(
"EQU_CATEGORY_CODE"
,
"2300"
));
if
(!
"2300"
.
equals
(
equipCode
)){
boolMust
.
mustNot
(
QueryBuilders
.
matchQuery
(
"EQU_CATEGORY_CODE"
,
"2300"
));
}
getStatisticCountByGroup
(
request
,
builder
,
boolMust
,
groupField
,
staticCountByGroup
,
"noGas"
);
AtomicReference
<
Long
>
otherCount
=
new
AtomicReference
<>(
0L
);
...
...
@@ -3060,7 +3092,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
queryBuilder
=
QueryBuilderUtils
.
copyBoolQuery
(
pipeBoolMust
);
String
code
=
categoryMap
.
get
(
"value"
).
toString
();
codes
.
add
(
code
);
if
(
code
.
startsWith
(
"2300"
))
{
// 去除类别中的气瓶
if
(
code
.
equals
(
"2300"
))
{
staticCountByGroup
.
remove
(
code
);
continue
;
}
...
...
@@ -3079,7 +3112,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map
.
put
(
"img"
,
dpEquipPhotoPrefix
+
code
+
dpEquipPhotoSuffix
);
Integer
count
=
tzsCustomFilterMapper
.
selectEquipmentCategoryCountByParentId
(
categoryMap
.
get
(
"key"
).
toString
());
map
.
put
(
"noChild"
,
0
==
count
?
Boolean
.
TRUE
:
Boolean
.
FALSE
);
map
.
put
(
"measurementUnit"
,
equipCode
!=
null
&&
equipCode
.
startsWith
(
"8"
)
?
"千米"
:
equipCode
!=
null
&&
equipC
ode
.
startsWith
(
"2"
)
?
"个"
:
"台套"
);
map
.
put
(
"measurementUnit"
,
code
.
startsWith
(
"8"
)
?
"千米"
:
c
ode
.
startsWith
(
"2"
)
?
"个"
:
"台套"
);
map
.
put
(
"noBottom"
,
code
.
startsWith
(
"8"
)
?
Boolean
.
TRUE
:
Boolean
.
FALSE
);
// 统计该分类下的数据完整性的分组数量 DATA_QUALITY_SCORE
BoolQueryBuilder
scoreQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
...
...
@@ -3124,7 +3157,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map
.
put
(
"measurementUnit"
,
"个"
);
map
.
put
(
"noBottom"
,
Boolean
.
FALSE
);
// 统计该分类下的数据完整性的分组数量 DATA_QUALITY_SCORE
BoolQueryBuilder
scoreQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
BoolQueryBuilder
scoreQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
gasBoolQueryBuilder
);
scoreQuery
.
must
(
QueryBuilders
.
termQuery
(
fieldKey
,
code
));
SearchSourceBuilder
scoreBuilder
=
new
SearchSourceBuilder
();
Map
<
String
,
Object
>
scoreCountByGroup
=
new
HashMap
<>();
...
...
@@ -3132,7 +3165,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map
.
put
(
"DATA_QUALITY_SCORE"
,
scoreCountByGroup
);
// 统计该分类下红黄绿码分别的分组数量 NEXT_INSPECT_DATE
Map
<
String
,
Long
>
nextInspectCountByGroup
=
new
HashMap
<>();
BoolQueryBuilder
nextInspectQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
BoolQueryBuilder
nextInspectQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
gasBoolQueryBuilder
);
nextInspectQuery
.
must
(
QueryBuilders
.
termQuery
(
fieldKey
,
code
));
getStatisticCountByDate
(
StatisticalAnalysisEnum
.
equip
.
getKey
(),
"NEXT_INSPECT_DATE"
,
nextInspectQuery
,
nextInspectCountByGroup
);
map
.
put
(
"NEXT_INSPECT_DATE"
,
nextInspectCountByGroup
);
...
...
@@ -3196,7 +3229,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 统计该分类下的数据完整性的分组数量 DATA_QUALITY_SCORE
BoolQueryBuilder
scoreQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
if
(
key
.
equals
(
"NA"
))
{
scoreQuery
.
mustNot
(
QueryBuilders
.
existsQuery
(
groupField
));
scoreQuery
.
mustNot
(
existsQuery
(
groupField
));
}
else
{
scoreQuery
.
must
(
QueryBuilders
.
termQuery
(
groupField
,
key
));
}
...
...
@@ -3211,7 +3244,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Map
<
String
,
Long
>
nextInspectCountByGroup
=
new
HashMap
<>();
BoolQueryBuilder
nextInspectQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
if
(
key
.
equals
(
"NA"
))
{
nextInspectQuery
.
mustNot
(
QueryBuilders
.
existsQuery
(
groupField
));
nextInspectQuery
.
mustNot
(
existsQuery
(
groupField
));
}
else
{
nextInspectQuery
.
must
(
QueryBuilders
.
termQuery
(
groupField
,
key
));
}
...
...
@@ -3260,7 +3293,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Long
normalCount
=
getStatisticCount
(
normalQuery
,
index
);
// 无日期
BoolQueryBuilder
noFieldQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
nextInspectQuery
);
noFieldQuery
.
mustNot
(
QueryBuilders
.
existsQuery
(
field
));
noFieldQuery
.
mustNot
(
existsQuery
(
field
));
Long
noFieldCount
=
getStatisticCount
(
noFieldQuery
,
index
);
nextInspectCountByGroup
.
put
(
"red"
,
overdueCount
);
nextInspectCountByGroup
.
put
(
"yellow"
,
nearCount
);
...
...
@@ -3388,7 +3421,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
nothingBoolQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolQuery
);
NestedQueryBuilder
nothingNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
nestedField
)),
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
nothingBoolQuery
.
must
(
nothingNestedQuery
);
...
...
@@ -3487,7 +3520,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
searchSourceBuilder
.
trackTotalHits
(
true
);
searchSourceBuilder
.
size
(
0
);
// 不返回任何文档,只返回聚合结果
SearchRequest
searchRequest
=
new
SearchRequest
();
QueryBuilderUtils
.
buildSplitFieldAggCondition
(
searchSourceBuilder
,
itemName
+
".keyword"
,
"
,
"
,
aggName
,
"其他"
);
QueryBuilderUtils
.
buildSplitFieldAggCondition
(
searchSourceBuilder
,
itemName
+
".keyword"
,
"
,
"
,
aggName
,
"其他"
);
searchSourceBuilder
.
query
(
boolQuery
);
searchRequest
.
source
(
searchSourceBuilder
);
try
{
...
...
@@ -3644,7 +3677,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
nothingBoolQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolQuery
);
NestedQueryBuilder
nothingNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
nestedField
)),
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
nothingBoolQuery
.
must
(
nothingNestedQuery
);
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/service/impl/DPSubServiceImpl.java
View file @
a4e4798a
...
...
@@ -66,7 +66,7 @@ public class DPSubServiceImpl {
private
String
supervisionCodePrefix
;
public
JSONObject
commonQuery
(
String
template
,
@RequestBody
Map
<
String
,
Object
>
param
)
{
JSONObject
result
=
new
JSONObject
()
;
JSONObject
result
;
String
templateJson
=
DpSubUtils
.
getFileContent
(
template
+
".json"
);
//1、替换json中所有的变量
...
...
@@ -993,4 +993,22 @@ public class DPSubServiceImpl {
}
return
bizResult
;
}
public
String
getOverrideTemplateName
(
String
template
,
String
paramKey
)
{
try
{
String
overrideTemplate
=
template
+
"_"
+
paramKey
;
try
{
// 尝试先获取覆盖模板
DpSubUtils
.
getFileContent
(
overrideTemplate
+
".json"
);
return
overrideTemplate
;
}
catch
(
Exception
e
)
{
// 未获取到覆盖模板,则使用基础模板
return
template
;
}
}
catch
(
Exception
e
)
{
log
.
info
(
"获取解析模板错误:{}"
,
e
.
getMessage
());
}
return
template
;
}
}
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/resources/json/problem.json
View file @
a4e4798a
...
...
@@ -90,8 +90,8 @@
"keyParams"
:
[
{
"key"
:
"sourceType"
,
"label"
:
"隐患主体类型"
},
{
"key"
:
"problemType"
,
"label"
:
"隐患类型"
},
{
"key"
:
"problemTime"
,
"label"
:
"超期时间"
},
{
"key"
:
"problemDesc"
,
"label"
:
"隐患描述"
},
{
"key"
:
"problemTime"
,
"label"
:
"隐患时间"
},
{
"key"
:
"problemLevel"
,
"label"
:
"隐患等级"
,
"value"
:
"重大"
},
{
"key"
:
"principalUnit"
,
"label"
:
"主体单位"
},
{
"key"
:
"principalUnitType"
,
"label"
:
"单位类型"
},
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/resources/json/problem_9.json
0 → 100644
View file @
a4e4798a
{
"name"
:
"隐患模板"
,
"tabs"
:
[
{
"key"
:
"keyinfo"
,
"displayName"
:
"基本信息"
,
"renderType"
:
"keyinfo"
,
"dataConfig"
:
{
"api"
:
{
"httpMethod"
:
"GET"
,
"apiPath"
:
"/statistics/dp/jg/safety-problem-tracing/{sequenceNbr}"
,
"params"
:
{
"sequenceNbr"
:
"{sequenceNbr}"
}
}
}
},
{
"key"
:
"devtable"
,
"displayName"
:
"关联设备"
,
"renderType"
:
"table"
,
"useAloneApi"
:
true
,
"dataConfig"
:
{
"api"
:
{
"httpMethod"
:
"GET"
,
"apiPath"
:
"/statistics/dp/jg/safety-problem-tracing/equip/list"
,
"params"
:
{
"current"
:
1
,
"size"
:
10
,
"sequenceNbr"
:
"{sequenceNbr}"
}
}
},
"visualParams"
:
{
"rowKey"
:
"record"
,
"columns"
:
[
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"problemStatusName"
,
"width"
:
150
,
"align"
:
"left"
,
"title"
:
"状态"
,
"key"
:
"1"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"equList"
,
"width"
:
200
,
"align"
:
"left"
,
"title"
:
"设备种类"
,
"key"
:
"2"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"equCategory"
,
"width"
:
300
,
"align"
:
"left"
,
"title"
:
"设备类别"
,
"key"
:
"3"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"supervisoryCode"
,
"width"
:
200
,
"align"
:
"left"
,
"title"
:
"监管码"
,
"key"
:
"4"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"code96333"
,
"width"
:
200
,
"align"
:
"left"
,
"title"
:
"96333码"
,
"key"
:
"5"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"useUnitName"
,
"width"
:
300
,
"align"
:
"left"
,
"title"
:
"主体单位"
,
"key"
:
"6"
},
{
"dataRenderingMode"
:
"actionDetailBtn"
,
"dataIndex"
:
"action"
,
"width"
:
60
,
"align"
:
"left"
,
"title"
:
"操作"
,
"key"
:
"7"
,
"conf"
:
{
"title"
:
"设备详情"
,
"linkModelKey"
:
"equip"
}}
]
}
},
{
"key"
:
"devtable1"
,
"displayName"
:
"关联企业"
,
"renderType"
:
"table"
,
"useAloneApi"
:
true
,
"dataConfig"
:
{
"api"
:
{
"httpMethod"
:
"GET"
,
"apiPath"
:
"/statistics/dp/jg/safety-problem-tracing/unit/list"
,
"params"
:
{
"current"
:
1
,
"size"
:
10
,
"sequenceNbr"
:
"{sequenceNbr}"
}
}
},
"visualParams"
:
{
"rowKey"
:
"sequenceNbr"
,
"columns"
:
[
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"problemStatusName"
,
"width"
:
150
,
"align"
:
"left"
,
"title"
:
"状态"
,
"key"
:
"1"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"unitName"
,
"width"
:
300
,
"align"
:
"left"
,
"title"
:
"企业名称"
,
"key"
:
"2"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"unitType"
,
"width"
:
200
,
"align"
:
"left"
,
"title"
:
"企业类型"
,
"key"
:
"3"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"useUnitCode"
,
"width"
:
300
,
"align"
:
"left"
,
"title"
:
"企业统一信用代码"
,
"key"
:
"4"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"useContact"
,
"width"
:
200
,
"align"
:
"left"
,
"title"
:
"企业联系人"
,
"key"
:
"5"
},
{
"dataRenderingMode"
:
"defaultText"
,
"dataIndex"
:
"contactPhone"
,
"width"
:
200
,
"align"
:
"left"
,
"title"
:
"联系电话"
,
"key"
:
"6"
},
{
"dataRenderingMode"
:
"actionDetailBtn"
,
"dataIndex"
:
"action"
,
"width"
:
60
,
"align"
:
"left"
,
"title"
:
"操作"
,
"key"
:
"7"
,
"conf"
:
{
"title"
:
"企业详情"
,
"linkModelKey"
:
"company"
}}
]
}
}
],
"content"
:
{
"keyinfo"
:
{
"title"
:
"{principalUnit}"
,
"qrcode"
:
{
"title"
:
""
,
"problem"
:
[],
"picUrl"
:
{
"red"
:
"/upload/tzs/dpscreen/images/安全守护-红.png"
,
"grey"
:
"/upload/tzs/dpscreen/images/安全守护-灰.png"
,
"orange"
:
"/upload/tzs/dpscreen/images/安全守护-橙.png"
,
"green"
:
"/upload/tzs/dpscreen/images/安全守护-绿.png"
}
},
"keyParams"
:
[
{
"key"
:
"sourceType"
,
"label"
:
"隐患主体类型"
},
{
"key"
:
"problemType"
,
"label"
:
"隐患类型"
},
{
"key"
:
"userName"
,
"label"
:
"人员名称"
},
{
"key"
:
"problemTime"
,
"label"
:
"超期时间"
},
{
"key"
:
"problemDesc"
,
"label"
:
"隐患描述"
},
{
"key"
:
"problemLevel"
,
"label"
:
"隐患等级"
,
"value"
:
"重大"
},
{
"key"
:
"principalUnit"
,
"label"
:
"主体单位"
},
{
"key"
:
"principalUnitType"
,
"label"
:
"单位类型"
},
{
"key"
:
"governingBody"
,
"label"
:
"管辖机构"
},
{
"key"
:
"governingBodyCode"
,
"label"
:
"所属区域"
},
{
"key"
:
"problemStatus"
,
"label"
:
"隐患状态"
},
{
"key"
:
"equipSuperviseCode"
,
"label"
:
"监管码"
},
{
"key"
:
"equipList"
,
"label"
:
"设备种类"
}
]
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment