|
@@ -0,0 +1,142 @@
|
|
|
+package com.diagbot.web;
|
|
|
+
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.annotation.IdType;
|
|
|
+import com.baomidou.mybatisplus.annotation.TableId;
|
|
|
+import com.diagbot.annotation.SysLogger;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.UserInfoDTO;
|
|
|
+import com.diagbot.dto.UserInfoExportDTO;
|
|
|
+import com.diagbot.facade.UserFacade;
|
|
|
+import com.diagbot.util.ExportBeanExcelUtil;
|
|
|
+import com.diagbot.vo.UserExportVO;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @Description: 客户中心导出功能
|
|
|
+ * @author wangfeng
|
|
|
+ * @date 2018年9月25日 上午9:45:56
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@Api(value = "客户中心导出功能API", tags = { "客户中心导出功能API" })
|
|
|
+@RequestMapping("/report")
|
|
|
+@SuppressWarnings("unchecked")
|
|
|
+public class ReportFormController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserFacade userFacade;
|
|
|
+
|
|
|
+ @ApiOperation(value = "导出用户信息和机构信息:[by:wangfeng]", notes = "根据时间 导出用户信息和机构信息")
|
|
|
+ @PostMapping("/exportUserInfo")
|
|
|
+ @SysLogger("/exportUserInfo")
|
|
|
+ @Transactional
|
|
|
+ public RespDTO export(final HttpServletRequest request, final HttpServletResponse response,UserExportVO userExportVO)
|
|
|
+ throws Exception {
|
|
|
+ Map<String, Object> userMap = new HashMap<String, Object>();
|
|
|
+ userMap.put("startTime", userExportVO.getStartTime());
|
|
|
+ userMap.put("endTime", userExportVO.getEndTime());
|
|
|
+ List<UserInfoExportDTO> datas = userFacade.dependentuserInfoByTime(userMap);
|
|
|
+ List<String> listName = new ArrayList<>();
|
|
|
+
|
|
|
+ listName.add("用户id");
|
|
|
+ listName.add("记录创建时间");
|
|
|
+ listName.add("用户名");
|
|
|
+ listName.add("联系人");
|
|
|
+ listName.add("邮箱");
|
|
|
+ listName.add("机构ID");
|
|
|
+ listName.add("机构名称");
|
|
|
+ listName.add("机构属性");
|
|
|
+ listName.add("负责人");
|
|
|
+ listName.add("机构地址");
|
|
|
+ listName.add("上级机构id");
|
|
|
+ listName.add("下属机构数量");
|
|
|
+ listName.add("岗位信息");
|
|
|
+ listName.add("是否通过认证 ");
|
|
|
+ listName.add("认证状态");
|
|
|
+
|
|
|
+ List<String> listId = new ArrayList<>();
|
|
|
+ listId.add("userId");//用户ID
|
|
|
+ listId.add("userGmtCreate");//记录创建时间
|
|
|
+ listId.add("userName");// 用户名
|
|
|
+ listId.add("linKman");//联系人
|
|
|
+ listId.add("email");// 邮箱
|
|
|
+ listId.add("orgId");//机构ID
|
|
|
+ //listId.add("orgGmtCreate");//记录创建时间
|
|
|
+ listId.add("orgName");//机构名称
|
|
|
+ listId.add("orgType");//机构属性
|
|
|
+ listId.add("orgPrincipal");//负责人
|
|
|
+ listId.add("orgAddress");//机构地址
|
|
|
+ listId.add("orgParentId");//上级机构id
|
|
|
+ listId.add("orgSubNum");//下属机构数量
|
|
|
+ listId.add("autPosition");//岗位信息
|
|
|
+ listId.add("autIsReject");//是否通过认证 N:未通过,Y:已通过
|
|
|
+ listId.add("autStatus");//认证状态
|
|
|
+
|
|
|
+ List<UserInfoExportDTO> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ UserInfoExportDTO userInfo = datas.get(i);
|
|
|
+ list.add(new UserInfoExportDTO(userInfo.getUserId(),
|
|
|
+ userInfo.getUserGmtCreate(),
|
|
|
+ userInfo.getUserName(),
|
|
|
+ userInfo.getLinKman(),
|
|
|
+ userInfo.getEmail(),
|
|
|
+ userInfo.getOrgId(),
|
|
|
+ userInfo.getOrgName(),
|
|
|
+ userInfo.getOrgType(),
|
|
|
+ userInfo.getOrgPrincipal(),
|
|
|
+ userInfo.getOrgAddress(),
|
|
|
+ userInfo.getOrgParentId(),
|
|
|
+ userInfo.getOrgSubNum(),
|
|
|
+ userInfo.getAutPosition(),
|
|
|
+ userInfo.getAutIsReject(),
|
|
|
+ userInfo.getAutStatus()));
|
|
|
+ }
|
|
|
+ response.setContentType("text/html;charset=UTF-8");
|
|
|
+ String filePath =userExportVO.getFilePath();//文件路径
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat();//设置日期格式
|
|
|
+ System.out.println();// new Date()为获取当前系统时间
|
|
|
+ String fileName = userExportVO.getFileName();//文件名
|
|
|
+ ExportBeanExcelUtil ex = new ExportBeanExcelUtil();
|
|
|
+ RespDTO resul = ex.exportExcel("测试POI导出EXCEL文档", listName, listId, list,filePath,fileName);
|
|
|
+ return resul;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发送响应流方法
|
|
|
+ public void setResponseHeader(HttpServletResponse response, String fileName) {
|
|
|
+ try {
|
|
|
+ try {
|
|
|
+ fileName = new String(fileName.getBytes(), "ISO8859-1");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
+ response.addHeader("Pargam", "no-cache");
|
|
|
+ response.addHeader("Cache-Control", "no-cache");
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|