|
@ -0,0 +1,132 @@
|
|
|
package com.yihu.wlyy.controller.manager.datastatic;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
import com.yihu.wlyy.entity.consult.WlyyConsultTeamExportVO;
|
|
|
import com.yihu.wlyy.service.manager.consult.WlyyConsultTeamService;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by humingfen on 2018/8/7.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping("admin/static/consult")
|
|
|
public class ReplyStaticController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyConsultTeamService consultTeamService;
|
|
|
@Autowired
|
|
|
ObjectMapper objectMapper;
|
|
|
|
|
|
@RequestMapping(value = "initial")
|
|
|
public String initList(){
|
|
|
return "static/static_consult";
|
|
|
}
|
|
|
|
|
|
//导出报表
|
|
|
@RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
|
|
|
public void exportList(
|
|
|
@RequestParam(value = "town",required = false)String town,
|
|
|
@RequestParam(value = "hospital",required = false)String hospital,
|
|
|
HttpServletResponse response){
|
|
|
try {
|
|
|
List<WlyyConsultTeamExportVO> consultTeams = consultTeamService.exportReplyDelayList(town,hospital);
|
|
|
/*String data = "[{" +
|
|
|
"\"symptoms\":\"李医生,我孩子赖抒明的续费,为什么无法操作?\"," +
|
|
|
"\"name\":\"易鹭燕\"," +
|
|
|
"\"create_time\":\"2018/7/4 13:09:26\"," +
|
|
|
"\"reply_time\":\"2018/7/12 20:00:02\"," +
|
|
|
"\"content\":\"没有关系,下次来社区现场缴费即可。\"," +
|
|
|
"\"team_name\":\"禾山社区团队\"," +
|
|
|
"\"doctor_name\":\"李冬彬\"," +
|
|
|
"\"doctor_health_name\":\"李冬彬\"" +
|
|
|
"}," +
|
|
|
"{" +
|
|
|
"\"symptoms\":\"小腹会有涨痛感,白天有多次放屁,晨起时也会放屁。要如何治疗?\"," +
|
|
|
"\"name\":\"杨秋梅\"," +
|
|
|
"\"create_time\":\"2018/7/5 11:15:08\"," +
|
|
|
"\"reply_time\":\"2018/7/17 18:24:54\"," +
|
|
|
"\"content\":\"不好意思,之前没看到消息,你这样应该是肠胃不好,最好是中药调理,有空过来当面看一下\"," +
|
|
|
"\"team_name\":\"岭下社区团队\"," +
|
|
|
"\"doctor_name\":\"陈余妍\"," +
|
|
|
"\"doctor_health_name\":\"张陈大添\"" +
|
|
|
"}" +
|
|
|
"]" ;
|
|
|
List<WlyyConsultTeamExportVO> consultTeams = (List<WlyyConsultTeamExportVO>)JSONArray.toList(JSONArray.fromObject(data), WlyyConsultTeamExportVO.class);*/
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "ReplyDelayList.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.write(os,consultTeams);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void write(OutputStream os, List ls) throws Exception{
|
|
|
write(Workbook.createWorkbook(os), ls);
|
|
|
}
|
|
|
|
|
|
public void write(WritableWorkbook wwb, List ls) throws Exception {
|
|
|
try {
|
|
|
WritableSheet ws;
|
|
|
ws = wwb.createSheet("sheet",1);
|
|
|
addHeader(ws);
|
|
|
int i = 1;
|
|
|
for (WlyyConsultTeamExportVO c : (List<WlyyConsultTeamExportVO>) ls) {
|
|
|
addCell(ws, i, 0, c.getSymptoms(),"");
|
|
|
addCell(ws, i, 1, c.getName(),"");
|
|
|
addCell(ws, i, 2, c.getCreate_time(),"");
|
|
|
addCell(ws, i, 3, c.getReply_time(),"");
|
|
|
addCell(ws, i, 4, c.getContent(),"");
|
|
|
addCell(ws, i, 5, c.getTeam_name(),"");
|
|
|
addCell(ws, i, 6, c.getDoctor_name(),"");
|
|
|
addCell(ws, i, 7, c.getDoctor_health_name(),"");
|
|
|
i++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void addHeader(WritableSheet ws) throws WriteException {
|
|
|
|
|
|
String[] header = {"咨询内容","居民姓名","咨询时间","回复时间","回复内容","团队", "全科医生", "健管师"};
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(ws, 0, i, h);//表名,行,列,header
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//添加单元格内容
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column ,row, data);
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
//添加单元格内容
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
|
|
|
Label label = new Label(column ,row, data);
|
|
|
if(!org.springframework.util.StringUtils.isEmpty(memo)){
|
|
|
WritableCellFeatures cellFeatures = new WritableCellFeatures();
|
|
|
cellFeatures.setComment(memo);
|
|
|
label.setCellFeatures(cellFeatures);
|
|
|
}
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
}
|