|
@ -1,8 +1,11 @@
|
|
package com.yihu.wlyy.controller.manager.device;
|
|
package com.yihu.wlyy.controller.manager.device;
|
|
|
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
|
import com.yihu.wlyy.device.entity.PatientDeviceVO;
|
|
import com.yihu.wlyy.entity.WlyyPatientDevice;
|
|
import com.yihu.wlyy.entity.WlyyPatientDevice;
|
|
import com.yihu.wlyy.service.manager.device.WlyyPatientDeviceService;
|
|
import com.yihu.wlyy.service.manager.device.WlyyPatientDeviceService;
|
|
|
|
import jxl.Workbook;
|
|
|
|
import jxl.write.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
@ -11,6 +14,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by yww on 2016/12/7.
|
|
* Created by yww on 2016/12/7.
|
|
*/
|
|
*/
|
|
@ -60,4 +68,77 @@ public class WlyyPatientDeviceController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//导出报表
|
|
|
|
@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<PatientDeviceVO> wlyyDevices = patientDeviceService.exportPatientDeviceList(town,hospital);
|
|
|
|
response.setContentType("octets/stream");
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "patientDeviceDataList.xls"));
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
this.write(os,wlyyDevices);
|
|
|
|
}catch (Exception ex){
|
|
|
|
error(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addHeader(WritableSheet ws) throws WriteException {
|
|
|
|
|
|
|
|
String[] header = {"居民姓名","手机号","身份证","设备码", "设备类型","签约医生", "居民住址", "openid", "是否绑定微信号"};
|
|
|
|
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 (PatientDeviceVO m : (List<PatientDeviceVO>) ls) {
|
|
|
|
addCell(ws, i, 0, m.getName(),"");
|
|
|
|
addCell(ws, i, 1, m.getMobile(),"");
|
|
|
|
addCell(ws, i, 2, m.getIdcard(),"");
|
|
|
|
addCell(ws, i, 3, m.getDevice_sn(),"");
|
|
|
|
addCell(ws, i, 4, m.getDevice_name(),"");
|
|
|
|
addCell(ws, i, 5, m.getDoctor_name(),"");
|
|
|
|
addCell(ws, i, 6, m.getAddress(),"");
|
|
|
|
addCell(ws, i, 7, m.getOpenid(),"");
|
|
|
|
addCell(ws, i, 8, m.getIsopenid(),"");
|
|
|
|
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);
|
|
|
|
}
|
|
}
|
|
}
|