Commit e8519499 authored by licc's avatar licc

对方案志愿进行排序

parent 4f7b043b
...@@ -31,12 +31,4 @@ public interface VolunteerService extends IService<Volunteer> { ...@@ -31,12 +31,4 @@ public interface VolunteerService extends IService<Volunteer> {
* @throws IOException 异常 * @throws IOException 异常
*/ */
void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException; void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException;
/**
* Excel批量添加方案志愿
* @param file 志愿文件
* @param response 相应数据
* @throws IOException 异常
*/
void ceshi(MultipartFile file, HttpServletResponse response) throws IOException;
} }
...@@ -18,18 +18,15 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,18 +18,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author 86187
* @ Description: 方案查询记录接口实现 * @ Description: 方案查询记录接口实现
* @ Author : 86187 * @ Author : 86187
* @ Date : 2021/1/8 11:41 * @ Date : 2021/1/8 11:41
* @author 86187
*/ */
@Slf4j @Slf4j
@Service @Service
...@@ -102,6 +99,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch ...@@ -102,6 +99,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
List<Integer> ids = list.stream().map(UserVolunteer::getVolunteerId).collect(Collectors.toList()); List<Integer> ids = list.stream().map(UserVolunteer::getVolunteerId).collect(Collectors.toList());
List<Volunteer> result = volunteerMapper.getListByIds(ids); List<Volunteer> result = volunteerMapper.getListByIds(ids);
result.sort(Comparator.comparing(Volunteer::getLowestMark));
return R.ok(result); return R.ok(result);
} }
......
...@@ -22,10 +22,7 @@ import org.springframework.stereotype.Service; ...@@ -22,10 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -714,7 +711,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp ...@@ -714,7 +711,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
List<Volunteer> volunteers = otherList.subList(0, number); List<Volunteer> volunteers = otherList.subList(0, number);
result.addAll(volunteers); result.addAll(volunteers);
} }
result.sort(Comparator.comparing(Volunteer::getLowestMark));
return result; return result;
} }
} }
...@@ -76,34 +76,6 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer ...@@ -76,34 +76,6 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer
volunteerManager.saveSchemeAndVolunteer(schemeInfo, list); volunteerManager.saveSchemeAndVolunteer(schemeInfo, list);
} }
@Override
public void ceshi(MultipartFile file, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty()) {
throw new BaseException("操作错误");
}
VolunteerListener excelListener = new VolunteerListener();
//判断文件类型=
boolean valid = this.validContentType(file.getOriginalFilename());
if (!valid) {
throw new BaseException("请传入Excel文件");
}
//2.读取数据进行入库操作
EasyExcel.read(file.getInputStream(), Volunteer.class, excelListener).sheet().doRead();
List<Volunteer> list = excelListener.getList();
//3、保存方案和志愿信息
SchemeInfo schemeInfo = new SchemeInfo();
schemeInfo.setSchemeName("专科文学编导一批");
schemeInfo.setType(7);
schemeInfo.setUploadTime(new Date());
schemeInfo.setIsDelete(0);
volunteerManager.saveSchemeAndVolunteer(schemeInfo, list);
log.info("导入方案数据成功!");
}
/** /**
* 判断文件类型 * 判断文件类型
* *
......
...@@ -63,19 +63,6 @@ public class SchemeController { ...@@ -63,19 +63,6 @@ public class SchemeController {
return R.ok("添加成功"); return R.ok("添加成功");
} }
@ApiOperation(value = "测试Excel", notes = "测试Excel")
@ApiImplicitParam(name = "file", value = "志愿查询参数", dataType = "MultipartFile")
@PostMapping("/excel/add/ceshi")
public R ceshi(@RequestBody MultipartFile file, HttpServletResponse response) throws IOException {
log.info("");
if (file == null || file.isEmpty()) {
throw new BaseException("操作错误");
}
volunteerService.ceshi(file, response);
return R.ok("添加成功");
}
@ApiOperation(value = "获取方案列表", notes = "获取方案列表", httpMethod = "GET") @ApiOperation(value = "获取方案列表", notes = "获取方案列表", httpMethod = "GET")
@ApiImplicitParam(name = "queryVo", value = "查询参数", dataType = "SchemeQueryVo") @ApiImplicitParam(name = "queryVo", value = "查询参数", dataType = "SchemeQueryVo")
@GetMapping("/getSchemeList") @GetMapping("/getSchemeList")
......
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