Commit 6b6a2439 authored by liaoanyuan's avatar liaoanyuan

Merge remote-tracking branch 'origin/master'

parents 214d9a63 fb9d6ca1
...@@ -11,7 +11,7 @@ public interface LoginRecordMapper extends BaseMapper<LoginRecord> { ...@@ -11,7 +11,7 @@ public interface LoginRecordMapper extends BaseMapper<LoginRecord> {
* @param loginRecord 登录信息 * @param loginRecord 登录信息
* @return 登录信息 * @return 登录信息
*/ */
LoginRecord add(LoginRecord loginRecord); int add(LoginRecord loginRecord);
/** /**
* 编辑 * 编辑
......
...@@ -7,7 +7,7 @@ import java.util.List; ...@@ -7,7 +7,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface SchemeMapper extends BaseMapper<SchemeInfo> { public interface SchemeMapper extends BaseMapper<SchemeInfo> {
SchemeInfo add(SchemeInfo schemeInfo); int add(SchemeInfo schemeInfo);
List<SchemeInfo> getList(Map<String,Object> map); List<SchemeInfo> getList(Map<String,Object> map);
} }
package cn.wisenergy.model.app; package cn.wisenergy.model.app;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -13,7 +18,11 @@ import java.util.Date; ...@@ -13,7 +18,11 @@ import java.util.Date;
* @ Date : 2021/1/7 15:15 * @ Date : 2021/1/7 15:15
*/ */
@Data @Data
@Builder
@ApiModel(value = "Volunteer") @ApiModel(value = "Volunteer")
@NoArgsConstructor
@AllArgsConstructor
@ExcelIgnoreUnannotated
public class Volunteer implements Serializable { public class Volunteer implements Serializable {
private static final long serialVersionUID = -7880251929353475087L; private static final long serialVersionUID = -7880251929353475087L;
...@@ -27,60 +36,70 @@ public class Volunteer implements Serializable { ...@@ -27,60 +36,70 @@ public class Volunteer implements Serializable {
* 专业名称 * 专业名称
*/ */
@ApiModelProperty(value = "专业名称", name = "majorName") @ApiModelProperty(value = "专业名称", name = "majorName")
@ExcelProperty(value = "姓名")
private String majorName; private String majorName;
/** /**
* 院校 * 院校
*/ */
@ApiModelProperty(value = "院校", name = "academy") @ApiModelProperty(value = "院校", name = "academy")
@ExcelProperty(value = "姓名")
private String academy; private String academy;
/** /**
* 选考科目要求 * 选考科目要求
*/ */
@ApiModelProperty(value = "选考科目要求", name = "courseDemand") @ApiModelProperty(value = "选考科目要求", name = "courseDemand")
@ExcelProperty(value = "姓名")
private String courseDemand; private String courseDemand;
/** /**
* 学校性质 * 学校性质
*/ */
@ApiModelProperty(value = "学校性质", name = "nature") @ApiModelProperty(value = "学校性质", name = "nature")
@ExcelProperty(value = "姓名")
private String nature; private String nature;
/** /**
* 学年制(年) * 学年制(年)
*/ */
@ApiModelProperty(value = "学年制(年)", name = "yearLimit") @ApiModelProperty(value = "学年制(年)", name = "yearLimit")
@ExcelProperty(value = "姓名")
private Integer yearLimit; private Integer yearLimit;
/** /**
* 计划投档 * 计划
*/ */
@ApiModelProperty(value = "计划投档", name = "planNum") @ApiModelProperty(value = "计划数", name = "planNum")
@ExcelProperty(value = "姓名")
private Integer planNum; private Integer planNum;
/** /**
* 投档计划 * 计划投档
*/ */
@ApiModelProperty(value = "投档计划数", name = "投档计划数") @ApiModelProperty(value = "计划投档数", name = "castArchivesNum")
@ExcelProperty(value = "姓名")
private Integer castArchivesNum; private Integer castArchivesNum;
/** /**
* 投出数 * 投出数
*/ */
@ApiModelProperty(value = "投出数量", name = "launchNum") @ApiModelProperty(value = "投出数", name = "launchNum")
@ExcelProperty(value = "姓名")
private Integer launchNum; private Integer launchNum;
/** /**
* 最低分 * 最低分
*/ */
@ApiModelProperty(value = "最低分", name = "lowestMark") @ApiModelProperty(value = "最低分", name = "lowestMark")
@ExcelProperty(value = "姓名")
private String lowestMark; private String lowestMark;
/** /**
* 最低位次 * 最低位次
*/ */
@ApiModelProperty(value = "最低位次", name = "lowestRank") @ApiModelProperty(value = "最低位次", name = "lowestRank")
@ExcelProperty(value = "姓名")
private String lowestRank; private String lowestRank;
/** /**
......
...@@ -37,4 +37,17 @@ public enum OperationTypeEnum { ...@@ -37,4 +37,17 @@ public enum OperationTypeEnum {
public void setDesc(String desc) { public void setDesc(String desc) {
this.desc = desc; this.desc = desc;
} }
public static String getByCode(Integer code) {
if (null == code) {
return null;
}
for (OperationTypeEnum operation : OperationTypeEnum.values()) {
if (operation.getCode().intValue() == code.intValue()) {
return operation.getDesc();
}
}
return null;
}
} }
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
*@ Description: 用户登录Vo
*@ Author : 86187
*@ Date : 2021/1/15 14:27
*/
@Data
@ApiModel(value = "UserLoginVo")
public class UserLoginVo implements Serializable {
private static final long serialVersionUID = 2206962675782086034L;
/**
* 手机号码
*/
@ApiModelProperty(value = "手机号码",name = "phone")
private String phone;
/**
* 密码
*/
@ApiModelProperty(value = "密码",name = "password")
private String password;
/**
* 验证码
*/
@ApiModelProperty(value = "验证码",name = "smCode")
private String smCode;
}
...@@ -3,6 +3,10 @@ package cn.wisenergy.service.app; ...@@ -3,6 +3,10 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.SchemeQueryVo; import cn.wisenergy.model.vo.SchemeQueryVo;
import cn.wisenergy.model.vo.VolunteerVo; import cn.wisenergy.model.vo.VolunteerVo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/** /**
......
...@@ -2,6 +2,7 @@ package cn.wisenergy.service.app; ...@@ -2,6 +2,7 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo; import cn.wisenergy.model.vo.UserRegisterVo;
/** /**
...@@ -21,20 +22,18 @@ public interface UserLoginService { ...@@ -21,20 +22,18 @@ public interface UserLoginService {
/** /**
* 手机验证码登录 * 手机验证码登录
* *
* @param code 验证码 * @param userLoginVo 登录信息
* @param phone 手机号
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<Boolean> loginCode(String code, String phone); R<Boolean> loginCode(UserLoginVo userLoginVo);
/** /**
* 手机-密码登录 * 手机-密码登录
* *
* @param phone 手机号 * @param userLoginVo 登录信息
* @param password 密码
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<UserInfoVo> login(String phone, String password); R<UserInfoVo> login(UserLoginVo userLoginVo);
/** /**
* 退出登录 * 退出登录
...@@ -65,9 +64,8 @@ public interface UserLoginService { ...@@ -65,9 +64,8 @@ public interface UserLoginService {
/** /**
* 短信重置密码 * 短信重置密码
* *
* @param code 用户id * @param userLoginVo 登录信息
* @param phone 手机号
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<Boolean> notePassword(Integer code, String phone); R<Boolean> notePassword(UserLoginVo userLoginVo);
} }
...@@ -2,10 +2,17 @@ package cn.wisenergy.service.app; ...@@ -2,10 +2,17 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Volunteer; import cn.wisenergy.model.app.Volunteer;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; import java.util.List;
public interface VolunteerService { /**
* @author 86187
*/
public interface VolunteerService extends IService<Volunteer> {
/** /**
* 批量添加志愿 * 批量添加志愿
* *
...@@ -13,4 +20,14 @@ public interface VolunteerService { ...@@ -13,4 +20,14 @@ public interface VolunteerService {
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<Boolean> batchAdd(List<Volunteer> list); R<Boolean> batchAdd(List<Volunteer> list);
/**
* Excel批量添加方案志愿
* @param file 志愿文件
* @param type 方案类型
* @param schemeName 方案名称
* @param response 相应数据
* @throws IOException 异常
*/
void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException;
} }
...@@ -2,10 +2,13 @@ package cn.wisenergy.service.app.impl; ...@@ -2,10 +2,13 @@ package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.Md5Util; import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.LoginRecordMapper;
import cn.wisenergy.mapper.UsersMapper; import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.LoginRecord; import cn.wisenergy.model.app.LoginRecord;
import cn.wisenergy.model.app.UserInfo; import cn.wisenergy.model.app.UserInfo;
import cn.wisenergy.model.enums.OperationTypeEnum;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo; import cn.wisenergy.model.vo.UserRegisterVo;
import cn.wisenergy.service.app.UserLoginService; import cn.wisenergy.service.app.UserLoginService;
import cn.wisenergy.service.common.Common; import cn.wisenergy.service.common.Common;
...@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* @author 86187
* @ Description: 用户登录相关接口实现 * @ Description: 用户登录相关接口实现
* @ Author : 86187 * @ Author : 86187
* @ Date : 2021/1/7 14:22 * @ Date : 2021/1/7 14:22
...@@ -28,6 +32,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -28,6 +32,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
@Autowired @Autowired
private UsersMapper usersMapper; private UsersMapper usersMapper;
@Autowired
private LoginRecordMapper loginRecordMapper;
@Override @Override
public R<Boolean> register(UserRegisterVo userVo) { public R<Boolean> register(UserRegisterVo userVo) {
log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:" + userVo); log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:" + userVo);
...@@ -60,27 +67,34 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -60,27 +67,34 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
} }
//4、保存操作记录 //4、保存操作记录
LoginRecord loginRecord=new LoginRecord(); LoginRecord loginRecord = new LoginRecord();
loginRecord.setType(1); loginRecord.setType(OperationTypeEnum.USER_REGISTER.getCode());
loginRecord.setUserId(user.getId());
String name = OperationTypeEnum.getByCode(OperationTypeEnum.USER_REGISTER.getCode());
loginRecord.setOperationName(name);
int sum = loginRecordMapper.add(loginRecord);
if (sum == 0) {
return R.ok(1, false);
}
return R.ok(0, true); return R.ok(0, true);
} }
@Override @Override
public R<Boolean> loginCode(String code, String phone) { public R<Boolean> loginCode(UserLoginVo userLoginVo) {
return null; return null;
} }
@Override @Override
public R<UserInfoVo> login(String phone, String password) { public R<UserInfoVo> login(UserLoginVo userVo) {
log.info("volunteer-service[]UserLoginServiceImpl[]login[]input.param.phone,password:" + phone, password); log.info("volunteer-service[]UserLoginServiceImpl[]login[]input.param.userVo:" + userVo);
if (StringUtils.isBlank(phone) || StringUtils.isBlank(password)) { if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) {
return R.error("入参为空!"); return R.error("入参为空!");
} }
//1、根据手机号,获取用户信息 //1、根据手机号,获取用户信息
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>(); QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("phone", phone); queryWrapper.eq("phone", userVo.getPhone());
queryWrapper.eq("is_delete", 0); queryWrapper.eq("is_delete", 0);
UserInfo userInfo = usersMapper.selectOne(queryWrapper); UserInfo userInfo = usersMapper.selectOne(queryWrapper);
if (null == userInfo) { if (null == userInfo) {
...@@ -89,7 +103,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -89,7 +103,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
//2、判断密码是否正确 //2、判断密码是否正确
//MD5加密 //MD5加密
String secret = Md5Util.digestMD5(phone + password); String secret = Md5Util.digestMD5(userVo.getPhone() + userVo.getPassword());
if (!userInfo.getPassword().equals(secret)) { if (!userInfo.getPassword().equals(secret)) {
return R.error("密码错误,请您输入正确密码!"); return R.error("密码错误,请您输入正确密码!");
...@@ -100,12 +114,38 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -100,12 +114,38 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
userInfoVo.setUserId(userInfo.getId()); userInfoVo.setUserId(userInfo.getId());
userInfoVo.setUserName(userInfo.getUserName()); userInfoVo.setUserName(userInfo.getUserName());
userInfoVo.setPhone(userInfo.getPhone()); userInfoVo.setPhone(userInfo.getPhone());
//3、保存操作记录
LoginRecord loginRecord = new LoginRecord();
loginRecord.setType(OperationTypeEnum.USER_LOGIN.getCode());
loginRecord.setUserId(userInfo.getId());
String name = OperationTypeEnum.getByCode(OperationTypeEnum.USER_LOGIN.getCode());
loginRecord.setOperationName(name);
int sum = loginRecordMapper.add(loginRecord);
if (sum == 0) {
return R.error("保存操作记录失败!");
}
return R.ok(userInfoVo); return R.ok(userInfoVo);
} }
@Override @Override
public R<Boolean> loginOut(Integer userId) { public R<Boolean> loginOut(Integer userId) {
return null; log.info("volunteer-service[]UserLoginServiceImpl[]loginOut[]input.param.userId:" + userId);
if (null == userId) {
return R.error("入参为空!");
}
//保存用户退出操作
LoginRecord loginRecord = new LoginRecord();
loginRecord.setType(OperationTypeEnum.USER_OUT.getCode());
loginRecord.setUserId(userId);
String name = OperationTypeEnum.getByCode(OperationTypeEnum.USER_OUT.getCode());
loginRecord.setOperationName(name);
int sum = loginRecordMapper.add(loginRecord);
if (sum == 0) {
return R.ok(1, false);
}
return R.ok(0, true);
} }
@Override @Override
...@@ -135,7 +175,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -135,7 +175,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
} }
@Override @Override
public R<Boolean> notePassword(Integer code, String phone) { public R<Boolean> notePassword(UserLoginVo userVo) {
return null; return null;
} }
...@@ -166,5 +206,4 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -166,5 +206,4 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
} }
} }
package cn.wisenergy.service.app.impl; package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.expection.BaseException;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.SchemeMapper;
import cn.wisenergy.mapper.VolunteerMapper; import cn.wisenergy.mapper.VolunteerMapper;
import cn.wisenergy.model.app.SchemeInfo;
import cn.wisenergy.model.app.Volunteer; import cn.wisenergy.model.app.Volunteer;
import cn.wisenergy.service.app.VolunteerService; import cn.wisenergy.service.app.VolunteerService;
import cn.wisenergy.service.common.VolunteerListener;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
*@ Description: 志愿接口实现 * @ Description: 志愿接口实现
*@ Author : 86187 * @ Author : 86187
*@ Date : 2021/1/8 9:44 * @ Date : 2021/1/8 9:44
*/ */
@Service @Service
@Slf4j @Slf4j
public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer> implements VolunteerService { public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer> implements VolunteerService {
@Autowired
private VolunteerMapper volunteerMapper;
@Autowired
private SchemeMapper schemeMapper;
@Override @Override
public R<Boolean> batchAdd(List<Volunteer> list) { public R<Boolean> batchAdd(List<Volunteer> list) {
return null; return null;
} }
@Override
public void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException {
//判断文件类型=
boolean valid = this.validContentType(file.getOriginalFilename());
if (!valid) {
throw new BaseException("请传入Excel文件");
}
//1、保存方案信息
SchemeInfo schemeInfo = new SchemeInfo();
schemeInfo.setSchemeName(schemeName);
schemeInfo.setType(type);
schemeInfo.setUploadTime(new Date());
schemeInfo.setIsDelete(0);
saveSchemeAndVolunteer(schemeInfo,file);
}
/**
* 保存方案和志愿信息
*
* @param schemeInfo 方案信息
* @param file 志愿文件
* @throws IOException 异常
*/
@Transactional(rollbackFor =Exception.class )
public void saveSchemeAndVolunteer(SchemeInfo schemeInfo, MultipartFile file) throws IOException {
//1、保存方案信息
int count = schemeMapper.add(schemeInfo);
if (count == 0) {
throw new RuntimeException("保存方案信息失败!");
}
//2.读取数据进行入库操作
EasyExcel.read(file.getInputStream(), Volunteer.class, new VolunteerListener(this)).sheet().doRead();
}
/**
* 判断文件类型
*
* @param fileName 文件名
* @return true or false
*/
public boolean validContentType(String fileName) {
if (StringUtils.isBlank(fileName)) {
return false;
}
String substring = fileName.substring(fileName.lastIndexOf(".") + 1);
if (substring.equals("xlsx") || substring.equals("xls")) {
return true;
}
return false;
}
} }
package cn.wisenergy.service.common;
import cn.wisenergy.model.app.Volunteer;
import cn.wisenergy.service.app.VolunteerService;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.Head;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* Excel批量添加社区居民 监听器
*/
@Slf4j
public class VolunteerListener extends AnalysisEventListener<Volunteer> {
private List<Volunteer> list;
private VolunteerService volunteerService;
private final int batch = 20000;
/**
* 导入模板头内容
*/
private Map<Integer, String> headMap = new HashMap<>();
/**
* 结果标记 默认错误
*/
private boolean isCorrectFormat = true;
public VolunteerListener(VolunteerService volunteerService) {
this.volunteerService = volunteerService;
list = new ArrayList<>();
}
/**
* 这个每一条数据解析都会来调用 ==
*
* @param volunteer 志愿信息
* @param analysisContext
*/
@Override
public void invoke(Volunteer volunteer, AnalysisContext analysisContext) {
if (!isCorrectFormat) {
//格式是否正确
return;
}
log.info("解析到一条志愿数据>>>>>>>>>>:{}", volunteer);
//此处做校验 本次没有校验
if (volunteer != null) {
if (StringUtils.isEmpty(volunteer.getMajorName())) {
throw new RuntimeException("专业不能为空!");
}
if (StringUtils.isEmpty(volunteer.getAcademy())) {
throw new RuntimeException("院校不能为空!");
}
if (StringUtils.isEmpty(volunteer.getCourseDemand())) {
throw new RuntimeException("选考科目要求不能为空!");
}
if (StringUtils.isEmpty(volunteer.getNature())) {
throw new RuntimeException("学校不能为空!");
}
if (null == volunteer.getYearLimit()) {
throw new RuntimeException("学年制不能为空!");
}
if (null == volunteer.getPlanNum()) {
throw new RuntimeException("计划数数不能为空!");
}
if (null == volunteer.getCastArchivesNum()) {
throw new RuntimeException("计划投档数不能为空!");
}
if (null == volunteer.getLaunchNum()) {
throw new RuntimeException("投出数不能为空!");
}
if (StringUtils.isEmpty(volunteer.getLowestMark())) {
throw new RuntimeException("最低分不能为空!");
}
if (StringUtils.isEmpty(volunteer.getLowestRank())) {
throw new RuntimeException("最低位次不能为空!");
}
list.add(volunteer);
}
//每500条插入一次数据库
if (list.size() >= batch) {
//判断数据库是否已有手机号的数据
log.info("invoke批量插入志愿数据,条数为>>>>>>>>>>:{}", list.size());
if (list.size() > 0) {
volunteerService.saveBatch(list);
}
//保存后清除,防止大量数据导致内存耗尽
list.clear();
}
}
/**
* 所有数据解析完成了 都会来调用
*
* @param analysisContext
*/
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
log.info("doAfterAllAnalysed解析玩一个志愿sheet工作表>>>>>>>>>>");
//如果集合不为空
if (!CollectionUtils.isEmpty(list)) {
//TODO 判断excel表中的手机号是否重复
log.info("批量插入志愿数据,条数为>>>>>>>>>>:{}", list.size());
if (list.size() > 0) {
volunteerService.saveBatch(list);
}
}
}
/**
* 校验导入模板表头是否正确
*
* @param headMap 表头
* @param context
*/
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
//是否手动传入表头信息 没有则自动读取实体类头信息
try {
if (this.headMap == null || this.headMap.size() <= 0) {
Map<Integer, Head> map = context.currentReadHolder().excelReadHeadProperty().getHeadMap();
for (int i = 0; i < map.size(); i++) {
//封装成headMap
this.headMap.put(map.get(i).getColumnIndex(), map.get(i).getHeadNameList().get(0));
}
}
} catch (Exception e) {
isCorrectFormat = false;
throw new RuntimeException("导入失败,请联系管理员!");
}
if (this.headMap == null || headMap == null || this.headMap.size() != headMap.size()) {
isCorrectFormat = false;
throw new RuntimeException("导入表的表头与模板表头不符!");
} else {
for (int i = 0; i < this.headMap.size(); i++) {
//循环遍历判断表格头是否一一对应
if (!this.headMap.get(i).equals(headMap.get(i))) {
isCorrectFormat = false;
throw new RuntimeException("导入表的表头与模板表头不符!");
}
}
}
}
}
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.expection.BaseException;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.SchemeQueryRecord; import cn.wisenergy.model.app.SchemeQueryRecord;
import cn.wisenergy.model.vo.SchemeQueryVo; import cn.wisenergy.model.vo.SchemeQueryVo;
import cn.wisenergy.model.vo.SchemeRecordQueryVo; import cn.wisenergy.model.vo.SchemeRecordQueryVo;
import cn.wisenergy.model.vo.VolunteerVo; import cn.wisenergy.model.vo.VolunteerVo;
import cn.wisenergy.service.app.SchemeService; import cn.wisenergy.service.app.SchemeService;
import cn.wisenergy.service.app.VolunteerService;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/** /**
* @ Description: PC-方案 * @ Description: PC-方案
...@@ -31,6 +35,9 @@ public class SchemeController { ...@@ -31,6 +35,9 @@ public class SchemeController {
@Autowired @Autowired
private SchemeService schemeService; private SchemeService schemeService;
@Autowired
private VolunteerService volunteerService;
@ApiOperation(value = "获取志愿列表", notes = "获取志愿列表", httpMethod = "GET") @ApiOperation(value = "获取志愿列表", notes = "获取志愿列表", httpMethod = "GET")
@ApiImplicitParam(name = "queryVo", value = "志愿查询参数", dataType = "SchemeQueryVo") @ApiImplicitParam(name = "queryVo", value = "志愿查询参数", dataType = "SchemeQueryVo")
@GetMapping("/getList") @GetMapping("/getList")
...@@ -43,4 +50,17 @@ public class SchemeController { ...@@ -43,4 +50,17 @@ public class SchemeController {
return schemeService.getList(queryVo); return schemeService.getList(queryVo);
} }
@ApiOperation(value = "Excel批量添加方案志愿", notes = "Excel批量添加方案志愿")
@ApiImplicitParam(name = "file", value = "excel文件", dataType = "MultipartFile")
@PostMapping("/excel/add")
public R excelAdd(@RequestParam("uploadfile") MultipartFile file, @RequestParam("type") Integer type,
@RequestParam("schemeName") String schemeName, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName)) {
throw new BaseException("操作错误");
}
volunteerService.excelAdd(file, type, schemeName, response);
return R.ok("添加成功");
}
} }
...@@ -2,6 +2,8 @@ package cn.wisenergy.web.admin.controller.app; ...@@ -2,6 +2,8 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo; import cn.wisenergy.model.vo.UserRegisterVo;
import cn.wisenergy.service.app.UserLoginService; import cn.wisenergy.service.app.UserLoginService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -41,6 +43,30 @@ public class UserLongController { ...@@ -41,6 +43,30 @@ public class UserLongController {
return userLoginService.register(userVo); return userLoginService.register(userVo);
} }
@ApiOperation(value = "用户账号密码登录", notes = "用户账号密码登录", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "登录用户信息", dataType = "UserLoginVo")
@PostMapping("/login")
public R<UserInfoVo> login(@RequestBody UserLoginVo userVo) {
log.info("volunteer-service[]UserLongController[]login[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) {
return R.error("入参不能为空!");
}
return userLoginService.login(userVo);
}
@ApiOperation(value = "退出登录", notes = "退出登录", httpMethod = "POST")
@PostMapping("/loginOut")
public R<Boolean> loginOut(Integer userId) {
log.info("volunteer-service[]UserLongController[]loginOut[]input.param.userId:" + userId);
if (null == userId) {
return R.error("入参不能为空!");
}
return userLoginService.loginOut(userId);
}
@ApiOperation(value = "重置密码", notes = "重置密码", httpMethod = "POST") @ApiOperation(value = "重置密码", notes = "重置密码", httpMethod = "POST")
@PostMapping("/resetPassword") @PostMapping("/resetPassword")
public R<Boolean> resetPassword(Integer userId) { public R<Boolean> resetPassword(Integer userId) {
......
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