ReportController.java
2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.glsx.usercenter.controller;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.exception.SysException;
import com.glsx.usercenter.pojo.user.SysMechanic;
import com.glsx.usercenter.pojo.vo.MerchanicExportVo;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
import com.glsx.usercenter.service.SysUserService;
import com.glsx.usercenter.utils.ShiroUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import javax.validation.groups.Default;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(value="/report")
public class ReportController extends BaseReportController{
@Autowired
private SysUserService sysUserService;
@RequestMapping(value="/exportMerchanic",method={RequestMethod.GET, RequestMethod.POST})
public void exportMerchanic(HttpServletResponse response,@Validated(value = {Default.class}) UserQueryVo userQueryVo){
List<MerchanicExportVo> list1=new ArrayList<>();
userQueryVo.setUserId(ShiroUtil.getUserId());
List<SysMechanic> list = sysUserService.getSysMechanicList(userQueryVo);
if (list.size()>10000) {
throw SysException.create(String.valueOf(ResultCodeEnum.MERCHANIC_EXPORT_OUTOFNUMBER.getCode()),ResultCodeEnum.MERCHANIC_EXPORT_OUTOFNUMBER.getMsg());
}
if(list!=null){
for(SysMechanic sysMechanic:list){
MerchanicExportVo merchanicExportVo=new MerchanicExportVo();
BeanUtils.copyProperties(sysMechanic,merchanicExportVo);
merchanicExportVo.setUserStatus(tranceUserStatu(sysMechanic.getUserStatus()));
merchanicExportVo.setServiceType(tranceServiceType(sysMechanic.getServiceType()));
list1.add(merchanicExportVo);
}
}
try {
exportObject(response,list1,"导出技工列表");
} catch (IOException e) {
logger.info("导出技工列表异常");
}
}
private String tranceUserStatu(String statu){
if(Constants.SYS_USER_STATUS_NORMAL.equals(statu)){
return "启用";
}else if(Constants.SYS_USER_STATUS_LOGOUT.equals(statu)){
return "注销";
}else{
return "停用";
}
}
private String tranceServiceType(Integer serviceType){
if(serviceType==1){
return "上门";
}else{
return "驻店";
}
}
}