|
@@ -3,8 +3,12 @@ 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.RandomUtil;
|
|
|
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.imed.costaccount.common.enums.CalcTypeEnum;
|
|
@@ -23,6 +27,9 @@ 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;
|
|
@@ -41,6 +48,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
private final ReportRelationService reportRelationService;
|
|
|
private final CostShareLevelService shareLevelService;
|
|
|
private final CostOtherPaymentsDataService otherPaymentsDataService;
|
|
|
+ private final ResponsibilityService responsibilityService;
|
|
|
|
|
|
public HospProfitAndLossServiceImpl(ReportFormService reportFormService,
|
|
|
IncomeCollectionService collectionService,
|
|
@@ -48,7 +56,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
AllocationService allocationService,
|
|
|
ReportRelationService reportRelationService,
|
|
|
CostShareLevelService shareLevelService,
|
|
|
- CostOtherPaymentsDataService otherPaymentsDataService) {
|
|
|
+ CostOtherPaymentsDataService otherPaymentsDataService, ResponsibilityService responsibilityService) {
|
|
|
this.reportFormService = reportFormService;
|
|
|
this.collectionService = collectionService;
|
|
|
this.allocationQueryService = allocationQueryService;
|
|
@@ -56,6 +64,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
this.reportRelationService = reportRelationService;
|
|
|
this.shareLevelService = shareLevelService;
|
|
|
this.otherPaymentsDataService = otherPaymentsDataService;
|
|
|
+ this.responsibilityService = responsibilityService;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -366,5 +375,42 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
PageUtils pageUtils = new PageUtils(pages);
|
|
|
pageUtils.setList(hospProfitVOS);
|
|
|
return pageUtils;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出全院损益计算
|
|
|
+ * @param date yyyy-MM-dd
|
|
|
+ * @param hospId
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void hospProfitReport(String date, Long hospId, HttpServletResponse response) {
|
|
|
+ DateTime parse = DateUtil.parse(date);
|
|
|
+ int year = DateUtil.year(parse);
|
|
|
+ int month = DateUtil.month(parse) + 1;
|
|
|
+
|
|
|
+ // 得到所有责任中心的子节点
|
|
|
+ List<Responsibility> leafResp= responsibilityService.getLeafResp(hospId);
|
|
|
+
|
|
|
+ ExcelWriter writer = ExcelUtil.getWriter();
|
|
|
+ writer.write(leafResp.stream().map(Responsibility::getResponsibilityName).collect(Collectors.toList()));
|
|
|
+
|
|
|
+
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + year + month + ".xls");
|
|
|
+ ServletOutputStream out = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ out = response.getOutputStream();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ writer.flush(out, true);
|
|
|
+ writer.close();
|
|
|
+ IoUtil.close(out);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|