Explorar o código

医生圈导出功能

wangzhinan hai 1 ano
pai
achega
309d55e628

+ 98 - 1
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -20,6 +20,8 @@ import com.yihu.jw.restmodel.hospital.statistics.ScreenQvo;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import jxl.format.VerticalAlignment;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -29,6 +31,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
@ -5820,13 +5824,106 @@ public class StatisticsEsService {
        return object;
    }
    /**
     * 导出语句
     *
     * @param flag
     * @param startDate
     * @param endDate
     * @param level
     * @param area
     * @param lowLevel
     * @param lowCode
     * @return
     * @throws Exception
     */
    public List<Map<String,Object>> selectArticleCountExcel(Integer flag, String startDate, String endDate,int level, String area, String lowLevel, String lowCode) throws Exception {
        if (level==4){
            List<Map<String,Object>> mapList = getArticleExcel(flag,startDate,endDate,level,area, "5", null);
            for (Map<String,Object> map:mapList){
                List<Map<String,Object>> maps= getArticleExcel(flag,startDate,endDate,5,map.get("code").toString(), "6", null);
                map.put("doctors",maps);
            }
            return mapList;
        }
        return null;
    }
    public void pushArticleTotalExcel(OutputStream os, List<Map<String, Object>> list) throws Exception{
        WritableWorkbook wwb = jxl.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;
            String n = "";
            for (Map<String, Object> m : list) {
                addCell(ws, i, 0, m.get("name")!=null?m.get("name").toString():n);
                addCell(ws, i, 1, "-");
                addCell(ws, i, 2, m.get("publishTypeCount")!=null?m.get("publishTypeCount").toString():n);
                addCell(ws, i, 3, m.get("total")!=null?m.get("total").toString():n);
                addCell(ws, i, 4, m.get("dianzangCount")!=null?m.get("dianzangCount").toString():n);
                addCell(ws, i, 5, m.get("collectCount")!=null?m.get("collectCount").toString():n);
                addCell(ws, i, 6, m.get("pinglunCount")!=null?m.get("pinglunCount").toString():n);
                i++;
                List<Map<String,Object>> maps = (List<Map<String, Object>>) m.get("doctors");
                for (Map<String,Object> map:maps){
                    addCell(ws, i, 0, m.get("name")!=null?m.get("name").toString():n);
                    addCell(ws, i, 1, map.get("name")!=null?map.get("name").toString():n);
                    addCell(ws, i, 2, map.get("publishTypeCount")!=null?map.get("publishTypeCount").toString():n);
                    addCell(ws, i, 3, map.get("total")!=null?map.get("total").toString():n);
                    addCell(ws, i, 4, map.get("dianzangCount")!=null?map.get("dianzangCount").toString():n);
                    addCell(ws, i, 5, map.get("collectCount")!=null?map.get("collectCount").toString():n);
                    addCell(ws, i, 6, map.get("pinglunCount")!=null?map.get("pinglunCount").toString():n);
                    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);
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        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);
    }
    /**
     * 全院统计
     *
     * @param flag      0自定义 1本月2近半年3本年
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @param level     等级 1 省 2 市 3 区县 4 机构 5团队
     * @param level     等级 2 市  3区  4医院 5、科室 6医生
     * @param area      code  厦门市 350200 code 和level是对应的
     * @param lowLevel
     * @param lowCode

+ 1 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1498,7 +1498,7 @@ public class BaseHospitalRequestMapping {
        public static final String getArticleOperateDateLine = "/getArticleOperateDateLine";
        public static final String getArticleExcel="/getArticleExcel";
        public static final String getArticleTypeCircle="/getArticleTypeCircle";
        public static final String pushArticleCountExcel="/pushArticleCountExcel";
        public static final String getArticleTotalList="/getArticleTotalList";
    }

+ 35 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -7,6 +7,7 @@ import com.yihu.jw.es.service.StatisticsEsService;
import com.yihu.jw.restmodel.hospital.statistics.ScreenQvo;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
@ -1091,6 +1093,39 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.pushArticleCountExcel)
    @ApiOperation(value = " 导出文章全院明细")
    public ListEnvelop pushArticleCountExcel(
            @ApiParam(name = "startDate", value = "开始时间", required = false)
            @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(name = "endDate", value = "结束时间", required = false)
            @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(name = "area", value = "区域编码 如 level2 area传市编码", required = true)
            @RequestParam(value = "area", required = true) String area,
            @ApiParam(name = "level", value = "2 市  3区  4医院 5、科室 6医生", required = true)
            @RequestParam(value = "level", required = true) int level,
            @ApiParam(name = "flag", value = "0自定义 1本月2近半年3本年", required = true)
            @RequestParam(value = "flag", required = true) Integer flag,
            @ApiParam(name = "lowLevel", value = "下一级区域等级   2 市  3区  4医院 5、科室 6医生", required = false)
            @RequestParam(value = "lowLevel", required = false) String lowLevel,
            @ApiParam(name = "lowCode", value = "", required = false)
            @RequestParam(value = "lowCode", required = false) String lowCode,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = statisticsEsService.selectArticleCountExcel(flag,startDate,endDate,level,area,lowLevel,lowCode);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("pushArticleTotalExcel.xls"));
            OutputStream os = response.getOutputStream();
            statisticsEsService.pushArticleTotalExcel(os, list);
            return success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.getArticleTotalList)
    @ApiOperation(value = " 文章发布量排行")
    public Envelop getArticleTotalList(