| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.util.ExcelUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | import com.stylefeng.guns.modular.system.model.DriverActivityHistory; |
| | | import com.stylefeng.guns.modular.system.service.IDriverActivityHistoryService; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.OutputStream; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | public Object detail(@PathVariable("driverActivityHistoryId") Integer driverActivityHistoryId) { |
| | | return driverActivityHistoryService.selectById(driverActivityHistoryId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |
| | | @RequestMapping(value = "/exportRecord") |
| | | @ResponseBody |
| | | public Object exportRecord(HttpServletResponse response, @RequestParam Integer activityId, @RequestParam Integer type) { |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time = format.format(date); |
| | | String fileName = ""; |
| | | if (type == 1){ |
| | | fileName = "邀请司机注册记录"+time+".xls"; |
| | | }else if (type == 2){ |
| | | fileName = "邀请用户注册记录"+time+".xls"; |
| | | }else if (type == 3){ |
| | | fileName = "累计在线记录"+time+".xls"; |
| | | }else if (type == 4){ |
| | | fileName = "订单数奖励记录"+time+".xls"; |
| | | } |
| | | String[] title = new String[] {"领取时间","领取人","领取人电话","领取金额"}; |
| | | List<Map<String,Object>> mapList = driverActivityHistoryService.getListt(activityId,type); |
| | | |
| | | String[][] values = new String[mapList.size()][]; |
| | | for (int i = 0; i < mapList.size(); i++) { |
| | | Map<String,Object> d=mapList.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0]=d.get("collectionTime").toString(); |
| | | values[i][1]=d.get("name").toString(); |
| | | values[i][2]=d.get("phone").toString(); |
| | | values[i][3]=d.get("money").toString(); |
| | | } |
| | | String fileNameTitle=""; |
| | | if (type == 1){ |
| | | fileNameTitle = "邀请司机注册记录"; |
| | | }else if (type == 2){ |
| | | fileNameTitle = "邀请用户注册记录"; |
| | | }else if (type == 3){ |
| | | fileNameTitle = "累计在线记录"; |
| | | }else if (type == 4){ |
| | | fileNameTitle = "订单数奖励记录"; |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(fileNameTitle+time, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | /*return ApiUtil.putFailObj("导出失败");*/ |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | } |