|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
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.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -21,10 +22,13 @@ import com.imed.costaccount.model.vo.AllocationQueryReportVO;
|
|
|
import com.imed.costaccount.model.vo.CostDepartmentProfitVO;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
@@ -34,6 +38,12 @@ import java.util.stream.Collectors;
|
|
|
@Service("costDepartmentProfitService")
|
|
|
public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentProfitMapper, CostDepartmentProfit> implements CostDepartmentProfitService {
|
|
|
|
|
|
+ @Value("${file.filelocal}")
|
|
|
+ private String hospProfitReportUrl;
|
|
|
+
|
|
|
+ @Value("${file.serverUrl}")
|
|
|
+ private String serverUrl;
|
|
|
+
|
|
|
private final ReportFormService reportFormService;
|
|
|
|
|
|
private final IncomeCollectionService incomeCollectionService;
|
|
@@ -48,8 +58,9 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
private final AllocationQueryService allocationQueryService;
|
|
|
|
|
|
+ private final FileRecordService fileRecordService;
|
|
|
|
|
|
- public CostDepartmentProfitServiceImpl(ReportFormService reportFormService, IncomeCollectionService incomeCollectionService, CostShareLevelService costShareLevelService, ResponsibilityService responsibilityService, ReportRelationService reportRelationService, AllocationService allocationService, AllocationQueryService allocationQueryService) {
|
|
|
+ public CostDepartmentProfitServiceImpl(ReportFormService reportFormService, IncomeCollectionService incomeCollectionService, CostShareLevelService costShareLevelService, ResponsibilityService responsibilityService, ReportRelationService reportRelationService, AllocationService allocationService, AllocationQueryService allocationQueryService, FileRecordService fileRecordService) {
|
|
|
this.reportFormService = reportFormService;
|
|
|
this.incomeCollectionService = incomeCollectionService;
|
|
|
this.costShareLevelService = costShareLevelService;
|
|
@@ -57,6 +68,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
this.reportRelationService = reportRelationService;
|
|
|
this.allocationService = allocationService;
|
|
|
this.allocationQueryService = allocationQueryService;
|
|
|
+ this.fileRecordService = fileRecordService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -387,6 +399,30 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 科室损益计算导出
|
|
|
+ *
|
|
|
+ * @param date
|
|
|
+ * @param hospId
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getDepartProfitReport(String date, Long hospId, HttpServletResponse response) {
|
|
|
+ DateTime dateTime = DateUtil.parse(date);
|
|
|
+ int year = DateUtil.year(dateTime);
|
|
|
+ int month = DateUtil.month(dateTime)+1;
|
|
|
+ String time = DateUtil.format(DateUtil.date(), "yyyy年MM月dd日HH时mm分ss秒");
|
|
|
+ String fileName = hospProfitReportUrl + File.separator + hospId + File.separator + "hospReport" + File.separator + "科室损益" + time + ".xlsx";
|
|
|
+ ExcelWriter writer = ExcelUtil.getWriter(fileName);
|
|
|
+ Sheet sheet = writer.getSheet();
|
|
|
+ getDepartmentProfit(writer,sheet,date);
|
|
|
+ FileRecord fileRecord = new FileRecord();
|
|
|
+ fileRecord.setFileName("科室损益" + time + ".xlsx").setFileSource(2).setFileType("科室损益").setFileUrl(serverUrl + hospId + File.separator + "hospReport" + File.separator + "科室损益" + time + ".xlsx").setHospId(hospId)
|
|
|
+ .setDateYear(year).setDateMonth(month)
|
|
|
+ .setCreateTime(System.currentTimeMillis());
|
|
|
+ fileRecordService.save(fileRecord);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按照会计科目进行计算
|
|
|
*
|