|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@ -52,8 +53,36 @@ public class DeviceHealthIndexController extends BaseController{
|
|
|
}
|
|
|
|
|
|
//导出报表
|
|
|
@ResponseBody
|
|
|
@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<DeviceHealthIndexExportVO> wlyyDevices = healthIndexService.exportDeviceHealthIndexList(town,hospital);
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceHealthIndexDataList.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.write(os,wlyyDevices);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按筛选条件导出居民体征数据报表
|
|
|
* @param deviceSn 设备sn码
|
|
|
* @param date 查询日期
|
|
|
* @param idcard 居民身份证号
|
|
|
* @param userName 居民姓名
|
|
|
* @param indexType 体征类别
|
|
|
* @param indexTypeMin 体征最小值
|
|
|
* @param indexTypeMax 体征最大值
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value="getExcelByFilter",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
|
|
|
public String exportList(
|
|
|
@RequestParam(value = "deviceSn",required = false) String deviceSn,
|
|
|
@RequestParam(value = "date",required = false) String date,
|
|
@ -64,15 +93,15 @@ public class DeviceHealthIndexController extends BaseController{
|
|
|
@RequestParam(value = "indexTypeMax",required = false) String indexTypeMax,
|
|
|
HttpServletResponse response){
|
|
|
try {
|
|
|
// List<DeviceHealthIndexExportVO> wlyyDevices = healthIndexService.exportDeviceHealthIndexList(town,hospital);
|
|
|
List<DeviceHealthIndexVO> deviceHealthIndexes = healthIndexService.getExcelByFilter(deviceSn,date, idcard, userName, indexType,indexTypeMin,indexTypeMax);
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceHealthIndexDataList.xls"));
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "patientHealthIndexDataList.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
// this.write(os,wlyyDevices);
|
|
|
// write(200, "操作成功!");
|
|
|
// Map<Object, Object> map = new HashMap<Object, Object>();
|
|
|
// map.put("status", 200);
|
|
|
// map.put("msg", "操作成功!");
|
|
|
this.writePatientHealth(os,deviceHealthIndexes);
|
|
|
write(200, "操作成功!");
|
|
|
Map<Object, Object> map = new HashMap<Object, Object>();
|
|
|
map.put("status", 200);
|
|
|
map.put("msg", "操作成功!");
|
|
|
return write(200, "操作成功");
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
@ -80,7 +109,6 @@ public class DeviceHealthIndexController extends BaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void addHeader(WritableSheet ws) throws WriteException {
|
|
|
|
|
|
String[] header = {"居民姓名","手机号","身份证","设备码","设备名称","签约医生", "地址"};
|
|
@ -90,6 +118,16 @@ public class DeviceHealthIndexController extends BaseController{
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void addPatientHealthHeader(WritableSheet ws) throws WriteException {
|
|
|
|
|
|
String[] header = {"SN码","创建日期","身份证号","姓名","数据类型","value1","value2","value3","value4","value5","value6","value7"};
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(ws, 0, i, h);//表名,行,列,header
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void write(WritableWorkbook wwb, List ls) throws Exception {
|
|
|
try {
|
|
@ -115,9 +153,54 @@ public class DeviceHealthIndexController extends BaseController{
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void writePatientHealth(WritableWorkbook wwb, List ls) throws Exception {
|
|
|
try {
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
WritableSheet ws;
|
|
|
ws = wwb.createSheet("sheet",1);
|
|
|
addPatientHealthHeader(ws);
|
|
|
int i = 1;
|
|
|
for (DeviceHealthIndexVO m : (List<DeviceHealthIndexVO>) ls) {
|
|
|
String type = "未知";
|
|
|
if (m.getType()==1){
|
|
|
type = "血糖";
|
|
|
}else if (m.getType()==2){
|
|
|
type = "血压";
|
|
|
}else if (m.getType()==3){
|
|
|
type = "体重";
|
|
|
}else if (m.getType()==4){
|
|
|
type = "腰围";
|
|
|
}
|
|
|
addCell(ws, i, 0, m.getDeviceSn(),"");
|
|
|
addCell(ws, i, 1, format.format(m.getCzrq()),"");
|
|
|
addCell(ws, i, 2, m.getIdcard(),"");
|
|
|
addCell(ws, i, 3, m.getUserName(),"");
|
|
|
addCell(ws, i, 4, "","");
|
|
|
addCell(ws, i, 5, m.getValue1(),"");
|
|
|
addCell(ws, i, 6, m.getValue2(),"");
|
|
|
addCell(ws, i, 7, m.getValue3(),"");
|
|
|
addCell(ws, i, 8, m.getValue4(),"");
|
|
|
addCell(ws, i, 9, m.getValue5(),"");
|
|
|
addCell(ws, i, 10, m.getValue6(),"");
|
|
|
addCell(ws, i, 11, m.getValue7(),"");
|
|
|
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 writePatientHealth(OutputStream os, List ls) throws Exception{
|
|
|
writePatientHealth(Workbook.createWorkbook(os), ls);
|
|
|
}
|
|
|
//添加单元格内容
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column ,row, data);
|