| @@ -98,7 +98,7 @@ public class WxCUserBasicInfo extends TenantEntity { | |||
| private Integer status; | |||
| @TableField(exist = false) | |||
| @Excel(name="标签",width = 50,orderNum = "10") | |||
| //@Excel(name="标签",width = 50,orderNum = "10") | |||
| private String tagNames; | |||
| @@ -119,6 +119,12 @@ public class WxCUserBasicInfo extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private Date endTime; | |||
| @TableField(exist = false) | |||
| private Integer begin; | |||
| @TableField(exist = false) | |||
| private Integer limit; | |||
| public String getAddressStr() { | |||
| if (address == null) | |||
| @@ -7,6 +7,8 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ExportParams; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelExportServer; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.exception.MallinkException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -37,6 +39,28 @@ public class ExcelService { | |||
| defaultExport(list, pojoClass, fileName, response, exportParams, false); | |||
| } | |||
| public void exportBigExcel(IExcelExportServer server,Object queryParams, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response, boolean template) { | |||
| exportBig(server,queryParams, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF), template); | |||
| } | |||
| private void exportBig(IExcelExportServer server,Object queryParams,Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams, boolean template) { | |||
| Workbook workbook = ExcelExportUtil.exportBigExcel(exportParams, pojoClass, server, queryParams); | |||
| if (workbook != null) { | |||
| if (template) { | |||
| Sheet sheetAt = workbook.getSheetAt(0); | |||
| CellStyle cellStyle = workbook.createCellStyle(); | |||
| Font font = workbook.createFont(); | |||
| font.setColor(IndexedColors.RED.getIndex()); | |||
| cellStyle.setFont(font); | |||
| Row row = sheetAt.createRow(sheetAt.getLastRowNum() + 2); | |||
| Cell cell = row.createCell(0); | |||
| cell.setCellValue("*为必填字段(导入数据时此行文字请删除)"); | |||
| cell.setCellStyle(cellStyle); | |||
| } | |||
| } | |||
| downLoadExcel(fileName, response, workbook); | |||
| } | |||
| public void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response, boolean template) { | |||
| defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF), template); | |||
| } | |||
| @@ -16,6 +16,9 @@ import com.iformall.domain.vo.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelExportServer; | |||
| import org.apache.commons.compress.utils.Lists; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -38,7 +41,7 @@ import java.util.concurrent.TimeUnit; | |||
| import java.util.stream.Collectors; | |||
| @Service | |||
| public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExcelExportServer { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| @@ -656,15 +659,15 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| public void exportData(WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response) { | |||
| List<WxCUserBasicInfoVo> list = wxCUserBasicInfoMapper.findVoList(basicInfo); | |||
| List<WxTags> tagList = wxTagsMapper.findListAll(); | |||
| Map<Long, String> tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); | |||
| list.stream().filter(u->u.getTags()!=null).forEach(u->{ | |||
| List<Long> ids = JSONObject.parseArray(u.getTags(), Long.class); | |||
| String tagNames = StringUtils.join(ids.stream().map(id->tagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| u.setTagNames(tagNames); | |||
| }); | |||
| excelService.exportExcel(list, null, "会员信息", WxCUserBasicInfoVo.class, "会员信息数据.xlsx", response, false); | |||
| // List<WxCUserBasicInfoVo> list = wxCUserBasicInfoMapper.findVoList(basicInfo); | |||
| // List<WxTags> tagList = wxTagsMapper.findListAll(); | |||
| // Map<Long, String> tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); | |||
| // list.stream().filter(u->u.getTags()!=null).forEach(u->{ | |||
| // List<Long> ids = JSONObject.parseArray(u.getTags(), Long.class); | |||
| // String tagNames = StringUtils.join(ids.stream().map(id->tagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| // u.setTagNames(tagNames); | |||
| // }); | |||
| excelService.exportBigExcel(this,basicInfo, null, "会员信息", WxCUserBasicInfoVo.class, "会员信息数据.xlsx", response, false); | |||
| } | |||
| public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { | |||
| @@ -1021,5 +1024,14 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| wxCUserBasicInfoMapper.updateById(wxCUserBasicInfo); | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public List<Object> selectListForExcelExport(Object queryParams, int page) { | |||
| WxCUserBasicInfo basicInfo = (WxCUserBasicInfo) queryParams; | |||
| basicInfo.setBegin((page-1)*10000); | |||
| basicInfo.setLimit(10000); | |||
| List a = wxCUserBasicInfoMapper.findVoList(basicInfo); | |||
| return a; | |||
| } | |||
| } | |||
| @@ -33,6 +33,11 @@ | |||
| where poins >= points and tenant_id=wcubi.tenant_id | |||
| order by points desc limit 1 ) level,status | |||
| </sql> | |||
| <sql id="allSimpleColumns"> | |||
| `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, | |||
| `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| @@ -444,17 +449,19 @@ | |||
| <select id="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap"> | |||
| select | |||
| <include refid="allVoColumns"/> | |||
| <include refid="allSimpleColumns"/> | |||
| from wx_c_user_basic_info cu | |||
| left join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | |||
| <include refid="dynamicVoWhereConditions"/> | |||
| <if test=" null != begin "> | |||
| limit #{begin}, #{limit} | |||
| </if> | |||
| </select> | |||
| <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer"> | |||
| select | |||
| count(*) | |||
| count(1) | |||
| from wx_c_user_basic_info cu | |||
| left join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | |||
| <include refid="dynamicVoWhereConditions"/> | |||
| </select> | |||