| | |
| | | import com.gkhy.exam.common.utils.SecurityUtils; |
| | | import com.gkhy.exam.system.domain.*; |
| | | import com.gkhy.exam.system.domain.vo.StudentStudyVO; |
| | | import com.gkhy.exam.system.mapper.ExCoursePhaseMapper; |
| | | import com.gkhy.exam.system.mapper.ExPhaseStudentMapper; |
| | | import com.gkhy.exam.system.mapper.ExStudentMapper; |
| | | import com.gkhy.exam.system.mapper.ExStudentStudyMapper; |
| | | import com.gkhy.exam.system.mapper.*; |
| | | import com.gkhy.exam.system.service.ExCompanyPeriodService; |
| | | import com.gkhy.exam.system.service.ExPhaseStudentService; |
| | | import com.gkhy.exam.system.service.ExStudentStudyService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | private SysCompanyService companyService; |
| | | @Autowired |
| | | private ExCompanyPeriodService companyPeriodService; |
| | | @Autowired |
| | | private ExCourseChapterPeriodMapper courseChapterPeriodMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = RuntimeException.class) |
| | | public int batchAddPhaseStudent(List<ExPhaseStudent> phaseStudents) { |
| | | if(phaseStudents==null|| phaseStudents.isEmpty()){ |
| | | throw new ApiException("学员数据不能为空"); |
| | | } |
| | | checkUserAllowed(phaseStudents.get(0)); |
| | | checkStudentUnique(phaseStudents); |
| | | for(ExPhaseStudent phaseStudent:phaseStudents){ |
| | |
| | | throw new ApiException("没有权限操作"); |
| | | } |
| | | ExCoursePhase coursePhase=coursePhaseMapper.selectById(phaseStudent.getPhaseId()); |
| | | if(!currentUser.getCompanyId().equals(coursePhase.getCompanyId())){ |
| | | if(!coursePhase.getCompanyId().equals(currentUser.getCompanyId())){ |
| | | throw new ApiException("没有权限操作其他企业批次"); |
| | | } |
| | | |
| | |
| | | } |
| | | PageUtils.startPage(); |
| | | List<ExPhaseStudent> phaseStudentList=baseMapper.selectPhaseStudentList(phaseStudent); |
| | | if(phaseStudentList.size()>0) { |
| | | //获取课程所有课时数量 |
| | | int count = courseChapterPeriodMapper.selectCountByCourseId(phaseStudentList.get(0).getCourse().getId()); |
| | | if(count>0) { |
| | | for (ExPhaseStudent ps : phaseStudentList) { |
| | | if (ps.getTotalProgress() != null) { |
| | | ps.setTotalProgress(ps.getTotalProgress().divide(BigDecimal.valueOf(count), BigDecimal.ROUND_UP)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return CommonPage.restPage(phaseStudentList); |
| | | } |
| | | |
| | |
| | | public int deletePhaseStudent(Long phaseStudentId) { |
| | | ExPhaseStudent phaseStudent=baseMapper.selectPhaseStudentById(phaseStudentId); |
| | | if(ObjectUtil.isNull(phaseStudent)){ |
| | | throw new ApiException(String.format("该批次下不存在该学员<>",phaseStudent.getStudentName())); |
| | | throw new ApiException("该批次下不存在该学员id"); |
| | | } |
| | | checkUserAllowed(phaseStudent); |
| | | int studentStudyCount=studentStudyMapper.countByPhaseId(phaseStudent.getPhaseId(),phaseStudent.getStudentId()); |
| | |
| | | ExCoursePhase coursePhase= coursePhaseMapper.selectCoursePhaseById(phaseId); |
| | | ExCompanyPeriod companyPeriod=new ExCompanyPeriod(); |
| | | companyPeriod.setPhaseId(phaseId); |
| | | companyPeriod.setModifyPeriod(-1*studentCount*coursePhase.getCoursePeriod()); |
| | | companyPeriod.setModifyPeriod(-1L*studentCount*coursePhase.getCoursePeriod()); |
| | | companyPeriod.setOrigin("\""+coursePhase.getName()+"\"新增学员消耗"); |
| | | SysCompany company=companyService.getById(coursePhase.getCompanyId()); |
| | | int remainPeriod=company.getTotalPeriod()+companyPeriod.getModifyPeriod(); |
| | | Long remainPeriod=company.getRemainPeriod()+companyPeriod.getModifyPeriod(); |
| | | if(remainPeriod<0){ |
| | | throw new ApiException("企业剩余课时不足"); |
| | | } |
| | | companyPeriod.setCompanyId(company.getId()); |
| | | companyPeriod.setRemainPeriod(remainPeriod); |
| | | companyPeriodService.save(companyPeriod); |
| | | company.setRemainPeriod(companyPeriod.getRemainPeriod()); |