|
@@ -103,24 +103,42 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
AtomicInteger open = new AtomicInteger();
|
|
|
//处理印花机运行数据
|
|
|
List<TwinCalcHourYhj> calcList = redisCache.getCacheObject(CacheConstants.YHJ_TODAY);
|
|
|
- Map<Integer, Map<String, Integer>> sumByDeviceAndTeam = calcList.stream()
|
|
|
+ Map<Integer, List<TwinCalcHourYhj>> calcListByDevice = calcList.stream()
|
|
|
+ .collect(Collectors.groupingBy(TwinCalcHourYhj::getDeviceId));
|
|
|
+
|
|
|
+ Map<Integer, Map<String, AbstractMap.SimpleEntry<Integer, BigDecimal>>> sumByDeviceAndTeam = calcList.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
|
TwinCalcHourYhj::getDeviceId,
|
|
|
Collectors.groupingBy(
|
|
|
TwinCalcHourYhj::getTeam,
|
|
|
- Collectors.summingInt(TwinCalcHourYhj::getLength)
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.toList(),
|
|
|
+ list1 -> {
|
|
|
+ int length = list1.stream().mapToInt(TwinCalcHourYhj::getLength).sum();
|
|
|
+ BigDecimal weight = list1.stream().map(TwinCalcHourYhj::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return new AbstractMap.SimpleEntry<>(length, weight);
|
|
|
+ }
|
|
|
+ )
|
|
|
)
|
|
|
));
|
|
|
AtomicInteger openTimes = new AtomicInteger(0);
|
|
|
sumByDeviceAndTeam.forEach((deviceId, teamMap) -> {
|
|
|
Pair<Integer, Integer> pair = deviceStatus.get(deviceId);
|
|
|
|
|
|
- Integer lengthA = teamMap.get("A");
|
|
|
- Integer lengthB = teamMap.get("B");
|
|
|
+ Integer lengthA = teamMap.get("A").getKey();
|
|
|
+ Integer lengthB = teamMap.get("B").getKey();
|
|
|
if (lengthB == null) {
|
|
|
lengthB = 0;
|
|
|
}
|
|
|
Integer length = lengthA + lengthB;
|
|
|
+
|
|
|
+ BigDecimal weightA = teamMap.get("A").getValue();
|
|
|
+ BigDecimal weightB = teamMap.get("B").getValue();
|
|
|
+ if (weightB == null) {
|
|
|
+ weightB = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ BigDecimal weight = weightA.add(weightB);
|
|
|
+
|
|
|
YrProdEfficiencyVO vo = arr[deviceId];
|
|
|
if (pair != null) {
|
|
|
vo.setTotal(pair.getKey());
|
|
@@ -143,9 +161,7 @@ public class ApiYrServiceImpl implements IApiYrService {
|
|
|
vo.setEffA(BigDecimal.ZERO);
|
|
|
vo.setEffB(BigDecimal.ZERO);
|
|
|
}
|
|
|
- BigDecimal weightA = BigDecimal.valueOf(lengthA).divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
|
|
|
- BigDecimal weightB = BigDecimal.valueOf(lengthB).divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
|
|
|
- BigDecimal weight = BigDecimal.valueOf(length).divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
vo.setLengthA(BigDecimal.valueOf(lengthA));
|
|
|
vo.setLengthB(BigDecimal.valueOf(lengthB));
|
|
|
vo.setWeightA(weightA);
|