Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skboot-zhongye
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
a552dad8
由
康伟
编写于
2025-02-20 16:44:15 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
kangwei: 完善能耗分析,添加单位,解决value空值,解决环比、同比数据数据错误问题
1 个父辈
0a31951e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
76 行增加
和
19 行删除
sk-base-common/src/main/java/com/skua/common/report/ReportViewUtil.java
sk-base-common/src/main/java/com/skua/tool/util/DateUtils.java
sk-module-biz/src/main/java/com/skua/modules/algorithm/service/impl/ReportItemvService.java
sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java
sk-module-datafill/src/main/java/com/skua/modules/report/vo/FRportlCommandCenterVO.java
sk-base-common/src/main/java/com/skua/common/report/ReportViewUtil.java
查看文件 @
a552dad
...
...
@@ -325,8 +325,8 @@ public class ReportViewUtil {
public
static
ReportItemVO
getSumValueByTBHB
(
String
reportId
,
String
fields
,
String
departIds
,
String
startTime
,
String
endTime
,
String
operatorSign
){
ReportItemVO
reportItemVO
=
null
;
String
dataViewName3a24_value
=
ReportViewUtil
.
buildViewLike
(
reportId
,
fields
,
departIds
,
startTime
,
endTime
,
operatorSign
);
String
dataViewName3a24_valueHB
=
ReportViewUtil
.
buildViewLike
(
reportId
,
fields
,
departIds
,
DateUtils
.
getHbDate
(
startTime
),
DateUtils
.
getHb
Date
(
endTime
)
,
operatorSign
);
String
dataViewName3a24_valueTB
=
ReportViewUtil
.
buildViewLike
(
reportId
,
fields
,
departIds
,
DateUtils
.
getTbDate
(
startTime
),
DateUtils
.
get
TbDate
(
endTime
)
,
operatorSign
);
String
dataViewName3a24_valueHB
=
ReportViewUtil
.
buildViewLike
(
reportId
,
fields
,
departIds
,
DateUtils
.
getHbDate
(
startTime
),
DateUtils
.
getHb
MonthDate
(
endTime
)+
"-31"
,
operatorSign
);
String
dataViewName3a24_valueTB
=
ReportViewUtil
.
buildViewLike
(
reportId
,
fields
,
departIds
,
DateUtils
.
getTbDate
(
startTime
),
DateUtils
.
get
HbMonthDate
(
endTime
)+
"-31"
,
operatorSign
);
String
fieldsSql
=
""
;
if
(
StringUtils
.
isNotEmpty
(
fields
))
{
...
...
@@ -343,6 +343,7 @@ public class ReportViewUtil {
sql
+=
" from dual"
;
JdbcTemplate
masterDB
=
(
JdbcTemplate
)
SpringContextUtils
.
getBean
(
"master"
);
List
<
ReportItemVO
>
dataList
=
masterDB
.
query
(
sql
,
new
BeanPropertyRowMapper
<
ReportItemVO
>(
ReportItemVO
.
class
));
if
(
dataList
!=
null
&&
!
dataList
.
isEmpty
()){
reportItemVO
=
dataList
.
get
(
0
);
...
...
sk-base-common/src/main/java/com/skua/tool/util/DateUtils.java
查看文件 @
a552dad
...
...
@@ -10,6 +10,7 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
import
java.time.YearMonth
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
import
java.util.*
;
/**
...
...
@@ -71,9 +72,34 @@ public class DateUtils {
};
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
);
System
.
out
.
println
(
getHbMonth
(
formatDate
(
"2024-01-01"
,
"yyyy-MM"
)));
// System.out.println("天数差异: " + daysBetween);
}
/***
* 判断一个时间字符串是否表示当前月,并且如果它是当前月的话,再与当前时间进行比较
* @param endTime
* @return
*/
public
static
String
checkDateByCurrentDate
(
String
endTime
){
LocalDate
currentDate
=
LocalDate
.
now
();
// 定义日期格式
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
// 将字符串转换为LocalDate对象
LocalDate
endDate
=
LocalDate
.
parse
(
endTime
,
formatter
);
System
.
out
.
println
(
endDate
.
getYear
());
// 比较年份和月份
if
(
endDate
.
getYear
()
==
currentDate
.
getYear
()
&&
endDate
.
getMonth
()
==
currentDate
.
getMonth
())
{
// 如果是当前月,比较时间
if
(
currentDate
.
isBefore
(
endDate
))
{
// 当前时间小于给定时间,返回当前时间
// System.out.println("当前时间小于给定时间,当前时间: " + currentDate);
return
currentDate
.
toString
();
}
}
return
endTime
;
}
/***
* 字符串日期格式化
...
...
@@ -593,6 +619,30 @@ public class DateUtils {
return
previousMonth
.
format
(
formatter
);
// 环比
}
/***
* 环比年月
* @param dateStr yyyy-MM-dd
* @return
*/
public
static
String
getHbMonthDate
(
String
dateStr
)
{
// 定义日期格式
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
try
{
// 将日期字符串转换为LocalDate对象
LocalDate
date
=
LocalDate
.
parse
(
dateStr
,
formatter
);
// 获取上个月的日期
LocalDate
lastMonth
=
date
.
minusMonths
(
1
);
// 格式化上个月的日期为字符串
String
lastMonthStr
=
lastMonth
.
format
(
formatter
);
// 打印结果
// System.out.println("原始日期: " + dateStr);
// System.out.println("上个月的日期字符串: " + lastMonthStr);
return
lastMonthStr
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"日期字符串格式错误或解析失败: "
+
e
.
getMessage
());
}
return
null
;
}
/**
...
...
sk-module-biz/src/main/java/com/skua/modules/algorithm/service/impl/ReportItemvService.java
查看文件 @
a552dad
...
...
@@ -397,11 +397,11 @@ public class ReportItemvService {
ReportItemVO
csl_reportVO
=
ReportViewUtil
.
getSumValueByTBHB
(
ReportConstant
.
view2119
,
ReportConstant
.
field_CSL
,
departId
,
startTime
,
endTime
);
//当月数据/环比、同比
FRportlCommandCenterVO
nowMonthVO
=
new
FRportlCommandCenterVO
(
"月总电耗
"
,
JSUtils
.
divide
(
dlhjData
.
getValue
(),
10000
),
JSUtils
.
divide
(
dlhjData
.
getValueTb
(),
10000
),
JSUtils
.
divide
(
dlhjData
.
getValueHb
(),
10000
));
FRportlCommandCenterVO
nowMonthVO
=
new
FRportlCommandCenterVO
(
"月总电耗
(万kwh)"
,
"万kwh"
,
JSUtils
.
divide
(
dlhjData
.
getValue
(),
10000
),
JSUtils
.
divide
(
dlhjData
.
getValueTb
(),
10000
),
JSUtils
.
divide
(
dlhjData
.
getValueHb
(),
10000
));
//日均数据:/环比/同比
FRportlCommandCenterVO
lastMonthVO
=
new
FRportlCommandCenterVO
(
"吨水电费
"
,
JSUtils
.
divide
(
dfValueSql
,
csl_reportVO
.
getValue
())
,
JSUtils
.
divide
(
dfTBValue
,
csl_reportVO
.
getValueTb
())
,
JSUtils
.
divide
(
dfHBValue
,
csl_reportVO
.
getValueHb
()));
FRportlCommandCenterVO
lastMonthVO
=
new
FRportlCommandCenterVO
(
"吨水电费
(元/t)"
,
"元/t"
,
JSUtils
.
divide
(
dfValue
,
csl_reportVO
.
getValue
())
,
JSUtils
.
divide
(
dfTBValue
,
csl_reportVO
.
getValueTb
())
,
JSUtils
.
divide
(
dfHBValue
,
csl_reportVO
.
getValueHb
()));
//吨水消耗
FRportlCommandCenterVO
lastYearVo
=
new
FRportlCommandCenterVO
(
"吨水电耗"
,
dsdh_value
,
dsdh_value_Tb
,
dsdh_value_Hb
);
FRportlCommandCenterVO
lastYearVo
=
new
FRportlCommandCenterVO
(
"吨水电耗
(kwh/t)"
,
"kwh/t
"
,
dsdh_value
,
dsdh_value_Tb
,
dsdh_value_Hb
);
fRportlCommandCenterVOList
.
add
(
nowMonthVO
)
;
fRportlCommandCenterVOList
.
add
(
lastMonthVO
)
;
fRportlCommandCenterVOList
.
add
(
lastYearVo
)
;
...
...
sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java
查看文件 @
a552dad
...
...
@@ -70,7 +70,7 @@ public class SysCommandCentreController {
List
<
FRportlCommandCenterVO
>
fReportItemvList
=
new
ArrayList
<>();
//返回集合对象
DateVO
dateVO
=
new
DateVO
(
reportItemvParam
.
getStartDate
());
String
departIds
=
BaseContextHandler
.
getDeparts
();
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
//本月数据
...
...
@@ -108,7 +108,7 @@ public class SysCommandCentreController {
public
Result
<
DepartLoadRateResultVO
>
statisticsByLoadRate
(
ReportItemvParam
reportItemvParam
)
{
Result
<
DepartLoadRateResultVO
>
result
=
new
Result
<>();
String
departIds
=
BaseContextHandler
.
getDeparts
();
//1818214519948836864,1711662624459804674
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
Integer
loadRateType
=
reportItemvParam
.
getLoadRateType
();
...
...
@@ -126,7 +126,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
WaterTreatmentVO
>>
getCLSLXQ
(
ReportItemvParam
reportItemvParam
){
Result
<
List
<
WaterTreatmentVO
>>
result
=
new
Result
<>();
String
departIds
=
BaseContextHandler
.
getDeparts
();
//1818214519948836864,1711662624459804674
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
List
<
WaterTreatmentVO
>
waterTrendVOList
=
commandCentreService
.
statisticsCLSLXQ
(
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
(),
departIds
);
...
...
@@ -141,7 +141,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
FRportlCommandCenterVO
>>
statisticsByCement
(
ReportItemvParam
reportItemvParam
)
{
Result
<
List
<
FRportlCommandCenterVO
>>
result
=
new
Result
();
String
departIds
=
BaseContextHandler
.
getDeparts
();
//1818214519948836864,1711662624459804674
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
List
<
FRportlCommandCenterVO
>
dataList
=
reportItemvService
.
statisticsByCement
(
departIds
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -155,7 +155,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
ReportItemVO
>>
statisticsByCementList
(
ReportItemvParam
reportItemvParam
)
{
Result
<
List
<
ReportItemVO
>>
result
=
new
Result
();
String
departIds
=
BaseContextHandler
.
getDeparts
();
//1818214519948836864,1711662624459804674
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
List
<
ReportItemVO
>
dataList
=
reportItemvService
.
statisticsByCementList
(
departIds
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -182,7 +182,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
FRportlCommandCenterVO
>>
statisticsByYh
(
ReportItemvParam
reportItemvParam
)
{
Result
<
List
<
FRportlCommandCenterVO
>>
result
=
new
Result
();
String
departId
=
BaseContextHandler
.
getDeparts
();
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departId
=
reportItemvParam
.
getDepartIds
();
}
List
<
FRportlCommandCenterVO
>
dataList
=
reportItemvService
.
statisticsByYh
(
departId
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -197,7 +197,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
FRportlCommandCenterVO
>>
statisticsByElectricity
(
ReportItemvParam
reportItemvParam
)
{
Result
<
List
<
FRportlCommandCenterVO
>>
result
=
new
Result
();
String
departId
=
BaseContextHandler
.
getDeparts
();
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departId
=
reportItemvParam
.
getDepartIds
();
}
List
<
FRportlCommandCenterVO
>
dataList
=
reportItemvService
.
statisticsByElectricity
(
departId
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -210,7 +210,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
FRportlCommandCenterVO
>>
statisticsByElectricityNew
(
ReportItemvParam
reportItemvParam
)
{
Result
<
List
<
FRportlCommandCenterVO
>>
result
=
new
Result
();
String
departId
=
BaseContextHandler
.
getDeparts
();
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departId
=
reportItemvParam
.
getDepartIds
();
}
List
<
FRportlCommandCenterVO
>
dataList
=
reportItemvService
.
statisticsByElectricityNew
(
departId
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -225,7 +225,7 @@ public class SysCommandCentreController {
public
Result
<
List
<
ReportItemVO
>>
statisticsByElectricityList
(
ReportItemvParam
reportItemvParam
)
{
Result
<
List
<
ReportItemVO
>>
result
=
new
Result
();
String
departIds
=
BaseContextHandler
.
getDeparts
();
//1818214519948836864,1711662624459804674
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
List
<
ReportItemVO
>
dataList
=
reportItemvService
.
statisticsByElectricityList
(
departIds
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -242,7 +242,7 @@ public class SysCommandCentreController {
List
<
String
>
waterList
=
new
ArrayList
<>();
// 水集合
List
<
String
>
consumeList
=
new
ArrayList
<>();
//电耗集合
String
departIds
=
BaseContextHandler
.
getDeparts
();
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
List
<
ReportDateTrendVO
>
dlhjDateList
=
reportItemvService
.
getDayDateFieldList
(
ReportConstant
.
view3a24
,
"DLHJ"
,
departIds
,
reportItemvParam
.
getStartDate
(),
reportItemvParam
.
getEndDate
());
...
...
@@ -311,7 +311,7 @@ public class SysCommandCentreController {
reportItemvParam
.
setStartDate
(
DateUtils
.
formatDate
(
startDate
,
"YYYY-MM"
));
reportItemvParam
.
setEndDate
(
DateUtils
.
formatDate
(
endDate
,
"YYYY-MM"
));
String
departIds
=
BaseContextHandler
.
getDeparts
();
if
(
reportItemvParam
.
getDepartIds
()!=
null
){
if
(
StringUtils
.
isNotEmpty
(
reportItemvParam
.
getDepartIds
())
){
departIds
=
reportItemvParam
.
getDepartIds
();
}
reportItemvParam
.
setDepartIds
(
JSUtils
.
quoteEach
(
departIds
,
","
));
...
...
sk-module-datafill/src/main/java/com/skua/modules/report/vo/FRportlCommandCenterVO.java
查看文件 @
a552dad
...
...
@@ -47,7 +47,13 @@ public class FRportlCommandCenterVO implements Serializable {
this
.
valueTb
=
valueTb
;
this
.
valueHb
=
valueHb
;
}
public
FRportlCommandCenterVO
(
String
label
,
String
unit
,
String
value
,
String
valueTb
,
String
valueHb
)
{
this
.
label
=
label
;
this
.
unit
=
unit
;
this
.
value
=
value
;
this
.
valueTb
=
valueTb
;
this
.
valueHb
=
valueHb
;
}
public
FRportlCommandCenterVO
(
String
label
,
String
code
,
String
unit
,
String
value
,
String
valueTb
,
String
valueHb
)
{
this
.
label
=
label
;
this
.
code
=
code
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论