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
dc18bb94
Commit
dc18bb94
authored
Jun 01, 2024
by
kinky2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register
parents
53d387db
a25cba7d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
265 additions
and
55 deletions
+265
-55
CylinderInspectionDto.java
...ot/module/cylinder/flc/api/dto/CylinderInspectionDto.java
+33
-31
CylinderInspection.java
...ot/module/cylinder/flc/api/entity/CylinderInspection.java
+7
-6
CylinderInfoMapper.java
...ot/module/cylinder/flc/api/mapper/CylinderInfoMapper.java
+5
-0
CylinderInfoMapper.xml
...nder-api/src/main/resources/mapper/CylinderInfoMapper.xml
+30
-0
InspectionQuestionJob.java
...s/boot/module/cylinder/biz/job/InspectionQuestionJob.java
+63
-14
CylinderInfoController.java
...e/cylinder/flc/biz/controller/CylinderInfoController.java
+12
-4
CylinderInfoServiceImpl.java
...ylinder/flc/biz/service/impl/CylinderInfoServiceImpl.java
+115
-0
No files found.
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/api/dto/CylinderInspectionDto.java
View file @
dc18bb94
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
api
.
dto
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
api
.
dto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
...
@@ -15,52 +16,53 @@ import java.util.Date;
...
@@ -15,52 +16,53 @@ import java.util.Date;
*/
*/
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"CylinderInspectionDto"
,
description
=
"气瓶检验信息"
)
@ApiModel
(
value
=
"CylinderInspectionDto"
,
description
=
"气瓶检验信息"
)
public
class
CylinderInspectionDto
extends
BaseDto
{
public
class
CylinderInspectionDto
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"id"
)
@ApiModelProperty
(
value
=
"id"
)
private
Long
sequenceNbr
;
private
Long
sequenceNbr
;
@ApiModelProperty
(
value
=
"检验单位"
)
private
String
inspectionUnit
;
@ApiModelProperty
(
value
=
"检验单位
"
)
@ApiModelProperty
(
value
=
"气瓶唯一标识码
"
)
private
String
inspectionUnit
;
private
String
sequenceCode
;
@ApiModelProperty
(
value
=
"气瓶唯一标识码
"
)
@ApiModelProperty
(
value
=
"检验日期
"
)
private
String
sequenceCod
e
;
private
String
inspectionDat
e
;
@ApiModelProperty
(
value
=
"
检验日期"
)
@ApiModelProperty
(
value
=
"下次
检验日期"
)
private
String
i
nspectionDate
;
private
String
nextI
nspectionDate
;
@ApiModelProperty
(
value
=
"下次检验日期
"
)
@ApiModelProperty
(
value
=
"检验结果
"
)
private
String
nextInspectionDate
;
private
String
inspectionResult
;
@ApiModelProperty
(
value
=
"检验结果
"
)
@ApiModelProperty
(
value
=
"创建时间
"
)
private
String
inspectionResult
;
private
Date
recDate
;
@ApiModelProperty
(
value
=
"创建时间
"
)
@ApiModelProperty
(
value
=
"操作人员
"
)
private
Date
recDate
;
private
String
recUserId
;
@ApiModelProperty
(
value
=
"操作人员
"
)
@ApiModelProperty
(
value
=
"同步时间 yyyy-MM-dd HH24:mi:ss
"
)
private
String
recUserId
;
private
Date
syncDate
;
@ApiModelProperty
(
value
=
"同步时间 yyyy-MM-dd HH24:mi:ss
"
)
@ApiModelProperty
(
value
=
"0-新增 1-更新 2-删除
"
)
private
Date
syncD
ate
;
private
Integer
syncSt
ate
;
@ApiModelProperty
(
value
=
"0-新增 1-更新 2-删除
"
)
@ApiModelProperty
(
value
=
"对接公司编码
"
)
private
Integer
syncState
;
private
String
appId
;
@ApiModelProperty
(
value
=
"对接公司编码
"
)
@ApiModelProperty
(
value
=
"数据完整度
"
)
private
String
appId
;
private
Double
integrity
;
@ApiModelProperty
(
value
=
"数据完整度
"
)
@ApiModelProperty
(
value
=
"不合格报废数量
"
)
private
Double
integr
ity
;
private
String
scrapQuant
ity
;
@ApiModelProperty
(
value
=
"不合格报废数量
"
)
@ApiModelProperty
(
value
=
"是否处理生过问题
"
)
private
String
scrapQuantity
;
private
Boolean
isDealQuestion
;
}
}
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/api/entity/CylinderInspection.java
View file @
dc18bb94
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
api
.
entity
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
api
.
entity
;
import
java.util.Dat
e
;
import
com.baomidou.mybatisplus.annotation.TableNam
e
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity
;
import
org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity
;
import
java.util.Date
;
/**
/**
* 气瓶检验信息
* 气瓶检验信息
*
*
...
@@ -19,14 +20,12 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
...
@@ -19,14 +20,12 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
"tz_cylinder_inspection"
)
@TableName
(
"tz_cylinder_inspection"
)
@ApiModel
(
value
=
"TzCylinderInspection对象"
,
description
=
"气瓶检验信息"
)
@ApiModel
(
value
=
"TzCylinderInspection对象"
,
description
=
"气瓶检验信息"
)
public
class
CylinderInspection
extends
BaseEntity
{
public
class
CylinderInspection
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"检验单位"
)
@ApiModelProperty
(
value
=
"检验单位"
)
private
String
inspectionUnit
;
private
String
inspectionUnit
;
...
@@ -43,7 +42,6 @@ public class CylinderInspection extends BaseEntity {
...
@@ -43,7 +42,6 @@ public class CylinderInspection extends BaseEntity {
private
String
inspectionResult
;
private
String
inspectionResult
;
@ApiModelProperty
(
value
=
"同步时间 yyyy-MM-dd HH24:mi:ss"
)
@ApiModelProperty
(
value
=
"同步时间 yyyy-MM-dd HH24:mi:ss"
)
private
Date
syncDate
;
private
Date
syncDate
;
...
@@ -58,4 +56,7 @@ public class CylinderInspection extends BaseEntity {
...
@@ -58,4 +56,7 @@ public class CylinderInspection extends BaseEntity {
@ApiModelProperty
(
value
=
"不合格报废数量"
)
@ApiModelProperty
(
value
=
"不合格报废数量"
)
private
String
scrapQuantity
;
private
String
scrapQuantity
;
@ApiModelProperty
(
value
=
"是否处理生过问题"
)
private
Boolean
isDealQuestion
=
false
;
}
}
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/CylinderInfoMapper.java
View file @
dc18bb94
...
@@ -109,4 +109,9 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
...
@@ -109,4 +109,9 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
Map
<
String
,
Object
>
countFillingTimesAndQuantityByCompany
(
@Param
(
"companyId"
)
String
companyId
,
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"endTime"
)
String
endTime
);
Map
<
String
,
Object
>
countFillingTimesAndQuantityByCompany
(
@Param
(
"companyId"
)
String
companyId
,
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"endTime"
)
String
endTime
);
List
<
CylinderInfoDto
>
queryCylinderOfInspectionOverdue
();
List
<
CylinderInfoDto
>
queryCylinderOfInspectionOverdue
();
List
<
CylinderInfoDto
>
queryCylinderOfUnqualifiedQuestion
();
List
<
Map
<
String
,
Object
>>
countFillingTimesAndQuantityByCity
();
}
}
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-api/src/main/resources/mapper/CylinderInfoMapper.xml
View file @
dc18bb94
...
@@ -402,6 +402,18 @@
...
@@ -402,6 +402,18 @@
</if>
</if>
</where>
</where>
</select>
</select>
<select
id=
"countFillingTimesAndQuantityByCity"
resultType=
"java.util.Map"
>
SELECT regionCode AS regionCode,
COUNT(cfr.app_id) AS fillingTimes,
ROUND(SUM(cfr.filling_quantity)) AS fillingQuantity
FROM (SELECT cu.app_id,
SUBSTRING_INDEX(SUBSTRING_INDEX(cu.region_code, '#', 2), '#', -1) AS regionCode
FROM tz_cylinder_unit cu) cu
LEFT JOIN tz_cylinder_filling_record cfr ON cu.app_id = cfr.app_id
GROUP BY regionCode
</select>
<select
id=
"countNumber"
resultType=
"java.lang.Integer"
>
<select
id=
"countNumber"
resultType=
"java.lang.Integer"
>
SELECT count(DISTINCT(onlyCode))
SELECT count(DISTINCT(onlyCode))
FROM(
FROM(
...
@@ -455,6 +467,24 @@
...
@@ -455,6 +467,24 @@
and a.last_inspection_id = b.sequence_nbr
and a.last_inspection_id = b.sequence_nbr
and date_gt(CURRENT_DATE, cast(b.next_inspection_date as date))
and date_gt(CURRENT_DATE, cast(b.next_inspection_date as date))
</select>
</select>
<select
id=
"queryCylinderOfUnqualifiedQuestion"
resultType=
"com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto"
>
SELECT
b.sequence_nbr,
a.sequence_code,
a.app_id,
u.unit_name,
u.region_code,
a.factory_num
FROM
tz_cylinder_info a,
tz_cylinder_inspection b,
tz_cylinder_unit u
where
a.sequence_code = b.sequence_code
and u.credit_code = a.credit_code
and a.last_inspection_id = b.sequence_nbr
and (b.is_deal_question = false or b.is_deal_question is null)
</select>
<update
id=
"updateEsCylinderInfoStatus"
>
<update
id=
"updateEsCylinderInfoStatus"
>
UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN
UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/biz/job/Inspection
Overdue
Job.java
→
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/biz/job/Inspection
Question
Job.java
View file @
dc18bb94
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
biz
.
job
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
biz
.
job
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderQuestionInfo
;
import
com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderQuestionInfo
;
import
com.yeejoin.amos.boot.module.cylinder.api.enums.QuestionTypeEnum
;
import
com.yeejoin.amos.boot.module.cylinder.api.enums.QuestionTypeEnum
;
import
com.yeejoin.amos.boot.module.cylinder.biz.service.impl.CylinderQuestionInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.cylinder.biz.service.impl.CylinderQuestionInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto
;
import
com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInspection
;
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.biz.service.impl.CylinderInspectionServiceImpl
;
import
net.javacrumbs.shedlock.spring.annotation.SchedulerLock
;
import
net.javacrumbs.shedlock.spring.annotation.SchedulerLock
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -19,39 +25,82 @@ import java.util.stream.Collectors;
...
@@ -19,39 +25,82 @@ import java.util.stream.Collectors;
*/
*/
@Component
@Component
@EnableScheduling
@EnableScheduling
public
class
Inspection
Overdue
Job
{
public
class
Inspection
Question
Job
{
private
CylinderInfoMapper
cylinderInfoMapper
;
private
CylinderInfoMapper
cylinderInfoMapper
;
private
CylinderInspectionServiceImpl
cylinderInspectionService
;
private
CylinderQuestionInfoServiceImpl
questionInfoService
;
private
CylinderQuestionInfoServiceImpl
questionInfoService
;
public
InspectionOverdueJob
(
CylinderInfoMapper
cylinderInfoMapper
,
public
InspectionQuestionJob
(
CylinderInfoMapper
cylinderInfoMapper
,
CylinderQuestionInfoServiceImpl
questionInfoService
)
{
CylinderInspectionServiceImpl
cylinderInspectionService
,
CylinderQuestionInfoServiceImpl
questionInfoService
)
{
this
.
cylinderInfoMapper
=
cylinderInfoMapper
;
this
.
cylinderInfoMapper
=
cylinderInfoMapper
;
this
.
questionInfoService
=
questionInfoService
;
this
.
questionInfoService
=
questionInfoService
;
this
.
cylinderInspectionService
=
cylinderInspectionService
;
}
}
@SchedulerLock
(
name
=
"overdueQuestionJobCylinder"
,
lockAtMostFor
=
"PT1H"
)
/**
* 检验超期
*/
@SchedulerLock
(
name
=
"genOverdueQuestionJobCylinder"
,
lockAtMostFor
=
"PT1H"
)
@Scheduled
(
cron
=
"${inspection.overdue.job.cron:0 0 2 * * ?}"
)
@Scheduled
(
cron
=
"${inspection.overdue.job.cron:0 0 2 * * ?}"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
genOverdueQuestion
()
{
public
void
genOverdueQuestion
()
{
List
<
CylinderInfoDto
>
cylinder
Info
=
cylinderInfoMapper
.
queryCylinderOfInspectionOverdue
();
List
<
CylinderInfoDto
>
cylinder
List
=
cylinderInfoMapper
.
queryCylinderOfInspectionOverdue
();
List
<
CylinderQuestionInfo
>
cylinderQuestionInfos
=
cylinder
Info
.
stream
().
map
(
cylinderInfoDto
->
{
List
<
CylinderQuestionInfo
>
cylinderQuestionInfos
=
cylinder
List
.
stream
().
map
(
cylinderInfoDto
->
{
CylinderQuestionInfo
cylinderQuestionInfo
=
new
CylinderQuestionInfo
();
CylinderQuestionInfo
cylinderQuestionInfo
=
new
CylinderQuestionInfo
();
cylinderQuestionInfo
.
setQuestionType
(
QuestionTypeEnum
.
JYCQ
.
getCode
());
cylinderQuestionInfo
.
setQuestionType
(
QuestionTypeEnum
.
JYCQ
.
getCode
());
cylinderQuestionInfo
.
setQuestionTypeName
(
QuestionTypeEnum
.
JYCQ
.
getName
());
cylinderQuestionInfo
.
setQuestionTypeName
(
QuestionTypeEnum
.
JYCQ
.
getName
());
cylinderQuestionInfo
.
setHappenDate
(
new
Date
());
return
fillCommonField
(
cylinderInfoDto
,
cylinderQuestionInfo
);
cylinderQuestionInfo
.
setRecDate
(
new
Date
());
cylinderQuestionInfo
.
setRegionCode
(
cylinderInfoDto
.
getRegionCode
());
cylinderQuestionInfo
.
setQuestionObjectId
(
cylinderInfoDto
.
getSequenceCode
());
cylinderQuestionInfo
.
setQuestionObjectName
(
cylinderInfoDto
.
getFactoryNum
());
cylinderQuestionInfo
.
setQuestionAttributionId
(
cylinderInfoDto
.
getAppId
());
cylinderQuestionInfo
.
setQuestionAttributionName
(
cylinderInfoDto
.
getUnitName
());
return
cylinderQuestionInfo
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
if
(
cylinderQuestionInfos
.
size
()
>
0
)
{
if
(
cylinderQuestionInfos
.
size
()
>
0
)
{
questionInfoService
.
saveBatch
(
cylinderQuestionInfos
);
questionInfoService
.
saveBatch
(
cylinderQuestionInfos
);
}
}
}
}
/**
* 检验不合格任务
*/
@SchedulerLock
(
name
=
"genInspectionUnqualifiedQuestionJobCylinder"
,
lockAtMostFor
=
"PT1H"
)
@Scheduled
(
cron
=
"${inspection.unqualified.job.cron:0 0/5 * * * ?}"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
genInspectionUnqualifiedQuestion
()
{
List
<
CylinderInfoDto
>
cylinderList
=
cylinderInfoMapper
.
queryCylinderOfUnqualifiedQuestion
();
List
<
CylinderQuestionInfo
>
cylinderQuestionInfos
=
cylinderList
.
stream
().
map
(
cylinderInfoDto
->
{
CylinderQuestionInfo
cylinderQuestionInfo
=
new
CylinderQuestionInfo
();
cylinderQuestionInfo
.
setQuestionType
(
QuestionTypeEnum
.
JYBHG
.
getCode
());
cylinderQuestionInfo
.
setQuestionTypeName
(
QuestionTypeEnum
.
JYBHG
.
getName
());
return
fillCommonField
(
cylinderInfoDto
,
cylinderQuestionInfo
);
}).
collect
(
Collectors
.
toList
());
if
(
cylinderQuestionInfos
.
size
()
>
0
)
{
questionInfoService
.
saveBatch
(
cylinderQuestionInfos
);
updateDealStatusAfterJobDeal
(
cylinderList
);
}
}
private
void
updateDealStatusAfterJobDeal
(
List
<
CylinderInfoDto
>
cylinderList
)
{
LambdaUpdateWrapper
<
CylinderInspection
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
cylinderList
.
forEach
(
cylinder
->
{
updateWrapper
.
eq
(
BaseEntity:
:
getSequenceNbr
,
cylinder
.
getSequenceNbr
());
updateWrapper
.
set
(
CylinderInspection:
:
getIsDealQuestion
,
true
);
cylinderInspectionService
.
update
(
updateWrapper
);
});
}
@NotNull
private
CylinderQuestionInfo
fillCommonField
(
CylinderInfoDto
cylinderInfoDto
,
CylinderQuestionInfo
cylinderQuestionInfo
)
{
cylinderQuestionInfo
.
setHappenDate
(
new
Date
());
cylinderQuestionInfo
.
setRecDate
(
new
Date
());
cylinderQuestionInfo
.
setRegionCode
(
cylinderInfoDto
.
getRegionCode
());
cylinderQuestionInfo
.
setQuestionObjectId
(
cylinderInfoDto
.
getSequenceCode
());
cylinderQuestionInfo
.
setQuestionObjectName
(
cylinderInfoDto
.
getFactoryNum
());
cylinderQuestionInfo
.
setQuestionAttributionId
(
cylinderInfoDto
.
getAppId
());
cylinderQuestionInfo
.
setQuestionAttributionName
(
cylinderInfoDto
.
getUnitName
());
return
cylinderQuestionInfo
;
}
}
}
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 @
dc18bb94
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
controller
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cylinder
.
flc
.
biz
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
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
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
@@ -1349,9 +1350,16 @@ public class CylinderInfoController extends BaseController {
...
@@ -1349,9 +1350,16 @@ public class CylinderInfoController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"某个企业充装次数及累计充装量统计"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"某个企业充装次数及累计充装量统计"
)
@GetMapping
(
value
=
"/countFillingTimesAndQuantityByCompany"
)
@GetMapping
(
value
=
"/countFillingTimesAndQuantityByCompany"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
countFillingTimesAndQuantityByCompany
(
@RequestParam
(
value
=
"companyId"
)
String
companyId
,
public
ResponseModel
<
JSONObject
>
countFillingTimesAndQuantityByCompany
(
@RequestParam
(
value
=
"companyId"
)
String
companyId
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
String
startTime
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
String
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
String
endTime
)
{
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
String
endTime
)
{
return
ResponseHelper
.
buildResponse
(
cylinderInfoServiceImpl
.
getBaseMapper
().
countFillingTimesAndQuantityByCompany
(
companyId
,
startTime
,
endTime
));
return
ResponseHelper
.
buildResponse
(
cylinderInfoServiceImpl
.
countFillingTimesAndQuantityByCompany
(
companyId
,
startTime
,
endTime
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"市级为维度,各市的充装次数和累计充装量"
)
@GetMapping
(
value
=
"/countFillingTimesAndQuantityByCity"
)
public
ResponseModel
<
Object
>
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 @
dc18bb94
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
;
...
@@ -9,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -9,6 +10,7 @@ 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
;
...
@@ -33,6 +35,11 @@ import org.elasticsearch.client.RequestOptions;
...
@@ -33,6 +35,11 @@ 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.Aggregations
;
import
org.elasticsearch.search.aggregations.metrics.*
;
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
;
...
@@ -54,9 +61,11 @@ import java.text.NumberFormat;
...
@@ -54,9 +61,11 @@ import java.text.NumberFormat;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
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
;
/**
/**
* 气瓶基本信息服务实现类
* 气瓶基本信息服务实现类
...
@@ -69,6 +78,11 @@ import java.util.stream.Collectors;
...
@@ -69,6 +78,11 @@ import java.util.stream.Collectors;
public
class
CylinderInfoServiceImpl
extends
BaseService
<
CylinderInfoDto
,
CylinderInfo
,
CylinderInfoMapper
>
public
class
CylinderInfoServiceImpl
extends
BaseService
<
CylinderInfoDto
,
CylinderInfo
,
CylinderInfoMapper
>
implements
ICylinderInfoService
{
implements
ICylinderInfoService
{
public
static
final
String
REGION_CODE
=
"regionCode"
;
public
static
final
String
FILLING_TIMES
=
"fillingTimes"
;
public
static
final
String
FILLING_QUANTITY
=
"fillingQuantity"
;
public
static
final
String
REGION_NAME
=
"regionName"
;
private
static
final
String
INDEX_NAME
=
"cylinder_filling"
;
@Autowired
@Autowired
CylinderUnitServiceImpl
cylinderUnitServiceImpl
;
CylinderUnitServiceImpl
cylinderUnitServiceImpl
;
...
@@ -1208,4 +1222,104 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
...
@@ -1208,4 +1222,104 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
public
Page
<
CylinderInfoDto
>
cyinderOutInfoList
(
Page
<
CylinderInfoDto
>
page
,
CylinderInfoDto
cylinderInfoDto
,
String
sort
,
List
<
String
>
appids
)
{
public
Page
<
CylinderInfoDto
>
cyinderOutInfoList
(
Page
<
CylinderInfoDto
>
page
,
CylinderInfoDto
cylinderInfoDto
,
String
sort
,
List
<
String
>
appids
)
{
return
cylinderInfoMapper
.
cyinderOutInfoList
(
page
,
cylinderInfoDto
,
sort
,
appids
);
return
cylinderInfoMapper
.
cyinderOutInfoList
(
page
,
cylinderInfoDto
,
sort
,
appids
);
}
}
public
JSONObject
countFillingTimesAndQuantityByCompany
(
String
companyId
,
String
startTime
,
String
endTime
)
{
Map
<
String
,
Object
>
stringObjectMap
=
cylinderInfoMapper
.
countFillingTimesAndQuantityByCompany
(
companyId
,
startTime
,
endTime
);
// 组装成柱状图能渲染的格式
//{
// "seriesData": [
// {
// "data": [
// 3
// ],
// "name": "充装次数(次)"
// },
// {
// "data": [
// 1
// ],
// "name": "累计充装量(kg)"
// }
// ],
// "axisData": [
// "总数"
// ]
// }
String
template
=
"{\"seriesData\": [{\"data\": [%s],\"name\": \"充装次数(次)\"},{\"data\": [%s],\"name\": \"累计充装量(kg)\"}],\"axisData\": [\"总数\"]}"
;
String
format
=
String
.
format
(
template
,
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"fillingTimes"
))
?
0
:
stringObjectMap
.
get
(
"fillingTimes"
),
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"fillingQuantity"
))
?
0
:
stringObjectMap
.
get
(
"fillingQuantity"
));
return
JSON
.
parseObject
(
format
);
}
public
List
<
Map
<
String
,
Object
>>
countFillingTimesAndQuantityByCity
()
{
// 查询所有的市级城市
List
<
RegionModel
>
regionModelList
=
Systemctl
.
regionClient
.
queryByLevel
(
"2"
).
getResult
();
// 并行处理每个城市的数据
List
<
CompletableFuture
<
Map
<
String
,
Object
>>>
futures
=
regionModelList
.
stream
()
.
map
(
regionModel
->
CompletableFuture
.
supplyAsync
(()
->
esQuery
(
regionModel
)))
.
collect
(
Collectors
.
toList
());
return
futures
.
stream
()
.
map
(
CompletableFuture:
:
join
)
.
collect
(
Collectors
.
toList
());
}
private
Map
<
String
,
Object
>
esQuery
(
RegionModel
regionModel
)
{
SearchRequest
searchRequest
=
new
SearchRequest
(
INDEX_NAME
);
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
// 将 regionModel.getRegionCode() 转换成匹配中间部分的格式
String
regionCodePattern
=
"*"
+
regionModel
.
getRegionCode
()
+
"*"
;
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
must
(
QueryBuilders
.
wildcardQuery
(
"regionCode"
,
regionCodePattern
));
searchSourceBuilder
.
query
(
boolQueryBuilder
);
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
cardinality
(
"total_filling_count"
)
.
field
(
"sequenceNbr.keyword"
)
);
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
sum
(
"total_filling_quantity"
)
.
field
(
"fillingQuantity"
)
);
searchRequest
.
source
(
searchSourceBuilder
);
System
.
out
.
println
(
"Search Request: "
+
searchRequest
);
try
{
// 执行搜索请求
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
// 获取所有聚合结果
Aggregations
aggregations
=
searchResponse
.
getAggregations
();
ParsedCardinality
cardinalityAgg
=
aggregations
.
get
(
"total_filling_count"
);
long
uniqueCount
=
cardinalityAgg
.
getValue
();
Sum
sumAgg
=
aggregations
.
get
(
"total_filling_quantity"
);
double
totalSum
=
sumAgg
.
getValue
();
System
.
out
.
println
(
"填充数量的唯一值数量: "
+
uniqueCount
);
System
.
out
.
println
(
"填充量的总和: "
+
totalSum
);
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
REGION_CODE
,
regionModel
.
getRegionCode
());
resultMap
.
put
(
REGION_NAME
,
regionModel
.
getRegionName
());
resultMap
.
put
(
FILLING_TIMES
,
uniqueCount
);
resultMap
.
put
(
FILLING_QUANTITY
,
totalSum
);
return
resultMap
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
Collections
.
emptyMap
();
}
}
}
\ 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