|  | @@ -10,11 +10,13 @@ import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.service.OssFileService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.StudentService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.TeacherService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.vo.StudentVo;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.wrapper.OssFileWrapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
	
	
		
			
				|  | @@ -44,7 +46,10 @@ import org.springframework.web.bind.annotation.RequestParam;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  |  import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import javax.annotation.Resource;
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  |  import java.util.ArrayList;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.HashMap;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
	
		
			
				|  | @@ -58,18 +63,17 @@ public class StudentController extends BaseController {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentService studentService;
 | 
	
		
			
				|  |  | -    @Autowired
 | 
	
		
			
				|  |  | -    private TeacherService teacherService;
 | 
	
		
			
				|  |  | -    @Autowired
 | 
	
		
			
				|  |  | +    @Resource
 | 
	
		
			
				|  |  |      private SysUserFeignService sysUserFeignService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private ImUserFriendService imUserFriendService;
 | 
	
		
			
				|  |  | -    @Autowired
 | 
	
		
			
				|  |  |      private TenantInfoService tenantInfoService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TenantActivationCodeService tenantActivationCodeService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private OssFileService ossFileService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @GetMapping("/detail/{id}")
 | 
	
		
			
				|  |  |      @ApiOperation(value = "详情", notes = "传入id")
 | 
	
		
			
				|  |  |      public HttpResponseResult<StudentVo> detail(@PathVariable("id") Long id) {
 | 
	
	
		
			
				|  | @@ -93,7 +97,7 @@ public class StudentController extends BaseController {
 | 
	
		
			
				|  |  |          rows.stream().forEach(r->{
 | 
	
		
			
				|  |  |              if (StringUtils.isEmpty(r.getRealName())){
 | 
	
		
			
				|  |  |                  if (StringUtils.isNotEmpty(r.getUsername()))
 | 
	
		
			
				|  |  | -                r.setRealName(r.getUsername());
 | 
	
		
			
				|  |  | +                    r.setRealName(r.getUsername());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -102,7 +106,7 @@ public class StudentController extends BaseController {
 | 
	
		
			
				|  |  |          if (!rows.isEmpty() && query.getTenantAlbumPurchaseId() != null) {
 | 
	
		
			
				|  |  |              List<String> studentPhones =
 | 
	
		
			
				|  |  |                      rows.stream().map(StudentVo::getPhone).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -             groupByPhone = tenantActivationCodeService.lambdaQuery()
 | 
	
		
			
				|  |  | +            groupByPhone = tenantActivationCodeService.lambdaQuery()
 | 
	
		
			
				|  |  |                      .eq(TenantActivationCode::getId, query.getTenantAlbumPurchaseId())
 | 
	
		
			
				|  |  |                      .in(TenantActivationCode::getActivationPhone, studentPhones)
 | 
	
		
			
				|  |  |                      .list().stream().collect(Collectors.groupingBy(TenantActivationCode::getActivationPhone));
 | 
	
	
		
			
				|  | @@ -126,6 +130,39 @@ public class StudentController extends BaseController {
 | 
	
		
			
				|  |  |          return succeed(PageUtil.pageInfo(pages));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @PostMapping("/exportStudent")
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "导出学生", notes = "传入TeacherSearch")
 | 
	
		
			
				|  |  | +    public HttpResponseResult<OssFileWrapper.ExportFile> exportTeacher(@RequestBody StudentSearch query) {
 | 
	
		
			
				|  |  | +        TenantInfo tenantInfo = getTenantInfo();
 | 
	
		
			
				|  |  | +        query.setTenantId(tenantInfo.getId());
 | 
	
		
			
				|  |  | +        query.setDelFlag(YesOrNoEnum.NO);
 | 
	
		
			
				|  |  | +        query.setLockFlag(UserLockFlag.NORMAL);
 | 
	
		
			
				|  |  | +        query.setOrderBy("u.username_ asc");
 | 
	
		
			
				|  |  | +        query.setPage(1);
 | 
	
		
			
				|  |  | +        query.setRows(9999);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        IPage<StudentVo> pages = studentService.selectPage(PageUtil.getPage(query), query);
 | 
	
		
			
				|  |  | +        List<StudentVo> rows = pages.getRecords();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (rows.isEmpty()) {
 | 
	
		
			
				|  |  | +            throw new BizException("没有可导出数据");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<StudentWrapper.ExportStudentTemplate> templateList = rows.stream().map(next -> {
 | 
	
		
			
				|  |  | +            StudentWrapper.ExportStudentTemplate template = new StudentWrapper.ExportStudentTemplate();
 | 
	
		
			
				|  |  | +            template.setUserName(next.getUsername());
 | 
	
		
			
				|  |  | +            template.setPhone(next.getPhone());
 | 
	
		
			
				|  |  | +            template.setSubjectName(next.getSubjectName());
 | 
	
		
			
				|  |  | +            template.setTenantGroupName(next.getTenantGroupName());
 | 
	
		
			
				|  |  | +            return template;
 | 
	
		
			
				|  |  | +        }).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String format = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
 | 
	
		
			
				|  |  | +        OssFileWrapper.ExportFile exportFile = ossFileService.uploadFile(templateList,
 | 
	
		
			
				|  |  | +                StudentWrapper.ExportStudentTemplate.class, format, "学生");
 | 
	
		
			
				|  |  | +        return succeed(exportFile);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @PostMapping("/save")
 | 
	
		
			
				|  |  |      @ApiOperation(value = "新增/修改", notes = "传入Student")
 | 
	
		
			
				|  |  |      public HttpResponseResult<Boolean> save(
 |