|
@@ -19,6 +19,7 @@ import com.imed.costaccount.common.util.PageUtils;
|
|
import com.imed.costaccount.model.*;
|
|
import com.imed.costaccount.model.*;
|
|
import com.imed.costaccount.model.vo.HospProfitVO;
|
|
import com.imed.costaccount.model.vo.HospProfitVO;
|
|
import com.imed.costaccount.model.vo.RelationVO;
|
|
import com.imed.costaccount.model.vo.RelationVO;
|
|
|
|
+import com.imed.costaccount.model.vo.ReportFormVO;
|
|
import com.imed.costaccount.service.*;
|
|
import com.imed.costaccount.service.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -302,16 +303,19 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
if (CollUtil.isEmpty(shareLevelId)) {
|
|
if (CollUtil.isEmpty(shareLevelId)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+ // 分摊层级计算金额
|
|
|
|
+ // TODO: 2021/8/31
|
|
|
|
+
|
|
List<CostShareLevel> costShareLevels = shareLevelService.listByIds(shareLevelId);
|
|
List<CostShareLevel> costShareLevels = shareLevelService.listByIds(shareLevelId);
|
|
if (costShareLevels.isEmpty()) {
|
|
if (costShareLevels.isEmpty()) {
|
|
throw new CostException("医院分摊层级设置错误," + reportForm.getReportName());
|
|
throw new CostException("医院分摊层级设置错误," + reportForm.getReportName());
|
|
}
|
|
}
|
|
List<Integer> levelSorts = costShareLevels.stream().map(CostShareLevel::getLeverSort).collect(Collectors.toList());
|
|
List<Integer> levelSorts = costShareLevels.stream().map(CostShareLevel::getLeverSort).collect(Collectors.toList());
|
|
- List<Allocation> allocations = allocationService.getByDate(year, month, hospId, levelSorts);
|
|
|
|
|
|
+ List<AllocationQuery> allocations = allocationQueryService.getByDate(year, month, hospId, levelSorts);
|
|
if (allocations.isEmpty()) {
|
|
if (allocations.isEmpty()) {
|
|
throw new CostException("医院未分摊本月数据");
|
|
throw new CostException("医院未分摊本月数据");
|
|
}
|
|
}
|
|
- BigDecimal reduce = allocations.stream().map(Allocation::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
+ BigDecimal reduce = allocations.stream().map(AllocationQuery::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
HospProfitAndLoss loss = new HospProfitAndLoss();
|
|
HospProfitAndLoss loss = new HospProfitAndLoss();
|
|
return loss.setReportName(reportForm.getReportName()).setReportNum(reportForm.getNum())
|
|
return loss.setReportName(reportForm.getReportName()).setReportNum(reportForm.getNum())
|
|
.setAmount(reduce).setCreateTime(System.currentTimeMillis()).setHospId(hospId);
|
|
.setAmount(reduce).setCreateTime(System.currentTimeMillis()).setHospId(hospId);
|
|
@@ -379,7 +383,8 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
|
|
|
/**
|
|
/**
|
|
* 导出全院损益计算
|
|
* 导出全院损益计算
|
|
- * @param date yyyy-MM-dd
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param date yyyy-MM-dd
|
|
* @param hospId
|
|
* @param hospId
|
|
* @param response
|
|
* @param response
|
|
*/
|
|
*/
|
|
@@ -390,11 +395,42 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
int month = DateUtil.month(parse) + 1;
|
|
int month = DateUtil.month(parse) + 1;
|
|
|
|
|
|
// 得到所有责任中心的子节点
|
|
// 得到所有责任中心的子节点
|
|
- List<Responsibility> leafResp= responsibilityService.getLeafResp(hospId);
|
|
|
|
|
|
+ List<Responsibility> leafResp = responsibilityService.getLeafResp(hospId);
|
|
|
|
|
|
ExcelWriter writer = ExcelUtil.getWriter();
|
|
ExcelWriter writer = ExcelUtil.getWriter();
|
|
- writer.write(leafResp.stream().map(Responsibility::getResponsibilityName).collect(Collectors.toList()));
|
|
|
|
|
|
+ List<String> secondTitleList = leafResp.stream().map(Responsibility::getResponsibilityName).collect(Collectors.toList());
|
|
|
|
+ writer.merge(leafResp.size() + 1, "全院损益计算导出 \n" + "制表时间:" + DateUtil.now());
|
|
|
|
+ writer.setColumnWidth(-1, 20);
|
|
|
|
+ writer.passCurrentRow();
|
|
|
|
+ writer.merge(2, 2, 0, 1, "项目", false);
|
|
|
|
+ for (int i = 0; i < secondTitleList.size(); i++) {
|
|
|
|
+ String str = secondTitleList.get(i);
|
|
|
|
+ writer.writeCellValue(i + 2, 2, str);
|
|
|
|
+ }
|
|
|
|
+ // 得到全院损益报表处理 树状结构(only 2层)
|
|
|
|
+ List<ReportFormVO> allHospList = reportFormService.getAllHospList(hospId);
|
|
|
|
+ if (allHospList.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int lastRow = 3;
|
|
|
|
+ for (int i = 0; i < allHospList.size(); i++) {
|
|
|
|
+ ReportFormVO parentFormVO = allHospList.get(i);
|
|
|
|
+ List<ReportFormVO> children = parentFormVO.getChildren();
|
|
|
|
+ if (CollUtil.isEmpty(children)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ int size = children.size();
|
|
|
|
+ writer.merge(lastRow, lastRow + size - 1, 0, 0, parentFormVO.getReportName(), true);
|
|
|
|
+ // 具体的报表项目
|
|
|
|
+ for (int j = 0; j < size; j++) {
|
|
|
|
+ // todo 可以抽取出单独方法
|
|
|
|
+ ReportFormVO childFormVO = children.get(j);
|
|
|
|
+ writer.writeCellValue(1, lastRow + j, childFormVO.getReportName());
|
|
|
|
+ // 单独计每个数据的责任中心对应的金额
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ lastRow = lastRow + size;
|
|
|
|
+ }
|
|
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + year + month + ".xls");
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + year + month + ".xls");
|
|
@@ -410,7 +446,5 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
IoUtil.close(out);
|
|
IoUtil.close(out);
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|