Commit 8e716824 authored by suhuiguang's avatar suhuiguang

1.赋码只记录场站的

parent 5bb11ac7
......@@ -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() {
// 1.先删除数据
String now = DateUtils.getDateNowShortStr();
LambdaQueryWrapper<StationQrCodeStatistics> qw = new LambdaQueryWrapper<>();
qw.eq(StationQrCodeStatistics::getRecordDate, DateUtils.getDateNowShortStr());
Integer integer = stationQrCodeStatisticsMapper.selectCount(qw);
if (integer <= 0) {
// 人员赋码数据
List<StationQrCodeStatistics> personStatistics = personBasicMapper.getPersonStatistics();
// 设备赋码数据
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));
equipQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode())));
// 任务赋码数据
List<StationQrCodeStatistics> taskQrcodeInfo = sjglZsjZsbtzMapper.getTaskQrcodeInfo();
taskQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode())));
// 人员、任务、设备整合插入数据库
personStatistics.addAll(equipQrcodeInfo);
personStatistics.addAll(taskQrcodeInfo);
stationQrCodeStatisticsService.saveBatch(personStatistics);
}
qw.eq(StationQrCodeStatistics::getRecordDate, now);
stationQrCodeStatisticsService.remove(qw);
// 2.当天统计数据组装
List<StationBasicDto> stationBasicListAll = stationBasicMapper.getStationBasicListAll();
// 2.1人员赋码数据
List<StationQrCodeStatistics> personStatistics = personBasicMapper.getPersonStatistics();
// 2.2设备赋码数据
List<StationQrCodeStatistics> equipQrcodeInfo = sjglZsjZsbtzMapper.getEquipQrcodeInfo();
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())));
// 2.3任务赋码数据
List<StationQrCodeStatistics> taskQrcodeInfo = sjglZsjZsbtzMapper.getTaskQrcodeInfo();
taskQrcodeInfo.stream().filter(t -> collect.containsKey(t.getCode())).forEach( item -> item.setCode(collect.get(item.getCode())));
// 3.人员、任务、设备整合且过滤只有场站的才统计(原因评估这边是显示的场站下的数据)
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());
stationQrCodeStatisticsService.saveBatch(withStationStatistics);
}
......
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