Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skboot-zhongye
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
3ed2d4ec
由
sonin
编写于
2025-04-25 10:34:35 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
设备统计分析 设备完好率
1 个父辈
99a09abe
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
41 行增加
和
10 行删除
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/impl/EquipmentAnalysisServiceImpl.java
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/impl/ProductionEquipmentServiceImpl.java
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/impl/EquipmentAnalysisServiceImpl.java
查看文件 @
3ed2d4e
...
...
@@ -49,7 +49,7 @@ public class EquipmentAnalysisServiceImpl implements IEquipmentAnalysisService {
.
in
(
StringUtils
.
isNotEmpty
(
departId
),
"depart_id"
,
departIdList
)
.
groupBy
(
"depart_id"
);
List
<
Map
<
String
,
Object
>>
equipmentInfoList
=
equipmentInfoService
.
listMaps
(
queryWrapper0
);
// 机构 => 设备数量
// 机构 => 设备数量
Map
<
String
,
Integer
>
departId2EquipCountMap
=
equipmentInfoList
.
stream
().
collect
(
Collectors
.
toMap
(
item
->
ConvertUtils
.
getString
(
item
.
get
(
"depart_id"
)),
item
->
Integer
.
parseInt
(
ConvertUtils
.
getString
(
item
.
get
(
"total"
))),
(
v1
,
v2
)
->
v2
));
// 查询设备的故障时间
QueryWrapper
<
EquipmentRepair
>
queryWrapper1
=
new
QueryWrapper
<>();
...
...
@@ -92,15 +92,17 @@ public class EquipmentAnalysisServiceImpl implements IEquipmentAnalysisService {
String
tmpDepartId
=
entry
.
getKey
();
int
equipCount
=
entry
.
getValue
();
// 计算完好率
long
value0
=
departId2Equip2FaultTimeMap
.
getOrDefault
(
tmpDepartId
,
new
HashMap
<>()).
values
().
stream
().
mapToLong
(
item
->
item
).
sum
();
long
value1
=
equipCount
*
interval
;
double
intactRate
=
1
-
1.0
*
value0
/
value1
;
long
faultSecond
=
departId2Equip2FaultTimeMap
.
getOrDefault
(
tmpDepartId
,
new
HashMap
<>()).
values
().
stream
().
mapToLong
(
item
->
item
).
sum
();
long
allSecond
=
equipCount
*
interval
;
double
intactRate
=
1
-
1.0
*
faultSecond
/
allSecond
;
String
departName
=
sysDepartDictMap
.
get
(
tmpDepartId
);
// 结果
Map
<
String
,
Object
>
resMap
=
new
HashMap
<>(
4
);
resMap
.
put
(
"departId"
,
tmpDepartId
);
resMap
.
put
(
"departName"
,
departName
);
resMap
.
put
(
"intactRate"
,
intactRate
);
resMap
.
put
(
"faultSecond"
,
faultSecond
);
resMap
.
put
(
"intactSecond"
,
allSecond
-
faultSecond
);
resMapList
.
add
(
resMap
);
}
return
resMapList
;
...
...
@@ -170,13 +172,15 @@ public class EquipmentAnalysisServiceImpl implements IEquipmentAnalysisService {
long
interval
=
DateUtils
.
dateStr2Sec
(
timeRangeArray
[
1
],
BusinessConstant
.
dateFormat
)
-
DateUtils
.
dateStr2Sec
(
timeRangeArray
[
0
],
BusinessConstant
.
dateFormat
)
+
1
;
Map
<
String
,
Long
>
equip2FaultTimeMap
=
entry
.
getValue
();
// 计算完好率
long
value0
=
equip2FaultTimeMap
.
values
().
stream
().
mapToLong
(
Long:
:
longValue
).
sum
();
long
value1
=
equipTotal
*
interval
;
double
intactRate
=
1
-
1.0
*
value0
/
value1
;
long
faultSecond
=
equip2FaultTimeMap
.
values
().
stream
().
mapToLong
(
Long:
:
longValue
).
sum
();
long
allSecond
=
equipTotal
*
interval
;
double
intactRate
=
1
-
1.0
*
faultSecond
/
allSecond
;
// 结果
Map
<
String
,
Object
>
resMap
=
new
HashMap
<>(
4
);
resMap
.
put
(
"time"
,
timeRange
);
resMap
.
put
(
"intactRate"
,
intactRate
);
resMap
.
put
(
"faultSecond"
,
faultSecond
);
resMap
.
put
(
"intactSecond"
,
allSecond
-
faultSecond
);
resMapList
.
add
(
resMap
);
}
return
resMapList
;
...
...
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/impl/ProductionEquipmentServiceImpl.java
查看文件 @
3ed2d4e
...
...
@@ -3,6 +3,7 @@ package com.skua.modules.equipment.service.impl;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.skua.common.constant.BusinessConstant
;
import
com.skua.core.context.BaseContextHandler
;
import
com.skua.core.util.ConvertUtils
;
import
com.skua.core.util.DoubleOperaUtils
;
...
...
@@ -10,9 +11,11 @@ import com.skua.modules.common.mapper.CommonSqlMapper;
import
com.skua.modules.common.service.ICommonSqlService
;
import
com.skua.modules.equipment.dto.ReportStatisticsDTO
;
import
com.skua.modules.equipment.mapper.ProductionEquipmentMapper
;
import
com.skua.modules.equipment.service.IEquipmentAnalysisService
;
import
com.skua.modules.equipment.service.IProductionEquipmentService
;
import
com.skua.modules.equipment.vo.*
;
import
com.skua.tool.util.DateUtils
;
import
com.skua.tool.util.DigitalUtils
;
import
com.skua.tool.util.JSUtils
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -43,6 +46,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
private
ProductionEquipmentMapper
productionEquipmentMapper
;
@Autowired
private
ICommonSqlService
commonSqlService
;
@Autowired
private
IEquipmentAnalysisService
equipmentAnalysisService
;
private
static
final
String
MONTH_START
=
"-01 00:00:00"
;
private
static
final
String
MONTH_END
=
"-31 23:59:59"
;
...
...
@@ -74,6 +79,13 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
Double
sbwhCost
=
0
d
;
//维护费用
Double
sbbyCost
=
0
d
;
//保养费用
Double
jjwxCost
=
0
d
;
//基建维修费用
// 开始时间往前推一个月,方便计算环比
String
startTime0
=
DateUtils
.
date2Str
(
DateUtils
.
prevMonth
(
DateUtils
.
str2Date
(
reportStatisticsDTO
.
getStartTime
(),
BusinessConstant
.
dateFormat
)),
BusinessConstant
.
dateFormat
);
// endTime修改到本月月底
int
days
=
DateUtils
.
lengthOfSomeMonth
(
Integer
.
parseInt
(
reportStatisticsDTO
.
getEndTime
().
split
(
"-"
)[
0
]),
Integer
.
parseInt
(
reportStatisticsDTO
.
getEndTime
().
split
(
"-"
)[
1
]));
String
endTime0
=
reportStatisticsDTO
.
getEndTime
().
substring
(
0
,
7
)
+
"-"
+
days
+
BusinessConstant
.
endTimeSuffix
;
//ab总数
Integer
ABEquipmentNum
=
0
;
if
(
reportStatisticsDTO
.
getTimeUnit
()
!=
null
&&
reportStatisticsDTO
.
getTimeUnit
()
==
3
)
{
...
...
@@ -245,21 +257,36 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
}
}
List
<
Map
<
String
,
Object
>>
inTactRateMapList
=
equipmentAnalysisService
.
equipmentInTactRateByTime
(
new
HashMap
<
String
,
Object
>(){{
put
(
"startTime"
,
startTime0
);
put
(
"endTime"
,
endTime0
);
put
(
"timeType"
,
"month"
);
put
(
"departId"
,
""
);
}});
productionEquipmentVO
.
setEquipmentNum
(
equipmentNum
);
productionEquipmentVO
.
setAbEquipmentNum
(
ABEquipmentNum
);
//本月新增
productionEquipmentVO
.
setIncrease
(
increase
);
//设备完好率
BigDecimal
bigDecimal
=
new
BigDecimal
(
ConvertUtils
.
getDou
(
v
,
0
d
)*
100
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
productionEquipmentVO
.
setEquipmentIntactRate
(
bigDecimal
.
toString
()
+
"%"
);
// productionEquipmentVO.setEquipmentIntactRate(bigDecimal.toString() + "%");
productionEquipmentVO
.
setEquipmentIntactRate
(
DigitalUtils
.
nPoint
(
ConvertUtils
.
getDouble
(
inTactRateMapList
.
get
(
inTactRateMapList
.
size
()
-
1
).
get
(
"intactRate"
),
0
D
)
*
100
,
2
)
+
"%"
);
//设备完好总台日
BigDecimal
bigDecimal5
=
new
BigDecimal
(
goodDay
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
productionEquipmentVO
.
setEquipmentIntactDay
(
bigDecimal5
.
toString
());
// productionEquipmentVO.setEquipmentIntactDay(bigDecimal5.toString());
// 从第2条开始算,因为开始时间往前推了一个月,方便计算环比
long
okSecond
=
0L
;
for
(
int
i
=
1
;
i
<
inTactRateMapList
.
size
();
i
++)
{
okSecond
+=
Long
.
parseLong
(
ConvertUtils
.
getString
(
inTactRateMapList
.
get
(
i
).
get
(
"intactSecond"
)));
}
productionEquipmentVO
.
setEquipmentIntactDay
(
DigitalUtils
.
nPoint
(
ConvertUtils
.
getDouble
(
okSecond
,
0
D
)
/
3600
/
24
,
1
));
//维护台次
productionEquipmentVO
.
setMaintainUnits
(
repairNum
);
//设备完好率月环比
BigDecimal
bigDecimal1
=
new
BigDecimal
(
goodDayRing
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
productionEquipmentVO
.
setEquipmentIntactRingRate
(
bigDecimal1
.
toString
()
+
"%"
);
// productionEquipmentVO.setEquipmentIntactRingRate(bigDecimal1.toString() + "%");
productionEquipmentVO
.
setEquipmentIntactRingRate
(
DigitalUtils
.
nPoint
(
ConvertUtils
.
getDouble
(
inTactRateMapList
.
get
(
inTactRateMapList
.
size
()
-
2
).
get
(
"intactRate"
),
0
D
)
*
100
,
2
)
+
"%"
);
//维修计划完成率
BigDecimal
bigDecimal2
=
new
BigDecimal
(
repairCompleteRate
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
productionEquipmentVO
.
setRepairCompleteRate
(
bigDecimal2
.
toString
()
+
"%"
);
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论