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
0815483e
Commit
0815483e
authored
Oct 16, 2024
by
韩桐桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ys): F1-C1应急保障统计
parent
c1065979
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
9 deletions
+123
-9
CommonController.java
.../amos/boot/module/ys/biz/controller/CommonController.java
+20
-9
CommonService.java
...eejoin/amos/boot/module/ys/biz/service/CommonService.java
+1
-0
CommonServiceImpl.java
...os/boot/module/ys/biz/service/impl/CommonServiceImpl.java
+102
-0
No files found.
amos-boot-system-tzs/amos-boot-module-ys/amos-boot-module-ys-biz/src/main/java/com/yeejoin/amos/boot/module/ys/biz/controller/CommonController.java
View file @
0815483e
...
...
@@ -3,12 +3,19 @@ package com.yeejoin.amos.boot.module.ys.biz.controller;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.module.ys.biz.service.CommonService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
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
;
/**
*
* @author system_generator
* @date 2024-09-24
*/
...
...
@@ -17,13 +24,17 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
value
=
"/common"
)
public
class
CommonController
extends
BaseController
{
@Autowired
private
CommonService
commonService
;
@Autowired
private
CommonService
commonService
;
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @ApiOperation(httpMethod = "GET",value = "模板下载", notes = "模板下载")
// @RequestMapping(value = "/templateDownload", method = RequestMethod.GET)
// public void queryForPage(HttpServletResponse response, @RequestParam(value = "path") String path) {
// commonService.templateDownload(response,path);
// }
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"应急保障四项统计"
,
notes
=
"应急保障四项统计"
)
@RequestMapping
(
value
=
"/emergencySupportStatistics/{businessType}/{componentType}"
,
method
=
RequestMethod
.
GET
)
public
ResponseModel
<
Object
>
queryForPage
(
@ApiParam
(
value
=
"业务类型(教育培训:education、体系建设:construct、应急演练:rehearsal、应急预案:prePlan)"
,
required
=
true
)
@PathVariable
(
value
=
"businessType"
)
String
businessType
,
@ApiParam
(
value
=
"组件类型(饼图:pieChart、富文本:richText)"
,
required
=
true
)
@PathVariable
(
value
=
"componentType"
)
String
componentType
)
{
return
ResponseHelper
.
buildResponse
(
commonService
.
emergencySupportStatistics
(
businessType
,
componentType
));
}
}
amos-boot-system-tzs/amos-boot-module-ys/amos-boot-module-ys-biz/src/main/java/com/yeejoin/amos/boot/module/ys/biz/service/CommonService.java
View file @
0815483e
...
...
@@ -2,5 +2,6 @@ package com.yeejoin.amos.boot.module.ys.biz.service;
public
interface
CommonService
{
Object
emergencySupportStatistics
(
String
businessType
,
String
componentType
);
}
amos-boot-system-tzs/amos-boot-module-ys/amos-boot-module-ys-biz/src/main/java/com/yeejoin/amos/boot/module/ys/biz/service/impl/CommonServiceImpl.java
View file @
0815483e
package
com
.
yeejoin
.
amos
.
boot
.
module
.
ys
.
biz
.
service
.
impl
;
import
cn.hutool.core.util.NumberUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.DynamicFormInstanceServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum
;
import
com.yeejoin.amos.boot.module.ys.api.entity.YsEmergencyPlan
;
import
com.yeejoin.amos.boot.module.ys.api.entity.YsEmergencyRehearsal
;
import
com.yeejoin.amos.boot.module.ys.api.enums.MaintenanceExpiredEarlyWarningEnum
;
import
com.yeejoin.amos.boot.module.ys.api.vo.SortVo
;
import
com.yeejoin.amos.boot.module.ys.biz.service.CommonService
;
import
org.apache.lucene.queryparser.classic.QueryParser
;
...
...
@@ -16,10 +24,13 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.util.Optional
;
import
java.util.concurrent.atomic.AtomicLong
;
...
...
@@ -37,9 +48,47 @@ public class CommonServiceImpl implements CommonService {
*/
public
final
static
String
EQU_CATEGORY_CYLINDER
=
"2300"
;
/**
* 应急保障四项统计使用 - 饼图
*/
public
final
static
String
PIECHART
=
"pieChart"
;
/**
* 应急保障四项统计使用 - 饼图模板
*/
public
final
static
String
PIECHART_TEMPLATE
=
"[{\"name\": \"%s\",\"value\": %s},{\"name\": \"其他\",\"value\": %s}]"
;
/**
* 应急保障四项统计使用 - 富文本
*/
public
final
static
String
RICHTEXT
=
"richText"
;
/**
* 应急保障四项统计使用 - 富文本模板
*/
public
final
static
String
RICHTEXT_TEMPLATE
=
"{\"total\": %s,\"%s\": %s}"
;
/**
* 应急保障四项统计使用 - 业务类型
*/
public
final
static
JSONObject
businessTypeJSON
=
new
JSONObject
();
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
CommonServiceImpl
.
class
);
@Autowired
private
RestHighLevelClient
restHighLevelClient
;
@Autowired
private
DynamicFormInstanceServiceImpl
dynamicFormInstanceService
;
@Autowired
private
YsEmergencyRehearsalServiceImpl
ysEmergencyRehearsalService
;
@Autowired
private
YsEmergencyPlanServiceImpl
ysEmergencyPlanService
;
static
{
businessTypeJSON
.
fluentPut
(
"education"
,
"教育培训数"
).
fluentPut
(
"construct"
,
"体系建设数"
)
.
fluentPut
(
"rehearsal"
,
"应急演练数"
).
fluentPut
(
"prePlan"
,
"应急预案数"
);
}
/**
* 排序 :页面列表排序功能支持,将 "字段,ascend" 或 "字段,descend" 转化为对应JSONObject
*
...
...
@@ -116,6 +165,7 @@ public class CommonServiceImpl implements CommonService {
/**
* 八大类设备数量统计
*
* @param equTypeCode
* @param cylinderNum
* @param orgCode
...
...
@@ -161,4 +211,55 @@ public class CommonServiceImpl implements CommonService {
return
result
.
get
();
}
/**
* 应急保障四项统计
*
* @param businessType 业务类型(教育培训:education、体系建设:construct、应急演练:rehearsal、应急预案:prePlan)
* @param componentType 组件类型(饼图:pieChart、富文本:richText)
* @return 模板数据
*/
@Override
public
Object
emergencySupportStatistics
(
String
businessType
,
String
componentType
)
{
// 教育培训数
long
educationNum
=
dynamicFormInstanceService
.
pageList
(
1
,
1
,
MaintenanceExpiredEarlyWarningEnum
.
JYPX
.
getGroupCode
()).
getTotal
();
// 体系建设数
long
constructNum
=
dynamicFormInstanceService
.
pageList
(
1
,
1
,
MaintenanceExpiredEarlyWarningEnum
.
TXJS
.
getGroupCode
()).
getTotal
();
// 应急演练数
int
rehearsalNum
=
ysEmergencyRehearsalService
.
getBaseMapper
().
selectCount
(
new
LambdaQueryWrapper
<
YsEmergencyRehearsal
>().
eq
(
YsEmergencyRehearsal:
:
getIsDelete
,
Boolean
.
FALSE
));
// 应急预案数
int
prePlanNum
=
ysEmergencyPlanService
.
getBaseMapper
().
selectCount
(
new
LambdaQueryWrapper
<
YsEmergencyPlan
>().
eq
(
YsEmergencyPlan:
:
getIsDelete
,
Boolean
.
FALSE
));
// 四项总数
BigDecimal
totalNum
=
NumberUtil
.
add
(
educationNum
,
constructNum
,
rehearsalNum
,
prePlanNum
);
// 其他数量
BigDecimal
otherNum
=
new
BigDecimal
(
0
);
// 请求类型数量
BigDecimal
valueNum
=
new
BigDecimal
(
0
);
switch
(
businessType
)
{
case
"education"
:
valueNum
=
BigDecimal
.
valueOf
(
educationNum
);
otherNum
=
NumberUtil
.
sub
(
totalNum
,
educationNum
);
break
;
case
"construct"
:
valueNum
=
BigDecimal
.
valueOf
(
constructNum
);
otherNum
=
NumberUtil
.
sub
(
totalNum
,
constructNum
);
break
;
case
"rehearsal"
:
valueNum
=
BigDecimal
.
valueOf
(
rehearsalNum
);
otherNum
=
NumberUtil
.
sub
(
totalNum
,
rehearsalNum
);
break
;
case
"prePlan"
:
valueNum
=
BigDecimal
.
valueOf
(
prePlanNum
);
otherNum
=
NumberUtil
.
sub
(
totalNum
,
prePlanNum
);
break
;
}
if
(
PIECHART
.
equals
(
componentType
))
{
// 组装 饼图 模板数据
return
JSONArray
.
parseArray
(
String
.
format
(
PIECHART_TEMPLATE
,
businessTypeJSON
.
get
(
businessType
).
toString
(),
valueNum
,
otherNum
));
}
if
(
RICHTEXT
.
equals
(
componentType
))
{
// 组装 富文本 模板数据
return
JSONObject
.
parseObject
(
String
.
format
(
RICHTEXT_TEMPLATE
,
totalNum
,
businessType
,
valueNum
));
}
return
null
;
}
}
\ 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