|
@ -1,8 +1,23 @@
|
|
package com.yihu.wlyy.controller.manager.datastatic;
|
|
package com.yihu.wlyy.controller.manager.datastatic;
|
|
|
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
|
import com.yihu.wlyy.entity.prescription.PrescriptionVO;
|
|
|
|
import com.yihu.wlyy.entity.wechat.WechatSignVO;
|
|
|
|
import com.yihu.wlyy.entity.wechat.WechatTotalVO;
|
|
|
|
import com.yihu.wlyy.service.wechat.WechatService;
|
|
|
|
import jxl.Workbook;
|
|
|
|
import jxl.write.*;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
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.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 微信报表导出
|
|
* 微信报表导出
|
|
@ -13,9 +28,145 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
@RequestMapping(value = "/admin/static/wechat")
|
|
@RequestMapping(value = "/admin/static/wechat")
|
|
public class WeChatStaticController extends BaseController {
|
|
public class WeChatStaticController extends BaseController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private WechatService wechatService;
|
|
|
|
|
|
//页面跳转(主页面)
|
|
//页面跳转(主页面)
|
|
@RequestMapping(value = "initial")
|
|
@RequestMapping(value = "initial")
|
|
public String listInit() {
|
|
public String listInit() {
|
|
return "static/static_wechat";
|
|
return "static/static_wechat";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//导出详情报表报表
|
|
|
|
@RequestMapping(value="listToExcel",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 = "attention",required = false)String attention,
|
|
|
|
HttpServletResponse response){
|
|
|
|
try {
|
|
|
|
List<WechatSignVO> datalist = wechatService.geSignWechatDataList(hospital,attention);
|
|
|
|
response.setContentType("octets/stream");
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "signWechatDataList.xls"));
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
this.listWrite(os,datalist);
|
|
|
|
}catch (Exception ex){
|
|
|
|
error(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//导出详情报表
|
|
|
|
@RequestMapping(value="hosipitaTotalToExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
|
|
|
|
public void hosipitaTotalData(
|
|
|
|
HttpServletResponse response){
|
|
|
|
try {
|
|
|
|
List<WechatTotalVO> datalist = wechatService.hosipitaTotalData();
|
|
|
|
response.setContentType("octets/stream");
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "hosipitaTotalData.xls"));
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
this.listWrite(os,datalist);
|
|
|
|
}catch (Exception ex){
|
|
|
|
error(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//导出社区/行政区报表
|
|
|
|
@RequestMapping(value="townTotalToExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
|
|
|
|
public void townTotalData(
|
|
|
|
HttpServletResponse response){
|
|
|
|
try {
|
|
|
|
List<WechatTotalVO> datalist = wechatService.townTotalData();
|
|
|
|
response.setContentType("octets/stream");
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="+ new String( "townTotalData.xls"));
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
this.totalWrite(os,datalist);
|
|
|
|
}catch (Exception ex){
|
|
|
|
error(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void totalWrite(OutputStream os, List ls) throws Exception{
|
|
|
|
WritableWorkbook wwb = Workbook.createWorkbook(os);
|
|
|
|
try {
|
|
|
|
WritableSheet ws;
|
|
|
|
ws = wwb.createSheet("sheet",1);
|
|
|
|
|
|
|
|
String[] header = {"机构/行政区","关注率(关注数/签约数)","关注数","签约数"};
|
|
|
|
int k = 0;
|
|
|
|
for (String h : header) {
|
|
|
|
addCell(ws, 0, k, h);//表名,行,列,header
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
for (WechatTotalVO m : (List<WechatTotalVO>) ls) {
|
|
|
|
addCell(ws, i, 0, m.getName(),"");
|
|
|
|
addCell(ws, i, 1,String.valueOf(m.getAttRate()),"");
|
|
|
|
addCell(ws, i, 2, String.valueOf(m.getAttNumber()),"");
|
|
|
|
addCell(ws, i, 3, String.valueOf(m.getSignNumber()),"");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
wwb.write();
|
|
|
|
wwb.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
if (wwb != null) wwb.close();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void listWrite(OutputStream os, List ls) throws Exception{
|
|
|
|
WritableWorkbook wwb = Workbook.createWorkbook(os);
|
|
|
|
try {
|
|
|
|
WritableSheet ws;
|
|
|
|
ws = wwb.createSheet("sheet",1);
|
|
|
|
|
|
|
|
String[] header = {"居民openid","居民姓名","手机号码","openid更新时间", "身份证号","全科医生", "健管师", "社区医院", "居委会","住址","街道","openid重复数"};
|
|
|
|
int k = 0;
|
|
|
|
for (String h : header) {
|
|
|
|
addCell(ws, 0, k, h);//表名,行,列,header
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
for (WechatSignVO m : (List<WechatSignVO>) ls) {
|
|
|
|
addCell(ws, i, 0, m.getOpenid(),"");
|
|
|
|
addCell(ws, i, 1, m.getPatientname(),"");
|
|
|
|
addCell(ws, i, 2, m.getMobile(),"");
|
|
|
|
addCell(ws, i, 3, m.getOpenid_time(),"");
|
|
|
|
addCell(ws, i, 4, m.getIdcard(),"");
|
|
|
|
addCell(ws, i, 5, m.getDoctor_name(),"");
|
|
|
|
addCell(ws, i, 6, m.getDoctor_name(),"");
|
|
|
|
addCell(ws, i, 7, m.getDoctor_health_name(),"");
|
|
|
|
addCell(ws, i, 8, m.getHospital_name(),"");
|
|
|
|
addCell(ws, i, 9, m.getSick_village_name(),"");
|
|
|
|
addCell(ws, i, 10, m.getAddress(),"");
|
|
|
|
addCell(ws, i, 11, m.getStreet_name(),"");
|
|
|
|
addCell(ws, i, 12, m.getTcount(),"");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
wwb.write();
|
|
|
|
wwb.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
if (wwb != null) wwb.close();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//添加单元格内容
|
|
|
|
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);
|
|
|
|
}
|
|
}
|
|
}
|