| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelSheetPO; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelUtil; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelVersion; |
| | | import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil; |
| | | import cc.mrbird.febs.mall.dto.AdminHappyActivityCategoryDto; |
| | | import cc.mrbird.febs.mall.dto.activity.*; |
| | | import cc.mrbird.febs.mall.entity.HappyActivity; |
| | | import cc.mrbird.febs.mall.entity.HappyActivityOption; |
| | | import cc.mrbird.febs.mall.service.IAdminHappyActivityService; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | |
| | | return adminHappyActivityService.activityOrderDel(id); |
| | | } |
| | | |
| | | @SneakyThrows |
| | | @GetMapping("/exportOptionList") |
| | | public void exportOptionList(@RequestParam Map<String, String> params, HttpServletResponse response) { |
| | | List<ExcelSheetPO> res = new ArrayList<>(); |
| | | ExcelSheetPO orderSheet = new ExcelSheetPO(); |
| | | String title = "报名列表"; |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"序号", "姓名", "联系方式", "兴趣爱好","家庭住址","地区","是否签约mcn机构", "备注"}; |
| | | orderSheet.setHeaders(header); |
| | | List<HappyActivityOption> dataList = adminHappyActivityService.getVoteOptionListForExport(params); |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | if (dataList.size() > 0) { |
| | | int i = 0; |
| | | for (HappyActivityOption item : dataList) { |
| | | i++; |
| | | List<Object> temp = new ArrayList<>(); |
| | | temp.add(i); |
| | | temp.add(item.getOptionName()); |
| | | temp.add(item.getMobilePhone()); |
| | | temp.add(item.getHobby()); |
| | | temp.add(item.getAddress()); |
| | | temp.add(item.getProvince()+item.getCity()); |
| | | temp.add(item.getMcnState() == 1 ?"是":"否"); |
| | | temp.add(item.getDescription()); |
| | | list.add(temp); |
| | | } |
| | | } |
| | | orderSheet.setDataList(list); |
| | | res.add(orderSheet); |
| | | response = ResponseHeadUtil.setExcelHead(response); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), "yyyyMMDDHHmmss") + ".xlsx".trim(), "UTF-8")); |
| | | OutputStream os = null; |
| | | os = response.getOutputStream(); |
| | | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, false); |
| | | } |
| | | |
| | | } |