|
@@ -3,28 +3,22 @@ package com.imed.costaccount.service.impl;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.ReUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
|
-import cn.hutool.poi.excel.StyleSet;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.imed.costaccount.common.enums.CalcTypeEnum;
|
|
|
import com.imed.costaccount.common.enums.ReportTypeEnum;
|
|
|
import com.imed.costaccount.common.exception.CostException;
|
|
|
-import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
|
import com.imed.costaccount.model.*;
|
|
|
-import com.imed.costaccount.model.vo.HospProfitVO;
|
|
|
import com.imed.costaccount.model.vo.RelationVO;
|
|
|
import com.imed.costaccount.model.vo.ReportFormVO;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
-import org.apache.poi.ss.usermodel.*;
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
@@ -32,9 +26,7 @@ import com.imed.costaccount.mapper.HospProfitAndLossMapper;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -45,35 +37,40 @@ import java.util.stream.Collectors;
|
|
|
@Service("hospProfitAndLossService")
|
|
|
public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossMapper, HospProfitAndLoss> implements HospProfitAndLossService {
|
|
|
|
|
|
+ @Value("${file.filelocal}")
|
|
|
+ private String hospProfitReportUrl;
|
|
|
+
|
|
|
+ @Value("${file.serverUrl}")
|
|
|
+ private String serverUrl;
|
|
|
+
|
|
|
private final ReportFormService reportFormService;
|
|
|
private final IncomeCollectionService collectionService;
|
|
|
private final AllocationQueryService allocationQueryService;
|
|
|
- private final AllocationService allocationService;
|
|
|
|
|
|
private final ReportRelationService reportRelationService;
|
|
|
private final CostShareLevelService shareLevelService;
|
|
|
private final CostOtherPaymentsDataService otherPaymentsDataService;
|
|
|
private final ResponsibilityService responsibilityService;
|
|
|
private final CostAccountShareService accountShareService;
|
|
|
+ private final FileRecordService fileRecordService;
|
|
|
|
|
|
public HospProfitAndLossServiceImpl(ReportFormService reportFormService,
|
|
|
IncomeCollectionService collectionService,
|
|
|
AllocationQueryService allocationQueryService,
|
|
|
- AllocationService allocationService,
|
|
|
ReportRelationService reportRelationService,
|
|
|
CostShareLevelService shareLevelService,
|
|
|
CostOtherPaymentsDataService otherPaymentsDataService,
|
|
|
ResponsibilityService responsibilityService,
|
|
|
- CostAccountShareService accountShareService) {
|
|
|
+ CostAccountShareService accountShareService, FileRecordService fileRecordService) {
|
|
|
this.reportFormService = reportFormService;
|
|
|
this.collectionService = collectionService;
|
|
|
this.allocationQueryService = allocationQueryService;
|
|
|
- this.allocationService = allocationService;
|
|
|
this.reportRelationService = reportRelationService;
|
|
|
this.shareLevelService = shareLevelService;
|
|
|
this.otherPaymentsDataService = otherPaymentsDataService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.accountShareService = accountShareService;
|
|
|
+ this.fileRecordService = fileRecordService;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -363,19 +360,10 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
DateTime parse = DateUtil.parse(date);
|
|
|
int year = DateUtil.year(parse);
|
|
|
int month = DateUtil.month(parse) + 1;
|
|
|
- Page<HospProfitAndLoss> page = new Page<>(current, pageSize);
|
|
|
- Page<HospProfitAndLoss> pages = this.page(
|
|
|
- page,
|
|
|
- new LambdaQueryWrapper<HospProfitAndLoss>()
|
|
|
- .eq(HospProfitAndLoss::getHospId, hospId)
|
|
|
- .eq(HospProfitAndLoss::getDateMonth, month)
|
|
|
- .eq(HospProfitAndLoss::getDateYear, year)
|
|
|
- );
|
|
|
- List<HospProfitAndLoss> records = pages.getRecords();
|
|
|
- List<HospProfitVO> hospProfitVOS = BeanUtil.convertList(records, HospProfitVO.class);
|
|
|
- PageUtils pageUtils = new PageUtils(pages);
|
|
|
- pageUtils.setList(hospProfitVOS);
|
|
|
- return pageUtils;
|
|
|
+ int startIndex = (current - 1) * pageSize;
|
|
|
+ List<HospProfitAndLoss> list = baseMapper.getPageList(startIndex, pageSize, year, month, hospId);
|
|
|
+ int totalCount = baseMapper.getPageCount(year, month, hospId);
|
|
|
+ return new PageUtils(list, totalCount, pageSize, current);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -395,7 +383,11 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
List<Responsibility> leafResp = responsibilityService.getLeafResp(hospId);
|
|
|
|
|
|
// 得到上一层的title子节点
|
|
|
- ExcelWriter writer = ExcelUtil.getWriter();
|
|
|
+// ExcelWriter writer = ExcelUtil.getWriter();
|
|
|
+ String time = DateUtil.format(DateUtil.date(), "yyyy年MM月dd日HH时mm分ss秒");
|
|
|
+ String fileName = hospProfitReportUrl + "全院损益" + time + ".xlsx";
|
|
|
+ ExcelWriter writer = ExcelUtil.getWriter(fileName);
|
|
|
+
|
|
|
List<String> secondTitleListCode = leafResp.stream().map(Responsibility::getResponsibilityCode).collect(Collectors.toList());
|
|
|
writer.merge(leafResp.size() + 1, "全院损益计算导出 \n" + "制表时间:" + DateUtil.now());
|
|
|
// 得到两层结构
|
|
@@ -441,7 +433,6 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
// 查询所有的全院损益数据 内存溢出问题
|
|
|
List<HospProfitAndLoss> list = getAllDataByDate(year, month, hospId);
|
|
|
int lastRow = 3;
|
|
|
- Sheet sheet = writer.getSheet();
|
|
|
for (int i = 0; i < allHospList.size(); i++) {
|
|
|
ReportFormVO parentFormVO = allHospList.get(i);
|
|
|
List<ReportFormVO> children = parentFormVO.getChildren();
|
|
@@ -470,28 +461,23 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
}
|
|
|
lastRow = lastRow + size;
|
|
|
}
|
|
|
-
|
|
|
- response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + "全院损益列表" + ".xls");
|
|
|
- ServletOutputStream out = null;
|
|
|
-
|
|
|
- try {
|
|
|
- out = response.getOutputStream();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- writer.flush(out, true);
|
|
|
+ FileRecord fileRecord = new FileRecord();
|
|
|
+ fileRecord.setFileName("全院损益" + time + ".xlsx").setFileSource(1).setFileType("全院损益").setFileUrl(serverUrl + fileName).setHospId(hospId)
|
|
|
+ .setDateYear(year).setDateMonth(month)
|
|
|
+ .setCreateTime(System.currentTimeMillis());
|
|
|
+ fileRecordService.save(fileRecord);
|
|
|
writer.close();
|
|
|
- IoUtil.close(out);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-// private List<String> getLeafRespOnlyOne(Long hospId, List<Responsibility> leafResp) {
|
|
|
-// List<Long> parentIds = leafResp.stream().map(Responsibility::getParentId).collect(Collectors.toList());
|
|
|
-// responsibilityService.getById(pare)
|
|
|
-//
|
|
|
-// }
|
|
|
+ @Override
|
|
|
+ public PageUtils hospProfitReports(Integer current, Integer pageSize, Long hospId) {
|
|
|
+ Page<FileRecord> page = new Page<>(current, pageSize);
|
|
|
+ Page<FileRecord> pageUtils = fileRecordService.page(page,
|
|
|
+ new LambdaQueryWrapper<FileRecord>()
|
|
|
+ .eq(FileRecord::getHospId, hospId)
|
|
|
+ );
|
|
|
+ return new PageUtils(pageUtils);
|
|
|
+ }
|
|
|
|
|
|
private List<HospProfitAndLoss> getAllDataByDate(int year, int month, Long hospId) {
|
|
|
return this.list(
|