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
1eb1f9db
Commit
1eb1f9db
authored
Oct 17, 2024
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(jg):设备保险信息功能开发
parent
13ab63b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
5 deletions
+167
-5
JgEquipInsuranceController.java
.../module/jg/biz/controller/JgEquipInsuranceController.java
+8
-0
JgEquipInsuranceServiceImpl.java
...dule/jg/biz/service/impl/JgEquipInsuranceServiceImpl.java
+159
-5
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/controller/JgEquipInsuranceController.java
View file @
1eb1f9db
...
@@ -17,6 +17,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...
@@ -17,6 +17,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 设备保险信息控制类
* 设备保险信息控制类
...
@@ -113,4 +114,11 @@ public class JgEquipInsuranceController extends BaseController {
...
@@ -113,4 +114,11 @@ public class JgEquipInsuranceController extends BaseController {
public
ResponseModel
<
List
<
JgEquipInsurance
>>
selectForList
()
{
public
ResponseModel
<
List
<
JgEquipInsurance
>>
selectForList
()
{
return
ResponseHelper
.
buildResponse
(
jgEquipInsuranceServiceImpl
.
queryForJgEquipInsuranceList
());
return
ResponseHelper
.
buildResponse
(
jgEquipInsuranceServiceImpl
.
queryForJgEquipInsuranceList
());
}
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"市级为维度,责任保险统计"
)
@GetMapping
(
value
=
"/countLiabilityInsuranceStatisticsByCity"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
countLiabilityInsuranceStatisticsByCity
()
{
return
ResponseHelper
.
buildResponse
(
jgEquipInsuranceServiceImpl
.
countLiabilityInsuranceStatisticsByCity
());
}
}
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgEquipInsuranceServiceImpl.java
View file @
1eb1f9db
...
@@ -5,13 +5,26 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
...
@@ -5,13 +5,26 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jg.api.dto.JgEquipInsuranceDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.JgEquipInsuranceDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgEquipInsurance
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgEquipInsurance
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.JgEquipInsuranceMapper
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.JgEquipInsuranceMapper
;
import
com.yeejoin.amos.boot.module.jg.api.service.IJgEquipInsuranceService
;
import
com.yeejoin.amos.boot.module.jg.api.service.IJgEquipInsuranceService
;
import
com.yeejoin.amos.boot.module.jg.api.vo.SortVo
;
import
com.yeejoin.amos.boot.module.jg.api.vo.SortVo
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.lucene.queryparser.classic.QueryParser
;
import
org.elasticsearch.action.search.SearchRequest
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.filter.Filters
;
import
org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregator
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -21,10 +34,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
...
@@ -21,10 +34,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.util.ArrayList
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.*
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -46,6 +60,18 @@ public class JgEquipInsuranceServiceImpl extends BaseService<JgEquipInsurance,Jg
...
@@ -46,6 +60,18 @@ public class JgEquipInsuranceServiceImpl extends BaseService<JgEquipInsurance,Jg
private
static
final
String
DEVICE_LIST
=
"deviceList"
;
private
static
final
String
DEVICE_LIST
=
"deviceList"
;
private
static
final
String
INDEX_NAME
=
"idx_biz_view_jg_all"
;
public
static
final
String
REGION_CODE
=
"regionCode"
;
private
static
final
Map
<
String
,
String
>
regionCodeOrgCodeMap
=
new
ConcurrentHashMap
<>();
@Autowired
RestHighLevelClient
restHighLevelClient
;
@Autowired
CommonMapper
commonMapper
;
/**
/**
* 分页查询
* 分页查询
*/
*/
...
@@ -104,4 +130,131 @@ public class JgEquipInsuranceServiceImpl extends BaseService<JgEquipInsurance,Jg
...
@@ -104,4 +130,131 @@ public class JgEquipInsuranceServiceImpl extends BaseService<JgEquipInsurance,Jg
public
JgEquipInsuranceDto
getDetail
(
Long
sequenceNbr
)
{
public
JgEquipInsuranceDto
getDetail
(
Long
sequenceNbr
)
{
return
this
.
getBaseMapper
().
getDetailById
(
sequenceNbr
);
return
this
.
getBaseMapper
().
getDetailById
(
sequenceNbr
);
}
}
public
Map
<
String
,
Object
>
countLiabilityInsuranceStatisticsByCity
()
{
List
<
RegionModel
>
regionModelList
=
Systemctl
.
regionClient
.
queryByLevel
(
"2"
).
getResult
();
List
<
Map
<
String
,
Object
>>
esQueryResults
=
processAsync
(
regionModelList
,
this
::
esQuery
);
List
<
Map
<
String
,
Object
>>
insuranceResults
=
processAsync
(
regionModelList
,
this
::
getInsurance
);
return
assemblingHistogramData
(
esQueryResults
,
insuranceResults
);
}
// 公共方法,用于异步处理逻辑
private
List
<
Map
<
String
,
Object
>>
processAsync
(
List
<
RegionModel
>
regionModelList
,
Function
<
RegionModel
,
Map
<
String
,
Object
>>
function
)
{
return
regionModelList
.
stream
()
.
map
(
regionModel
->
CompletableFuture
.
supplyAsync
(()
->
function
.
apply
(
regionModel
)))
.
collect
(
Collectors
.
toList
())
.
stream
()
.
map
(
CompletableFuture:
:
join
)
.
collect
(
Collectors
.
toList
());
}
private
Map
<
String
,
Object
>
getInsurance
(
RegionModel
regionModel
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"ELEVATOR_INSURANCE"
,
""
);
resultMap
.
put
(
"CYLINDER_INSURANCE"
,
""
);
return
resultMap
;
}
public
String
getAndSetOrgCode
(
String
cityCode
)
{
String
orgCode
=
regionCodeOrgCodeMap
.
get
(
cityCode
);
if
(
orgCode
==
null
)
{
orgCode
=
commonMapper
.
getOrgCodeByCompanyCode
(
cityCode
);
if
(
orgCode
!=
null
)
{
regionCodeOrgCodeMap
.
put
(
cityCode
,
orgCode
);
}
}
return
orgCode
;
}
private
Map
<
String
,
Object
>
esQuery
(
RegionModel
regionModel
)
{
SearchRequest
searchRequest
=
new
SearchRequest
(
INDEX_NAME
);
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
this
.
getAndSetOrgCode
(
String
.
valueOf
(
regionModel
.
getRegionCode
()));
boolQueryBuilder
.
must
(
QueryBuilders
.
wildcardQuery
(
"ORG_BRANCH_CODE.keyword"
,
QueryParser
.
escape
(
orgCode
)
+
"*"
));
// 有监管码
boolQueryBuilder
.
must
(
QueryBuilders
.
existsQuery
(
"SUPERVISORY_CODE"
));
boolQueryBuilder
.
mustNot
(
QueryBuilders
.
termQuery
(
"SUPERVISORY_CODE"
,
"null"
));
searchSourceBuilder
.
query
(
boolQueryBuilder
);
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
filters
(
"equipmentCount"
,
new
FiltersAggregator
.
KeyedFilter
(
"电梯"
,
QueryBuilders
.
termQuery
(
"EQU_LIST_CODE"
,
"3000"
)
),
new
FiltersAggregator
.
KeyedFilter
(
"气瓶"
,
QueryBuilders
.
termQuery
(
"EQU_CATEGORY_CODE"
,
"2300"
)
)
)
);
searchRequest
.
source
(
searchSourceBuilder
);
try
{
// 执行搜索请求
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
// 获取所有聚合结果
Filters
aggregation
=
searchResponse
.
getAggregations
().
get
(
"equipmentCount"
);
return
getStringObjectMap
(
regionModel
,
aggregation
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
Collections
.
emptyMap
();
}
private
static
Map
<
String
,
Object
>
getStringObjectMap
(
RegionModel
regionModel
,
Filters
aggregation
)
{
long
elevatorCount
=
0
;
long
gasCylinderCount
=
0
;
for
(
Filters
.
Bucket
bucket
:
aggregation
.
getBuckets
())
{
String
key
=
bucket
.
getKeyAsString
();
long
docCount
=
bucket
.
getDocCount
();
if
(
"电梯"
.
equals
(
key
))
{
elevatorCount
=
docCount
;
}
else
if
(
"气瓶"
.
equals
(
key
))
{
gasCylinderCount
=
docCount
;
}
}
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
REGION_CODE
,
regionModel
.
getRegionCode
());
resultMap
.
put
(
"REGION_NAME"
,
regionModel
.
getRegionName
());
resultMap
.
put
(
"ELEVATOR"
,
elevatorCount
);
resultMap
.
put
(
"CYLINDER"
,
gasCylinderCount
);
return
resultMap
;
}
private
static
Map
<
String
,
Object
>
assemblingHistogramData
(
List
<
Map
<
String
,
Object
>>
esQueryResults
,
List
<
Map
<
String
,
Object
>>
insuranceResults
)
{
// 组装数据
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
List
<
String
>
axisData
=
new
ArrayList
<>();
List
<
String
>
cylinderDataList
=
new
ArrayList
<>();
List
<
String
>
elevatorDataList
=
new
ArrayList
<>();
List
<
String
>
cylinderDataListRate
=
new
ArrayList
<>();
List
<
String
>
elevatorDataListRate
=
new
ArrayList
<>();
esQueryResults
.
forEach
(
x
->
{
axisData
.
add
(
String
.
valueOf
(
x
.
get
(
"regionName"
)));
cylinderDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"CYLINDER"
)));
elevatorDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"ELEVATOR"
)));
});
HashMap
<
String
,
Object
>
temMap1
=
new
HashMap
<>();
temMap1
.
put
(
"data"
,
elevatorDataList
);
temMap1
.
put
(
"name"
,
"电梯"
);
HashMap
<
String
,
Object
>
temMap2
=
new
HashMap
<>();
temMap1
.
put
(
"data"
,
cylinderDataList
);
temMap1
.
put
(
"name"
,
"气瓶"
);
HashMap
<
String
,
Object
>
temMap3
=
new
HashMap
<>();
temMap1
.
put
(
"data"
,
elevatorDataListRate
);
temMap1
.
put
(
"name"
,
"电梯覆盖率"
);
HashMap
<
String
,
Object
>
temMap4
=
new
HashMap
<>();
temMap2
.
put
(
"data"
,
cylinderDataListRate
);
temMap2
.
put
(
"name"
,
"气瓶覆盖率"
);
seriesData
.
add
(
temMap1
);
seriesData
.
add
(
temMap2
);
seriesData
.
add
(
temMap3
);
seriesData
.
add
(
temMap4
);
result
.
put
(
"seriesData"
,
seriesData
);
result
.
put
(
"axisData"
,
axisData
);
return
result
;
}
}
}
\ 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