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
8aafabca
Commit
8aafabca
authored
Jun 01, 2024
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
气瓶预警预报统计接口
parent
0552ff9a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
236 additions
and
5 deletions
+236
-5
pom.xml
amos-boot-data/amos-boot-data-openapi/pom.xml
+1
-1
ESCylinderFillingRecordDto.java
...odule/cylinder/api/entity/ESCylinderFillingRecordDto.java
+4
-4
CylinderAreaDataMapper.java
...odule/cylinder/flc/api/mapper/CylinderAreaDataMapper.java
+8
-0
CylinderAreaDataMapper.xml
...-api/src/main/resources/mapper/CylinderAreaDataMapper.xml
+48
-0
CylinderStatisticsController.java
...nder/flc/biz/controller/CylinderStatisticsController.java
+36
-0
CylinderAreaDataServiceImpl.java
...der/flc/biz/service/impl/CylinderAreaDataServiceImpl.java
+139
-0
No files found.
amos-boot-data/amos-boot-data-openapi/pom.xml
View file @
8aafabca
...
...
@@ -38,7 +38,7 @@
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<!-- Vastbase G100 -->
<dependency>
@
<dependency>
<groupId>
cn.com.vastdata
</groupId>
<artifactId>
vastbase
</artifactId>
<version>
1.0.0.2
</version>
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/java/com/yeejoin/amos/boot/module/cylinder/api/entity/ESCylinderFillingRecordDto.java
View file @
8aafabca
...
...
@@ -102,19 +102,19 @@ public class ESCylinderFillingRecordDto {
private
String
fillingResult
;
//
重
装后检查人员姓名
//
充
装后检查人员姓名
@Field
(
type
=
FieldType
.
Text
)
private
String
inspector
;
//
重
装后检查时间
//
充
装后检查时间
@Field
(
type
=
FieldType
.
Text
)
private
String
inspectionDateAfter
;
//充装
前
检查结果毫秒值
//充装
后
检查结果毫秒值
@Field
(
type
=
FieldType
.
Long
)
private
Long
inspectionDateAfterMS
;
//
重
装后检查结果
//
充
装后检查结果
@Field
(
type
=
FieldType
.
Text
)
private
String
checkResult
;
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/api/mapper/CylinderAreaDataMapper.java
View file @
8aafabca
...
...
@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Map
;
/**
* 气瓶区域统计表 Mapper 接口
...
...
@@ -11,4 +14,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public
interface
CylinderAreaDataMapper
extends
BaseMapper
<
CylinderAreaData
>
{
Map
<
String
,
Object
>
getLicenseEfficiency
(
@Param
(
value
=
"regionCode"
)
String
regionCode
,
@Param
(
value
=
"appId"
)
String
appId
);
Map
<
String
,
Object
>
getInspectionExpiredRate
(
@Param
(
value
=
"regionCode"
)
String
regionCode
,
@Param
(
value
=
"appId"
)
String
appId
);
Map
<
String
,
Object
>
getInspectionResultRate
(
@Param
(
value
=
"regionCode"
)
String
regionCode
,
@Param
(
value
=
"appId"
)
String
appId
);
}
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/resources/mapper/CylinderAreaDataMapper.xml
View file @
8aafabca
...
...
@@ -2,4 +2,52 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper"
>
<select
id=
"getLicenseEfficiency"
resultType=
"java.util.Map"
>
SELECT
CASE WHEN COUNT ( CASE WHEN ul.expiry_date >= now( ) THEN 1 END ) = 1 THEN '正常' ELSE '已超期' END AS licenseOk,
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND( ( COUNT ( CASE WHEN ul.expiry_date >= now( ) THEN 1 END ) * 100.0 / COUNT ( * ) ), 2 ) END AS licenseRate
FROM
tz_cylinder_unit cu
LEFT JOIN tz_base_unit_licence ul ON cu.credit_code = ul.unit_code
<where>
<if
test=
"regionCode != null and regionCode != ''"
>
cu.region_code like concat('%', #{regionCode}, '%')
</if>
<if
test=
"appId != null and appId != ''"
>
cu.app_id = #{appId}
</if>
</where>
</select>
<select
id=
"getInspectionExpiredRate"
resultType=
"java.util.Map"
>
SELECT
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN ci.next_inspection_date > now() THEN 1 END) * 100.0 / COUNT(*)), 2) END AS expiredRate
FROM
"tz_cylinder_inspection" ci
LEFT JOIN tz_cylinder_unit cu on ci.app_id = cu.app_id
<where>
<if
test=
"regionCode != null and regionCode != ''"
>
cu.region_code like concat('%', #{regionCode}, '%')
</if>
<if
test=
"appId != null and appId != ''"
>
cu.app_id = #{appId}
</if>
</where>
</select>
<select
id=
"getInspectionResultRate"
resultType=
"java.util.Map"
>
SELECT
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN ci.inspection_result = '3123' THEN 1 END) * 100.0 / COUNT(*)), 2) END AS resultRate
FROM
"tz_cylinder_inspection" ci
LEFT JOIN tz_cylinder_unit cu on ci.app_id = cu.app_id
<where>
<if
test=
"regionCode != null and regionCode != ''"
>
cu.region_code like concat('%', #{regionCode}, '%')
</if>
<if
test=
"appId != null and appId != ''"
>
cu.app_id = #{appId}
</if>
</where>
</select>
</mapper>
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/biz/controller/CylinderStatisticsController.java
0 → 100644
View file @
8aafabca
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
controller
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDataServiceImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@Api
(
tags
=
"气瓶统计Api"
)
@RequestMapping
(
value
=
"/statistics"
)
public
class
CylinderStatisticsController
{
@Autowired
private
CylinderAreaDataServiceImpl
service
;
/**
* 预警预报统计
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@RequestMapping
(
value
=
"/earlyWarning"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"预警预报"
)
public
ResponseModel
<
Page
<
Map
<
String
,
Object
>>>
getEarlyWarning
(
@RequestParam
(
value
=
"regionCode"
,
required
=
false
)
String
regionCode
,
@RequestParam
(
value
=
"appId"
,
required
=
false
)
String
appId
){
return
ResponseHelper
.
buildResponse
(
service
.
getEarlyWarningStatistics
(
regionCode
,
appId
));
}
}
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/biz/service/impl/CylinderAreaDataServiceImpl.java
View file @
8aafabca
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderAreaDataDto
;
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.client.core.CountRequest
;
import
org.elasticsearch.client.core.CountResponse
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 气瓶区域统计表服务实现类
...
...
@@ -17,6 +39,13 @@ import java.util.List;
*/
@Service
public
class
CylinderAreaDataServiceImpl
extends
BaseService
<
CylinderAreaDataDto
,
CylinderAreaData
,
CylinderAreaDataMapper
>
implements
ICylinderAreaDataService
{
@Autowired
private
CylinderAreaDataMapper
mapper
;
@Autowired
RestHighLevelClient
restHighLevelClient
;
/**
* 分页查询
*/
...
...
@@ -30,4 +59,113 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
public
List
<
CylinderAreaDataDto
>
queryForCylinderAreaDataList
()
{
return
this
.
queryForList
(
""
,
false
);
}
public
Page
<
Map
<
String
,
Object
>>
getEarlyWarningStatistics
(
String
regionCode
,
String
appId
)
{
Page
<
Map
<
String
,
Object
>>
page
=
new
Page
<>();
List
<
Map
<
String
,
Object
>>
list
=
Lists
.
newArrayList
();
Map
<
String
,
Object
>
result1
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
result2
=
Maps
.
newHashMap
();
// 1.许可有效率
if
(!
ValidationUtil
.
isEmpty
(
appId
))
{
result1
.
put
(
"name"
,
"许可有效期"
);
result1
.
put
(
"value"
,
mapper
.
getLicenseEfficiency
(
null
,
appId
).
get
(
"licenseOk"
).
toString
());
}
else
if
(!
ValidationUtil
.
isEmpty
(
regionCode
)){
result1
.
put
(
"name"
,
"许可有效率(%)"
);
result1
.
put
(
"value"
,
mapper
.
getLicenseEfficiency
(
regionCode
,
null
).
get
(
"licenseRate"
).
toString
());
}
// 2.使用登记办理率
if
(!
ValidationUtil
.
isEmpty
(
appId
))
{
result2
.
put
(
"name"
,
"使用登记"
);
result2
.
put
(
"value"
,
"已办理"
);
}
else
{
result2
.
put
(
"name"
,
"使用登记办理率(%)"
);
result2
.
put
(
"value"
,
"100"
);
}
// 3.检验超期率
Map
<
String
,
Object
>
result3
=
Maps
.
newHashMap
();
result3
.
put
(
"name"
,
"检验超期率(%)"
);
result3
.
put
(
"value"
,
mapper
.
getInspectionExpiredRate
(
regionCode
,
appId
).
get
(
"expiredRate"
).
toString
());
// 4.检验合格率
Map
<
String
,
Object
>
result4
=
Maps
.
newHashMap
();
result4
.
put
(
"name"
,
"检验合格率(%)"
);
result4
.
put
(
"value"
,
mapper
.
getInspectionResultRate
(
regionCode
,
appId
).
get
(
"resultRate"
).
toString
());
// 5.充装检查率
Map
<
String
,
Object
>
result5
=
Maps
.
newHashMap
();
long
totalAll
=
searchEsCount
(
false
,
false
,
regionCode
,
appId
);
long
totalCheck
=
searchEsCount
(
true
,
false
,
regionCode
,
appId
);
long
totalResult
=
searchEsCount
(
false
,
true
,
regionCode
,
appId
);
result5
.
put
(
"name"
,
"充装检查率(%)"
);
if
(
totalAll
!=
0
)
{
result5
.
put
(
"value"
,
(
totalCheck
/
totalAll
)
*
100
);
}
else
{
result5
.
put
(
"value"
,
0
);
}
// 6.充装检查合格率
Map
<
String
,
Object
>
result6
=
Maps
.
newHashMap
();
result6
.
put
(
"name"
,
"充装检查合格率(%)"
);
if
(
totalAll
!=
0
)
{
result6
.
put
(
"value"
,
(
totalResult
/
totalAll
)
*
100
);
}
else
{
result6
.
put
(
"value"
,
0
);
}
// list中按以下固定顺序返回给前端
list
.
add
(
result1
);
list
.
add
(
result3
);
list
.
add
(
result5
);
list
.
add
(
result2
);
list
.
add
(
result4
);
list
.
add
(
result6
);
page
.
setRecords
(
list
);
return
page
;
}
private
Map
<
String
,
Object
>
getFillingCheckRate
(
ESCylinderFillingRecordDto
esCylinderFillingRecordDto
)
{
return
null
;
}
private
Map
<
String
,
Object
>
getValidFillingCheckRate
(
ESCylinderFillingRecordDto
esCylinderFillingRecordDto
)
{
return
null
;
}
private
long
searchEsCount
(
Boolean
checkOk
,
Boolean
resultOk
,
String
regionCode
,
String
appId
)
{
CountRequest
countRequest
=
new
CountRequest
();
countRequest
.
indices
(
"cylinder_filling"
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
if
(
checkOk
)
{
//匹配充装前检查和充装后检查都有数据
BoolQueryBuilder
meBuilder
=
QueryBuilders
.
boolQuery
();
meBuilder
.
must
(
QueryBuilders
.
existsQuery
(
"inspectionDateMs"
));
meBuilder
.
must
(
QueryBuilders
.
existsQuery
(
"inspectionDateAfterMS"
));
boolMust
.
must
(
meBuilder
);
}
if
(
resultOk
)
{
//匹配充装前检查和充装后检查都有数据
BoolQueryBuilder
meBuilder
=
QueryBuilders
.
boolQuery
();
meBuilder
.
must
(
QueryBuilders
.
matchQuery
(
"fillingResult"
,
"合格"
));
meBuilder
.
must
(
QueryBuilders
.
matchQuery
(
"checkResult"
,
"合格"
));
boolMust
.
must
(
meBuilder
);
}
//匹配行政区划
if
(!
ObjectUtils
.
isEmpty
(
regionCode
))
{
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
query
.
must
(
QueryBuilders
.
wildcardQuery
(
"regionCode"
,
"*"
+
regionCode
+
"*"
));
boolMust
.
must
(
query
);
}
//匹配appId
if
(!
ObjectUtils
.
isEmpty
(
appId
))
{
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
query
.
must
(
QueryBuilders
.
matchQuery
(
"appId"
,
appId
));
boolMust
.
must
(
query
);
}
countRequest
.
query
(
boolMust
);
try
{
CountResponse
countResponse
=
restHighLevelClient
.
count
(
countRequest
,
RequestOptions
.
DEFAULT
);
return
countResponse
.
getCount
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
\ 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