New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TEvaluateResp; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TOrderResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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 org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.model.TEvaluate; |
| | | import com.stylefeng.guns.modular.system.service.ITEvaluateService; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * |
| | | * @author fengshuonan |
| | | * @Date 2023-02-27 14:03:41 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/tEvaluate") |
| | | public class TEvaluateController extends BaseController { |
| | | |
| | | private String PREFIX = "/system/tEvaluate/"; |
| | | |
| | | @Autowired |
| | | private ITEvaluateService tEvaluateService; |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | | */ |
| | | @RequestMapping("") |
| | | public String index() { |
| | | return PREFIX + "tEvaluate.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到添加 |
| | | */ |
| | | @RequestMapping("/tEvaluate_add") |
| | | public String tEvaluateAdd() { |
| | | return PREFIX + "tEvaluate_add.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到修改 |
| | | */ |
| | | @RequestMapping("/tEvaluate_update/{tEvaluateId}") |
| | | public String tEvaluateUpdate(@PathVariable Integer tEvaluateId, Model model) { |
| | | TEvaluate tEvaluate = tEvaluateService.selectById(tEvaluateId); |
| | | model.addAttribute("item",tEvaluate); |
| | | LogObjectHolder.me().set(tEvaluate); |
| | | return PREFIX + "tEvaluate_edit.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转详情页面 |
| | | */ |
| | | @RequestMapping("/evaluateDetail") |
| | | public String evaluateDetail(Integer evaluateId, Model model) { |
| | | tEvaluateService.evaluateDetail(evaluateId,model); |
| | | return PREFIX + "tEvaluateDetail.html"; |
| | | } |
| | | |
| | | /** |
| | | * 获取列表 |
| | | */ |
| | | @RequestMapping(value = "/list") |
| | | @ResponseBody |
| | | public Object list(String createTime,String userName,String driverName ,Integer score) { |
| | | return tEvaluateService.selectPageList(createTime,userName,driverName,null,score); |
| | | } |
| | | |
| | | /** |
| | | * 获取列表 |
| | | */ |
| | | @RequestMapping(value = "/list-back") |
| | | @ResponseBody |
| | | public Object listBack(String condition) { |
| | | return tEvaluateService.selectList(null); |
| | | } |
| | | |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @RequestMapping(value = "/add") |
| | | @ResponseBody |
| | | public Object add(TEvaluate tEvaluate) { |
| | | tEvaluateService.insert(tEvaluate); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @RequestMapping(value = "/delete") |
| | | @ResponseBody |
| | | public Object delete(@RequestParam Integer tEvaluateId) { |
| | | tEvaluateService.deleteById(tEvaluateId); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @RequestMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update(TEvaluate tEvaluate) { |
| | | tEvaluateService.updateById(tEvaluate); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @RequestMapping(value = "/detail/{tEvaluateId}") |
| | | @ResponseBody |
| | | public Object detail(@PathVariable("tEvaluateId") Integer tEvaluateId) { |
| | | return tEvaluateService.selectById(tEvaluateId); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出评价列表",notes="导出评价列表") |
| | | @RequestMapping(value = "/export") |
| | | @ResponseBody |
| | | public void export(String createTime,String userName,String driverName,Integer score, HttpServletResponse response) { |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName = "EvaluateInfo"+time1+".xls"; |
| | | String[] title = new String[] {"评价时间","订单编号","评论用户", |
| | | "评论用户手机号","评论司机","司机手机号","评价分数","评价内容"}; |
| | | List<TEvaluateResp> list = tEvaluateService.selectPageList(createTime, userName, driverName, null, score); |
| | | String[][] values = new String[list.size()][]; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TEvaluateResp d = list.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d.getCreateTime()); |
| | | values[i][1] = d.getCode(); |
| | | values[i][2] = d.getUserName(); |
| | | values[i][3] = d.getUserPhone(); |
| | | values[i][4] = d.getDriverName(); |
| | | values[i][5] = d.getDriverPhone(); |
| | | values[i][6] = String.valueOf(Objects.nonNull(d.getScore())?d.getScore(): ""); |
| | | Integer score1 = d.getScore(); |
| | | if(Objects.nonNull(score1)){ |
| | | if(1 == score1){ |
| | | values[i][6] = "非常差"; |
| | | }else if (2 == score1){ |
| | | values[i][6] = "差"; |
| | | }else if (3 == score1){ |
| | | values[i][6] = "一般"; |
| | | }else if (4 == score1){ |
| | | values[i][6] = "满意"; |
| | | }else if (5 == score1){ |
| | | values[i][6] = "非常满意"; |
| | | } |
| | | }else { |
| | | values[i][6] = ""; |
| | | } |
| | | values[i][7] = d.getEvaluate(); |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |