12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package thyyxxk.webserver.service.querydata;
- import com.alibaba.fastjson.JSON;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.dao.his.querydata.ConsumablesStatisticsDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
- import thyyxxk.webserver.entity.querydata.ConsumablesStatistics;
- import thyyxxk.webserver.utils.ExcelUtil;
- import thyyxxk.webserver.utils.ResultVoUtil;
- import javax.servlet.http.HttpServletResponse;
- import java.util.List;
- /**
- * <p>
- * 描述
- * </p>
- *
- * @author xc
- * @date 2021-04-06 14:35
- */
- @Service
- @Slf4j
- public class ConsumablesStatisticsService {
- private final ConsumablesStatisticsDao dao;
- @Autowired
- public ConsumablesStatisticsService(ConsumablesStatisticsDao dao) {
- this.dao = dao;
- }
- /**
- * 查询耗材使用统计 根据条件动态查询 这个sql语句太复杂了 mybatis-plus查询很慢
- *
- * @param param 条件 分页
- * @return 指定数据
- */
- public ResultVo<List<ConsumablesStatistics>> query(ConsumablesStatistics param) {
- List<ConsumablesStatistics> list = dao.query(param);
- if (list.size() > 0) {
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
- }
- /**
- * @param response 固定
- * @param param 查询条件
- */
- public void exportExcel(HttpServletResponse response, ConsumablesStatistics param) {
- log.info("导出耗材使用统计excel --> {}", JSON.toJSONString(param));
- List<ConsumablesStatistics> list = dao.query(param);
- String[] title = {"项目编码", "项目名称", "产地品牌", "耗材院内编码", "来源", "数量", "金额"};
- String[][] content = new String[list.size()][];
- for (int i = 0; i < list.size(); i++) {
- content[i] = new String[title.length];
- ConsumablesStatistics pojo = list.get(i);
- content[i][0] = pojo.getProjectCode();
- content[i][1] = pojo.getEntryName();
- content[i][2] = pojo.getOriginBrand();
- content[i][3] = pojo.getHospitalCode();
- content[i][4] = pojo.getSource();
- content[i][5] = String.valueOf(pojo.getNumber());
- content[i][6] = String.valueOf(pojo.getAmountOfMoney());
- }
- //传三个参数 一个是 固定的 response ,excel的头部信息,excel的内容
- ExcelUtil.exportExcel(response, title, content);
- }
- /**
- * 获取费用类型
- */
- public ResultVo<List<GetDropdownBox>> getDropdownBox() {
- return ResultVoUtil.success(dao.chargeClassName());
- }
- }
|