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
93657662
Commit
93657662
authored
Jun 04, 2024
by
韩桐桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cyl):市级为维度,各市的充装次数和累计充装量,取当前日期向前推31天的数据总和
parent
2f4aef99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
123 deletions
+111
-123
CylinderInfoController.java
...e/cylinder/flc/biz/controller/CylinderInfoController.java
+1
-1
CylinderInfoServiceImpl.java
...ylinder/flc/biz/service/impl/CylinderInfoServiceImpl.java
+110
-122
No files found.
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/CylinderInfoController.java
View file @
93657662
...
@@ -1361,7 +1361,7 @@ public class CylinderInfoController extends BaseController {
...
@@ -1361,7 +1361,7 @@ public class CylinderInfoController extends BaseController {
}
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"市级为维度,各市的充装次数和累计充装量"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"市级为维度,各市的充装次数和累计充装量
,当前日期向前推31天的数据总和
"
)
@GetMapping
(
value
=
"/countFillingTimesAndQuantityByCity"
)
@GetMapping
(
value
=
"/countFillingTimesAndQuantityByCity"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
countFillingTimesAndQuantityByCity
()
{
public
ResponseModel
<
Map
<
String
,
Object
>>
countFillingTimesAndQuantityByCity
()
{
return
ResponseHelper
.
buildResponse
(
cylinderInfoServiceImpl
.
countFillingTimesAndQuantityByCity
());
return
ResponseHelper
.
buildResponse
(
cylinderInfoServiceImpl
.
countFillingTimesAndQuantityByCity
());
...
...
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/CylinderInfoServiceImpl.java
View file @
93657662
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
@@ -10,7 +9,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -10,7 +9,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto
;
import
com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.MsgLog
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.MsgLog
;
import
com.yeejoin.amos.boot.module.cylinder.api.enums.EarlyWarningLevelEnum
;
import
com.yeejoin.amos.boot.module.cylinder.api.enums.EarlyWarningLevelEnum
;
...
@@ -20,7 +18,10 @@ import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.MsgLogServiceImpl;
...
@@ -20,7 +18,10 @@ import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.MsgLogServiceImpl;
import
com.yeejoin.amos.boot.module.cylinder.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.cylinder.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzsAuthServiceImpl
;
import
com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzsAuthServiceImpl
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.*
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.*
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.*
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInfo
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderIntegrityData
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderTags
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderInfoMapper
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderInfoMapper
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderInfoService
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderInfoService
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
...
@@ -35,11 +36,10 @@ import org.elasticsearch.client.RequestOptions;
...
@@ -35,11 +36,10 @@ import org.elasticsearch.client.RequestOptions;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.aggregations.Aggregation
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.Aggregations
;
import
org.elasticsearch.search.aggregations.Aggregations
;
import
org.elasticsearch.search.aggregations.metrics.*
;
import
org.elasticsearch.search.aggregations.metrics.ParsedCardinality
;
import
org.elasticsearch.search.aggregations.metrics.Sum
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
...
@@ -55,17 +55,15 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
...
@@ -55,17 +55,15 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.ZonedDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
java.util.function.IntConsumer
;
import
java.util.function.IntConsumer
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
/**
/**
* 气瓶基本信息服务实现类
* 气瓶基本信息服务实现类
...
@@ -82,6 +80,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -82,6 +80,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
public
static
final
String
FILLING_TIMES
=
"fillingTimes"
;
public
static
final
String
FILLING_TIMES
=
"fillingTimes"
;
public
static
final
String
FILLING_QUANTITY
=
"fillingQuantity"
;
public
static
final
String
FILLING_QUANTITY
=
"fillingQuantity"
;
public
static
final
String
REGION_NAME
=
"regionName"
;
public
static
final
String
REGION_NAME
=
"regionName"
;
public
static
final
String
FILLING_END_TIME
=
"fillingEndTime"
;
public
static
final
String
TOTAL_FILLING_COUNT
=
"total_filling_count"
;
public
static
final
String
SEQUENCE_NBR
=
"sequenceNbr"
;
public
static
final
String
TOTAL_FILLING_QUANTITY
=
"total_filling_quantity"
;
private
static
final
String
INDEX_NAME
=
"cylinder_filling"
;
private
static
final
String
INDEX_NAME
=
"cylinder_filling"
;
@Autowired
@Autowired
CylinderUnitServiceImpl
cylinderUnitServiceImpl
;
CylinderUnitServiceImpl
cylinderUnitServiceImpl
;
...
@@ -133,34 +135,84 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -133,34 +135,84 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Autowired
@Autowired
MsgLogServiceImpl
msgLogService
;
MsgLogServiceImpl
msgLogService
;
@Autowired
private
RuleTrigger
ruleTrigger
;
@Autowired
@Autowired
TzsAuthServiceImpl
tzsAuthService
;
TzsAuthServiceImpl
tzsAuthService
;
@Autowired
private
ScheduleMapper
scheduleMapper
;
@Value
(
"${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}"
)
private
String
packageId
;
@Value
(
"${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}"
)
private
String
cylPackageId
;
@Autowired
@Autowired
RestHighLevelClient
restHighLevelClient
;
RestHighLevelClient
restHighLevelClient
;
@Autowired
@Autowired
StartPlatformTokenService
startPlatformTokenService
;
StartPlatformTokenService
startPlatformTokenService
;
@Autowired
@Autowired
CylinderInfoMapper
cylinderInfoMapper
;
CylinderInfoMapper
cylinderInfoMapper
;
@Autowired
@Autowired
ESCylinderInfoRepository
esCylinderInfoRepository
;
ESCylinderInfoRepository
esCylinderInfoRepository
;
@Autowired
private
RuleTrigger
ruleTrigger
;
@Autowired
private
ScheduleMapper
scheduleMapper
;
@Value
(
"${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}"
)
private
String
packageId
;
@Value
(
"${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}"
)
private
String
cylPackageId
;
private
static
Map
<
String
,
Object
>
assemblingHistogramData
(
List
<
Map
<
String
,
Object
>>
collect
)
{
// 组装数据
// {
// "seriesData": [
// {
// "data": [
// 3,
// 2,
// 2,
// 3,
// 1
// ],
// "name": "正常点",
// "stack": "正常点"
// },
// {
// "data": [
// 1,
// 1,
// 2,
// 1,
// 2
// ],
// "name": "异常点",
// "stack": "巡检点"
// }
// ],
// "axisData": [
// "A",
// "B",
// "C",
// "D",
// "E"
// ]
// }
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
List
<
String
>
axisData
=
new
ArrayList
<>();
List
<
String
>
seriesFillingTimesDataList
=
new
ArrayList
<>();
List
<
String
>
seriesCumulativeFillingQuantityDataList
=
new
ArrayList
<>();
collect
.
forEach
(
x
->
{
axisData
.
add
(
String
.
valueOf
(
x
.
get
(
"regionName"
)));
seriesFillingTimesDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"fillingTimes"
)));
seriesCumulativeFillingQuantityDataList
.
add
(
String
.
valueOf
(
x
.
get
(
FILLING_QUANTITY
)));
});
HashMap
<
String
,
Object
>
temMap1
=
new
HashMap
<>();
temMap1
.
put
(
"data"
,
seriesFillingTimesDataList
);
temMap1
.
put
(
"name"
,
"充装次数"
);
// temMap1.put("stack","充装次数");
HashMap
<
String
,
Object
>
temMap2
=
new
HashMap
<>();
temMap2
.
put
(
"data"
,
seriesCumulativeFillingQuantityDataList
);
temMap2
.
put
(
"name"
,
"累计充装量"
);
// temMap2.put("stack","累计充装量");
seriesData
.
add
(
temMap1
);
seriesData
.
add
(
temMap2
);
result
.
put
(
"seriesData"
,
seriesData
);
result
.
put
(
"axisData"
,
axisData
);
return
result
;
}
/**
/**
* 分页查询
* 分页查询
...
@@ -575,11 +627,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -575,11 +627,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
@SchedulerLock
(
name
=
"synUnitIntegrityDataTask"
,
lockAtMostFor
=
"PT6H"
)
@SchedulerLock
(
name
=
"synUnitIntegrityDataTask"
,
lockAtMostFor
=
"PT6H"
)
public
void
synUnitIntegrityDataJob
(){
public
void
synUnitIntegrityDataJob
()
{
this
.
synUnitIntegrityData
();
this
.
synUnitIntegrityData
();
}
}
@Override
@Override
public
void
synUnitIntegrityData
()
{
public
void
synUnitIntegrityData
()
{
cylinderIntegrityDataUnitServiceImpl
.
remove
(
new
LambdaQueryWrapper
<>());
cylinderIntegrityDataUnitServiceImpl
.
remove
(
new
LambdaQueryWrapper
<>());
...
@@ -870,7 +921,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -870,7 +921,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
BeanUtils
.
copyProperties
(
ci
,
esCylinderInfoDto
);
BeanUtils
.
copyProperties
(
ci
,
esCylinderInfoDto
);
ESCylinderInfoDto
saveResult
=
esCylinderInfoRepository
.
save
(
esCylinderInfoDto
);
ESCylinderInfoDto
saveResult
=
esCylinderInfoRepository
.
save
(
esCylinderInfoDto
);
if
(!
ObjectUtils
.
isEmpty
(
saveResult
))
{
if
(!
ObjectUtils
.
isEmpty
(
saveResult
))
{
//同步到es后修改
//
同步到es后修改
CylinderInfo
cylinderInfo
=
new
CylinderInfo
();
CylinderInfo
cylinderInfo
=
new
CylinderInfo
();
cylinderInfo
.
setIsNotEs
(
"1"
);
cylinderInfo
.
setIsNotEs
(
"1"
);
cylinderInfoMapper
.
update
(
cylinderInfo
,
new
QueryWrapper
<
CylinderInfo
>().
eq
(
"sequence_nbr"
,
ci
.
getSequenceNbr
()));
cylinderInfoMapper
.
update
(
cylinderInfo
,
new
QueryWrapper
<
CylinderInfo
>().
eq
(
"sequence_nbr"
,
ci
.
getSequenceNbr
()));
...
@@ -878,7 +929,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -878,7 +929,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
return
saveResult
;
return
saveResult
;
}
}
@Override
@Override
public
Page
<
ESCylinderInfoDto
>
queryByKeys
(
CylinderInfoDto
cylinderInfoDto
,
int
pageNum
,
int
pageSize
)
{
public
Page
<
ESCylinderInfoDto
>
queryByKeys
(
CylinderInfoDto
cylinderInfoDto
,
int
pageNum
,
int
pageSize
)
{
...
@@ -886,13 +936,13 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -886,13 +936,13 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
SearchRequest
request
=
new
SearchRequest
();
SearchRequest
request
=
new
SearchRequest
();
request
.
indices
(
"cylinder_info"
);
request
.
indices
(
"cylinder_info"
);
//通用匹配规则,条件构建
//
通用匹配规则,条件构建
boolean
flag
=
true
;
boolean
flag
=
true
;
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
//匹配统一信用代码
//
匹配统一信用代码
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getCreditCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getCreditCode
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
meBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
meBuilder
=
QueryBuilders
.
boolQuery
();
...
@@ -900,7 +950,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -900,7 +950,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
meBuilder
);
boolMust
.
must
(
meBuilder
);
}
}
//匹配RegionCode
//
匹配RegionCode
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getRegionCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getRegionCode
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
appIdBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
appIdBuilder
=
QueryBuilders
.
boolQuery
();
...
@@ -908,16 +958,16 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -908,16 +958,16 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
should
(
appIdBuilder
);
boolMust
.
should
(
appIdBuilder
);
}
}
//应用id
//
应用id
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getAppId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getAppId
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
query
.
must
(
QueryBuilders
.
termsQuery
(
"appId"
,
cylinderInfoDto
.
getAppId
().
toLowerCase
()));
query
.
must
(
QueryBuilders
.
termsQuery
(
"appId"
,
cylinderInfoDto
.
getAppId
().
toLowerCase
()));
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//匹配产权单位
//
匹配产权单位
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getUnitName
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getUnitName
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -925,7 +975,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -925,7 +975,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//匹配出厂编号
//
匹配出厂编号
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getFactoryNum
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getFactoryNum
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -933,7 +983,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -933,7 +983,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//匹配气瓶品种
//
匹配气瓶品种
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getCylinderVariety
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getCylinderVariety
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -941,7 +991,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -941,7 +991,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//匹配二维码编码
//
匹配二维码编码
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getQrCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getQrCode
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -949,7 +999,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -949,7 +999,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//匹配电子标签
//
匹配电子标签
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getElectronicLabelCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getElectronicLabelCode
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -957,7 +1007,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -957,7 +1007,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//匹配气瓶唯一标识
//
匹配气瓶唯一标识
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getSequenceCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getSequenceCode
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
sequenceCodeBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
sequenceCodeBuilder
=
QueryBuilders
.
boolQuery
();
...
@@ -965,7 +1015,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -965,7 +1015,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
sequenceCodeBuilder
);
boolMust
.
must
(
sequenceCodeBuilder
);
}
}
//匹配单位内部编号
//
匹配单位内部编号
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getUnitInnerCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getUnitInnerCode
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -973,7 +1023,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -973,7 +1023,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//气瓶状态
//
气瓶状态
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getCylinderStatus
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getCylinderStatus
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -981,7 +1031,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -981,7 +1031,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
//制造单位
//
制造单位
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getManufacturingUnit
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getManufacturingUnit
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -989,7 +1039,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -989,7 +1039,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
//检验日期
//
检验日期
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateStart
())
&&
!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateEnd
()))
{
if
(!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateStart
())
&&
!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateEnd
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
...
@@ -1014,7 +1064,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1014,7 +1064,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
boolMust
.
must
(
query
);
boolMust
.
must
(
query
);
}
else
if
(
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateStart
())
&&
!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateEnd
()))
{
}
else
if
(
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateStart
())
&&
!
ObjectUtils
.
isEmpty
(
cylinderInfoDto
.
getInspectionDateEnd
()))
{
flag
=
false
;
flag
=
false
;
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
try
{
try
{
...
@@ -1032,7 +1082,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1032,7 +1082,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
}
}
builder
.
query
(
boolMust
);
builder
.
query
(
boolMust
);
builder
.
sort
(
"sequenceNbr"
,
SortOrder
.
DESC
);
builder
.
sort
(
SEQUENCE_NBR
,
SortOrder
.
DESC
);
builder
.
from
((
pageNum
-
1
)
*
pageSize
);
builder
.
from
((
pageNum
-
1
)
*
pageSize
);
builder
.
size
(
pageSize
);
builder
.
size
(
pageSize
);
builder
.
trackTotalHits
(
true
);
builder
.
trackTotalHits
(
true
);
...
@@ -1056,7 +1106,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1056,7 +1106,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
return
result
;
return
result
;
}
}
/**
/**
* 根据月份统计
* 根据月份统计
*/
*/
...
@@ -1226,7 +1275,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1226,7 +1275,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
return
cylinderInfoMapper
.
cyinderInfoList
(
page
,
cylinderInfoDto
,
sort
,
appids
);
return
cylinderInfoMapper
.
cyinderInfoList
(
page
,
cylinderInfoDto
,
sort
,
appids
);
}
}
public
Page
<
CylinderInfoDto
>
getCyinderInfoList
(
Page
<
CylinderInfoDto
>
page
)
{
public
Page
<
CylinderInfoDto
>
getCyinderInfoList
(
Page
<
CylinderInfoDto
>
page
)
{
return
cylinderInfoMapper
.
getCyinderInfoList
(
page
);
return
cylinderInfoMapper
.
getCyinderInfoList
(
page
);
}
}
...
@@ -1260,12 +1308,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1260,12 +1308,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
String
template
=
"{\"seriesData\": [{\"data\": [%s],\"name\": \"充装次数(次)\"},{\"data\": [%s],\"name\": \"累计充装量(kg)\"}],\"axisData\": [\"总数\"]}"
;
String
template
=
"{\"seriesData\": [{\"data\": [%s],\"name\": \"充装次数(次)\"},{\"data\": [%s],\"name\": \"累计充装量(kg)\"}],\"axisData\": [\"总数\"]}"
;
String
format
=
String
.
format
(
template
,
String
format
=
String
.
format
(
template
,
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"fillingTimes"
))
?
0
:
stringObjectMap
.
get
(
"fillingTimes"
),
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"fillingTimes"
))
?
0
:
stringObjectMap
.
get
(
"fillingTimes"
),
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"fillingQuantity"
))
?
0
:
stringObjectMap
.
get
(
"fillingQuantity"
));
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
FILLING_QUANTITY
))
?
0
:
stringObjectMap
.
get
(
FILLING_QUANTITY
));
return
JSON
.
parseObject
(
format
);
return
JSON
.
parseObject
(
format
);
}
}
public
Map
<
String
,
Object
>
countFillingTimesAndQuantityByCity
()
{
public
Map
<
String
,
Object
>
countFillingTimesAndQuantityByCity
()
{
// 查询所有的市级城市
// 查询所有的市级城市
List
<
RegionModel
>
regionModelList
=
Systemctl
.
regionClient
.
queryByLevel
(
"2"
).
getResult
();
List
<
RegionModel
>
regionModelList
=
Systemctl
.
regionClient
.
queryByLevel
(
"2"
).
getResult
();
...
@@ -1283,82 +1329,26 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1283,82 +1329,26 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
// return assemblingHistogramData(ss);
// return assemblingHistogramData(ss);
}
}
private
static
Map
<
String
,
Object
>
assemblingHistogramData
(
List
<
Map
<
String
,
Object
>>
collect
)
{
// 组装数据
// {
// "seriesData": [
// {
// "data": [
// 3,
// 2,
// 2,
// 3,
// 1
// ],
// "name": "正常点",
// "stack": "正常点"
// },
// {
// "data": [
// 1,
// 1,
// 2,
// 1,
// 2
// ],
// "name": "异常点",
// "stack": "巡检点"
// }
// ],
// "axisData": [
// "A",
// "B",
// "C",
// "D",
// "E"
// ]
// }
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
List
<
String
>
axisData
=
new
ArrayList
<>();
List
<
String
>
seriesFillingTimesDataList
=
new
ArrayList
<>();
List
<
String
>
seriesCumulativeFillingQuantityDataList
=
new
ArrayList
<>();
collect
.
forEach
(
x
->{
axisData
.
add
(
String
.
valueOf
(
x
.
get
(
"regionName"
)));
seriesFillingTimesDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"fillingTimes"
)));
seriesCumulativeFillingQuantityDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"fillingQuantity"
)));
});
HashMap
<
String
,
Object
>
temMap1
=
new
HashMap
<>();
temMap1
.
put
(
"data"
,
seriesFillingTimesDataList
);
temMap1
.
put
(
"name"
,
"充装次数"
);
// temMap1.put("stack","充装次数");
HashMap
<
String
,
Object
>
temMap2
=
new
HashMap
<>();
temMap2
.
put
(
"data"
,
seriesCumulativeFillingQuantityDataList
);
temMap2
.
put
(
"name"
,
"累计充装量"
);
// temMap2.put("stack","累计充装量");
seriesData
.
add
(
temMap1
);
seriesData
.
add
(
temMap2
);
result
.
put
(
"seriesData"
,
seriesData
);
result
.
put
(
"axisData"
,
axisData
);
return
result
;
}
private
Map
<
String
,
Object
>
esQuery
(
RegionModel
regionModel
)
{
private
Map
<
String
,
Object
>
esQuery
(
RegionModel
regionModel
)
{
SearchRequest
searchRequest
=
new
SearchRequest
(
INDEX_NAME
);
SearchRequest
searchRequest
=
new
SearchRequest
(
INDEX_NAME
);
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
// 将 regionModel.getRegionCode() 转换成匹配中间部分的格式
// 将 regionModel.getRegionCode() 转换成匹配中间部分的格式
String
regionCodePattern
=
"*"
+
regionModel
.
getRegionCode
()
+
"*"
;
String
regionCodePattern
=
"*"
+
regionModel
.
getRegionCode
()
+
"*"
;
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
must
(
QueryBuilders
.
wildcardQuery
(
"regionCode"
,
regionCodePattern
));
boolQueryBuilder
.
must
(
QueryBuilders
.
wildcardQuery
(
REGION_CODE
,
regionCodePattern
));
searchSourceBuilder
.
query
(
boolQueryBuilder
);
searchSourceBuilder
.
query
(
boolQueryBuilder
);
// 添加新的条件:筛选fillingEndTime在当前时间往前推31天之内的数据
ZonedDateTime
thirtyOneDaysAgo
=
ZonedDateTime
.
now
().
minusDays
(
31
);
Date
thirtyOneDaysAgoDate
=
Date
.
from
(
thirtyOneDaysAgo
.
toInstant
());
boolQueryBuilder
.
must
(
QueryBuilders
.
rangeQuery
(
FILLING_END_TIME
).
gte
(
thirtyOneDaysAgoDate
));
searchSourceBuilder
.
aggregation
(
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
cardinality
(
"total_filling_count"
)
AggregationBuilders
.
cardinality
(
TOTAL_FILLING_COUNT
)
.
field
(
"sequenceNbr"
)
.
field
(
SEQUENCE_NBR
)
);
);
searchSourceBuilder
.
aggregation
(
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
sum
(
"total_filling_quantity"
)
AggregationBuilders
.
sum
(
TOTAL_FILLING_QUANTITY
)
.
field
(
"fillingQuantity"
)
.
field
(
FILLING_QUANTITY
)
);
);
searchRequest
.
source
(
searchSourceBuilder
);
searchRequest
.
source
(
searchSourceBuilder
);
System
.
out
.
println
(
"Search Request: "
+
searchRequest
);
System
.
out
.
println
(
"Search Request: "
+
searchRequest
);
...
@@ -1368,9 +1358,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1368,9 +1358,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
// 获取所有聚合结果
// 获取所有聚合结果
Aggregations
aggregations
=
searchResponse
.
getAggregations
();
Aggregations
aggregations
=
searchResponse
.
getAggregations
();
ParsedCardinality
cardinalityAgg
=
aggregations
.
get
(
"total_filling_count"
);
ParsedCardinality
cardinalityAgg
=
aggregations
.
get
(
TOTAL_FILLING_COUNT
);
long
uniqueCount
=
cardinalityAgg
.
getValue
();
long
uniqueCount
=
cardinalityAgg
.
getValue
();
Sum
sumAgg
=
aggregations
.
get
(
"total_filling_quantity"
);
Sum
sumAgg
=
aggregations
.
get
(
TOTAL_FILLING_QUANTITY
);
double
totalSum
=
sumAgg
.
getValue
();
double
totalSum
=
sumAgg
.
getValue
();
System
.
out
.
println
(
"填充数量的唯一值数量: "
+
uniqueCount
);
System
.
out
.
println
(
"填充数量的唯一值数量: "
+
uniqueCount
);
System
.
out
.
println
(
"填充量的总和: "
+
totalSum
);
System
.
out
.
println
(
"填充量的总和: "
+
totalSum
);
...
@@ -1387,5 +1377,4 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1387,5 +1377,4 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
}
}
}
}
\ 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