Commit 025bd0fb authored by liaoanyuan's avatar liaoanyuan

增加用户信息导出功能

parent 6b1f8929
......@@ -41,6 +41,13 @@ public interface UsersMapper extends BaseMapper<User> {
*/
int delById(@Param("id") Integer id);
/**
*
* @param id 用户id
* @return 用户信息
*/
User getById(@Param("id") Integer id);
int countByPhoneAnsUserId(@Param("phone") String phone, @Param("userId") Integer userId);
List<User> getList(Map<String, Object> map);
......
......@@ -92,6 +92,14 @@
where id = #{id}
</delete>
<select id="getById" resultMap="userMap">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>id = #{id}</where>
</select>
<select id="countByPhoneAnsUserId" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM
......@@ -118,7 +126,9 @@
<if test="phone != null">and phone like ('%' #{phone} '%')</if>
order by create_time desc
limit #{pageNo},#{pageSize}
<if test="pageNo != null">
limit #{pageNo},#{pageSize}
</if>
</where>
</select>
......
......@@ -48,6 +48,13 @@ public class Volunteer implements Serializable {
@ApiModelProperty(value = "方案id", name = "schemeId")
private Integer schemeId;
/**
* 用户名称
*/
@ApiModelProperty(name = "name", value = "用户名")
@ExcelProperty(value = "用户名")
private String userName;
/**
* 专业名称
*/
......@@ -90,6 +97,7 @@ public class Volunteer implements Serializable {
@ExcelProperty(value = "计划数")
private Integer planNum;
/**
* 计划投档数
*/
......
......@@ -68,4 +68,7 @@ public class UserCommitDto implements Serializable {
*/
@ApiModelProperty(value = "学生成绩信息", name = "scoreInfo")
private ScoreInfo scoreInfo;
@ApiModelProperty(value = "flag:1:添加 2:编辑", name = "scoreInfo")
private Integer flag;
}
package cn.wisenergy.model.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@ApiModel(value = "UserDto")
@NoArgsConstructor
@AllArgsConstructor
@Builder
//内容高度
@ContentRowHeight(25)
//表头行高度
@HeadRowHeight(25)
//列的宽度
@ColumnWidth(25)
public class UserDto implements Serializable {
private static final long serialVersionUID = 68008573682224495L;
/**
* 注册时间
*/
@ApiModelProperty(value = "注册时间", name = "registerTime")
@ExcelProperty(value = "注册时间")
private Date registerTime;
/**
* 登录来源
*/
@ApiModelProperty(name ="source",value = "登录来源:1 PC,2 WAP")
@ExcelProperty(value = "注册来源")
private String source;
/**
* 用户名称
*/
@ApiModelProperty(value = "用户名称", name = "userName")
@ExcelProperty(value = "用户名称")
private String userName;
/**
* 性别 0:男 1:女
*/
@ApiModelProperty(value = "性别 0:男 1:女", name = "sex")
@ExcelProperty(value = "性别")
private String sex;
/**
* 考生类型 1:文化课考生 2:美术生 3:体育生 4:文学编导考生
*/
@ApiModelProperty(value = "考生类型 1:文化课考生 2:美术生 3:体育生 4:文学编导考生", name = "examType")
@ExcelProperty(value = "考生类型")
private String examType;
/**
* 手机
*/
@ApiModelProperty(value = "手机号", name = "phone")
@ExcelProperty(value = "手机号")
private String phone;
/**
* 学校
*/
@ApiModelProperty(name = "school", value = "毕业院校")
@ExcelProperty(value = "毕业院校")
private String school;
/**
* 文化成绩
*/
@ApiModelProperty(value = "文化成绩", name = "cultureGrade")
@ExcelProperty(value = "文化成绩")
private String cultureGrade;
/**
* 专业成绩
*/
@ApiModelProperty(value = "专业成绩", name = "majorGrade")
@ExcelProperty(value = "专业成绩")
private String majorGrade;
/**
* 用户剩余查询次数
*/
@ApiModelProperty(value = "用户剩余查询次数", name = "queryLimit")
@ExcelProperty(value = "用户剩余查询次数")
private Integer queryLimit;
/**
* 用户微信充值总金额
*/
@ApiModelProperty(value ="用户微信充值总金额",name = "WeChatMoney")
@ExcelProperty(value = "用户微信充值总金额")
private String weChatMoney;
/**
* 用户支付宝充值总金额
*/
@ApiModelProperty(value ="用户支付宝充值总金额",name = "AlipayMoney")
@ExcelProperty(value = "用户支付宝充值总金额")
private String alipayMoney;
/**
* 用户充值次数
*/
@ApiModelProperty(value ="充值卡充值总次数",name = "RechargeTimes")
@ExcelProperty(value = "充值卡充值总次数")
private int rechargeTimes;
/**
* 用户最后登陆时间
*/
@ApiModelProperty(value = "用户最后登陆时间", name = "lastLoginTime")
@ExcelProperty(value = "用户最后登陆时间")
private Date lastLoginTime;
}
package cn.wisenergy.model.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
......@@ -15,6 +22,15 @@ import java.util.Date;
*/
@Data
@ApiModel(value = "UserInfoDto")
@NoArgsConstructor
@AllArgsConstructor
@Builder
//内容高度
@ContentRowHeight(25)
//表头行高度
@HeadRowHeight(25)
//列的宽度
@ColumnWidth(25)
public class UserInfoDto implements Serializable {
private static final long serialVersionUID = 4791446858538524520L;
......@@ -29,90 +45,112 @@ public class UserInfoDto implements Serializable {
* 用户名称
*/
@ApiModelProperty(value = "用户名称", name = "userName")
@ExcelProperty(value = "用户名称")
private String userName;
/**
* 性别 0:男 1:女
*/
@ApiModelProperty(value = "性别 0:男 1:女", name = "sex")
@ExcelProperty(value = "性别")
private Integer sex;
/**
* 考生类型 1:文化课考生 2:美术生 3:体育生 4:文学编导考生
*/
@ApiModelProperty(value = "考生类型 1:文化课考生 2:美术生 3:体育生 4:文学编导考生", name = "examType")
@ExcelProperty(value = "考生类型")
private Integer examType;
/**
* 登录来源
*/
@ApiModelProperty(name ="source",value = "登录来源:1 PC,2 WAP")
@ExcelProperty(value = "登录来源")
private Integer source;
/**
* 手机
*/
@ApiModelProperty(value = "手机号", name = "phone")
@ExcelProperty(value = "手机号")
private String phone;
/**
* 学校
*/
@ApiModelProperty(name = "school", value = "毕业院校")
@ExcelProperty(value = "毕业院校")
private String school;
/**
* 文化成绩
*/
@ApiModelProperty(value = "文化成绩", name = "cultureGrade")
@ExcelProperty(value = "文化成绩")
private String cultureGrade;
/**
* 专业成绩
*/
@ApiModelProperty(value = "专业成绩", name = "majorGrade")
@ExcelProperty(value = "专业成绩")
private String majorGrade;
/**
* 用户剩余查询次数
*/
@ApiModelProperty(value = "用户剩余查询次数", name = "queryLimit")
@ExcelProperty(value = "用户剩余查询次数")
private Integer queryLimit;
/**
* 用户充值总金额
*/
@ApiModelProperty(value = "用户充值总金额", name = "moneyAmount")
@ExcelProperty(value = "用户充值总金额")
private String moneyAmount;
/**
* 用户充值次数
*/
@ApiModelProperty(value ="充值卡充值总次数",name = "RechargeTimes")
@ExcelProperty(value = "充值卡充值总次数")
private int rechargeTimes;
/**
* 用户微信充值总金额
*/
@ApiModelProperty(value ="用户微信充值总金额",name = "WeChatMoney")
@ExcelProperty(value = "用户微信充值总金额")
private String weChatMoney;
/**
* 用户支付宝充值总金额
*/
@ApiModelProperty(value ="用户支付宝充值总金额",name = "AlipayMoney")
@ExcelProperty(value = "用户支付宝充值总金额")
private String alipayMoney;
/**
* ip
*/
@ApiModelProperty(value = "ip", name = "ip")
@ExcelProperty(value = "ip")
private String ip;
/**
* 注册时间
*/
@ApiModelProperty(value = "注册时间", name = "registerTime")
@ExcelProperty(value = "注册时间")
private Date registerTime;
/**
* 用户最后登陆时间
*/
@ApiModelProperty(value = "用户最后登陆时间", name = "lastLoginTime")
@ExcelProperty(value = "用户最后登陆时间")
private Date lastLoginTime;
......
......@@ -9,6 +9,7 @@ import cn.wisenergy.model.vo.UserQueryVo;
import cn.wisenergy.model.vo.UserShowVo;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
......@@ -66,6 +67,14 @@ public interface UserService {
*/
User getByPhone(String phone);
/**
* 导出excel
* @param queryVo 用户
* @param response
* @return Excel数据
*/
R<Boolean> createExcel(UserQueryVo queryVo, HttpServletResponse response);
R<List<User>> test();
}
......@@ -5,8 +5,10 @@ import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.SchemeRecordMapper;
import cn.wisenergy.mapper.UserVolunteerMapper;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.mapper.VolunteerMapper;
import cn.wisenergy.model.app.SchemeQueryRecord;
import cn.wisenergy.model.app.User;
import cn.wisenergy.model.app.UserVolunteer;
import cn.wisenergy.model.app.Volunteer;
import cn.wisenergy.model.vo.SchemeRecordQueryVo;
......@@ -49,6 +51,9 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
@Autowired
private VolunteerMapper volunteerMapper;
@Autowired
private UsersMapper usersMapper;
@Override
public R<SchemeQueryRecord> add(SchemeQueryRecord scheme) {
log.info("volunteer-service[]SchemeRecordServiceImpl[]getById[]input.param.scheme:" + scheme);
......@@ -139,6 +144,10 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
return R.error("入参为空!");
}
//获取用户信息
User byId = usersMapper.getById(userId);
String name=byId.getUserName();
//1、根据用户id和方案记录id,获取志愿ids
QueryWrapper<UserVolunteer> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId);
......@@ -177,7 +186,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
// 4.向文档中添加内容
PdfUtil pdfUtil = new PdfUtil();
pdfUtil.generatePDF(document, result,format);
pdfUtil.generatePDF(document, result,name,format);
// 5.关闭文档
document.close();
......@@ -215,6 +224,10 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
return R.error("入参为空!");
}
//获取用户信息
User byId = usersMapper.getById(userId);
String name=byId.getUserName();
//1、根据用户id和方案记录id,获取志愿ids
QueryWrapper<UserVolunteer> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId);
......@@ -245,6 +258,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
List<Volunteer> resultBo = result.stream().filter(Objects::nonNull)
.map(t -> {
return Volunteer.builder()
.userName(name)
.majorName(t.getMajorName())
.academy(t.getAcademy())
.courseDemand(t.getCourseDemand())
......
......@@ -116,7 +116,7 @@ public class WxPayServiceImpl implements WxPayService {
jsonObject.put("description", "充值");
jsonObject.put("out_trade_no", tradeNo);
jsonObject.put("notify_url", WxCommon.NOTIFY_URL);
jsonObject.put("amount", payPageDto);
jsonObject.put("amount", payPageDto.getTotal());
String sign = null;
try {
sign = SignDemo.getToken(method, httpurl, jsonObject.toJSONString(), nonceStr, timestamp);
......
......@@ -44,12 +44,12 @@ public class PdfUtil implements Serializable {
// 生成PDF文件
public void generatePDF(Document document, List<Volunteer> list, String queryRecordTime) throws Exception {
public void generatePDF(Document document, List<Volunteer> list,String name, String queryRecordTime) throws Exception {
// 表格
PdfPTable table = createTable(new float[] { 40,80,80, 80, 80, 80, 80, 80, 40, 40, 40 });
table.addCell(createCell("查询时间:"+queryRecordTime,headfont,Element.ALIGN_LEFT, 11, false));
table.addCell(createCell("查询时间:"+queryRecordTime+" "+"用户名:"+name,headfont,Element.ALIGN_LEFT, 11, false));
table.addCell(createCell("序号", keyfont, Element.ALIGN_CENTER));
table.addCell(createCell("专业", keyfont, Element.ALIGN_CENTER));
table.addCell(createCell("院校", keyfont, Element.ALIGN_CENTER));
......
......@@ -14,6 +14,7 @@ import cn.wisenergy.web.shiro.JwtUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
......@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -126,4 +128,17 @@ public class UserController {
return R.ok(token);
}
@ApiOperation(value = "用户Excel导出",notes = "方案Excel导出",httpMethod = "POST")
@ApiImplicitParam(name = "queryVo", value = "用户信息", dataType = "UserQueryVo")
@PostMapping(value = "/createExcel")
public R<Boolean> createExcel(@RequestBody UserQueryVo queryVo, HttpServletResponse response){
log.info("UserController[]createExcel[]input.param.userId,recordId:" + queryVo);
if (null == queryVo) {
return R.error("入参为空!");
}
return userService.createExcel(queryVo,response);
}
}
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