|
@@ -6,14 +6,20 @@ import cn.rankin.cmsweb.service.stmt.StmtUserTagService;
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
import cn.rankin.common.utils.util.BeanUtil;
|
|
import cn.rankin.common.utils.util.BeanUtil;
|
|
|
|
+import cn.rankin.data.api.cms.StmtSearchDTO;
|
|
import cn.rankin.data.api.cms.vo.UserTagStmt;
|
|
import cn.rankin.data.api.cms.vo.UserTagStmt;
|
|
-import cn.rankin.data.api.user.dto.UserTagSearchDTO;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -25,7 +31,7 @@ public class StmtUserTagController
|
|
private StmtUserTagService stmtService;
|
|
private StmtUserTagService stmtService;
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
- public APIResult<Page<UserTagStmt>> search(@NeedUser UserDetails user, UserTagSearchDTO searchDTO) {
|
|
|
|
|
|
+ public APIResult<Page<UserTagStmt>> search(@NeedUser UserDetails user, StmtSearchDTO searchDTO) {
|
|
if (!user.isPlatForm()) {
|
|
if (!user.isPlatForm()) {
|
|
searchDTO.setMerchantId(user.getMerchantId());
|
|
searchDTO.setMerchantId(user.getMerchantId());
|
|
}
|
|
}
|
|
@@ -33,5 +39,110 @@ public class StmtUserTagController
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询已开通校区报表
|
|
|
|
+ *
|
|
|
|
+ * @param user the user info
|
|
|
|
+ * @param searchDTO the campus search
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = {"/export"}, method = RequestMethod.GET)
|
|
|
|
+ public String exportCampus(HttpServletResponse res, @NeedUser UserDetails user, StmtSearchDTO searchDTO)
|
|
|
|
+ {
|
|
|
|
+ if (!user.isPlatForm())
|
|
|
|
+ {
|
|
|
|
+ searchDTO.setMerchantId(user.getMerchantId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ APIResult<Page<UserTagStmt>> pageAPIResult = stmtService.UserTagStmtPage(BeanUtil.convertToMap(searchDTO));
|
|
|
|
+ if(!pageAPIResult.getSuccess()){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<UserTagStmt> userTagStmtPage = pageAPIResult.getData();
|
|
|
|
+ if(null != userTagStmtPage){
|
|
|
|
+ List<UserTagStmt> list = userTagStmtPage.getList();
|
|
|
|
+
|
|
|
|
+ //创建HSSFWorkbook对象(excel的文档对象)
|
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
+ //建立新的sheet对象(excel的表单)
|
|
|
|
+ HSSFSheet sheet = wb.createSheet("已配置用户标签终端信息报表已配置用户标签");
|
|
|
|
+ //设置单元格宽度
|
|
|
|
+ sheet.setColumnWidth(0, 20 * 256);
|
|
|
|
+ sheet.setColumnWidth(1, 10 * 256);
|
|
|
|
+ sheet.setColumnWidth(2, 30 * 256);
|
|
|
|
+ sheet.setColumnWidth(3, 30 * 256);
|
|
|
|
+ sheet.setColumnWidth(4, 10 * 256);
|
|
|
|
+ sheet.setColumnWidth(5, 30 * 256);
|
|
|
|
+ sheet.setColumnWidth(6, 15 * 256);
|
|
|
|
+ sheet.setColumnWidth(7, 15 * 256);
|
|
|
|
+ //在sheet里创建第一行,参数为行索引(excel的行),可以是0~65535之间的任何一个
|
|
|
|
+ HSSFRow row1 = sheet.createRow(0);
|
|
|
|
+ //创建单元格并设置单元格内容
|
|
|
|
+ row1.createCell(0).setCellValue("终端编号");
|
|
|
|
+ row1.createCell(1).setCellValue("终端名称");
|
|
|
|
+ row1.createCell(2).setCellValue("校区名称");
|
|
|
|
+ row1.createCell(3).setCellValue("标签集合");
|
|
|
|
+ row1.createCell(4).setCellValue("标签数量");
|
|
|
|
+
|
|
|
|
+ //单元格日期格式
|
|
|
|
+ HSSFCellStyle cellStyle = wb.createCellStyle();
|
|
|
|
+ HSSFDataFormat format = wb.createDataFormat();
|
|
|
|
+ cellStyle.setDataFormat(format.getFormat("yyyy/mm/dd"));
|
|
|
|
+
|
|
|
|
+ //插入数据
|
|
|
|
+ if (!CollectionUtils.isEmpty(list))
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < list.size(); i++)
|
|
|
|
+ {
|
|
|
|
+ UserTagStmt stmt = list.get(i);
|
|
|
|
+
|
|
|
|
+ HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
+ row.createCell(0).setCellValue(stmt.getUCode());
|
|
|
|
+ row.createCell(1).setCellValue(stmt.getCName());
|
|
|
|
+ row.createCell(2).setCellValue(stmt.getCName());
|
|
|
|
+ row.createCell(3).setCellValue(stmt.getUserTags().toString());
|
|
|
|
+ row.createCell(4).setCellValue(stmt.getUserTagNum());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ long currentTime = new Date().getTime();
|
|
|
|
+ //输出Excel文件
|
|
|
|
+ OutputStream output = res.getOutputStream();
|
|
|
|
+ res.reset();
|
|
|
|
+ res.setHeader("Content-disposition", "attachment; filename=lingjiao_terminal_user_" + currentTime + ".xls");
|
|
|
|
+ res.setContentType("application/msexcel");
|
|
|
|
+ wb.write(output);
|
|
|
|
+ output.close();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|