|
|
@@ -249,7 +249,7 @@ public class CoreSafetyExceptionDataServiceImpl extends ServiceImpl<CoreSafetyEx
|
|
|
//计算连续数
|
|
|
CoreSafetySourceData safeSourceData = doNewSafetySourceData(monitoringContinuousNum, orgId, deductScore, year, month, continuousNum);
|
|
|
sourceDataList.add(safeSourceData);
|
|
|
- continuousNum=1;
|
|
|
+ continuousNum = 1;
|
|
|
usedConfigList.add(monitoringContinuousNum);
|
|
|
break;
|
|
|
}
|
|
|
@@ -368,32 +368,61 @@ public class CoreSafetyExceptionDataServiceImpl extends ServiceImpl<CoreSafetyEx
|
|
|
* @return
|
|
|
*/
|
|
|
private List<CoreSafetySourceData> calculateContinuousCumulativeCount(List<SafeIndexRuleCountVo> resumptionUndoIndexList, List<CoreSafetyExceptionData> dataList, Long orgId, int year, int month) {
|
|
|
- SafeIndexRuleCountVo indexConfigCountVo = resumptionUndoIndexList.get(0);
|
|
|
-
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
List<CoreSafetySourceData> sourceDataList = new ArrayList<>();
|
|
|
- int count = dataList.size();
|
|
|
-
|
|
|
- double deductScore = count * indexConfigCountVo.getItemValue();
|
|
|
+ //获取累计数的配置,并根据配置的连续数日期进行排序
|
|
|
+ resumptionUndoIndexList.stream()
|
|
|
+ .filter(r -> r.getCalculateType().equals(Constants.TWO))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(config -> {
|
|
|
+ double deductScore = dataList.size() * config.getItemValue();
|
|
|
+ //计算累计数
|
|
|
+ CoreSafetySourceData safeSourceData = doNewSafetySourceData(config, orgId, deductScore, year, month, dataList.size());
|
|
|
+ sourceDataList.add(safeSourceData);
|
|
|
|
|
|
- //计算累计数
|
|
|
- if (count != 0) {
|
|
|
- CoreSafetySourceData safeSourceData = doNewSafetySourceData(indexConfigCountVo, orgId, deductScore, year, month, count);
|
|
|
- sourceDataList.add(safeSourceData);
|
|
|
- }
|
|
|
- //将异常数据的时间进行排序并格式化
|
|
|
+ });
|
|
|
+ //将异常数据的时间进行排序并格式化,用于后面计算连续天数
|
|
|
List<String> dataTimeList = dataList.stream()
|
|
|
.sorted(Comparator.comparing(CoreSafetyExceptionData::getDataTime))
|
|
|
.map(CoreSafetyExceptionData::getDataTime)
|
|
|
.map(sdf::format).distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- //获取连续数的配置,并根据配置的连续数日期进行排序
|
|
|
+ //获取连续数的配置,并根据配置的连续数日期进行倒序,用于计算每个连续数
|
|
|
List<SafeIndexRuleCountVo> resumptionContinuousIndexList = resumptionUndoIndexList.stream()
|
|
|
- .filter(r -> r.getCalculateType() == 2)
|
|
|
- .sorted(Comparator.comparing(SafeIndexRuleCountVo::getIndicatorDays))
|
|
|
+ .filter(r -> r.getCalculateType().equals(Constants.TWO))
|
|
|
+ .sorted(Comparator.comparing(SafeIndexRuleCountVo::getIndicatorDays).reversed())
|
|
|
.collect(Collectors.toList());
|
|
|
+ //使用过的连续数配置项
|
|
|
+ List<SafeIndexRuleCountVo> usedConfigList = new ArrayList<>();
|
|
|
+ for (SafeIndexRuleCountVo indexRuleCountVo : resumptionContinuousIndexList) {
|
|
|
+ Integer indicatorDays = indexRuleCountVo.getIndicatorDays();
|
|
|
+ if (usedConfigList.contains(indexRuleCountVo)) {
|
|
|
+ //如果已经使用过了,则跳过
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //某一连续数出现的次数
|
|
|
+ AtomicReference<Integer> atomicContinuousDays = new AtomicReference<>(0);
|
|
|
+ //计算连续天数并获取连续天数集合
|
|
|
+ List<Map<Integer, List<String>>> mapList = groupContinuousDays(dataTimeList);
|
|
|
+ mapList.stream().flatMap(m -> m.entrySet().stream()).forEach(e -> {
|
|
|
+ Integer key = e.getKey();
|
|
|
+ if (key >= indicatorDays) {
|
|
|
+ atomicContinuousDays.getAndSet(atomicContinuousDays.get() + 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Integer times = atomicContinuousDays.get();
|
|
|
+ if (times != 0) {
|
|
|
+ double threeDayDeductScore = times * indexRuleCountVo.getItemValue();
|
|
|
+ CoreSafetySourceData sourceData = doNewSafetySourceData(indexRuleCountVo, orgId, threeDayDeductScore, year, month, times);
|
|
|
+ sourceDataList.add(sourceData);
|
|
|
+ usedConfigList.add(indexRuleCountVo);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ return sourceDataList;
|
|
|
+
|
|
|
+/*
|
|
|
//连续数 3/5/10 连续出现次数
|
|
|
AtomicReference<Integer> atomicContinuousThreeDays = new AtomicReference<>(0);
|
|
|
AtomicReference<Integer> atomicContinuousFiveDays = new AtomicReference<>(0);
|
|
|
@@ -437,7 +466,7 @@ public class CoreSafetyExceptionDataServiceImpl extends ServiceImpl<CoreSafetyEx
|
|
|
sourceDataList.add(sourceData);
|
|
|
}
|
|
|
|
|
|
- return sourceDataList;
|
|
|
+ return sourceDataList;*/
|
|
|
}
|
|
|
/*public static void main(String[] args) {
|
|
|
String[] dates = {"2022-01-01", "2022-01-02", "2022-01-03", "2022-01-04", "2022-01-06", "2022-01-07", "2022-01-08", "2022-01-09", "2022-01-11"};
|