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
c51e5840
Commit
c51e5840
authored
Dec 20, 2022
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改气瓶充装信息统计与定时任务数据同步不一致问题
parent
a46a2470
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
162 additions
and
83 deletions
+162
-83
WebSecurityConfigurer.java
...n/java/com/yeejoin/amos/config/WebSecurityConfigurer.java
+25
-25
AmosTzsApplication.java
...iz/src/main/java/com/yeejoin/amos/AmosTzsApplication.java
+12
-8
FillingRecordSyncListener.java
...ot/module/tzs/biz/listener/FillingRecordSyncListener.java
+31
-0
CylinderFillingCheckDataUnitServiceImpl.java
...service/impl/CylinderFillingCheckDataUnitServiceImpl.java
+9
-0
CylinderInfoServiceImpl.java
...ule/tzs/flc/biz/service/impl/CylinderInfoServiceImpl.java
+85
-50
No files found.
amos-boot-data/amos-boot-data-openapi/src/main/java/com/yeejoin/amos/config/WebSecurityConfigurer.java
View file @
c51e5840
package
com
.
yeejoin
.
amos
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
@Configuration
@EnableWebSecurity
public
class
WebSecurityConfigurer
extends
WebSecurityConfigurerAdapter
{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
httpBasic
().
and
()
.
authorizeRequests
()
.
regexMatchers
(
"^(?!/actuator).*$"
).
permitAll
()
.
regexMatchers
(
"/actuator/health"
).
permitAll
()
.
regexMatchers
(
"/actuator/info"
).
permitAll
()
.
regexMatchers
(
"/actuator/metrics"
).
permitAll
()
.
antMatchers
(
"/actuator/metrics/**"
).
permitAll
()
.
anyRequest
()
.
authenticated
()
.
and
().
csrf
().
disable
();
}
}
//
package com.yeejoin.amos.config;
//
//
import org.springframework.context.annotation.Configuration;
//
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//
//
@Configuration
//
@EnableWebSecurity
//
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
//
//
@Override
//
protected void configure(HttpSecurity http) throws Exception {
//
http.httpBasic().and()
//
.authorizeRequests()
//
.regexMatchers("^(?!/actuator).*$").permitAll()
//
.regexMatchers("/actuator/health").permitAll()
//
.regexMatchers("/actuator/info").permitAll()
//
.regexMatchers("/actuator/metrics").permitAll()
//
.antMatchers("/actuator/metrics/**").permitAll()
//
.anyRequest()
//
.authenticated()
//
.and().csrf().disable();
//
}
//
}
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/AmosTzsApplication.java
View file @
c51e5840
package
com
.
yeejoin
.
amos
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
com.yeejoin.amos.boot.biz.common.utils.oConvertUtils
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.BaseEnterpriseMqTtlListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.CarcylUnitInspectMqTtlListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.FillingRecordSyncListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.PrivilegeCompanyDeleteListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.PrivilegeCompanyUpdateAddListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.slf4j.Logger
;
...
...
@@ -26,11 +29,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
com.yeejoin.amos.boot.biz.common.utils.oConvertUtils
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.BaseEnterpriseMqTtlListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.listener.CarcylUnitInspectMqTtlListener
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
/**
* <pre>
...
...
@@ -73,6 +73,9 @@ public class AmosTzsApplication {
private
PrivilegeCompanyDeleteListener
privilegeCompanyDeleteListener
;
@Autowired
private
FillingRecordSyncListener
fillingRecordSyncListener
;
@Autowired
ICylinderInfoService
cylinderInfoServiceImpl
;
public
static
void
main
(
String
[]
args
)
throws
UnknownHostException
{
...
...
@@ -98,6 +101,7 @@ public class AmosTzsApplication {
emqKeeper
.
getMqttClient
().
subscribe
(
"/tm/tz_base_enterprise_info"
,
1
,
baseEnterpriseMqTtlListener
);
emqKeeper
.
getMqttClient
().
subscribe
(
"/tz/privilege_company_add_update"
,
1
,
privilegeCompanyUpdateAddListener
);
emqKeeper
.
getMqttClient
().
subscribe
(
"/tz/privilege_company_delete"
,
1
,
privilegeCompanyDeleteListener
);
emqKeeper
.
getMqttClient
().
subscribe
(
"/tzs/sync/fillingRecord"
,
1
,
fillingRecordSyncListener
);
// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam", 1, examMqTtlListener);
// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam_record", 1, examMqTtRecordListener);
}
...
...
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/listener/FillingRecordSyncListener.java
0 → 100644
View file @
c51e5840
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
listener
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderInfoServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
/**
* @Description: 气瓶充装信息mqtt监听服务
* @Author: tb
* @Date: 2022/12/20
*/
@Component
@Slf4j
public
class
FillingRecordSyncListener
extends
EmqxListener
{
@Autowired
CylinderInfoServiceImpl
cylinderInfoService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
System
.
out
.
println
(
message
);
if
(!
ValidationUtil
.
isEmpty
(
message
.
toString
()))
{
cylinderInfoService
.
synUnitFillingCheckData
();
}
}
}
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/biz/service/impl/CylinderFillingCheckDataUnitServiceImpl.java
View file @
c51e5840
...
...
@@ -30,4 +30,12 @@ public class CylinderFillingCheckDataUnitServiceImpl extends BaseService<Cylinde
public
List
<
CylinderFillingCheckDataUnitDto
>
queryForCylinderFillingCheckDataUnitList
()
{
return
this
.
queryForList
(
""
,
false
);
}
/**
* 列表查询 示例
*/
public
List
<
CylinderFillingCheckDataUnitDto
>
queryCylinderFillingCheckListByParam
(
String
appId
,
String
fillingDate
)
{
return
this
.
queryForList
(
""
,
false
,
appId
,
fillingDate
);
}
}
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/biz/service/impl/CylinderInfoServiceImpl.java
View file @
c51e5840
...
...
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -556,66 +557,100 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
public
void
synUnitFillingCheckData
()
{
cylinderFillingCheckDataUnitServiceImpl
.
remove
(
new
LambdaQueryWrapper
<
CylinderFillingCheckDataUnit
>());
//
cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit
(
cylinderUnit
->
{
List
<
CylinderFillingCheckDataUnitDto
>
allCylinderFillingCheckDataList
=
cylinderFillingCheckDataUnitServiceImpl
.
queryCylinderFillingCheckListByParam
(
cylinderUnit
.
getAppId
(),
null
);
// 按照月份 获取数据 取一年数据
Calendar
c
=
Calendar
.
getInstance
();
// 按月份获取充装量
// 当月与上月 对比获取数据
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
// 获取当月数据
CylinderFillingCheckDataUnitDto
temp
=
new
CylinderFillingCheckDataUnitDto
();
String
year
=
c
.
get
(
Calendar
.
YEAR
)
+
""
;
int
month
=
c
.
get
(
Calendar
.
MONTH
)
+
1
;
String
monthStr
=
month
<
10
?
"0"
+
month
:
month
+
""
;
temp
.
setFillingMonth
(
monthStr
);
temp
.
setFillingYear
(
year
);
temp
.
setFillingDate
(
year
+
"-"
+
monthStr
);
Integer
countThisMonth
=
cylinderFillingRecordServiceImpl
.
getFillingCountByMonth
(
cylinderUnit
.
getAppId
(),
c
.
getTime
());
temp
.
setTotalSum
((
long
)
countThisMonth
);
// 获取本月数据
Integer
fillingCount
=
cylinderFillingServiceImpl
.
getFillingCountByMonth
(
cylinderUnit
.
getAppId
(),
c
.
getTime
());
Integer
fillingCheckCount
=
cylinderFillingCheckServiceImpl
.
getFillingCountByMonth
(
cylinderUnit
.
getAppId
(),
c
.
getTime
());
// 充装前检查率:充装前检查次数/充装次数
double
before
=
0
d
;
if
(
countThisMonth
!=
0
)
{
before
=
(
double
)
(
fillingCount
)
/
(
double
)
countThisMonth
;
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if
(
ValidationUtil
.
isEmpty
(
allCylinderFillingCheckDataList
))
{
// 按月份获取充装量
// 当月与上月 对比获取数据
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
// 获取当月数据
CylinderFillingCheckDataUnitDto
temp
=
new
CylinderFillingCheckDataUnitDto
();
calcCylinderFillingCheckDataUnitData
(
cylinderUnit
,
c
,
temp
);
c
.
add
(
Calendar
.
MONTH
,
-
1
);
cylinderFillingCheckDataUnitServiceImpl
.
createWithModel
(
temp
);
}
temp
.
setFillingCount
((
long
)
fillingCount
);
temp
.
setFillingPercent
(
before
*
100
);
// 充装后检查率:充装后检查次数/充装次数
double
after
=
0
d
;
if
(
countThisMonth
!=
0
)
{
after
=
(
double
)
(
fillingCheckCount
)
/
(
double
)
countThisMonth
;
}
temp
.
setFillingCheckCount
((
long
)
fillingCheckCount
);
temp
.
setFillingCheckPercent
(
after
*
100
);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double
passed
=
0
d
;
// 充装前检查合格次数
Integer
fillingPassedCount
=
cylinderFillingServiceImpl
.
getFillingPassedCountByMonth
(
cylinderUnit
.
getAppId
(),
c
.
getTime
());
// 充装后检查合格次数
Integer
fillingCheckPassedCount
=
cylinderFillingCheckServiceImpl
.
getFillingPassedCountByMonth
(
cylinderUnit
.
getAppId
(),
c
.
getTime
());
if
(
countThisMonth
!=
0
)
{
passed
=
((
double
)
(
fillingPassedCount
)
+
(
double
)
fillingCheckPassedCount
)
/
(
double
)
(
2
*
countThisMonth
);
}
else
{
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar
current
=
Calendar
.
getInstance
();
String
year
=
current
.
get
(
Calendar
.
YEAR
)
+
""
;
int
month
=
current
.
get
(
Calendar
.
MONTH
)
+
1
;
String
monthStr
=
month
<
10
?
"0"
+
month
:
month
+
""
;
List
<
CylinderFillingCheckDataUnitDto
>
existDataDtoList
=
cylinderFillingCheckDataUnitServiceImpl
.
queryCylinderFillingCheckListByParam
(
cylinderUnit
.
getAppId
(),
year
+
"-"
+
monthStr
);
CylinderFillingCheckDataUnitDto
tempDto
=
new
CylinderFillingCheckDataUnitDto
();
if
(!
ValidationUtil
.
isEmpty
(
existDataDtoList
)
&&
!
ValidationUtil
.
isEmpty
(
existDataDtoList
.
get
(
0
)))
{
tempDto
=
existDataDtoList
.
get
(
0
);
calcCylinderFillingCheckDataUnitData
(
cylinderUnit
,
current
,
tempDto
);
cylinderFillingCheckDataUnitServiceImpl
.
updateWithModel
(
tempDto
);
}
else
if
(
ValidationUtil
.
isEmpty
(
existDataDtoList
))
{
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData
(
cylinderUnit
,
current
,
tempDto
);
cylinderFillingCheckDataUnitServiceImpl
.
createWithModel
(
tempDto
);
}
temp
.
setFillingPassedCount
((
long
)
(
fillingPassedCount
+
fillingCheckPassedCount
));
temp
.
setTotalSumDouble
((
long
)
2
*
countThisMonth
);
temp
.
setFillingPassedPercent
(
passed
*
100
);
temp
.
setAppId
(
cylinderUnit
.
getAppId
());
c
.
add
(
Calendar
.
MONTH
,
-
1
);
cylinderFillingCheckDataUnitServiceImpl
.
createWithModel
(
temp
);
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public
void
calcCylinderFillingCheckDataUnitData
(
CylinderUnit
cylinderUnit
,
Calendar
calender
,
CylinderFillingCheckDataUnitDto
cylinderFillingCheckDataUnitDto
)
{
String
year
=
calender
.
get
(
Calendar
.
YEAR
)
+
""
;
int
month
=
calender
.
get
(
Calendar
.
MONTH
)
+
1
;
String
monthStr
=
month
<
10
?
"0"
+
month
:
month
+
""
;
cylinderFillingCheckDataUnitDto
.
setFillingMonth
(
monthStr
);
cylinderFillingCheckDataUnitDto
.
setFillingYear
(
year
);
cylinderFillingCheckDataUnitDto
.
setFillingDate
(
year
+
"-"
+
monthStr
);
Integer
countThisMonth
=
cylinderFillingRecordServiceImpl
.
getFillingCountByMonth
(
cylinderUnit
.
getAppId
(),
calender
.
getTime
());
cylinderFillingCheckDataUnitDto
.
setTotalSum
((
long
)
countThisMonth
);
// 获取本月数据
Integer
fillingCount
=
cylinderFillingServiceImpl
.
getFillingCountByMonth
(
cylinderUnit
.
getAppId
(),
calender
.
getTime
());
Integer
fillingCheckCount
=
cylinderFillingCheckServiceImpl
.
getFillingCountByMonth
(
cylinderUnit
.
getAppId
(),
calender
.
getTime
());
// 充装前检查率:充装前检查次数/充装次数
double
before
=
0
d
;
if
(
countThisMonth
!=
0
)
{
before
=
(
double
)
(
fillingCount
)
/
(
double
)
countThisMonth
;
}
cylinderFillingCheckDataUnitDto
.
setFillingCount
((
long
)
fillingCount
);
cylinderFillingCheckDataUnitDto
.
setFillingPercent
(
before
*
100
);
// 充装后检查率:充装后检查次数/充装次数
double
after
=
0
d
;
if
(
countThisMonth
!=
0
)
{
after
=
(
double
)
(
fillingCheckCount
)
/
(
double
)
countThisMonth
;
}
cylinderFillingCheckDataUnitDto
.
setFillingCheckCount
((
long
)
fillingCheckCount
);
cylinderFillingCheckDataUnitDto
.
setFillingCheckPercent
(
after
*
100
);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double
passed
=
0
d
;
// 充装前检查合格次数
Integer
fillingPassedCount
=
cylinderFillingServiceImpl
.
getFillingPassedCountByMonth
(
cylinderUnit
.
getAppId
(),
calender
.
getTime
());
// 充装后检查合格次数
Integer
fillingCheckPassedCount
=
cylinderFillingCheckServiceImpl
.
getFillingPassedCountByMonth
(
cylinderUnit
.
getAppId
(),
calender
.
getTime
());
if
(
countThisMonth
!=
0
)
{
passed
=
((
double
)
(
fillingPassedCount
)
+
(
double
)
fillingCheckPassedCount
)
/
(
double
)
(
2
*
countThisMonth
);
}
cylinderFillingCheckDataUnitDto
.
setFillingPassedCount
((
long
)
(
fillingPassedCount
+
fillingCheckPassedCount
));
cylinderFillingCheckDataUnitDto
.
setTotalSumDouble
((
long
)
2
*
countThisMonth
);
cylinderFillingCheckDataUnitDto
.
setFillingPassedPercent
(
passed
*
100
);
cylinderFillingCheckDataUnitDto
.
setAppId
(
cylinderUnit
.
getAppId
());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
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