66 lines
2.2 KiB
Java
66 lines
2.2 KiB
Java
|
|
package com.gunshi.project.ss.service;
|
|||
|
|
|
|||
|
|
|
|||
|
|
import com.gunshi.project.ss.entity.vo.ScreenPositionTrainingVo;
|
|||
|
|
import com.gunshi.project.ss.model.PersonnelPlan;
|
|||
|
|
import com.gunshi.project.ss.model.PersonnelPlanLog;
|
|||
|
|
import com.gunshi.project.ss.model.ResPerson;
|
|||
|
|
import lombok.extern.slf4j.Slf4j;
|
|||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
|
import org.springframework.stereotype.Service;
|
|||
|
|
|
|||
|
|
import java.util.Arrays;
|
|||
|
|
import java.util.List;
|
|||
|
|
import java.util.stream.Collectors;
|
|||
|
|
|
|||
|
|
@Slf4j
|
|||
|
|
@Service
|
|||
|
|
public class ScreenResponsibilityService {
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
private PersonnelPlanService personnelPlanService;
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
private PersonnelPlanLogService personnelPlanLogService;
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
private ResPersonService resPersonService;
|
|||
|
|
|
|||
|
|
public ScreenPositionTrainingVo getTraining() {
|
|||
|
|
ScreenPositionTrainingVo vo = new ScreenPositionTrainingVo();
|
|||
|
|
List<PersonnelPlan> list = personnelPlanService.lambdaQuery().orderByDesc(PersonnelPlan::getCreateTime).list();
|
|||
|
|
vo.setTrainingCount(Long.valueOf(list.size()));
|
|||
|
|
|
|||
|
|
//已开展
|
|||
|
|
List<Long> ids = list.stream().map(o -> o.getId()).collect(Collectors.toList());
|
|||
|
|
Long hasTraining = 0l;
|
|||
|
|
Long hasNoTraining = 0l;
|
|||
|
|
Long totalTraining = 0L;
|
|||
|
|
//TODO 这里N+1问题自己去解决一下吧,我懒得改了。
|
|||
|
|
for (Long id : ids) {
|
|||
|
|
List<PersonnelPlanLog> logs = personnelPlanLogService.lambdaQuery().eq(PersonnelPlanLog::getPlanId, id).list();
|
|||
|
|
if(logs.isEmpty()){
|
|||
|
|
hasNoTraining++;
|
|||
|
|
}else{
|
|||
|
|
hasTraining++;
|
|||
|
|
totalTraining += logs.stream().mapToLong(o -> o.getNumPeople()).sum();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
vo.setHasTraining(hasTraining);
|
|||
|
|
vo.setHasNoTraining(hasNoTraining);
|
|||
|
|
vo.setTotalTraining(totalTraining);
|
|||
|
|
if(!list.isEmpty()){
|
|||
|
|
PersonnelPlan personnelPlan = list.get(0);
|
|||
|
|
vo.setLatestPersonnelPlan(personnelPlan);
|
|||
|
|
}
|
|||
|
|
return vo;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<ResPerson> getPerson() {
|
|||
|
|
List<ResPerson> list = resPersonService.lambdaQuery().in(ResPerson::getType, Arrays.asList(0, 1, 2))
|
|||
|
|
.orderByDesc(ResPerson::getCreateTime)
|
|||
|
|
.list();
|
|||
|
|
return list;
|
|||
|
|
}
|
|||
|
|
}
|