|
@ -1,10 +1,15 @@
|
|
|
package com.yihu.wlyy.controller.manager.datastatic;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
import com.yihu.wlyy.device.entity.WlyyDevice;
|
|
|
import com.yihu.wlyy.entity.SignFamily;
|
|
|
import com.yihu.wlyy.entity.prescription.Prescription;
|
|
|
import com.yihu.wlyy.entity.prescription.PrescriptionVO;
|
|
|
import com.yihu.wlyy.service.prescription.PrescriptionService;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@ -13,6 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@ -55,4 +64,84 @@ public class PrescriptionStaticController extends BaseController {
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//导出设备报表
|
|
|
@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,
|
|
|
@RequestParam(value = "disease",required = false)String disease,
|
|
|
@RequestParam(value = "dispensarytype",required = false)String dispensarytype,
|
|
|
@RequestParam(value = "status",required = false)String status,
|
|
|
@RequestParam(value = "beginDate",required = false)String beginDate,
|
|
|
@RequestParam(value = "endDate",required = false)String endDate,
|
|
|
HttpServletResponse response){
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, WlyyDevice.class);
|
|
|
List<PrescriptionVO> datalist = prescriptionService.getPrescriptionList(hospital,disease,dispensarytype,status,beginDate,endDate,0,0,false);
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "prescriptionDataList.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.write(os,datalist);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
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 write(WritableWorkbook wwb, List ls) throws Exception {
|
|
|
try {
|
|
|
WritableSheet ws;
|
|
|
ws = wwb.createSheet("sheet",1);
|
|
|
addHeader(ws);
|
|
|
int i = 1;
|
|
|
for (PrescriptionVO m : (List<PrescriptionVO>) ls) {
|
|
|
addCell(ws, i, 0, m.getPatient_name()+"","");
|
|
|
addCell(ws, i, 1, m.getIdcard(),"");
|
|
|
addCell(ws, i, 2, m.getMobile(),"");
|
|
|
addCell(ws, i, 3, m.getHospital_name(),"");
|
|
|
addCell(ws, i, 4, m.getCreate_time(),"");
|
|
|
addCell(ws, i, 5, m.getDoctor_name(),"");
|
|
|
addCell(ws, i, 6, m.getHealth_problem_name(),"");
|
|
|
addCell(ws, i, 7, m.getPay(),"");
|
|
|
addCell(ws, i, 8, m.getStatusName(),"");
|
|
|
addCell(ws, i, 9, m.getCreate_time(),"");
|
|
|
i++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
public void write(OutputStream os, List ls) throws Exception{
|
|
|
write(Workbook.createWorkbook(os), ls);
|
|
|
}
|
|
|
//添加单元格内容
|
|
|
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);
|
|
|
}
|
|
|
}
|