Commit 7f17e5be authored by 竹天卫's avatar 竹天卫

人员产值统计导出功能 优化2

parent dcf345c2
...@@ -34,9 +34,9 @@ public class NonStandardApplyController { ...@@ -34,9 +34,9 @@ public class NonStandardApplyController {
@ApiOperation(value = "非标产值申请分页") @ApiOperation(value = "非标产值申请分页")
@GetMapping("/getPage") @GetMapping("/getPage")
public BaseResponse getPage(PageQuery pageQuery, String name,Integer userId) { public BaseResponse getPage(PageQuery pageQuery) {
try { try {
return iNonStandardApplyService.getPage(pageQuery, name,userId); return iNonStandardApplyService.getPage(pageQuery);
} catch (Exception e) { } catch (Exception e) {
log.debug("非标产值申请分页列表{}", e); log.debug("非标产值申请分页列表{}", e);
} }
...@@ -115,9 +115,9 @@ public class NonStandardApplyController { ...@@ -115,9 +115,9 @@ public class NonStandardApplyController {
@ApiOperation("导出-非标产值申请列表") @ApiOperation("导出-非标产值申请列表")
@PostMapping("/exportList") @PostMapping("/exportList")
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) { public void exportList(String filename, HttpServletResponse response) {
try { try {
iNonStandardApplyService.exportList(filename, userId, name, response); iNonStandardApplyService.exportList(filename, response);
} catch (Exception e) { } catch (Exception e) {
log.debug("导出-非标产值申请导出列表{}", e); log.debug("导出-非标产值申请导出列表{}", e);
} }
......
...@@ -27,7 +27,7 @@ public interface INonStandardApplyService extends IService<NonStandardApply> { ...@@ -27,7 +27,7 @@ public interface INonStandardApplyService extends IService<NonStandardApply> {
* @param pageQuery 非标产值信息分页 * @param pageQuery 非标产值信息分页
* @return IPage<NoneStandardApply> * @return IPage<NoneStandardApply>
*/ */
BaseResponse<IPage<NonStandardApplyVo>> getPage(PageQuery pageQuery, String name,Integer userId); BaseResponse<IPage<NonStandardApplyVo>> getPage(PageQuery pageQuery);
/** /**
* 获取所有非标产值申请信息 * 获取所有非标产值申请信息
...@@ -67,15 +67,7 @@ public interface INonStandardApplyService extends IService<NonStandardApply> { ...@@ -67,15 +67,7 @@ public interface INonStandardApplyService extends IService<NonStandardApply> {
*/ */
BaseResponse delete(Integer id); BaseResponse delete(Integer id);
/** void exportList(String filename, HttpServletResponse response);
* 非标产值申请列表导出
*
* @param userId 用户id
* @param name 姓名
* @param filename 文件名
* @param response
*/
void exportList(String filename, Integer userId, String name, HttpServletResponse response);
/** /**
* 更改状态信息,达到改变显示的效果 * 更改状态信息,达到改变显示的效果
......
...@@ -50,10 +50,11 @@ public class NonStandardApplyServiceImpl extends ServiceImpl<NonStandardApplyMap ...@@ -50,10 +50,11 @@ public class NonStandardApplyServiceImpl extends ServiceImpl<NonStandardApplyMap
private ISysUserService userService; private ISysUserService userService;
@Override @Override
public BaseResponse<IPage<NonStandardApplyVo>> getPage(PageQuery pageQuery, String name,Integer userId) { public BaseResponse<IPage<NonStandardApplyVo>> getPage(PageQuery pageQuery) {
LoginUser loginUser = userService.getLoginUser();
Assert.notNull(loginUser, "用户未登录!");
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("name", name); params.put("userId", loginUser.getId());
params.put("userId", userId);
Page<NonStandardApplyVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize()); Page<NonStandardApplyVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<NonStandardApplyVo> pages = nonStandardApplyMapper.getPage(page, params); IPage<NonStandardApplyVo> pages = nonStandardApplyMapper.getPage(page, params);
return BaseResponse.okData(pages); return BaseResponse.okData(pages);
...@@ -140,49 +141,43 @@ public class NonStandardApplyServiceImpl extends ServiceImpl<NonStandardApplyMap ...@@ -140,49 +141,43 @@ public class NonStandardApplyServiceImpl extends ServiceImpl<NonStandardApplyMap
} }
@Override @Override
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) { public void exportList(String filename,HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
LoginUser loginUser = userService.getLoginUser(); LoginUser loginUser = userService.getLoginUser();
Assert.notNull(loginUser, "用户未登录!"); Assert.notNull(loginUser, "用户未登录!");
Map<String, Object> params = new HashMap<>();
if(loginUser!=null){ params.put("userId", loginUser.getId());
if(!loginUser.getRoleList().getName().equals("系统管理员")){ List<Map<String, Object>> list = nonStandardApplyMapper.exportList(params);
params.put("userId", loginUser.getId());
} if (!CollectionUtils.isEmpty(list)) {
params.put("name", name); Map<String, Object> map = list.get(0);
List<Map<String, Object>> list = nonStandardApplyMapper.exportList(params); String[] headers = new String[map.size()];
headers[0] = "序号";
if (!CollectionUtils.isEmpty(list)) { headers[1] = "姓名";
Map<String, Object> map = list.get(0); headers[2] = "账户";
String[] headers = new String[map.size()]; headers[3] = "起止时间";
headers[0] = "序号"; headers[4] = "上报工日";
headers[1] = "姓名"; headers[5] = "状态";
headers[2] = "账户";
headers[3] = "起止时间"; List<Object[]> datas = new ArrayList<>(list.size());
headers[4] = "上报工日"; for (Map<String, Object> m : list) {
headers[5] = "状态"; Object[] objects = new Object[headers.length];
for (int j = 0; j < headers.length; j++) {
List<Object[]> datas = new ArrayList<>(list.size()); String obj = m.get(headers[j]) == null ? "" : m.get(headers[j]).toString();
for (Map<String, Object> m : list) { if (j == 0 && obj != null) {
Object[] objects = new Object[headers.length]; obj = obj.split("\\.")[0];
for (int j = 0; j < headers.length; j++) {
String obj = m.get(headers[j]) == null ? "" : m.get(headers[j]).toString();
if (j == 0 && obj != null) {
obj = obj.split("\\.")[0];
}
objects[j] = obj;
} }
objects[j] = obj;
datas.add(objects);
} }
ExcelUtil.excelExport(
filename == null || filename.trim().length() <= 0 ? "非标产值申请" : filename, headers, datas.add(objects);
datas, response);
} }
ExcelUtil.excelExport(
filename == null || filename.trim().length() <= 0 ? "非标产值申请" : filename, headers,
datas, 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