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
b6dcf2e4
Commit
b6dcf2e4
authored
Aug 18, 2021
by
李腾威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日常管理-警情统计优化
parent
0c325b95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
33 deletions
+181
-33
AlertCalledMapper.java
...in/amos/boot/module/tzs/api/mapper/AlertCalledMapper.java
+13
-1
AlertCalledMapper.xml
...e-tzs-api/src/main/resources/mapper/AlertCalledMapper.xml
+124
-3
AlertCalledController.java
...boot/module/tzs/biz/controller/AlertCalledController.java
+15
-14
AlertCalledServiceImpl.java
...t/module/tzs/biz/service/impl/AlertCalledServiceImpl.java
+29
-15
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/mapper/AlertCalledMapper.java
View file @
b6dcf2e4
...
...
@@ -23,11 +23,23 @@ public interface AlertCalledMapper extends BaseMapper<AlertCalled> {
* @param endDate
* @return
*/
List
<
Map
<
String
,
Integer
>>
queryNearlyCount
(
@Param
(
"beginDate"
)
String
beginDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"orgCode"
)
String
orgCode
,
@Param
(
"recUserId"
)
String
recUserId
);
/**
* 接警情况统计
*
* @param beginDate
* @param endDate
* @return
*/
Map
<
String
,
Integer
>
queryAlertStatusCount
(
@Param
(
"beginDate"
)
String
beginDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"orgCode"
)
String
orgCode
,
@Param
(
"recUserId"
)
String
recUserId
);
);
/**
* 根据查询条件返回警情记录
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/resources/mapper/AlertCalledMapper.xml
View file @
b6dcf2e4
...
...
@@ -6,9 +6,9 @@
SELECT
count( 1 ) calledCount,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount,
sum( CASE WHEN alarm_type_code = '
KRJY
' THEN 1 ELSE 0 END ) sleepyIncidentCount,
sum( CASE WHEN alarm_type_code = '
GZWX
' THEN 1 ELSE 0 END ) faultRescueCount,
sum( CASE WHEN alarm_type_code = '
TSZX
' THEN 1 ELSE 0 END ) suggestionsCount
sum( CASE WHEN alarm_type_code = '
960
' THEN 1 ELSE 0 END ) sleepyIncidentCount,
sum( CASE WHEN alarm_type_code = '
961
' THEN 1 ELSE 0 END ) faultRescueCount,
sum( CASE WHEN alarm_type_code = '
962
' THEN 1 ELSE 0 END ) suggestionsCount
FROM
tz_alert_called
WHERE 1 = 1
...
...
@@ -24,6 +24,127 @@
</if>
</select>
<select
id=
"queryNearlyCount"
resultType=
"java.util.Map"
>
SELECT
DATE_ADD(#{beginDate},INTERVAL -1 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -1 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -1 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
UNION ALL
SELECT
DATE_ADD(#{beginDate},INTERVAL -2 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -2 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -2 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
UNION ALL
SELECT
DATE_ADD(#{beginDate},INTERVAL -3 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -3 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -3 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
UNION ALL
SELECT
DATE_ADD(#{beginDate},INTERVAL -4 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -4 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -4 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
UNION ALL
SELECT
DATE_ADD(#{beginDate},INTERVAL -5 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -5 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -5 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
UNION ALL
SELECT
DATE_ADD(#{beginDate},INTERVAL -6 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -6 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -6 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
UNION ALL
SELECT
DATE_ADD(#{beginDate},INTERVAL -7 DAY) dateTime,
sum( CASE WHEN father_alert is null THEN 1 ELSE 0 END ) majorAlertCount
FROM
tz_alert_called
WHERE 1 = 1
<if
test=
"beginDate != null and beginDate != ''"
>
and call_time >= DATE_ADD(#{beginDate},INTERVAL -7 DAY)
</if>
<if
test=
"endDate != null and endDate != ''"
>
and call_time
<![CDATA[ <= ]]>
DATE_ADD(#{endDate},INTERVAL -7 DAY)
</if>
<if
test=
"orgCode != null and orgCode != '' and recUserId != null and recUserId != ''"
>
and org_code= #{orgCode}
or rec_user_id = #{recUserId}
</if>
</select>
<select
id=
"queryAlertListByQueryDto"
resultType=
"com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto"
>
SELECT
a.work_order_number AS workOrderNumber,
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/AlertCalledController.java
View file @
b6dcf2e4
...
...
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.SystemClock
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.google.common.collect.Maps
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
...
...
@@ -50,6 +49,7 @@ import java.lang.reflect.Field;
import
java.text.ParseException
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Stream
;
...
...
@@ -165,8 +165,8 @@ public class AlertCalledController extends BaseController {
// Map<String, Object> map = iAlertCalledService.getAlertInfoList(DateUtils.dateFormat(new Date(),"")+" 00:00:00",
// DateUtils.dateFormat(new Date(),"")+" 23:59:59",reginParams.getCompany().getOrgCode(),
// reginParams.getUserModel().getUserId());
Map
<
String
,
Object
>
map
=
iAlertCalledService
.
getAlertInfoList
(
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
"yyyy-MM-dd"
)+
" 00:00:00"
,
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
"yyyy-MM-dd"
)+
" 23:59:59"
,
null
,
Map
<
String
,
Object
>
map
=
iAlertCalledService
.
getAlertInfoList
(
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
DateUtils
.
DATE_TIME_PATTERN
)
,
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
DateUtils
.
DATE_TIME_PATTERN
)
,
null
,
null
);
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
newNumber
);
...
...
@@ -182,7 +182,7 @@ public class AlertCalledController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/alertStatistics"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"警情统计"
,
notes
=
"警情统计"
)
public
ResponseModel
<
AlarmStatisticsDto
>
alertStatistics
()
throws
ParseException
{
public
ResponseModel
<
AlarmStatisticsDto
>
alertStatistics
()
{
ReginParams
reginParams
=
getSelectedOrgInfo
();
//我的待办数量
...
...
@@ -202,8 +202,8 @@ public class AlertCalledController extends BaseController {
alarmStatisticsDto
.
setAllNum
(
iAlertCalledService
.
list
(
allNumQueryWrapper
).
size
());
Map
<
String
,
Object
>
map
=
iAlertCalledService
.
getAlertInfoList
(
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
"yyyy-MM-dd"
)+
" 00:00:00"
,
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
"yyyy-MM-dd"
)+
" 23:59:59"
,
null
,
Map
<
String
,
Object
>
map
=
iAlertCalledService
.
getAlertInfoList
(
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
DateUtils
.
DATE_PATTERN
)
,
DateUtils
.
stampToDate
(
DateUtils
.
dateAddDays
(
new
Date
(),
1
).
getTime
(),
DateUtils
.
DATE_PATTERN
)
,
null
,
getUserInfo
().
getUserId
());
// 当天接警
...
...
@@ -217,15 +217,16 @@ public class AlertCalledController extends BaseController {
//困人救援数量
alarmStatisticsDto
.
setSleepyIncident
(
map
.
get
(
"sleepyIncidentCount"
)
==
null
?
0
:
Integer
.
valueOf
(
map
.
get
(
"sleepyIncidentCount"
).
toString
()))
;
Map
<
String
,
Integer
>
recordMap
=
Maps
.
newHashMap
();
LinkedHashMap
<
String
,
Integer
>
recordMap
=
new
LinkedHashMap
<>
();
// 近七天办理数量
for
(
int
i
=
1
;
i
<
8
;
i
++)
{
Map
<
String
,
Object
>
nearlySevenDaysMap
=
iAlertCalledService
.
getAlertInfoList
(
DateUtils
.
stampToDate
(
DateUtils
.
dateAddDays
(
new
Date
(),
-
i
).
getTime
(),
"yyyy-MM-dd"
)+
" 00:00:00"
,
DateUtils
.
stampToDate
(
DateUtils
.
dateAddDays
(
new
Date
(),
-
i
).
getTime
(),
"yyyy-MM-dd"
)+
" 23:59:59"
,
null
,
getUserInfo
().
getUserId
());
recordMap
.
put
(
DateUtils
.
stampToDate
(
DateUtils
.
dateAddDays
(
new
Date
(),
-
i
).
getTime
(),
"yyyy-MM-dd"
),
nearlySevenDaysMap
.
get
(
"calledCount"
)
==
null
?
0
:
Integer
.
valueOf
(
nearlySevenDaysMap
.
get
(
"calledCount"
).
toString
()));
}
alarmStatisticsDto
.
setNearlySevenDaysNum
(
recordMap
);
Map
<
String
,
Object
>
nearlySevenDaysMap
=
iAlertCalledService
.
getNearlyInfo
(
DateUtils
.
stampToDate
(
System
.
currentTimeMillis
(),
DateUtils
.
DATE_PATTERN
),
DateUtils
.
stampToDate
(
DateUtils
.
dateAddDays
(
new
Date
(),
1
).
getTime
(),
DateUtils
.
DATE_PATTERN
),
null
,
getUserInfo
().
getUserId
());
for
(
int
i
=
0
;
i
<
nearlySevenDaysMap
.
size
()/
2
;
i
++)
{
recordMap
.
put
(
DateUtils
.
dateToString
(
nearlySevenDaysMap
.
get
(
"dateTime"
+
i
).
toString
()),
Integer
.
parseInt
(
nearlySevenDaysMap
.
get
(
"majorAlertCount"
+
i
).
toString
()));
}
alarmStatisticsDto
.
setNearlySevenDaysNum
(
recordMap
);
}
return
ResponseHelper
.
buildResponse
(
alarmStatisticsDto
);
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/AlertCalledServiceImpl.java
View file @
b6dcf2e4
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.google.common.collect.Maps
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
...
...
@@ -34,6 +20,17 @@ import com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper;
import
com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 警情接警填报记录服务实现类
...
...
@@ -263,4 +260,20 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
return
result
;
}
public
Map
<
String
,
Object
>
getNearlyInfo
(
String
beginDate
,
String
endDate
,
String
orgCode
,
String
recUserId
)
{
Map
<
String
,
Object
>
result
=
Maps
.
newHashMap
();
List
<
Map
<
String
,
Integer
>>
statusCountMap
=
alertCalledMapper
.
queryNearlyCount
(
beginDate
,
endDate
,
orgCode
,
recUserId
);
for
(
int
i
=
0
;
i
<
statusCountMap
.
size
();
i
++)
{
if
(
statusCountMap
.
get
(
i
).
size
()
>
1
)
{
result
.
put
(
"dateTime"
+
i
,
statusCountMap
.
get
(
i
).
get
(
"dateTime"
));
result
.
put
(
"majorAlertCount"
+
i
,
statusCountMap
.
get
(
i
).
get
(
"majorAlertCount"
));
}
else
{
result
.
put
(
"dateTime"
+
i
,
statusCountMap
.
get
(
i
).
get
(
"dateTime"
));
result
.
put
(
"majorAlertCount"
+
i
,
0
);
}
}
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