Commit 8e716824 authored by suhuiguang's avatar suhuiguang

1.赋码只记录场站的

parent 5bb11ac7
...@@ -168,31 +168,30 @@ public class PersonYardTimeTask { ...@@ -168,31 +168,30 @@ public class PersonYardTimeTask {
} }
// @Scheduled(cron = "0 55 23 1/1 * ? ") @Scheduled(cron = "0 0/30 * * * ?")
@Scheduled(cron = "0 0/30 * * * ? ")
public void stationQrCodeStatisticsData() { public void stationQrCodeStatisticsData() {
// 1.先删除数据
String now = DateUtils.getDateNowShortStr();
LambdaQueryWrapper<StationQrCodeStatistics> qw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationQrCodeStatistics> qw = new LambdaQueryWrapper<>();
qw.eq(StationQrCodeStatistics::getRecordDate, DateUtils.getDateNowShortStr()); qw.eq(StationQrCodeStatistics::getRecordDate, now);
Integer integer = stationQrCodeStatisticsMapper.selectCount(qw); stationQrCodeStatisticsService.remove(qw);
if (integer <= 0) { // 2.当天统计数据组装
// 人员赋码数据 List<StationBasicDto> stationBasicListAll = stationBasicMapper.getStationBasicListAll();
List<StationQrCodeStatistics> personStatistics = personBasicMapper.getPersonStatistics(); // 2.1人员赋码数据
List<StationQrCodeStatistics> personStatistics = personBasicMapper.getPersonStatistics();
// 设备赋码数据 // 2.2设备赋码数据
List<StationQrCodeStatistics> equipQrcodeInfo = sjglZsjZsbtzMapper.getEquipQrcodeInfo(); List<StationQrCodeStatistics> equipQrcodeInfo = sjglZsjZsbtzMapper.getEquipQrcodeInfo();
List<StationBasicDto> stationBasicListAll = stationBasicMapper.getStationBasicListAll(); Map<String, String> collect = stationBasicListAll.stream().filter(t -> StringUtils.isNotEmpty(t.getStationNumber())).filter(t -> StringUtils.isNotEmpty(t.getProjectOrgCode())).collect(Collectors.toMap(StationBasicDto::getStationNumber, StationBasicDto::getProjectOrgCode));
Map<String, String> collect = stationBasicListAll.stream().filter(t -> StringUtils.isNotEmpty(t.getStationNumber())).filter(t -> StringUtils.isNotEmpty(t.getProjectOrgCode())).collect(Collectors.toMap(StationBasicDto::getStationNumber, StationBasicDto::getProjectOrgCode)); equipQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode())));
equipQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode()))); // 2.3任务赋码数据
List<StationQrCodeStatistics> taskQrcodeInfo = sjglZsjZsbtzMapper.getTaskQrcodeInfo();
// 任务赋码数据 taskQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode())));
List<StationQrCodeStatistics> taskQrcodeInfo = sjglZsjZsbtzMapper.getTaskQrcodeInfo(); // 3.人员、任务、设备整合且过滤只有场站的才统计(原因评估这边是显示的场站下的数据)
taskQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode()))); personStatistics.addAll(equipQrcodeInfo);
personStatistics.addAll(taskQrcodeInfo);
// 人员、任务、设备整合插入数据库 List<StationQrCodeStatistics> withStationStatistics = personStatistics.stream().filter(p->StringUtils.isNotEmpty(p.getCode()) && stationBasicListAll.stream().anyMatch(s->s.getProjectOrgCode().equals(p.getCode()))).collect(Collectors.toList());
personStatistics.addAll(equipQrcodeInfo); stationQrCodeStatisticsService.saveBatch(withStationStatistics);
personStatistics.addAll(taskQrcodeInfo);
stationQrCodeStatisticsService.saveBatch(personStatistics);
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment