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
6a13d3df
Commit
6a13d3df
authored
Jul 10, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.大屏地图图列统计接口开发空指针处理
parent
ee6cead1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
35 deletions
+106
-35
DPStatisticsController.java
...boot/module/jg/biz/controller/DPStatisticsController.java
+12
-1
ApplicationRunnerImpl.java
...n/amos/boot/module/jg/biz/init/ApplicationRunnerImpl.java
+15
-1
DPStatisticsServiceImpl.java
...t/module/jg/biz/service/impl/DPStatisticsServiceImpl.java
+74
-29
TzsUserInfoMapper.java
...in/amos/boot/module/ymt/api/mapper/TzsUserInfoMapper.java
+1
-1
EquipTechParamPipelineMapper.xml
...rc/main/resources/mapper/EquipTechParamPipelineMapper.xml
+2
-2
TzsUserInfoMapper.xml
...e-ymt-api/src/main/resources/mapper/TzsUserInfoMapper.xml
+2
-1
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/DPStatisticsController.java
View file @
6a13d3df
...
...
@@ -51,7 +51,7 @@ public class DPStatisticsController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"大屏总览中间-地图左右两侧8大类、单位、人员数量全局统计"
,
notes
=
"大屏总览中间-地图左右两侧8大类、单位、人员数量全局统计"
)
@PostMapping
(
value
=
"/zl/center-map/
global/count
"
)
@PostMapping
(
value
=
"/zl/center-map/
legend
"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
centerMapCountForGlobal
(
@Validated
@RequestBody
DPFilterParamDto
dpFilterParamDto
,
BindingResult
result
)
{
List
<
FieldError
>
fieldErrors
=
result
.
getFieldErrors
();
if
(!
fieldErrors
.
isEmpty
())
{
...
...
@@ -61,6 +61,17 @@ public class DPStatisticsController {
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"大屏总览中间-地图地市统计"
,
notes
=
"大屏总览中间-地图地市统计"
)
@PostMapping
(
value
=
"/zl/center-map/overview"
)
public
ResponseModel
<
List
<
Map
<
String
,
Object
>>>
centerMapCountForOverview
(
@Validated
@RequestBody
DPFilterParamDto
dpFilterParamDto
,
BindingResult
result
)
{
List
<
FieldError
>
fieldErrors
=
result
.
getFieldErrors
();
if
(!
fieldErrors
.
isEmpty
())
{
throw
new
BadRequest
(
fieldErrors
.
get
(
0
).
getDefaultMessage
());
}
return
ResponseHelper
.
buildResponse
(
statisticsService
.
getCenterMapCountDataForOverview
(
dpFilterParamDto
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"大屏八大类左侧-使用登记统计"
,
notes
=
"大屏八大类左侧-使用登记统计"
)
@PostMapping
(
value
=
"/useRegisterCount"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
useRegisterCount
(
@Validated
@RequestBody
DPFilterParamDto
dpFilterParamDto
,
BindingResult
result
)
{
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/init/ApplicationRunnerImpl.java
View file @
6a13d3df
...
...
@@ -5,9 +5,11 @@ import com.yeejoin.amos.boot.module.jg.api.entity.*;
import
com.yeejoin.amos.boot.module.jg.api.service.IEquipUsedCheck
;
import
com.yeejoin.amos.boot.module.jg.biz.service.impl.*
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
java.util.List
;
...
...
@@ -48,6 +50,10 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
private
List
<
IEquipUsedCheck
>
equipUsedCheckList
;
private
DPStatisticsServiceImpl
statisticsService
;
private
AmosRequestContext
amosRequestContext
;
public
ApplicationRunnerImpl
(
JgUseRegistrationServiceImpl
useRegistrationService
,
CommonServiceImpl
commonService
,
JgInstallationNoticeServiceImpl
installationNoticeService
,
...
...
@@ -63,7 +69,7 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
JgScrapCancelServiceImpl
scrapCancelService
,
JgChangeRegistrationNameServiceImpl
changeRegistrationNameService
,
ReportAnalysisServiceImpl
reportAnalysisService
,
List
<
IEquipUsedCheck
>
equipUsedCheckList
)
{
List
<
IEquipUsedCheck
>
equipUsedCheckList
,
DPStatisticsServiceImpl
statisticsService
,
AmosRequestContext
amosRequestContext
)
{
this
.
commonService
=
commonService
;
this
.
useRegistrationService
=
useRegistrationService
;
...
...
@@ -95,6 +101,8 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
this
.
reportAnalysisService
=
reportAnalysisService
;
this
.
equipUsedCheckList
=
equipUsedCheckList
;
this
.
statisticsService
=
statisticsService
;
this
.
amosRequestContext
=
amosRequestContext
;
}
...
...
@@ -184,5 +192,11 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
// 流程中的设备统计数据预热
equipUsedCheckList
.
forEach
(
IEquipUsedCheck:
:
init
);
// 初始化数据到内存
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
statisticsService
.
init
();
}
}
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/DPStatisticsServiceImpl.java
View file @
6a13d3df
...
...
@@ -14,6 +14,8 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipTechParamPipelineMapper;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.action.search.SearchRequest
;
...
...
@@ -29,19 +31,14 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StopWatch
;
import
java.sql.Date
;
import
java.text.SimpleDateFormat
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.TemporalAdjusters
;
import
javax.annotation.PostConstruct
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
...
...
@@ -107,6 +104,8 @@ public class DPStatisticsServiceImpl {
private
static
Map
<
String
,
String
>
regionCodeOrgCodeMap
=
new
ConcurrentHashMap
<>();
private
static
List
<
RegionModel
>
regionModels
=
new
ArrayList
<>();
public
DPStatisticsServiceImpl
(
EquipmentCategoryMapper
equipmentCategoryMapper
,
JgUseRegistrationMapper
useRegistrationMapper
,
EquipTechParamPipelineMapper
techParamsPipelineMapper
,
JgEnableDisableMapper
enableDisableMapper
,
JgScrapCancelMapper
scrapCancelMapper
,
RestHighLevelClient
restHighLevelClient
,
TzBaseEnterpriseInfoMapper
enterpriseInfoMapper
,
CommonMapper
commonMapper
,
TzsUserInfoMapper
userInfoMapper
)
{
this
.
equipmentCategoryMapper
=
equipmentCategoryMapper
;
...
...
@@ -120,13 +119,21 @@ public class DPStatisticsServiceImpl {
this
.
userInfoMapper
=
userInfoMapper
;
}
@PostConstruct
public
void
init
()
{
// 数据不变所以放到内存,提高响应时间
equipmentCategoryDtos
=
equipmentCategoryMapper
.
selectClassify
();
initReginCode
();
}
private
List
<
LegendDataDto
>
buildLegendDataList
()
{
List
<
LegendDataDto
>
legendDataDtos
=
new
ArrayList
<>();
legendDataDtos
.
add
(
LegendDataDto
.
builder
().
dataKey
(
"newDevice"
).
value
(
"新增登记设备"
).
build
());
legendDataDtos
.
add
(
LegendDataDto
.
builder
().
dataKey
(
"stoppedDevice"
).
value
(
"报停设备"
).
build
());
legendDataDtos
.
add
(
LegendDataDto
.
builder
().
dataKey
(
"scrappedDevice"
).
value
(
"报废设备"
).
build
());
return
legendDataDtos
;
}
public
Map
<
String
,
Object
>
useRegisterCountByEquList
(
DPFilterParamDto
dpFilterParamDto
)
{
// 1.查询条件构造未上送时间时,默认查询数据为近一个月数据
this
.
setDefaultFilter
(
dpFilterParamDto
);
...
...
@@ -142,14 +149,6 @@ public class DPStatisticsServiceImpl {
return
result
;
}
private
List
<
LegendDataDto
>
buildLegendDataList
()
{
List
<
LegendDataDto
>
legendDataDtos
=
new
ArrayList
<>();
legendDataDtos
.
add
(
LegendDataDto
.
builder
().
dataKey
(
"newDevice"
).
value
(
"新增登记设备"
).
build
());
legendDataDtos
.
add
(
LegendDataDto
.
builder
().
dataKey
(
"stoppedDevice"
).
value
(
"报停设备"
).
build
());
legendDataDtos
.
add
(
LegendDataDto
.
builder
().
dataKey
(
"scrappedDevice"
).
value
(
"报废设备"
).
build
());
return
legendDataDtos
;
}
private
void
buildYData
(
Map
<
String
,
Object
>
result
,
DPFilterParamDto
dpFilterParamDto
,
List
<
EquipmentCategoryDto
>
equipmentCategoryDtos
)
{
// 待统计的数据本来sql可以单独统计,但是要求气瓶单独从压力容器里拎出来,与八大类同级,故java处理
// 1.新增登记统计
...
...
@@ -223,18 +222,32 @@ public class DPStatisticsServiceImpl {
//3.单位数量统计
this
.
staticsCenterMapCountDataForCompany
(
result
,
dpFilterParamDto
);
//4.人员数量统计
StopWatch
stopWatch5
=
new
StopWatch
();
stopWatch5
.
start
();
this
.
staticsCenterMapCountDataForPerson
(
result
,
dpFilterParamDto
);
stopWatch5
.
stop
();
log
.
info
(
"------人员查询>:{}"
,
stopWatch5
.
getTotalTimeSeconds
());
return
result
;
}
private
void
staticsCenterMapCountDataForPerson
(
Map
<
String
,
Object
>
result
,
DPFilterParamDto
dpFilterParamDto
)
{
Long
num
=
userInfoMapper
.
countUserByPostAndAreaCode
(
dpFilterParamDto
.
getCityCode
(),
"6552"
);
// String orgCode = regionCodeOrgCodeMap.get(dpFilterParamDto.getCityCode());
// if (orgCode == null) {
// orgCode = commonMapper.getOrgCodeByCompanyCode(dpFilterParamDto.getCityCode());
// regionCodeOrgCodeMap.put(dpFilterParamDto.getCityCode(), orgCode);
// }
// Long num = userInfoMapper.countUserByPostAndAreaCode(orgCode, "6552");
// result.put(DPMapStatisticsItemEnum.OPERATORS.getCode(), num);
result
.
put
(
DPMapStatisticsItemEnum
.
OPERATORS
.
getCode
(),
0
);
}
private
void
staticsCenterMapCountDataForCompany
(
Map
<
String
,
Object
>
result
,
DPFilterParamDto
dpFilterParamDto
)
{
String
orgCode
=
regionCodeOrgCodeMap
.
get
(
dpFilterParamDto
.
getCityCode
());
if
(
orgCode
==
null
)
{
orgCode
=
commonMapper
.
getOrgCodeByCompanyCode
(
dpFilterParamDto
.
getCityCode
());
if
(
orgCode
==
null
){
return
;
}
regionCodeOrgCodeMap
.
put
(
dpFilterParamDto
.
getCityCode
(),
orgCode
);
}
result
.
put
(
DPMapStatisticsItemEnum
.
USERS_UNITS
.
getCode
(),
enterpriseInfoMapper
.
countByUnitTypeAndOrgCode
(
orgCode
,
COMPANY_TYPE_USE
));
...
...
@@ -254,6 +267,7 @@ public class DPStatisticsServiceImpl {
boolMust
.
must
(
QueryBuilders
.
termsQuery
(
"EQU_CATEGORY_CODE"
,
EQU_CATEGORY_CYLINDER
));
// 纳管状态为已纳管
boolMust
.
must
(
QueryBuilders
.
termsQuery
(
"IS_INTO_MANAGEMENT"
,
true
));
request
.
query
(
boolMust
);
try
{
CountResponse
response
=
restHighLevelClient
.
count
(
request
,
RequestOptions
.
DEFAULT
);
num
=
response
.
getCount
();
...
...
@@ -299,6 +313,7 @@ public class DPStatisticsServiceImpl {
equipmentCategoryDtos
.
forEach
(
c
->
{
result
.
put
(
this
.
castCategoryCode2WebCode
(
c
.
getCode
()),
countMap
.
getOrDefault
(
c
.
getCode
(),
0L
));
});
result
.
put
(
DPMapStatisticsItemEnum
.
TOTAL
.
getCode
(),
countMap
.
values
().
stream
().
mapToLong
(
e
->
e
).
sum
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
@@ -315,15 +330,15 @@ public class DPStatisticsServiceImpl {
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
legendDataList
=
new
ArrayList
();
Map
<
String
,
Object
>
newDeviceMap
=
new
HashMap
<>();
newDeviceMap
.
put
(
"dataKey"
,
"newDevice"
);
newDeviceMap
.
put
(
"value"
,
"新增登记设备"
);
Map
<
String
,
Object
>
newDeviceMap
=
new
HashMap
<>();
newDeviceMap
.
put
(
"dataKey"
,
"newDevice"
);
newDeviceMap
.
put
(
"value"
,
"新增登记设备"
);
legendDataList
.
add
(
newDeviceMap
);
Map
<
String
,
Object
>
scrappedDeviceMap
=
new
HashMap
<>();
scrappedDeviceMap
.
put
(
"dataKey"
,
"scrappedDevice"
);
scrappedDeviceMap
.
put
(
"value"
,
"报废设备"
);
Map
<
String
,
Object
>
scrappedDeviceMap
=
new
HashMap
<>();
scrappedDeviceMap
.
put
(
"dataKey"
,
"scrappedDevice"
);
scrappedDeviceMap
.
put
(
"value"
,
"报废设备"
);
legendDataList
.
add
(
scrappedDeviceMap
);
result
.
put
(
"legendData"
,
legendDataList
);
result
.
put
(
"legendData"
,
legendDataList
);
LocalDate
today
=
LocalDate
.
now
();
List
xDataList
=
new
ArrayList
();
List
<
Integer
>
newDeviceList
=
new
ArrayList
();
...
...
@@ -336,14 +351,44 @@ public class DPStatisticsServiceImpl {
dpFilterParamDto
.
setEndDate
(
LocalDateTime
.
of
(
lastDayOfPrevMonth
,
java
.
time
.
LocalTime
.
MAX
).
format
(
sdf
));
Integer
useRegisterCount
=
useRegistrationMapper
.
getUseRegisterCount
(
dpFilterParamDto
);
Integer
scrappedDeviceCount
=
scrapCancelMapper
.
getScrappedDeviceCount
(
dpFilterParamDto
);
xDataList
.
add
(
firstDayOfPrevMonth
.
getMonthValue
()
+
"月"
);
xDataList
.
add
(
firstDayOfPrevMonth
.
getMonthValue
()
+
"月"
);
newDeviceList
.
add
(
null
==
useRegisterCount
?
0
:
useRegisterCount
);
scrappedDeviceList
.
add
(
null
==
scrappedDeviceCount
?
0
:
scrappedDeviceCount
);
}
result
.
put
(
"xdata"
,
xDataList
);
result
.
put
(
"newDevice"
,
newDeviceList
);
result
.
put
(
"scrappedDevice"
,
scrappedDeviceList
);
result
.
put
(
"xdata"
,
xDataList
);
result
.
put
(
"newDevice"
,
newDeviceList
);
result
.
put
(
"scrappedDevice"
,
scrappedDeviceList
);
return
result
;
}
public
List
<
Map
<
String
,
Object
>>
getCenterMapCountDataForOverview
(
DPFilterParamDto
dpFilterParamDto
)
{
return
regionModels
.
parallelStream
().
filter
(
e
->
e
.
getParentRegionCode
()
!=
null
&&
(
e
.
getParentRegionCode
().
toString
()).
equals
(
dpFilterParamDto
.
getCityCode
())).
map
(
r
->
{
DPFilterParamDto
filterParamDto
=
new
DPFilterParamDto
();
filterParamDto
.
setCityCode
(
r
.
getRegionCode
().
toString
());
Map
<
String
,
Object
>
itemResult
=
getCenterMapCountDataForGlobal
(
filterParamDto
);
if
(
itemResult
==
null
)
{
itemResult
=
new
HashMap
<>();
}
itemResult
.
put
(
"cityCode"
,
r
.
getRegionCode
());
return
itemResult
;
}).
collect
(
Collectors
.
toList
());
}
private
void
initReginCode
()
{
Collection
<
RegionModel
>
result
=
Systemctl
.
regionClient
.
queryForTree
(
null
).
getResult
();
result
.
forEach
(
r
->
{
regionModels
.
add
(
r
);
this
.
loopSetChildRegin
(
regionModels
,
r
.
getChildren
());
});
}
private
void
loopSetChildRegin
(
List
<
RegionModel
>
regionModels
,
Collection
<
RegionModel
>
children
)
{
if
(
children
!=
null
&&
children
.
size
()
>
0
)
{
children
.
forEach
(
c
->
{
regionModels
.
add
(
c
);
this
.
loopSetChildRegin
(
regionModels
,
c
.
getChildren
());
});
}
}
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/java/com/yeejoin/amos/boot/module/ymt/api/mapper/TzsUserInfoMapper.java
View file @
6a13d3df
...
...
@@ -12,5 +12,5 @@ import java.util.Set;
public
interface
TzsUserInfoMapper
extends
BaseMapper
<
TzsUserInfo
>
{
Page
<
TzsUserInfoDto
>
selectPageMessage
(
@Param
(
"page"
)
Page
<
TzsUserInfoDto
>
page
,
@Param
(
"dto"
)
TzsUserInfoDto
dto
);
Long
countUserByPostAndAreaCode
(
@Param
(
"
areaCode"
)
String
area
Code
,
@Param
(
"post"
)
String
post
);
Long
countUserByPostAndAreaCode
(
@Param
(
"
orgCode"
)
String
org
Code
,
@Param
(
"post"
)
String
post
);
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/resources/mapper/EquipTechParamPipelineMapper.xml
View file @
6a13d3df
...
...
@@ -27,7 +27,7 @@
</select>
<select
id=
"sumPipeLengthByArea"
resultType=
"java.lang.String"
>
select
round(sum(p."PIPE_LENGTH"), 2
) as PIPE_LENGTH
COALESCE(round(sum(p."PIPE_LENGTH"), 2),0
) as PIPE_LENGTH
from
idx_biz_jg_tech_params_pipeline p,
(
...
...
@@ -45,6 +45,6 @@
and ui.IS_INTO_MANAGEMENT =true
) a
where
p."RECORD" = a."RECORD" and
c
.areaCode like concat('%',#{cityCode}, '%')
p."RECORD" = a."RECORD" and
a
.areaCode like concat('%',#{cityCode}, '%')
</select>
</mapper>
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/resources/mapper/TzsUserInfoMapper.xml
View file @
6a13d3df
...
...
@@ -57,7 +57,7 @@
WHERE
tui.unit_code = bi.use_code
and tui.post LIKE concat ( '%', #{post}, '%' )
and bi.supervise_org_code LIKE CONCAT ( #{
areaCode}
}, '%' )
and bi.supervise_org_code LIKE CONCAT ( #{
orgCode
}, '%' )
and tui.is_delete=false
</select>
</mapper>
\ 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